Documentation
¶
Overview ¶
Package streamable provides a streamable HTTP proxy for MCP servers.
Index ¶
- Constants
- type HTTPProxy
- func (p *HTTPProxy) ForwardResponseToClients(_ context.Context, msg jsonrpc2.Message) error
- func (p *HTTPProxy) GetMessageChannel() chan jsonrpc2.Message
- func (p *HTTPProxy) GetResponseChannel() <-chan jsonrpc2.Message
- func (p *HTTPProxy) IsRunning() (bool, error)
- func (p *HTTPProxy) SendMessageToDestination(msg jsonrpc2.Message) error
- func (p *HTTPProxy) SendResponseMessage(msg jsonrpc2.Message) error
- func (p *HTTPProxy) Start(_ context.Context) error
- func (p *HTTPProxy) Stop(ctx context.Context) error
- type Option
- func WithAuthInfoHandler(h http.Handler) Option
- func WithPrefixHandlers(handlers map[string]http.Handler) Option
- func WithReadTimeout(d time.Duration) Option
- func WithSessionStorage(storage session.Storage) Option
- func WithSessionTTL(ttl time.Duration) Option
- func WithStandaloneSSE(enabled bool) Option
- func WithStrictProtocolValidation(enabled bool) Option
Constants ¶
const (
// StreamableHTTPEndpoint is the endpoint for streamable HTTP.
StreamableHTTPEndpoint = "/mcp"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPProxy ¶
type HTTPProxy struct {
// contains filtered or unexported fields
}
HTTPProxy implements a proxy for streamable HTTP transport.
func NewHTTPProxy ¶
func NewHTTPProxy( host string, port int, prometheusHandler http.Handler, middlewares []types.NamedMiddleware, opts ...Option, ) *HTTPProxy
NewHTTPProxy creates a new HTTPProxy for streamable HTTP transport.
func (*HTTPProxy) ForwardResponseToClients ¶
ForwardResponseToClients forwards a response from the container to the client.
func (*HTTPProxy) GetMessageChannel ¶
GetMessageChannel returns the message channel for sending JSON-RPC to the container.
func (*HTTPProxy) GetResponseChannel ¶
GetResponseChannel returns the response channel for receiving JSON-RPC from the container.
func (*HTTPProxy) SendMessageToDestination ¶
SendMessageToDestination sends a message to the container.
func (*HTTPProxy) SendResponseMessage ¶
SendResponseMessage is for compatibility with the Proxy interface.
type Option ¶ added in v0.13.0
type Option func(*HTTPProxy)
Option configures an HTTPProxy.
func WithAuthInfoHandler ¶ added in v0.29.2
WithAuthInfoHandler sets the handler for RFC 9728 OAuth protected resource discovery. When set, the handler is mounted at /.well-known/ outside the middleware chain. When nil, /.well-known/ returns a clean JSON 404 so OAuth clients parse it cleanly.
func WithPrefixHandlers ¶ added in v0.29.2
WithPrefixHandlers registers additional HTTP handlers mounted before the MCP endpoint. These are mounted outside the middleware chain (RFC 9728, embedded auth server routes).
func WithReadTimeout ¶ added in v0.30.0
WithReadTimeout overrides http.Server.ReadTimeout for this proxy, which bounds reading the entire request (headers + body). Zero or negative values are ignored so the constructor's default (defaultReadTimeout) is preserved.
func WithSessionStorage ¶ added in v0.13.0
WithSessionStorage injects a custom storage backend into the session manager. When not provided, the proxy uses in-memory LocalStorage (single-replica default).
func WithSessionTTL ¶ added in v0.28.0
WithSessionTTL overrides the session inactivity timeout used by this proxy. Zero or negative values are ignored so the constructor's default is preserved.
func WithStandaloneSSE ¶ added in v0.41.0
WithStandaloneSSE controls whether GET /mcp opens a standalone SSE stream for server->client notifications. It defaults to enabled; pass false to opt out and restore the prior behavior of returning 405 for GET requests.
func WithStrictProtocolValidation ¶ added in v0.41.0
WithStrictProtocolValidation enables strict MCP-Protocol-Version checking. When enabled, a request whose MCP-Protocol-Version header names an unsupported/unknown MCP revision is rejected with HTTP 400. An absent header is still accepted (the streamable HTTP spec says to assume 2025-03-26). Default (false) preserves the version-agnostic behavior: any version string is accepted.