Exposing an MCP Server from an App

Exposing an MCP Server from an App

Numerous apps can expose a remote Model Context Protocol (MCP) (opens in a new tab) server over Streamable HTTP alongside (or instead of) a web UI and HTTP API. This lets AI agents and MCP clients such as Claude Code, Cursor, and VS Code call tools and read resources served directly by your deployed app.

Enabling MCP in numerous.toml

Add an [mcp] section to your app's numerous.toml and deploy the app:

numerous.toml
name = "Sales Analytics"
description = "Sales dashboard with MCP tools"
port = 8501
exclude = ["*venv", "venv*", ".git", ".env", ".env.*", ".envrc"]
 
[docker]
dockerfile = "Dockerfile"
context = "."
 
[mcp]
enabled = true
path = "/mcp" # optional, defaults to "/mcp"
  • enabled (bool): enables MCP exposure on the app's API domain (https://<app-slug>.api.numerous.com<path>).
  • path (string, optional): the HTTP path where your app mounts its MCP Streamable HTTP endpoint. Defaults to "/mcp". Must start with "/".

If you enable [mcp] without enabling [api], only requests to your configured MCP path (and subpaths under it) are forwarded through the API proxy. Your app's other routes remain inaccessible via API keys or user tokens unless [api] enabled = true is also set.

Apps with [mcp] enabled = true stay warm and are excluded from idle workload garbage collection, just like apps with [api] enabled = true.

Authentication Modes

App MCP endpoints accept Authorization: Bearer <token> using either:

  1. User Personal Access Token (num_...) or Numerous user access token — authenticates an individual Numerous user who is a member of the app's owning organization (or an organization with an active subscription to the app). Numerous forwards that user's verified identity and organization context on every request.
  2. App API key (app_api_...) — authenticates a deployment- or subscription-scoped key for shared integrations, automation, or service accounts. Numerous forwards the verified organization and API key metadata (with no individual user identity).

If a user belongs to multiple organizations that each have access to an app with the same slug, specify which organization to target using the X-Numerous-Organization: <org-slug> header. Numerous still verifies the user's membership in that organization before routing the request. If a single organization has access to multiple apps sharing the same slug (for example, an owned app and a subscribed app), use an App API key to target a specific deployment or subscription.

Verified User & Organization Identity in Apps

On every authenticated MCP (and API) request, the Numerous proxy injects verified identity headers (and, for user-authenticated requests, the same numerous_user_info cookie used for web user sessions):

HeaderUser token (num_... / OIDC)App API key (app_api_...)Description
X-Numerous-Auth-Typeuserapi_keyAuthentication mode verified by the proxy
X-Numerous-User-IdUser UUID(not set)Verified user ID (matches user_id in numerous_user_info)
X-Numerous-User-EmailUser email(not set)Verified user email (UTF-8 percent-encoded if non-ASCII)
X-Numerous-User-NameUser full name(not set)Verified user display name (UTF-8 percent-encoded if non-ASCII)
X-Numerous-Organization-IdOrg API IDOrg API IDVerified organization ID (matches NUMEROUS_ORGANIZATION_ID)
X-Numerous-Organization-SlugOrg slugOrg slugVerified organization slug
X-Numerous-Organization-NameOrg nameOrg nameVerified organization display name (UTF-8 percent-encoded if non-ASCII)
X-Numerous-API-Key-Id(not set)API key UUIDVerified App API key ID
X-Numerous-API-Key-Name(not set)API key nameVerified App API key name (UTF-8 percent-encoded if non-ASCII)

Control characters are stripped from all identity headers, and free-text fields (X-Numerous-User-Name, X-Numerous-User-Email, X-Numerous-Organization-Name, X-Numerous-API-Key-Name) UTF-8 percent-encode % and non-ASCII bytes so ASCII-only servers (such as ASGI/WSGI) receive valid header values. Decode them with standard percent-decoding (e.g. urllib.parse.unquote in Python), or read the full UTF-8 user object from the base64-encoded JSON numerous_user_info cookie.

⚠️

Anti-impersonation guarantee: Before forwarding any request to your app container, the Numerous proxy unconditionally strips all client-supplied X-Numerous-* headers (including underscore spellings and Connection-header hop-by-hop tricks) and numerous_user_info / numerous_session cookies, rejects non-WebSocket Upgrade tunnels, and injects only values derived from the verified token. On user-token requests, the proxy also strips the Authorization header so callers' Numerous user tokens are never exposed to app code. Callers cannot impersonate another user or organization by forging headers or cookies.

Example: Python MCP Server (FastMCP)

Your container listens on the port declared in numerous.toml and serves an MCP Streamable HTTP endpoint at path (default /mcp). Inside a tool, you can read the verified caller identity headers directly from the HTTP request:

server.py
from mcp.server.fastmcp import Context, FastMCP
 
mcp = FastMCP("sales-analytics", stateless_http=True, host="0.0.0.0", port=8501)
 
 
@mcp.tool()
def quarterly_revenue(quarter: str, ctx: Context) -> dict:
    """Return revenue summary for a quarter (e.g. '2026-Q3')."""
    headers = ctx.request_context.request.headers
    return {
        "quarter": quarter,
        "revenue_eur": 420_000,
        "auth_type": headers.get("x-numerous-auth-type"),
        "user_id": headers.get("x-numerous-user-id"),
        "organization_id": headers.get("x-numerous-organization-id"),
    }
 
 
if __name__ == "__main__":
    mcp.run(transport="streamable-http")

Deploy as usual with numerous deploy.

Connecting an MCP Client

1. Get your token and MCP URL

  • Per-user identity (recommended for human users): create a Personal Access Token (num_...) with the Numerous CLI (numerous token create). Your app's MCP URL is https://<app-slug>.api.numerous.com<path> (for example, https://my-app.api.numerous.com/mcp, where <path> is [mcp] path from numerous.toml or /mcp by default). Organization admins can also copy the URL from the app card menu (MCP settings or API & MCP settings).
  • Shared / service key (organization admins): open the app card menu in the Numerous web app, select MCP settings (or API & MCP settings), and create an App API key (app_api_...).

2. Add the app's MCP server to your client

Set NUMEROUS_APP_TOKEN to either your user Personal Access Token (num_...) or an App API key (app_api_...):

Claude Code

terminal
claude mcp add --transport http my-app https://my-app.api.numerous.com/mcp \
  --header "Authorization: Bearer $NUMEROUS_APP_TOKEN"

Cursor (.cursor/mcp.json)

mcp.json
{
  "mcpServers": {
    "my-app": {
      "url": "https://my-app.api.numerous.com/mcp",
      "headers": {
        "Authorization": "Bearer ${env:NUMEROUS_APP_TOKEN}"
      }
    }
  }
}

VS Code (.vscode/mcp.json)

mcp.json
{
  "servers": {
    "my-app": {
      "type": "http",
      "url": "https://my-app.api.numerous.com/mcp",
      "headers": {
        "Authorization": "Bearer ${env:NUMEROUS_APP_TOKEN}"
      }
    }
  }
}