Documentation
¶
Overview ¶
Package tuitools gives an agent run in its own terminal the caller's tools. RunMCP is the small stdio MCP server the agent starts (Claude Code's interactive mode and -p runs, Grok, and every agent a plugin drives through `magpie tui-helper`); it hands each tool call back to the one who started the run, over an HTTP callback, and holds the call until that one answers. Bridge is that callback for a run magpie's gateway doesn't hold itself: tui-helper's.
Index ¶
Constants ¶
const Command = "mcp-helper"
Command is the hidden subcommand that runs RunMCP for any agent. Claude Code's runs name it by its first name, claudetui.MCPCommand.
Variables ¶
This section is empty.
Functions ¶
func RunMCP ¶
RunMCP runs the hidden stdio MCP subprocess. args are callback URL and tools JSON path, and for Claude Code's interactive mode a file written once Claude Code has listed the tools, which its first message waits for (claudetui.MCPCommand); or, for an agent whose MCP servers are set once for every run (Grok), MAGPIE_MCP_CALLBACK and MAGPIE_MCP_TOOLS in the environment it hands down. It intentionally implements only the MCP methods Claude Code needs.
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge is the far end of RunMCP's callback for a run that no gateway holds: it listens on loopback, under a path no one else knows, and hands each call to OnCall, holding the tool server's request until Answer is given the call's id. Its files (the callback's address, the tools, the listed mark) sit in a folder of its own, 0700, gone with Close.
func NewBridge ¶
NewBridge starts a bridge offering tools (MCP tools: name, description, inputSchema). onCall is told each call the agent makes, onDrop each call the agent gave up waiting for (its tool server gone); both are called on goroutines of their own.
func (*Bridge) Args ¶
Args are the tool server's arguments after exe: Command, then its files. The token is in the callback's file, never on a command line.
type Call ¶
type Call struct {
ID string `json:"id"`
Name string `json:"name"`
Arguments json.RawMessage `json:"arguments"`
}
Call is a tool call the agent made, held until it is answered.
type Result ¶
type Result struct {
ID string `json:"id"`
Content json.RawMessage `json:"content"`
IsError bool `json:"isError,omitempty"`
Tools json.RawMessage `json:"tools,omitempty"`
}
Result answers a Call. Content is the MCP result's content: a string is one text block; anything else goes as given (a list of MCP content blocks). Tools, when set, replace the tools offered before the agent is given the result, as a ToolSearch that loaded one mid-turn needs.