Documentation
¶
Overview ¶
Package mcp is a small Model Context Protocol server over stdio: tools and resources, as JSON-RPC 2.0 messages, one per line. It implements what tern mcp needs, without a dependency for users' modules.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalid = errors.New("invalid arguments")
ErrInvalid wraps argument errors.
View Source
var Versions = []string{"2025-06-18", "2025-03-26", "2024-11-05"}
Versions are the protocol versions the server speaks, newest first.
Functions ¶
Types ¶
type Resource ¶
type Resource struct {
URI string
Name string
Description string
MimeType string
Read func() (string, error)
}
Resource is a document a client can read.
type Server ¶
type Server struct {
Name, Version string
// Instructions tell the client's model how to use the server.
Instructions string
Tools []Tool
Resources []Resource
}
Server serves tools and resources.
type Tool ¶
type Tool struct {
Name string
Title string
Description string
// Schema is the JSON schema of the arguments, an object.
Schema map[string]any
// ReadOnly marks tools that change nothing, for clients that ask
// before running others.
ReadOnly bool
Handler func(ctx context.Context, args json.RawMessage) (string, error)
}
Tool is a function a client can call.
Click to show internal directories.
Click to hide internal directories.