Help us shape the future of Go! Take the 2026 Go Developer Survey

mcp

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, r io.Reader, w io.Writer, cfg *config.Config) error

Run reads newline-delimited JSON-RPC requests from r and writes responses to w until EOF. No session state is retained across calls beyond the caller's *config.Config, which handlers treat as read-only per call — this server never mutates the process working directory or dump-state files (see the statelessness rule in tools.go).

Types

type CallParams

type CallParams struct {
	Name      string         `json:"name"`
	Arguments map[string]any `json:"arguments,omitempty"`
}

CallParams are the tools/call parameters: which tool plus its arguments.

type CallResult

type CallResult struct {
	Content []ContentBlock `json:"content"`
	IsError bool           `json:"isError,omitempty"`
}

CallResult is the tools/call payload: human-readable content blocks.

type Capabilities

type Capabilities struct {
	Tools map[string]any `json:"tools"`
}

Capabilities advertises exactly the tool surface; nothing else.

type ContentBlock

type ContentBlock struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

ContentBlock is one text block in a tool result.

type InitializeResult

type InitializeResult struct {
	ProtocolVersion string       `json:"protocolVersion"`
	Capabilities    Capabilities `json:"capabilities"`
	ServerInfo      ServerInfo   `json:"serverInfo"`
}

InitializeResult is the response payload for initialize.

type Property

type Property struct {
	Type        string   `json:"type"`
	Description string   `json:"description,omitempty"`
	Enum        []string `json:"enum,omitempty"`
}

Property is a single named argument's schema.

type RPCError

type RPCError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

RPCError is a JSON-RPC 2.0 error object with the standard code space: -32601 method not found, -32602 invalid params, -32603 internal error.

type Request

type Request struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      json.RawMessage `json:"id,omitempty"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
}

Request is a single newline-delimited JSON-RPC 2.0 message. An absent ID marks a notification, which receives no reply.

func (Request) HasID

func (r Request) HasID() bool

HasID reports whether the request expects a reply.

type Response

type Response struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      json.RawMessage `json:"id"`
	Result  any             `json:"result,omitempty"`
	Error   *RPCError       `json:"error,omitempty"`
}

Response is the reply to a Request carrying an ID.

type Schema

type Schema struct {
	Type       string              `json:"type"`
	Properties map[string]Property `json:"properties,omitempty"`
	Required   []string            `json:"required,omitempty"`
}

Schema is the JSON Schema object constraining a tool's arguments.

type ServerInfo

type ServerInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

ServerInfo identifies this server to clients.

type Tool

type Tool struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	InputSchema Schema `json:"inputSchema"`
}

Tool describes one callable tool for tools/list.

type ToolsListResult

type ToolsListResult struct {
	Tools []Tool `json:"tools"`
}

ToolsListResult wraps tools/list output.

Jump to

Keyboard shortcuts

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