mcp

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package mcp implements the toolkit MCP server. It exposes the same read-only category surface as the headless `toolkit get` CLI as a set of MCP tools that an agent (Claude Code, Claude Desktop, any MCP-aware client) can call directly over stdio — no shell out, no output parsing.

The handlers reuse the existing loader composite (internal/infra/loader), so any improvement to data loading (partial-tolerance, variable defaults, etc.) is shared between CLI and MCP automatically.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the toolkit's MCP server. Build with NewServer, then call Run.

func NewServer

func NewServer(cfg config.Config, ld loader.Loader, logger logging.Logger, version string) *Server

NewServer constructs a server that exposes read-only category tools. cfg supplies the startup env defaults; each tool call may override env_type / env_region / env_realm per-call.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run blocks until any of:

  • stdin reaches EOF (the MCP client closed the pipe),
  • ctx is canceled,
  • the underlying transport returns a fatal error.

Returns nil on a clean client disconnect or ctx cancel, otherwise the transport's error. Uses stdio: stdin reads JSON-RPC frames, stdout writes them. Callers must keep stdout free of any other output (the toolkit logger writes to a file by default — see internal/cli/mcp.go).

Single-shot: a second Run on the same *Server reuses the SDK's session list rather than reinitializing cleanly. Construct a fresh Server (via NewServer) if you need to restart.

Jump to

Keyboard shortcuts

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