The Model Context Protocol (MCP) rapidly standardized how AI clients discover and invoke enterprise tools, but most early MCP servers rely on local stdio pipes or static environment tokens. Once organizations expose remote MCP servers over HTTP to connect copilots with CRMs, source repositories, and production databases, unauthenticated or coarsely scoped servers become an immediate privilege-escalation vector.
Key Takeaways
- Remote MCP servers must act as OAuth 2.0 Protected Resources that advertise their authorization server via RFC 9728 metadata and OIDC discovery.
- Every MCP access token should carry an explicit aud and mcp_server URI claim to prevent cross-server token replay and confused-deputy attacks.
- Authorization checks must run inside the JSON-RPC dispatcher for both tools/list and tools/call so agents cannot even enumerate restricted tools.
- Allowlisting authorized MCP server URIs at the identity provider stops compromised agents from exfiltrating data to rogue third-party MCP endpoints.
Why Local MCP Patterns Break in Enterprise Deployments
Early MCP adoption centered on single-developer desktop setups where an IDE spawned a local server process over standard input and output. In that model, the server inherited the developer's local shell credentials and assumed the single local user was implicitly trusted. When engineering teams promote MCP servers into shared cloud infrastructure using Streamable HTTP transport, every security boundary changes overnight.
A multi-user enterprise MCP server handles concurrent requests from interactive copilots, autonomous triage pipelines, and CI agents belonging to different departments and B2B customer tenants. Relying on a single server-side service token collapses tenant isolation and lets any connected prompt invoke the highest-privileged tool registered on that server. Securing MCP requires treating every MCP server as a first-class OAuth 2.0 resource server backed by centralized OIDC federation.
- Cross-tenant data leakage occurs immediately when a shared MCP backend queries databases using one global service credential.
- Tool-list overexposure reveals sensitive internal operations and parameter schemas to untrusted prompts when tools/list is unauthenticated.
- Token passthrough anti-patterns—forwarding a generic user token blindly to unrelated upstream APIs—violate audience boundaries and break auditability.
- Unvetted third-party MCP servers can impersonate legitimate tool providers if agents are not constrained by a strict server allowlist.
Dynamic OIDC Discovery and Protected Resource Metadata
Modern MCP authorization aligns directly with OAuth 2.0 Protected Resource Metadata (RFC 9728) and OpenID Connect Discovery. When an unauthenticated MCP client attempts to initialize a session, the MCP server responds with HTTP 401 Unauthorized and a WWW-Authenticate header pointing to its resource metadata document. That document declares the canonical resource identifier, supported least-privilege scopes, and the trusted SSO.ID authorization server URL.
The MCP client then fetches the SSO.ID OpenID configuration at /.well-known/openid-configuration to discover the authorization, token, and JWKS endpoints automatically. For interactive developer copilots, the client executes Authorization Code Flow with PKCE (S256) and passes the target resource parameter so the resulting token is minted specifically for that MCP server. No static secrets ever need to be pasted into developer IDE JSON files.
{
"resource": "https://mcp.acme.internal/crm-readonly",
"authorization_servers": [
"https://auth.sso.id"
],
"jwks_uri": "https://auth.sso.id/.well-known/jwks.json?appId=app_mcp_crm",
"bearer_methods_supported": ["header"],
"scopes_supported": [
"mcp:tools:list",
"crm:accounts:read",
"crm:tickets:read",
"crm:tickets:comment"
],
"resource_documentation": "https://sso.id/v2/aiagent"
}
Always validate the canonical resource URI in the token's aud claim against the exact hostname and path of your MCP server. Reject any token issued for a broader wildcard audience or a different MCP server URI.
Enforcing Audience Isolation and Per-Tool Scopes
Connection-level authentication is only the first gate; real MCP security happens inside the JSON-RPC method handler. Each tool exposed by an MCP server should declare its required OAuth scope and whether it performs a state-mutating operation. When the client invokes tools/list, the server filters the returned catalog dynamically so the LLM only sees tools permitted by the caller's verified JWT scopes.
When tools/call arrives, the server verifies the token signature, confirms the mcp_server claim matches its own identifier, checks the tool's required scope, and evaluates whether human-in-the-loop approval is required for writes. This guarantees that even if a prompt guesses the name of a hidden administrative tool such as delete_customer_record, the MCP runtime rejects execution deterministically before any backend connector runs.
- Bind every tool definition to an explicit scope (for example, jira:issues:read versus jira:issues:transition) rather than one coarse mcp:execute permission.
- Filter tools/list responses per caller token to reduce prompt surface area and prevent capability enumeration.
- Verify both aud and mcp_server claims on every JSON-RPC frame, not only during initial SSE or HTTP handshake.
- Propagate tenant_id and human_owner claims into downstream database queries to preserve row-level tenant isolation.
type ToolPolicy = { scope: string; mutatesState: boolean };
const TOOL_POLICIES: Record<string, ToolPolicy> = {
search_crm_accounts: { scope: 'crm:accounts:read', mutatesState: false },
get_ticket_history: { scope: 'crm:tickets:read', mutatesState: false },
post_ticket_reply: { scope: 'crm:tickets:comment', mutatesState: true }
};
export function authorizeMcpToolCall(claims: Record<string, unknown>, toolName: string) {
if (claims.mcp_server !== 'mcp://crm-readonly' || claims.aud !== 'mcp://crm-readonly') {
throw new Error('403: Token audience does not match this MCP server');
}
const policy = TOOL_POLICIES[toolName];
if (!policy) {
throw new Error(`403: Unknown or unregistered MCP tool ${toolName}`);
}
const granted = String(claims.scope || '').split(' ');
if (!granted.includes(policy.scope)) {
throw new Error(`403: Scope ${policy.scope} required for ${toolName}`);
}
if (policy.mutatesState && claims.hitl_write_required === true) {
throw new Error('403: Write tool blocked pending HITL approval');
}
}
Server Allowlisting and Delegation Boundaries
Securing individual MCP servers must be paired with outbound governance at the identity provider. Without an explicit allowlist, an agent compromised through indirect prompt injection could be instructed to connect to an attacker-controlled MCP server and leak internal context in tool arguments. By registering an agent's allowedMcpServers list inside the identity control plane, the token endpoint refuses to mint tokens for any unapproved target server URI.
Organizations should also separate interactive user-delegated MCP sessions from unattended backend workers. Developer copilots running inside IDEs should use OnBehalfOfUser delegation so every tool call inherits the signed-in engineer's RBAC and organization boundaries, while scheduled workflow agents run under tightly scoped AutonomousM2M policies with explicit API endpoint restrictions and automated quarterly recertification.
- Maintain an approved registry of internal and vendor MCP server URIs per AI agent identity (such as mcp://crm-readonly and mcp://jira-triage).
- Enforce PKCE (S256) and short token TTLs for IDE and browser-based MCP clients to protect against token interception.
- Require formal HITL access requests whenever an engineering team wants to attach a new MCP server to an existing production agent.
How SSO.ID Solves MCP Server Authentication and Governance
SSO.ID v2 treats MCP clients and remote MCP servers as governed identity boundaries with built-in OIDC discovery, per-agent MCP server allowlists, and audience-locked JIT tokens.
- ✓Per-agent allowedMcpServers enforcement so JIT token issuance fails immediately for unauthorized MCP endpoints.
- ✓Automatic embedding of targetMcpServer into both aud and mcp_server JWT claims for deterministic server-side verification.
- ✓Standards-compliant OIDC Discovery (/.well-known/openid-configuration) and PKCE (S256) support for IDE copilots and remote MCP gateways.
- ✓Native HITL access request workflow (/api/ai-agents/{agentId}/access-requests) to approve new MCP server attachments with full audit trails.
Frequently Asked Questions
No. Passing the incoming MCP access token straight to an upstream API violates audience isolation and lets a compromised MCP server impersonate the caller elsewhere. Instead, the MCP server should validate the incoming token locally and perform an audience-bound OAuth token exchange or scoped backend call for the downstream resource.
IDE-based MCP clients authenticate via OIDC Authorization Code Flow with PKCE (S256) using SSO.ID's Auth server, obtaining short-lived tokens tied to the developer's tenant, organization, and RBAC roles—eliminating hardcoded secrets in local MCP config files.
SSO.ID rejects the token request with an HTTP 400 error and records the policy denial in the AI Agent audit log stream, preventing the agent from authenticating to unapproved tool servers.