renderer

command
v1.164.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 35 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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