Documentation
¶
Overview ¶
Package server serves a set of tools as an MCP server. It enforces the permission decision for every tool: denied tools are left out of tools/list, and a call that names one anyway gets a denial result without any upstream request (docs/SPEC.md section 4). Every call is written to the audit log (section 6).
Index ¶
Constants ¶
const HealthPath = "/healthz"
HealthPath answers 200 without a key, for load balancers and scripts that wait for the server to be up. It says nothing about the API.
const MCPPath = "/mcp"
MCPPath is where the MCP endpoint is served over HTTP.
const MinHTTPKey = 16
MinHTTPKey is the shortest key HTTPHandler accepts.
const (
StoppedMessage = "" /* 126-byte string literal not displayed */
)
Result texts for a call refused because of the audit log.
Variables ¶
This section is empty.
Functions ¶
func DeniedMessage ¶
DeniedMessage is the result text for a call to a tool the policy denies.
func HTTPHandler ¶
HTTPHandler serves srv over Streamable HTTP (docs/SPEC.md section 5).
Every request to MCPPath must carry "Authorization: Bearer <key>". A request a browser sends from another site is refused, so a web page can't reach a writgate on the visitor's machine or network.
The transport is stateless: each request stands alone and gets a JSON response, so any number of instances can sit behind a load balancer. A tool call is cancelled when its HTTP request is.
func New ¶
New builds the MCP server. Decisions are made once, at startup: one policy per instance, so they can't change while it runs.
func UnresolvedMessage ¶
UnresolvedMessage is the result text for a call refused because an earlier attempt at the same action has an unknown result.
Types ¶
type Config ¶
type Config struct {
Name string // server name reported to clients
Version string
Tools []*tools.Tool
Client *upstream.Client
Policy *policy.Policy
Audit *audit.Log // nil serves without an audit log, for tests
// Secrets are values to keep out of the audit log wherever they appear,
// such as the upstream API key.
Secrets []string
// Unresolved are the intent records of calls whose result is still
// unknown after recovery. Each blocks a new attempt at the same action
// under a different Idempotency-Key.
Unresolved []audit.Record
Logger *slog.Logger // nil discards logs
}
Config is what New needs.