Documentation
¶
Overview ¶
Package mcp adapts explicitly reviewed MCP tools to the local agent runtime. It uses the official SDK over explicit HTTP or caller-supplied streams and does not discover credentials, launch processes, or grant permissions from server metadata.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrConfig = errors.New("mcp: invalid client configuration") ErrConnect = errors.New("mcp: connection failed") ErrProtocol = errors.New("mcp: incompatible protocol or server capabilities") ErrClosed = errors.New("mcp: client closed") ErrRemote = errors.New("mcp: remote tool failed") ErrUnsupported = errors.New("mcp: unsupported tool result") ErrLimit = errors.New("mcp: tool result exceeds limit") )
var ErrDiscovery = errors.New("mcp: discovery failed")
Functions ¶
This section is empty.
Types ¶
type Binding ¶
Binding is a caller-reviewed tool specification and the exact remote name. Server annotations and discovered schemas do not confer permission.
type Catalog ¶
type Catalog struct {
Tools []ToolInfo `json:"tools"`
Pages int `json:"pages"`
Complete bool `json:"complete"`
}
Catalog contains only metadata from SDK-returned pages. Complete means pagination ended within the configured budgets, not that the server disclosed every tool (the SDK may filter invalid definitions).
func DiscoverHTTP ¶
func DiscoverHTTP(ctx context.Context, h HTTPConfig, cfg DiscoveryConfig) (Catalog, error)
DiscoverHTTP opens and closes a fresh discovery-only HTTP connection. Use the same endpoint trust policy as ConnectHTTP. No executable client or remotely supplied schema is returned. Never register tools from this data.
func DiscoverIO ¶
func DiscoverIO(ctx context.Context, stream io.ReadWriteCloser, cfg DiscoveryConfig) (Catalog, error)
DiscoverIO uses a separate, already-open duplex stream. Configuration failure leaves ownership with the caller; once discovery begins the stream is owned and closed by this function, including on failure.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client owns the initialized SDK connection and its approved tool set. Close it after all runs finish. Tools must not be used after Close.
func ConnectHTTP ¶
ConnectHTTP uses the official SDK's Streamable HTTP request/response subset. Responses must terminate within the request deadline and fit in maxFrame. No standalone SSE, redirect, OAuth discovery, proxy or automatic reconnect. The caller chooses the trusted endpoint; this is not SSRF or remote isolation.
func ConnectIO ¶
ConnectIO connects through an already-open, trusted duplex stream. The caller retains ownership on configuration failure. Once the SDK connection attempt begins, this function owns the stream, including on failure. Closing the stream must unblock reads and writes. Context limits are cooperative; the transport is not a sandbox for remote effects.
type Config ¶
type Config struct {
// ProtocolVersion must be 2025-11-25 or 2026-07-28. A different
// negotiated version is rejected.
ProtocolVersion string
Bindings []Binding
// Zero selects the defaults (15 seconds for connect, 30 for each call).
// Positive values must not exceed two minutes.
ConnectTimeout time.Duration
CallTimeout time.Duration
}
type DiscoveryConfig ¶
type DiscoveryConfig struct {
ProtocolVersion string
Timeout time.Duration
MaxPages int
MaxTools int
}
DiscoveryConfig is independent of execution Config. Zero values select 15 seconds, four pages, and 64 tools; ProtocolVersion is required.
type HTTPConfig ¶
type HTTPConfig struct {
Endpoint string
BearerToken string
// RootCAs optionally replaces the system trust roots with a copied pool.
// Certificate and hostname verification are always enabled.
RootCAs *x509.CertPool
}
HTTPConfig specifies a caller-trusted MCP endpoint and optional credentials. HTTPS is required except for unauthenticated literal loopback HTTP.
type TextResult ¶
type TextResult struct {
Text []string `json:"text"`
}
TextResult retains individual textual blocks in order. Remote metadata and annotations are not included. Text may contain sensitive or untrusted data.