Help us shape the future of Go! Take the 2026 Go Developer Survey

renderer

command
v1.152.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

This example embeds cagent as a library and launches its TUI with a *custom tool renderer applied to an MCP-server tool*.

It is fully self-contained: it starts an in-process MCP server (over HTTP via httptest, no subprocess) exposing a "search_repositories" tool with canned data, attaches it to the agent as a remote MCP toolset named "github" — so the tool surfaces as "github_search_repositories" with category "mcp" (see pkg/tools/mcp/mcp.go) — and registers a custom renderer for that exposed name. When the agent calls the MCP tool, the result is drawn as a bordered repo list instead of the generic tool view.

The renderer is wired via tui.WithToolRenderers; the key is just the tool's name, so the exact same call styles built-in or Go-SDK tools too. To style every MCP tool at once, register under "category:mcp" instead.

Run it (uses a Gemini model, so set GOOGLE_API_KEY):

GOOGLE_API_KEY=... go run ./examples/golibrary/renderer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL