mcp

package
v0.0.0-...-c495aaa Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package mcp exposes the coreutils tool registry over the Model Context Protocol — the third consumption surface (alongside the in-process shell ExecHandler and the busybox multicall binary) so that non-Go agents (codex, claude, …) can drive the AgentOS userland.

The registry holds CLI-shaped tools (argv + stdin -> stdout/stderr/exit), so the faithful MCP mapping is two generic meta-tools rather than a schema per tool:

  • list_tools — enumerate the tools this build ships (name + synopsis)
  • run_tool — run one: {name, args, stdin, dir, env} -> {stdout, stderr, exit_code}

run_tool delegates to multicall.Dispatch, so name resolution and the unknown-tool diagnostic match the standalone `coreutils` binary exactly.

As agentic verbs (symbols, repomap, …) land in the registry they can additionally be registered as typed, individually-schema'd MCP tools on the same server via RegisterTool; the generic pair always covers the whole registry as a floor.

This package uses the official SDK (github.com/modelcontextprotocol/go-sdk), the same one the umbrella already pins, aliased mcpsdk to avoid clashing with this package's own name.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer(name, version string) *mcpsdk.Server

NewServer builds an MCP server exposing the current tool registry via the generic list_tools / run_tool pair. Callers must have blank-imported the tool sets they want available (e.g. coreutils/cmds/all) before any client lists or runs tools.

func ServeStdio

func ServeStdio(ctx context.Context, name, version string) error

ServeStdio runs an MCP server over stdio until the transport closes or ctx is cancelled — the entrypoint a `coreutils mcp` / `bashy mcp` front end calls. A client closing stdin (io.EOF) is the normal way to end a stdio session, so it is reported as a clean shutdown (nil), not an error.

Types

type ListToolsInput

type ListToolsInput struct{}

ListToolsInput is empty — list_tools takes no arguments.

type ListToolsOutput

type ListToolsOutput struct {
	Tools []ToolInfo `json:"tools" jsonschema:"every tool this build ships, sorted by name"`
}

ListToolsOutput is the list_tools result.

type RunToolInput

type RunToolInput struct {
	Name  string            `json:"name" jsonschema:"tool to run, e.g. \"grep\""`
	Args  []string          `json:"args,omitempty" jsonschema:"argument vector after the tool name"`
	Stdin string            `json:"stdin,omitempty" jsonschema:"standard input fed to the tool"`
	Dir   string            `json:"dir,omitempty" jsonschema:"working directory; relative operands resolve against it"`
	Env   map[string]string `json:"env,omitempty" jsonschema:"environment for the invocation; empty means none"`
}

RunToolInput is the run_tool argument set.

type RunToolOutput

type RunToolOutput struct {
	Stdout   string `json:"stdout" jsonschema:"captured standard output"`
	Stderr   string `json:"stderr" jsonschema:"captured standard error"`
	ExitCode int    `json:"exit_code" jsonschema:"process exit status (0 success, 2 usage error, …)"`
}

RunToolOutput is the run_tool result.

type ToolInfo

type ToolInfo struct {
	Name     string   `json:"name" jsonschema:"command name as spelled on the CLI"`
	Synopsis string   `json:"synopsis" jsonschema:"one-line description"`
	Usage    string   `json:"usage" jsonschema:"usage line"`
	Group    string   `json:"group,omitempty" jsonschema:"Command Atlas functional group (fileutils, textutils, code-intel, …)"`
	Caps     []string `json:"caps,omitempty" jsonschema:"Command Atlas capability flags (json, read-only, destructive, …)"`
}

ToolInfo describes one registered tool for list_tools. Group and Caps are the Command Atlas axes (pkg/atlas): the functional group and the agentic capability flags; both are additive and omitted when the atlas has no entry for the name.

Jump to

Keyboard shortcuts

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