tuitools

package
v0.1.5325 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 18 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

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

View Source
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

func RunMCP(args []string) error

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

func NewBridge(tools json.RawMessage, onCall func(Call), onDrop func(id string)) (*Bridge, error)

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) Answer

func (b *Bridge) Answer(r Result) error

Answer gives the agent a call's result.

func (*Bridge) Args

func (b *Bridge) Args() []string

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.

func (*Bridge) Close

func (b *Bridge) Close()

Close ends the bridge: calls still held are refused, and its files go. A nil Bridge has nothing to close.

func (*Bridge) Listed

func (b *Bridge) Listed() <-chan struct{}

Listed is closed once the agent has listed the tools: a message sent before then may find none of them.

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.

Jump to

Keyboard shortcuts

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