Documentation
¶
Overview ¶
Package client declares the interfaces that make up the *client side* of the Model Context Protocol (MCP).
The core element is Operations, a collection of strongly-typed methods that mirror the JSON-RPC requests defined by the MCP specification (e.g. roots listing, sampling, user interaction, etc.). Implementations embed or implement Operations to gain compile-time safety when calling an MCP server.
In addition, the Handler interface extends Operations with the ability to receive asynchronous JSON-RPC notifications via the OnNotification hook.
The package contains *interfaces only* and purposefully holds no concrete implementation so that different transports (HTTP, stdio, WebSockets, …) can provide their own clients while sharing the same contract.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶ added in v0.4.0
type Handler interface { Operations OnNotification(ctx context.Context, notification *jsonrpc.Notification) }
Handler extends Operations with support for JSON-RPC notifications.
type Operations ¶
type Operations interface { transport.Notifier transport.Sequencer ListRoots(ctx context.Context, request *jsonrpc.TypedRequest[*schema.ListRootsRequest]) (*schema.ListRootsResult, *jsonrpc.Error) CreateMessage(ctx context.Context, params *jsonrpc.TypedRequest[*schema.CreateMessageRequest]) (*schema.CreateMessageResult, *jsonrpc.Error) Elicit(ctx context.Context, params *jsonrpc.TypedRequest[*schema.ElicitRequest]) (*schema.ElicitResult, *jsonrpc.Error) Implements(method string) bool Init(ctx context.Context, capabilities *schema.ClientCapabilities) }