Documentation
¶
Index ¶
- type Client
- type Option
- func WithHTTPClient(client *http.Client) Option
- func WithHandler(handler transport.Handler) Option
- func WithHandshakeTimeout(duration time.Duration) Option
- func WithListener(listener jsonrpc.Listener) Option
- func WithProtocolVersion(version string) Option
- func WithSessionHeaderName(name string) Option
- func WithSessionID(id string) Option
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements streamable-http transport consumer (MCP 2025-03-26 spec). Handshake: POST /mcp -> obtains session id header. Stream : GET /mcp with same header and Accept: application/x-ndjson keeps receiving messages. Messages : subsequent POST /mcp with header carry requests/notifications.
func (*Client) Close ¶ added in v0.18.0
Close terminates the background SSE stream goroutine started by ensureStream and cancels any in-flight stream read. Safe to call multiple times. Returns nil; the signature exists so callers (e.g. pool managers) can treat the client as a regular io.Closer-like resource.
type Option ¶
type Option func(*Client)
Option mutates Client.
func WithHTTPClient ¶
WithHTTPClient allows custom http.Client for both SSE stream (GET) and JSON-RPC message (POST) requests.
func WithHandler ¶
WithHandler sets the handler for the SSE sseClient
func WithHandshakeTimeout ¶
WithHandshakeTimeout overrides default handshake timeout.
func WithListener ¶
WithListener sets a listener that observes low-level transport messages.
func WithProtocolVersion ¶
WithProtocolVersion sets the MCP protocol version header (MCP-Protocol-Version) to be included on all HTTP requests made by the client (handshake, POSTs, and GET stream).
func WithSessionHeaderName ¶
WithSessionHeaderName sets a custom HTTP header name used to carry the session id. Defaults to "Mcp-Session-Id".
func WithSessionID ¶ added in v0.15.0
WithSessionID sets an explicit session id for the client. When set, the client immediately applies the session header to POST requests and uses the same header on GET stream requests, allowing reconnects without a handshake. It also starts the background stream loop.