Documentation
¶
Index ¶
- Constants
- func AddModernRequestMetadata(params json.RawMessage, options ClientOptions) (json.RawMessage, error)
- func ProtocolVersionForMode(mode ProtocolMode) (string, error)
- type CallToolRequest
- type CallToolResult
- type Client
- type ClientOptions
- type Content
- type Implementation
- type ListToolsResult
- type ProtocolMode
- type SessionClient
- type Tool
Constants ¶
const ( // ProtocolModeLegacy uses the stateful initialize/session protocol. ProtocolModeLegacy ProtocolMode = "legacy" // ProtocolModeModern uses the stateless per-request metadata protocol. ProtocolModeModern ProtocolMode = "modern" ProtocolVersionLegacy = "2025-11-25" ProtocolVersionModern = "2026-07-28" // ProtocolVersion is retained for source compatibility and names the // default protocol used by existing constructors. ProtocolVersion = ProtocolVersionLegacy )
Variables ¶
This section is empty.
Functions ¶
func AddModernRequestMetadata ¶ added in v0.4.4
func AddModernRequestMetadata(params json.RawMessage, options ClientOptions) (json.RawMessage, error)
AddModernRequestMetadata merges the metadata required by the stateless MCP protocol into an object-shaped params payload.
func ProtocolVersionForMode ¶ added in v0.4.4
func ProtocolVersionForMode(mode ProtocolMode) (string, error)
ProtocolVersionForMode returns the wire revision for an explicit mode.
Types ¶
type CallToolRequest ¶
type CallToolRequest struct {
Name string `json:"name"`
Arguments json.RawMessage `json:"arguments,omitempty"`
}
type CallToolResult ¶
type CallToolResult struct {
Content []Content `json:"content,omitempty"`
StructuredContent json.RawMessage `json:"structuredContent,omitempty"`
IsError bool `json:"isError,omitempty"`
}
type Client ¶
type Client interface {
ListTools(ctx context.Context) ([]Tool, error)
CallTool(ctx context.Context, req CallToolRequest) (CallToolResult, error)
}
type ClientOptions ¶ added in v0.4.4
type ClientOptions struct {
Mode ProtocolMode
ClientInfo Implementation
ClientCapabilities map[string]any
}
ClientOptions configures the MCP protocol era and modern request metadata. The zero value selects legacy mode.
func NormalizeClientOptions ¶ added in v0.4.4
func NormalizeClientOptions(options ClientOptions, defaultVersion string) (ClientOptions, error)
NormalizeClientOptions validates options and fills deterministic defaults.
type Content ¶
type Content struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Data json.RawMessage `json:"data,omitempty"`
Mime string `json:"mimeType,omitempty"`
}
type Implementation ¶ added in v0.4.4
Implementation identifies an MCP implementation on the wire.
type ListToolsResult ¶ added in v0.4.2
type ListToolsResult struct {
Tools []Tool `json:"tools"`
NextCursor string `json:"nextCursor,omitempty"`
TTLMs *int64 `json:"ttlMs,omitempty"`
CacheScope string `json:"cacheScope,omitempty"`
}
ListToolsResult is the MCP tools/list response shape. TTLMs and CacheScope are optional forward-compatible cache hints for newer protocol revisions.
type ProtocolMode ¶ added in v0.4.4
type ProtocolMode string
ProtocolMode selects one MCP protocol era explicitly. Clients never auto-negotiate or fall back between eras: a deployment must choose the mode implemented by its server.
type SessionClient ¶ added in v0.3.1
type SessionClient interface {
Client
// SessionID returns the session id assigned during initialize (empty when
// the server is stateless or the handshake has not completed).
SessionID() string
// Terminate ends the server-side session and resets local handshake
// state; the next call re-initializes. No-op without an active session.
Terminate(ctx context.Context) error
}
SessionClient is an optional capability for clients that hold a server-side MCP session. Callers that manage long-lived clients should terminate the session instead of dropping the client silently, so servers can reclaim session state immediately instead of waiting for their idle TTL.