Authorization: who must do what
The authorization specification is optional and applies to HTTP transports. A stdio server should not use it and should take credentials from its environment. When it is used, the MCP server is an OAuth 2.1 resource server, the MCP client is an OAuth 2.1 client, and the authorization server is a separate role that may be co-hosted.
Discovery chain
- The server must publish Protected Resource Metadata (RFC 9728) with at least one entry in
authorization_servers. It points clients there with aresource_metadataparameter on the 401 challenge, or by serving the well-known URI/.well-known/oauth-protected-resource. Clients must support both. - The authorization server must publish either OAuth Authorization Server Metadata (RFC 8414) or OpenID Connect Discovery. Clients must support both, and the
issuerin the document must match.
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource",
scope="files:read"
Client registration
Three mechanisms exist (client registration). Clients that support all of them should prefer pre-registered credentials, then a Client ID Metadata Document (the client_id is an HTTPS URL that serves a JSON document with client_id, client_name and redirect_uris) when the authorization server advertises client_id_metadata_document_supported, then Dynamic Client Registration (RFC 7591). Dynamic registration is deprecated as of 2026-07-28.
Rules for clients
- Send the
resourceparameter (RFC 8707) in both the authorization request and the token request, naming the canonical URI of the MCP server, whether or not the authorization server supports it. - Use PKCE with
S256when capable. Refuse to proceed if the metadata lackscode_challenge_methods_supported. - Validate the
issresponse parameter (RFC 9207) when present. - Send
Authorization: Bearer <access-token>on every HTTP request. Never put the token in a query string. - Key stored credentials by issuer. Do not reuse them across authorization servers.
Rules for servers
- Validate every token, including that it was issued specifically for this server (audience). Accept no other tokens.
- Do not forward the client's token upstream. If the server calls another API, it acts as its own OAuth client there.
- Return 401 when authorization is required or the token is invalid, 403 for wrong scopes or insufficient permission, 400 for a malformed request.
Scopes and least privilege
The official security best practices describe a progressive model: start with a minimal scope set covering low-risk discovery and read operations, then raise privilege only when a privileged operation is first attempted. The mechanism is a 403 challenge that names what is missing:
HTTP/1.1 403 Forbidden
WWW-Authenticate: Bearer error="insufficient_scope",
scope="files:write",
resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource"
The client then re-authorizes with the union of the scopes it already had and the new ones. Mistakes that page names: publishing every scope in scopes_supported, wildcard scopes such as * or all, and treating a scope claim in the token as sufficient without server-side authorization logic.
Attack classes the project documents
Confused deputy
Applies to an MCP server that proxies to a third-party API. Conditions: the proxy uses one static client ID with the third-party authorization server, lets MCP clients register dynamically, and the third party remembers consent in a cookie. An attacker registers a client with their own redirect URI and sends the victim a crafted link. The third party sees the consent cookie, skips its consent screen, and the authorization code lands with the attacker. Required mitigation: the proxy must obtain its own per-client consent before forwarding. It keeps a registry of approved client_id values per user, shows the client name, scopes and redirect_uri on its consent page, and matches redirect URIs by exact string.
Token passthrough
The server accepts a token that was not issued to it and relays it downstream. This bypasses controls that depend on audience and breaks the audit trail, since the downstream log shows the wrong identity. The rule is absolute: servers must not accept tokens that were not explicitly issued for them.
State handle hijacking (formerly session hijacking)
Revision 2026-07-28 has no protocol-level sessions, so the session hijacking entry of earlier guidance has become state handle hijacking. A server that needs state across calls mints a handle (a cart ID, a workflow ID) and receives it back as an ordinary tool argument. If the server does not check that the handle belongs to the caller, anyone who obtains or guesses it gets the other user's state. Servers must not treat possession of a handle as authentication. They should generate handles with a secure random generator and bind them to the authenticated user, for example by keying state as <user_id>:<handle> with the user ID taken from the verified token. The 2025-11-25 version of the page still covers legacy session IDs.
Others on the same page
Server-side request forgery through OAuth metadata URLs, local server compromise through one-click install commands (the client must show the exact command untruncated and require explicit approval), and mix-up attacks.
Prompt injection and tool poisoning
The local server security guide states the problem directly: tool names and descriptions are instructions the model reads. A server can hide directives in them that steer the agent, including how it uses other servers' tools, without the poisoned tool ever being invoked. The guide calls this tool poisoning, or tool shadowing when it targets another server's tools. Definitions can also change after approval (a rug pull), so a one-time consent dialog and package pinning do not cover it. Prompt injection in untrusted content can likewise steer an honest server into overreach.
Every configured server shares the same model context, so each install extends the surface the others are exposed to. The stdio transport is not a sandbox. Containment (a container, sandbox or VM with as few privileges as possible) decides what a bad trust decision costs.
Tool design
The tools specification requires servers to validate all tool inputs, implement access controls, rate limit invocations and sanitize outputs. It says there should always be a human in the loop able to deny a tool invocation, and that clients should show tool inputs to the user before calling. The tool list must not vary per connection, though it may vary by the authorization presented.
Annotations are hints
| Field | Default | Meaning |
|---|---|---|
readOnlyHint | false | Tool does not modify its environment |
destructiveHint | true | Tool may perform destructive updates. Meaningful only when readOnlyHint is false |
idempotentHint | false | Repeating the call with the same arguments has no additional effect |
openWorldHint | true | Tool interacts with external entities |
Note the defaults: an unannotated tool is assumed to be destructive and open-world. The schema says these properties are not guaranteed to describe the tool faithfully, and that clients should never make tool use decisions based on annotations received from untrusted servers. Annotations inform a confirmation prompt. They are not an access control.
HTTP exposure
For Streamable HTTP, servers must validate the Origin header on incoming connections to prevent DNS rebinding, answering 403 when it is invalid. A server running locally should bind only to localhost (127.0.0.1), not all interfaces, and should implement authentication.
The official registry
The MCP Registry at registry.modelcontextprotocol.io is a metadata service for publicly accessible servers, in preview at the time of checking. It stores a server.json per version that points at a package (npm, PyPI, Docker Hub and others) or a remote URL. It hosts no code. Source: github.com/modelcontextprotocol/registry.
- Names are reverse-DNS, such as
io.github.username/serverorcom.example/server. Namespace ownership is proven through GitHub login, a DNS TXT record, or a file at/.well-known/mcp-registry-auth. - Publishing uses the
mcp-publisherCLI:init,login,publish. Published version metadata is immutable. - What it does not do matters to operators. The registry delegates security scanning to package registries and downstream aggregators. Its moderation policy says consumers should assume minimal to no moderation, and that servers with security vulnerabilities are not removed. A listing proves who controls a namespace, nothing about behavior.
Testing with the Inspector
The MCP Inspector (repository) ships as one npm package with a web UI, a CLI and a terminal UI.
npx @modelcontextprotocol/inspector node path/to/server/index.js
npx @modelcontextprotocol/inspector --cli node path/to/server/index.js --method tools/list
npx @modelcontextprotocol/inspector --cli https://api.example.com/mcp --transport http \
--method tools/call --tool-name get_weather --tool-arg city=Boston
It defaults to the legacy protocol era (a plain initialize). Pass --protocol-era modern to pin 2026-07-28, or auto to probe server/discover first. Per its security page, the web backend can spawn processes, binds 127.0.0.1 by default and guards its API with a per-launch token, and on a machine with no OS keychain it stores secrets in ~/.mcp-inspector/secrets.json, unencrypted unless a key is supplied.
Official SDKs
From the SDK page. SDKs adopt new revisions on their own schedules, so confirm 2026-07-28 support in the SDK's own documentation.
| Tier | Repositories under github.com/modelcontextprotocol |
|---|---|
| 1 | typescript-sdk, python-sdk, csharp-sdk, go-sdk, rust-sdk, ruby-sdk |
| 2 | java-sdk |
| 3 | swift-sdk, php-sdk, kotlin-sdk |