Skip to Content
Enterprise

External MCP access

Connecting external MCP clients: the endpoint, OAuth 2.1 and API keys, sessions, what is exposed and the boundary rules.

Maturity: stable (85 %)

MCP. Each agent's gated tools are served to outside MCP clients with OAuth 2.1 or per-agent keys, and agents use external MCP servers and interactive MCP App cards.

  • Keep the MCP port private unless remote MCP clients are intended.
  • Treat a per-agent MCP key like its creator's own credential.
  • The MCP Apps of one user share a single sandbox origin per deployment.

How maturity is measured

The package protocol runs in both directions: packages bring capabilities into Neuralis, and the embedded MCP (Model Context Protocol) HTTP service projects them back out, so external clients such as Claude Desktop, Cursor, VS Code, ChatGPT or any custom MCP client can use the platform's tools, prompts and resources. An external client is just another authenticated caller with a scope, under the same security layers as the in-app surface.

This page covers the inbound direction. An agent connecting out to someone else's MCP server is described under agent-core Routes.

The endpoint

The service listens on its own port (3101 by default, any address via MCP_BASE_URL). It is the OAuth issuer and the bearer endpoint; the browser part of a sign-in (login and consent) always happens on the app's own address, so a separate MCP hostname needs no extra cookie setup.

  • POST /mcp, GET /mcp (SSE), DELETE /mcp: the protocol endpoint (initialize, tools/*, resources/* including subscribe, prompts/*, logging control).
  • /healthz: process liveness only (readiness is on the app port, see Deployment).
  • OAuth discovery and flow routes: /.well-known/oauth-protected-resource (and …/api for the package-route API), /.well-known/oauth-authorization-server, /oauth/authorize, /oauth/token, /oauth/revoke (RFC 7009), /oauth/jwks.json and /oauth/register (RFC 7591). A URL-shaped client_id is accepted as a stable identifier, but the document it points at is never fetched: that would put an outbound request to a caller-supplied URL on an unauthenticated endpoint.

The agent configuration panel generates ready-to-paste snippets for every client: remote streamable HTTP or a local mcp-remote stdio bridge, with OAuth (the primary path) or a static API key for headless clients.

Authentication

Exactly two paths authenticate an external request; there is no anonymous access.

OAuth 2.1. The client obtains a Bearer JWT, and the caller's user, project and agent come from the verified claims. A token is audience-bound to one of two resources: this MCP server, or the app's package-route API (<app origin>/api, scope routes:call) that the Neuralis CLI signs in for. An RFC 8707 resource indicator selects one and is validated; codes and refresh grants are bound to their resource, so a token can never be minted for or replayed against the other. The consent screen names every resource asked for, its submission repeats every check the screen made, and every approval is audited without any code or token.

  • Refresh is client-bound. A refresh presents both the refresh_token and the registered client_id; a mismatched id cannot consume a valid token. Concurrent rotations are serialized, and for up to five minutes, in memory only, processes sharing one client credential receive the same successor.
  • A refresh token's lifetime slides with use: each rotation moves its expiry to thirty days from then, so an active client is never sent back to the browser, across restarts included. A token abandoned or stolen and never used still dies thirty days after its last use; the expiry is checked before it slides.
  • Only a SHA-256 hash is stored. If the token file becomes unreadable, the endpoint answers 503 temporarily_unavailable rather than acting as if no tokens existed. OAuth errors are fixed strings; detail goes to the server log.
  • Signing out revokes the grant (POST /oauth/revoke). An access token already issued stays valid until it expires, at most one hour.
  • The live feed. GET /api/events accepts the package-route API token when no browser cookie is present, runs the same account and membership checks, and keeps each channel's own authorization. ?channels= can only narrow it.

API keys, as a Bearer token or an x-api-key header, are for clients that cannot run the browser sign-in. A per-agent API key resolves to exactly that agent's user, project and agent. There is no platform-level key, and a value in x-api-key is never parsed as an OAuth token. Keys live in the encrypted credential store.

Sessions

An MCP session is a routing handle, not a credential: Mcp-Session-Id says which conversation a request belongs to, never who the caller is.

  • Every request re-authenticates, before the body is read and before the session is looked up. An expired or withdrawn token answers 401 with a WWW-Authenticate challenge, which makes a client refresh and retry.
  • Authorization is re-resolved, not remembered. When a role loses a feature mid-session, the next tools/call is denied and the next tools/list stops advertising it. An SSE stream that is already open stays open until the idle sweep; a denied request does not count as activity.
  • A session belongs to the principal that opened it. Your credential with someone else's session id is answered exactly like an unknown session.
  • An unknown session answers 404, the signal on which a client opens a fresh session after a restart or an upgrade; a missing header answers 400.
  • The per-user cap reclaims a slot: a new session over it closes that same user's oldest session not in use. Only when all of theirs are in use is it refused (429). The instance-wide cap always refuses.
  • Session limits are operational, not a security boundary, and apply on restart. Raising one widens no request, because the grant does not live in the session.

What is exposed

The service exposes every loaded package's hosted tools, prompts and resources, filtered for the authenticated scope: a disabled package's contributions and a contribution needing features the caller lacks are absent, never advertised as locked, and packages choose which contributions are hosted at all. A tools/call runs the same code path as in-app execution. Results are bounded: text content to 50,000 characters, structured content to 20,000, shrunk JSON-safely rather than cut mid-structure.

The in-run mcp tool, which reaches an agent's connected servers' on-demand tools, is not exposed here: an external client connects to those servers itself.

Hosted execute runs without an agent stream only when cwd names an exact registered executable source, and for a virtual desktop still requires machine.control and the caller's current scope. App or host shells and skill activation need a stream; MCP never creates a synthetic one.

Boundary rules

  • No identity override. x-user-id, x-project-id and x-agent-id from external callers are rejected; scope comes only from the verified token or key.
  • No synthetic identities. Claims naming an internal system identity are rejected before dispatch.
  • Method allowlist. Only the methods above (plus notifications and ping); batches are capped at 10 requests.
  • Origin allowlist. A request carrying an Origin header is refused 403 unless that origin is listed in MCP Allowed Origins (mcpAllowedOrigins, re-read per request). A request with no Origin (every non-browser client) is allowed, so an empty list stops only a web page driving the service through a visitor's browser.
  • Session hygiene. Per-user and instance-wide caps, idle and absolute timeouts, a periodic sweep, TCP keep-alive on SSE. A session carries no authority (see Sessions).

Deployment guidance

Keep port 3101 unexposed unless remote MCP clients, paired devices or the virtual desktop are intended, and put it behind TLS when they are. A client's redirect URI must be a loopback callback, an app's own scheme or a host listed in OAUTH_ALLOWED_REDIRECT_HOSTS, never the MCP address itself. Internally, packages never talk to each other through this endpoint; MCP is for the model and external clients (see the package system).

On this page