Documentation
¶
Overview ¶
Package httpserve exposes the aggregation endpoint over the MCP Streamable HTTP transport (POST + standalone GET SSE stream). It owns the listener, the session table, and the transport semantics; nothing here knows about aggregation — it only adapts HTTP to server.Session.
Index ¶
Constants ¶
const ( // DefaultAddr is the default listen address (web owns 8080). DefaultAddr = "127.0.0.1:8081" // DefaultSessionIdleTimeout reaps sessions whose client stopped acting. DefaultSessionIdleTimeout = 30 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
Core *server.Core
Addr string // default DefaultAddr
// Token is the bearer token required on every request. "" is only
// allowed on a loopback bind — New refuses a non-loopback Addr without
// one, because serve-mode tools/call is arbitrary code execution.
Token string
AllowedOrigins []string // extra Origin allowlist entries (loopback is always allowed)
// SessionIdleTimeout reaps sessions with no client action (POST, DELETE,
// GET attach) for this long. 0 = never reap. Keepalive writes are
// deliberately not activity — a write into a black-holed connection
// "succeeds" into the socket buffer for minutes.
SessionIdleTimeout time.Duration
// Per-Session defaults, mirroring the serve flags.
Namespace string // default when the URL has no namespace segment
EagerStart bool
ExposeManagerTools bool
ExposeResources bool
ExposePrompts bool
Compression server.CompressionLevel
CompressionForceOff bool // explicit `--compress off` (see server.Options)
ServerVersion string
}
Options configures the HTTP serve listener.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the Streamable HTTP listener plus its session table.
func (*Server) ListenAndServe ¶
ListenAndServe serves until Shutdown or a listener error.
func (*Server) Serve ¶
Serve serves on an existing listener (tests). New's tokenless-bind refusal checks only the configured Addr, so re-check whatever listener actually got passed in — it may reach interfaces New never saw.
func (*Server) Shutdown ¶
Shutdown drains active requests, then tears down every session. The Core is the caller's to close (it may outlive this listener in tests).
beginDrain runs first, deliberately: it marks the server closed so register refuses new sessions for the entire drain (one slipping past would otherwise register after the snapshot below and its session/private instances would never be stopped), and it ends only the standalone GET SSE streams — they never idle, so http.Shutdown would otherwise wait out its whole grace period on every Ctrl-C with a connected client. Ending just the streams — not a full teardown — keeps sessions alive while in-flight POST round trips finish.