This runtime now exposes a dedicated admin MCP surface at /admin/mcp.
Use it for operator-guided agents that already hold the runtime x-admin-secret
and need a tool-oriented interface for privileged tasks such as:
- minting bearer tokens for downstream mailbox or tenant workflows
- inspecting runtime state that is only available through debug surfaces
- updating tenant send policy during review or suspension flows
- managing suppressions
The normal /mcp endpoint is the default mailbox and tenant workflow surface.
It is bearer-token based, least-privilege by design, and intended for normal
agent integrations.
/admin/mcp is intentionally separate because it:
- uses
x-admin-secret, not bearer auth - is gated by
ADMIN_ROUTES_ENABLED - requires
ADMIN_ROUTES_ALLOW_PUBLIC_HOSTS=truein addition toADMIN_ROUTES_ENABLED=truewhen the request host is onmailagents.net - exposes high-trust operator and forensic capabilities
- should not appear in default mailbox-agent workflow planning
This keeps normal agent discovery safe while still giving operator agents a first-class MCP interface.
The TypeScript client also exposes typed admin helpers on top of this surface, including:
withAdminSecret()getAdminMcpMetadata()getAdminWorkflowSurface()adminCreateAccessToken()adminBootstrapMailboxAgentToken()adminBootstrapMailboxAgentWorkflow()adminListAgents()adminGetTenantSendPolicy()adminApplyTenantSendPolicyReview()adminGetTenantReviewContext()adminReviewTenantOutboundAccessWorkflow()adminGetDebugMessage()adminInspectDeliveryCase()adminInspectDeliveryCaseWorkflow()adminAddSuppression()
/admin/mcp supports the same minimal HTTP MCP methods as /mcp:
initializetools/listtools/call
Transport notes:
POSTaccepts JSON-RPC requests, notifications, and batches- JSON-RPC notifications return
202 Acceptedwith an empty body GETis exposed as a transport placeholder and currently returns405 Method Not Allowed- browser callers that send an
Originheader must be same-origin; SDK and CLI callers withoutOrigincontinue to work
Auth requirements:
ADMIN_ROUTES_ENABLED=trueADMIN_ROUTES_ALLOW_PUBLIC_HOSTS=trueas well when the request host is onmailagents.net- header:
x-admin-secret: ...
initialize returns the normal runtime metadata under result.meta plus an
adminMcp section describing the admin path, auth mode, admin tool list, and
the current admin workflow packs.
The narrower compatibility contract at /v2/meta/compatibility also exposes
an optional admin.mcp section when admin routes are enabled. That section is
useful for agents that want a more stable machine-readable discovery surface
before they call admin MCP directly.
Each admin workflow pack currently includes:
descriptiongoalcategoriesrecommendedToolSequencesideEffectsstopConditions
Current admin workflow packs:
bootstrap_mailbox_agentreview_tenant_outbound_accessforensic_delivery_inspection
For a doc-first and machine-readable snapshot of those workflow packs, see:
create_access_tokenbootstrap_mailbox_agent_tokenlist_agentsget_agentlist_mailboxesget_mailboxget_tenant_send_policyupsert_tenant_send_policyapply_tenant_send_policy_reviewget_tenant_review_contextget_debug_messageget_debug_draftget_debug_outbound_jobinspect_delivery_caseget_suppressionadd_suppression
The recommended pattern is:
- use
create_access_tokento mint the narrowest bearer token needed - drop back to the normal
/mcpor HTTP mailbox routes for standard work - reserve admin MCP for operator-only decisions and forensic inspection
For SDK users, MailagentsAgentClient(...).operator().openMailboxSession()
wraps that handoff directly: admin MCP performs the bootstrap, then the
returned mailbox session continues on the normal mailbox-scoped helper surface.
Runnable repository examples:
npm run example:agent:discover-adminnpm run example:agent:admin-workflowsnpm run example:agent:operator-clientnpm run example:agent:admin-bootstrapnpm run example:agent:admin-reviewnpm run example:agent:admin-forensics
List admin tools:
curl -sS http://127.0.0.1:8787/admin/mcp \
-H 'content-type: application/json' \
-H "x-admin-secret: $ADMIN_SECRET" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list",
"params": {}
}'Mint a mailbox-scoped bearer token:
curl -sS http://127.0.0.1:8787/admin/mcp \
-H 'content-type: application/json' \
-H "x-admin-secret: $ADMIN_SECRET" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "create_access_token",
"arguments": {
"sub": "operator-agent",
"tenantId": "t_demo",
"agentId": "agt_demo",
"scopes": ["mail:read", "draft:create", "draft:send"],
"mailboxIds": ["mbx_demo"],
"expiresInSeconds": 1800
}
}
}'Inspect a message plus delivery events:
curl -sS http://127.0.0.1:8787/admin/mcp \
-H 'content-type: application/json' \
-H "x-admin-secret: $ADMIN_SECRET" \
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "get_debug_message",
"arguments": {
"messageId": "msg_demo_inbound"
}
}
}'- do not use admin MCP as the default integration path
- prefer minting a least-privilege bearer token and switching back to
/mcp - keep
ADMIN_ROUTES_ENABLEDoff outside controlled environments unless there is an explicit operator need - treat
upsert_tenant_send_policy,apply_tenant_send_policy_review, andadd_suppressionas human-review actions