Documentation
¶
Overview ¶
Package server provides MCP transport serving (stdio/http/both) and the Transport type shared across acidsailor MCP servers.
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 ¶
Types ¶
type Option ¶
type Option func(*Server)
Option configures a Server.
func WithHTTPServer ¶ added in v0.2.0
WithHTTPServer sets the *http.Server for the HTTP and Both transports, served as-is (Handler, Addr, timeouts, TLSConfig, … unchanged). Set its Handler yourself — typically Handler(mcpServer), optionally wrapped or mounted in a mux. A non-nil TLSConfig serves HTTPS and must carry its own certificates. Required for HTTP and Both (else ErrNoHTTPServer); a nil Handler is rejected at serve time with ErrNilHandler.
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 // escape hatch to the underlying 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" // stdin/stdout HTTP Transport = "http" // streamable HTTP Both Transport = "both" // stdio + HTTP concurrently )
Supported transports.
func ParseTransport ¶
ParseTransport parses s into a Transport, wrapping ErrInvalidTransport for an unsupported value.
func (*Transport) UnmarshalText ¶
UnmarshalText lets text-based config loaders (env, flag, json) parse a Transport.