Documentation
¶
Overview ¶
Package server serves an mcp.Server over stdio, HTTP, or both.
HTTP transports require a caller-configured *http.Server. Its handler, address, timeouts, TLS settings, and hooks are used unchanged. A non-nil TLSConfig selects HTTPS. WithShutdownTimeout controls graceful shutdown.
A stateless streamable HTTP handler supports protocol 2026-07-28 and current elicitation. Older clients need stdio or a stateful handler for gated writes. Stateful multi-replica deployments need session affinity.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilServer = errors.New("nil mcp server") ErrInvalidTransport = errors.New("invalid transport") ErrInvalidAddr = errors.New("invalid server address") ErrServe = errors.New("serve") ErrShutdown = errors.New("shutdown") ErrNilHandler = errors.New("nil http handler") ErrNoHTTPServer = errors.New("no http server") )
Sentinels for server failures, wrapped with detail at the entry point.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Server)
Option configures a Server.
func WithHTTPServer ¶ added in v0.2.0
WithHTTPServer sets the caller-owned *http.Server for HTTP and Both.
func WithShutdownTimeout ¶
WithShutdownTimeout sets the HTTP graceful-shutdown timeout (default 30s).
func WithTransport ¶
WithTransport sets the transport (default Stdio).
type Server ¶
type Server struct {
MCP *mcp.Server // Underlying MCP server.
// contains filtered or unexported fields
}
Server serves an mcp.Server over the configured transport(s).
type Transport ¶
type Transport string
Transport selects the MCP transport mechanism.
const ( Stdio Transport = "stdio" // Stdio uses standard input and output. HTTP Transport = "http" // HTTP uses streamable HTTP. Both Transport = "both" // Both runs Stdio and HTTP concurrently. )
Supported transport values.
func ParseTransport ¶
ParseTransport parses s, wrapping ErrInvalidTransport for a bad value.
func (*Transport) UnmarshalText ¶
UnmarshalText lets text config loaders (env, flag, json) parse a Transport.