What Is MCP Server Authorization?
MCP (Model Context Protocol) server authorization is the process of verifying that a client or agent has the right to access specific resources and tools exposed by an MCP server. While authentication confirms who is making a request, authorization determines what that entity is allowed to do.
MCP servers expose tools, prompts, and data resources to AI agents and LLM-powered applications. Without proper authorization, any connected client could read sensitive data, invoke destructive tools, or escalate privileges across your system.
Authorization in MCP is governed by the MCP specification, which defines a standardized approach built on top of OAuth 2.0 for delegated access control.
How MCP Authorization Works
MCP authorization follows a request-validate-respond cycle. When a client connects to an MCP server and calls a tool or reads a resource, the server:
- Extracts the bearer token from the request header
- Validates the token against an authorization server
- Checks the token's scopes against the required permissions for that action
- Either fulfills or rejects the request
This flow ensures every operation is gated by an explicit permission check, not just a one-time login.
OAuth 2.0 and MCP Authorization Flow
The MCP specification mandates OAuth 2.0 as the authorization framework. The standard flow looks like this:
- Client registration — The MCP client registers with the authorization server and receives a
client_idandclient_secret. - Authorization request — The client redirects the user (or agent) to the authorization server's
/authorizeendpoint. - Token issuance — After consent, the authorization server issues an access token (and optionally a refresh token).
- Authenticated requests — The client includes the access token in the
Authorization: Bearer <token>header on every MCP request. - Token introspection — The MCP server validates the token via the authorization server's
/introspectendpoint or by verifying a signed JWT locally.
MCP servers must expose an OAuth 2.0 Authorization Server Metadata document at /.well-known/oauth-authorization-server so clients can auto-discover endpoints.
Token Scopes and Permissions
Scopes define the granular permissions attached to an access token. MCP uses scopes to restrict which tools and resources a client can access.
Common scope patterns for MCP servers:
| Scope | Description |
|---|---|
mcp:tools:read |
List available tools |
mcp:tools:execute |
Invoke tools |
mcp:resources:read |
Read exposed resources |
mcp:prompts:read |
Access prompt templates |
mcp:admin |
Full administrative access |
Best practice: Follow the principle of least privilege — only grant the minimum scopes required for a given client or agent use case.
Setting Up Authorization on an MCP Server
Configuring Authentication Providers
Most MCP server frameworks (such as the official TypeScript and Python SDKs) support pluggable auth providers. Here's how to configure one in a TypeScript MCP server:
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { OAuthProvider } from "./auth/oauth-provider.js";
const server = new McpServer({
name: "my-mcp-server",
version: "1.0.0",
});
server.setAuthorizationProvider(
new OAuthProvider({
issuer: "https://auth.example.com",
audience: "my-mcp-server",
jwksUri: "https://auth.example.com/.well-known/jwks.json",
requiredScopes: ["mcp:tools:read"],
})
);
Key configuration parameters:
issuer— The URL of your authorization server (e.g., Auth0, Keycloak, or a custom OAuth server)audience— The identifier of your MCP server resourcejwksUri— The endpoint for fetching public keys to verify JWTsrequiredScopes— The minimum scopes all requests must include
Defining Access Control Policies
Beyond token validation, you should enforce fine-grained access control at the tool and resource level. This means checking scopes (or custom claims) before executing any sensitive operation.
Example of per-tool scope enforcement:
server.tool(
"delete_record",
{ recordId: z.string() },
async ({ recordId }, context) => {
// Check for elevated scope before proceeding
if (!context.auth.scopes.includes("mcp:admin")) {
throw new McpError(
ErrorCode.Unauthorized,
"Insufficient permissions: mcp:admin required"
);
}
return await deleteRecord(recordId);
}
);
Recommended policy practices:
- Map each tool to a minimum required scope
- Use custom JWT claims (e.g.,
roles,tenant_id) for multi-tenant access control - Log every authorization decision for auditability
- Separate read and write scopes explicitly
Common MCP Authorization Errors and Fixes
| Error | Likely Cause | Fix |
|---|---|---|
401 Unauthorized |
Missing or expired token | Refresh the access token; verify the client sends the Authorization header |
403 Forbidden |
Valid token, insufficient scopes | Request additional scopes during the OAuth flow |
invalid_token |
JWT signature mismatch | Verify the jwksUri is correct and keys are rotating properly |
invalid_client |
Wrong client_id or client_secret |
Re-register the client or update credentials |
| Discovery endpoint not found | Missing /.well-known/ route |
Ensure your server exposes the metadata document |
Debugging tip: Enable verbose token logging in staging environments. Never log raw tokens in production — log only token metadata (e.g., sub, exp, scopes).
Security Best Practices for MCP Authorization
- Use short-lived access tokens. Set expiry to 15–60 minutes and rely on refresh tokens for continuity.
- Rotate signing keys regularly. Use a JWKS endpoint so clients automatically pick up new keys without redeployment.
- Validate every claim. Check
iss,aud,exp, andnbfon every token — not just the signature. - Enforce HTTPS everywhere. Never transmit tokens over unencrypted connections.
- Scope requests tightly per client. An AI agent that only reads data should never hold a write or admin scope.
- Implement token revocation. Maintain a blocklist or use short expiry windows to limit the blast radius of leaked tokens.
- Audit and alert. Log authorization failures and set up alerts for unusual patterns (e.g., sudden spikes in
403responses).
FAQ
Q: Does every MCP server require OAuth 2.0? No. The MCP specification recommends OAuth 2.0 for remote servers, but locally running MCP servers (e.g., stdio-based) can omit full OAuth flows if they operate in a trusted local environment. For any internet-exposed server, OAuth 2.0 is strongly recommended.
Q: Can I use API keys instead of OAuth tokens with MCP? API keys are not part of the MCP authorization specification. However, you can implement a custom auth middleware that validates API keys and translates them into a scope-bearing context object before requests reach your MCP handlers.
Q: What happens if my authorization server goes down? If your MCP server validates tokens via live introspection, an outage will block all requests. Prefer JWT-based validation with cached public keys so token verification remains available even if the auth server is temporarily unreachable.