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 WithRequestHeaderProvider(provider RequestHeaderProvider) Option
- func WithRunTimeout(timeout time.Duration) Option
- func WithSessionHeaderName(name string) Option
- func WithSessionID(id string) Option
- func WithStateless() Option
- type RequestHeaderProvider
- 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 stateful and stateless Streamable HTTP transport. Stateful mode retains the legacy POST handshake and background GET stream. Stateless mode carries requests, notifications, and bidirectional messages on independent POSTs, with optional SSE responses for streaming.
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 WithRequestHeaderProvider ¶ added in v0.24.0
func WithRequestHeaderProvider(provider RequestHeaderProvider) Option
WithRequestHeaderProvider installs a hook invoked for each outgoing POST after static transport headers have been copied.
func WithRunTimeout ¶ added in v0.24.0
WithRunTimeout controls how long Send waits for a JSON-RPC response. A non-positive duration disables the transport timer and relies on context cancellation, which is useful for long-lived requests.
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.
func WithStateless ¶ added in v0.24.0
func WithStateless() Option
WithStateless enables independent POST-based Streamable HTTP requests. In this mode no session id or background GET stream is required.
type RequestHeaderProvider ¶ added in v0.24.0
RequestHeaderProvider derives per-message HTTP headers from the encoded JSON-RPC payload. Protocol layers can use this without coupling jsonrpc to protocol-specific routing headers.