Documentation
¶
Overview ¶
Package gateway is the MCP gateway core. It terminates streamable-HTTP on the front, runs every message through the inspection pipeline, then routes to one or more backends (aggregating with tool prefixes when several).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
Gateway is the shared front for all sessions.
type HeldCall ¶
type HeldCall struct {
Session string
User string
Backend string
Tool string
Args []byte
Rule string
}
HeldCall describes one parked tool call.
type HeldStore ¶
type HeldStore interface {
// Hold parks a call and returns a resolution channel. The channel
// yields true (approved) or false (rejected) exactly once.
Hold(ctx context.Context, h HeldCall) (id string, resolved <-chan bool, err error)
}
HeldStore parks messages awaiting human approval.
type IdentityResolver ¶
IdentityResolver authenticates an HTTP request (inbound auth). It returns the caller identity or an error that terminates the request. The gateway stays auth-agnostic: the daemon (or hoop) supplies the resolver.
type Observer ¶
type Observer interface {
ObserveMessage(dir inspect.Direction, backendName, method, tool, decision string, dur time.Duration)
}
Observer is the telemetry seam: one call per gateway-processed message.
type Options ¶
type Options struct {
// Backends: name → factory. Names are tool prefixes in aggregation.
Backends map[string]backend.Factory
// Pipeline is the ordered check chain applied to every message.
Pipeline []inspect.Check
// Resolver authenticates requests. nil = anonymous.
Resolver IdentityResolver
// Sink receives audit events. nil = discard.
Sink audit.Sink
// SessionIdleTimeout reaps sessions with no traffic. 0 = 30m.
SessionIdleTimeout time.Duration
// RequestTimeout bounds one round-trip to a backend. 0 = 5m, since
// slow tool calls are normal. Approvals hold longer via ctx.
RequestTimeout time.Duration
// Held is the approval parking lot; nil disables Hold verdicts
// (they become Deny).
Held HeldStore
// Observer receives per-message timing/decision telemetry. Optional.
Observer Observer
Logger *slog.Logger
}
Options assemble a Gateway.