mcp

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package mcp implements the MCP (Model Context Protocol) stdio transport. It serves spec context and tools to MCP-compatible coding agents over JSON-RPC 2.0 on stdin/stdout.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(ctx context.Context, handler Handler, in io.Reader, out io.Writer, logOut io.Writer) error

Serve runs the MCP server, reading JSON-RPC from in and writing to out. Diagnostic logging goes to logOut (typically os.Stderr). Blocks until ctx is cancelled or in reaches EOF.

Types

type GenericHandler

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

GenericHandler provides spec resources and tools without requiring a build session. It serves as the default MCP handler, providing access to specs, pipeline info, and common operations.

func NewGenericHandler

func NewGenericHandler(cfg *config.ResolvedConfig, specsDir string) *GenericHandler

NewGenericHandler creates a handler that serves generic spec resources.

func (*GenericHandler) CallTool

func (h *GenericHandler) CallTool(name string, args json.RawMessage) (*ToolResult, error)

CallTool executes a tool.

func (*GenericHandler) GetResource

func (h *GenericHandler) GetResource(uri string) (*Resource, error)

GetResource returns a specific resource by URI.

func (*GenericHandler) ListResources

func (h *GenericHandler) ListResources() []Resource

ListResources returns available resources.

func (*GenericHandler) ListTools

func (h *GenericHandler) ListTools() []Tool

ListTools returns available tools.

type Handler

type Handler interface {
	ListResources() []Resource
	GetResource(uri string) (*Resource, error)
	ListTools() []Tool
	CallTool(name string, args json.RawMessage) (*ToolResult, error)
}

Handler defines the domain operations the MCP server delegates to. Implemented by a thin adapter over build.MCPServer in cmd/.

type Resource

type Resource struct {
	URI     string
	Name    string
	Content string
}

Resource represents content served by the MCP server.

type Tool

type Tool struct {
	Name        string
	Description string
	InputSchema map[string]interface{}
}

Tool represents a tool the agent can call.

type ToolResult

type ToolResult struct {
	Success bool
	Message string
}

ToolResult represents the outcome of a tool call.

Jump to

Keyboard shortcuts

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