Skip to content

Gating The Endpoint

The MCP endpoint must never answer an anonymous request. Arc enforces that with the capability gate: endpoints selected for gating are served only on the capabilities port and only after a verified caller is admitted.

WithMcp needs all of these, in any registration order. The check runs when the host starts:

  • WithCapabilities(...) for capability hosting.
  • A port for the capabilities endpoint group: options.EndpointGroups.Assign("capabilities", port).
  • A verified caller installation: WithPersonalAccessTokens(...) or WithVerifiedCallers(...).
.WithCapabilities()

You do not set CapabilitiesOptions.GatedEndpoints for MCP. When it is unset, Arc gates every endpoint on the capabilities port after routing, so /mcp is never served without a verified caller. The OAuth protected resource metadata endpoint stays reachable without a caller so clients can discover how to authenticate; it is the only exempt route. Other routes on that port, such as health probes, then need a verified caller too; see the upgrade notes.

An explicit GatedEndpoints selection is respected unchanged. WithMcp adds the MCP endpoint to it, so you do not list /mcp yourself, and the rest of the port stays outside the gate.

Situation Result
Request on the default port Not served.
Request on the capabilities port with no accepted credential 401 unauthorized with a WWW-Authenticate challenge.
Credential of a kind the profile does not accept 401 unauthorized.
Verified caller Admitted. Scope and authorizer checks follow; see Authorization.

Assigning the port does not bind a listener. Bind both the default listener and one on the capabilities port, and make that port reachable only through your trusted ingress; see Turn it on.

var app = builder.Build();
app.UseCratisArc();
app.MapArcMcp();

MapCratisArcMcp still works as an obsolete forwarder to MapArcMcp and is removed in Arc 24.