MCP gateway overview
The MCP gateway (mcp/) is how AI agents reach Luna. It is a remote Model Context Protocol server, at protocol revision 2026-07-28, that answers read-only tools on behalf of a person or a registered agent. Read this page if you are calling the gateway, adding a tool to it, or working out why a call was refused. For the tools themselves, see Tools.
The gateway README is the full protocol reference: the assertion format, every header and every check.
Who calls it
The gateway's only caller is and-harness, AND Digital's agent runtime. There is no Cognito client, no shared secret and no API Gateway authorizer in front of it: the gateway verifies every request itself, and a request without a valid harness assertion gets nothing back but a refusal.
It is not a domain service. It owns no business data and reads Luna by invoking the domain service that owns the data, as the person it is acting for.
How a request is authenticated
Each request goes through two checks before any tool runs:
- The harness assertion. and-harness signs a short-lived token for every request, sent as
Authorization: Bearer <assertion>. It names the principal and-harness is acting for, the gateway it is meant for and a hash of the exact request body. The gateway checks it against the and-harness issuers its environment trusts and refuses a replayed one. - The delegated identity mint. The gateway then invokes the
authservice's delegated identity mint with the verified principal. The mint decides whether Luna can act for it and, if so, answers a delegated identity token valid for 120 seconds that carries the same claims as a Luna sign-in (ANDi id, name, business unit, roles). The gateway sends that token on every domain call it makes for the request and never returns, stores or logs it.
Tools take the caller's identity from that token, never from an argument.
Principals
The assertion's subject names one of two principal kinds.
| Principal | Subject | Refused by the mint when | Answer |
|---|---|---|---|
| Person | person:<work email> | they are not exactly one Active ANDi of an allowed type | 403 not_in_luna |
| Agent | agent:<agent id> | it is unknown, suspended, expired or not this and-harness client's | 403 not_permitted |
The mint also refuses, as 403 not_permitted, a subject kind its issuer's registry entry does not list under principals (agents only when absent); the field is documented in mcp/README.md.
A person may call every tool that allows people. An agent may call only what its record in the agent registry grants it, within each grant's data scope: tools/list answers an agent just its granted tools, and an agent calling any other tool by name gets Unknown tool. The people tools allow people only; list_engagement_budgets allows agents only, and only the agents a per-tool grant names. The billing tools, get_invoicing_calendar and the billable amounts tools allow both: an agent through a per-tool grant, and a person within their own and additional business units (every unit for a commercial admin). The billable amounts tools also need the read Actuals permission on the caller's Luna roles, which Luna checks: a person holds it through the CommercialAdmin, BusinessUnitLead or ClientServices role, and an agent through the HarnessBillingAgent role beside its tool grant. They are listed only to people whose roles have a read Actuals row; Luna decides each call. See Agent access and grants and the tools.
Environments and issuers
Each environment trusts the and-harness issuers listed in the SSM parameter /luna/<env>/mcp-gateway/harness-issuers, set out of band.
| Environment | Trusted issuer |
|---|---|
sol | the and-harness dev issuer |
production | the and-harness prod issuer, once production is enabled |
polaris, pulsar, staging | none |
An environment with no issuer deploys closed: every assertion is refused with 401. Setting an issuer's status to anything but active cuts it off with 403 harness_suspended within a minute.
Calling the gateway from a lower environment
Only sol trusts an issuer today, so it is the lower environment to test against with the and-harness dev instance.
The endpoint
The gateway serves https://mcp-gateway.v2.<env>…/mcp. POST /mcp takes one JSON-RPC 2.0 request and returns one JSON response; there is no streaming, no session and no initialize handshake.
| Method | Answer |
|---|---|
server/discover | the supported protocol versions, the tools capability and the server identity |
tools/list | the tools the caller may call, each with its input and output schema |
tools/call | the result of one listed tool, see Tools |
initialize | refused with -32022: the gateway speaks only 2026-07-28 |
A client may validate a tool result's structuredContent against that tool's outputSchema from tools/list. An error result matches the one error shape every tool shares, listed under Tools.
GET /health and GET /.well-known/oauth-protected-resource are public and reveal nothing about callers.
Status codes
| Status | When |
|---|---|
200 | a result, including a tool's own error result |
400 | a malformed request, a header that does not match the body, an unsupported version, an unknown tool or invalid arguments |
401 | invalid_assertion: the harness assertion was refused |
403 | gateway_disabled or source_not_allowed (a kill switch), not_in_luna or not_permitted (the mint refused the principal), harness_suspended (the issuer is cut off) or origin_not_allowed |
404 | an unknown method |
405 | GET or DELETE /mcp |
429 | throttled by API Gateway (10 requests a second, bursts of 20) |
503 | luna_unavailable: something the gateway depends on to verify the request, such as a kill switch parameter, failed; treat it as an outage |
The gateway's own refusals (401, 403, 503) share one body, and and-harness maps on code:
{ "error": { "code": "not_in_luna", "message": "<short text>", "requestId": "<correlation id>" } }Every response carries x-correlation-id, which matches the requestId in a refusal.
