← Learn / Notebooks

AI securityTechnicalStudy guide

Model Context Protocol (MCP): Authorization

Trace protected HTTP access, distinguish token audience from permission, and test a small authorization decision model.

Before you start: Basic HTTP requests and the difference between a client and server. Python is optional.

AI-assisted study notebook · Published 14 Nov 2026. Source-support checks and synthetic examples are recorded; automated review is not independent expert fact verification.

In [1]: Architecture

1. Architecture and scope

MCP separates an application calling tools from the server exposing them. For a protected HTTP endpoint, authorization determines which requests that resource accepts. The protocol’s authorization specification describes OAuth roles, discovery and token handling; this notebook focuses on the resource-server decision after token validation. It does not describe the complete login flow. [1]

A token can be validly issued yet intended for another resource. RFC 8707 distinguishes where a token can be redeemed from what access a scope requests. The MCP server must check that the token was issued for its own intended audience. A matching permission name does not repair an audience mismatch. [1] [2]

Scope. Protected HTTP MCP resources. This is an authorization study, not an implementation of an OAuth client or a token validator.

Workflow and scope notes
  1. Protected request. A client calls an HTTP MCP resource using its issued access token. Record the requested resource and operation without logging the token.
  2. Validate token. Validate authenticity, issuer, expiry and the resource audience using the applicable authorization system. The lab receives validation outcomes; parsing claims alone does not establish validity.
  3. Check permission. Compare trusted granted permissions with the operation’s required permission. A valid token can still lack permission for a particular operation.
  4. Return outcome. Invalid or expired tokens receive 401; insufficient permission is a 403 case. Keep error responses useful without exposing token material.
MCP authorization: client, authorization server, protected MCP resource and token checks
Authorization flow and resource-server checks. The diagram illustrates the boundaries explored by the synthetic decision model below; authentication alone does not grant every tool permission.
Download editable draw.io diagram
In [2]: Experiment

2. Token validation and permission decisions

Set three trusted outcomes. These switches stand in for real validation that has already happened; the page never accepts a token. The requested operation requires the fictional scope notes:read.

Token validation and permission decisions

Original synthetic experiment · Change an input to update the figure.

This is a decision table over trusted booleans. It does not validate a signature, discover metadata, refresh credentials or secure an endpoint.

Authorization decision path403 · Insufficient permission. Token validity: pass; Resource audience: pass; Permission: failToken validityPassResource audiencePassPermissionFail
403 · Insufficient permission
Calculation record
{
  "inputs": {
    "valid": "yes",
    "audience": "yes",
    "scope": "no"
  },
  "status": 403,
  "outcome": "Insufficient permission"
}
CaseResultInterpretation
Valid token; wrong audience401The resource cannot accept a token issued for a different audience.
Valid token and audience; missing scope403The token is accepted as valid but does not authorize this operation.
All three checks passAllow in this toy modelReal deployments also enforce operation-specific policy and the rest of the protocol.
In [3]: Interpretation

3. Interpretation and limitations

Invalid-token and insufficient-scope errors are different cases in the standards. In the experiment, an invalid validation result takes priority over the scope result. The diagram shows that decision order explicitly. Neither a status code nor a successful local boolean test proves that the real validation system is correct. [1] [3]

Editorial implementation checklist: verify token handling at the actual server boundary, avoid token logging, test cross-resource rejection, and test each sensitive operation’s permission rule. Keep discovery, redirect validation and client security work in the full specification; they are outside this lesson’s simulator. [1]

Practice exercise

Set the audience to No while keeping the required scope. Predict the result before looking at the decision path. Then restore the audience and remove the scope. Explain why the two failures differ.

In [4]: Python

4. Worked Python example

The core calculation below uses only the Python standard library. The full download adds the verification assertions and input fixtures. It runs locally on synthetic data; it does not load a model or contact a service.

lab.py · Core example · Python 3.13
from itertools import product


def decision(valid, audience, scope):
    # Inputs are trusted validation outcomes, not token claims.
    if not valid or not audience:
        return {"status": 401, "outcome": "Reject token"}
    if not scope:
        return {"status": 403, "outcome": "Insufficient permission"}
    return {"status": 200, "outcome": "Allow in toy model"}

Download full Python example and checks ↓

Run: python -I lab.py. Recorded run: Python 3.13; 8 fixture states plus scenario assertions passed. The JSON output is a reproducibility record, not a real-system benchmark.

In [5]: Knowledge check

5. Questions and explanations

Predict before opening the explanation. Answers refer to the stated scope and synthetic inputs.

Q1 · AudienceA token grants notes:read but targets another resource. What should this protected resource do?
A token grants notes:read but targets another resource. What should this protected resource do?
Answer and explanation

Answer: Reject the token. The intended audience must match this resource. A scope name is not audience validation. [1] [2]

Q2 · PermissionA valid, correctly targeted token lacks the required scope. Which case is this?
A valid, correctly targeted token lacks the required scope. Which case is this?
Answer and explanation

Answer: Insufficient permission (403). The token can be valid while the operation remains forbidden. [1] [3]

Q3 · ValidationWhat does changing the switches demonstrate?
What does changing the switches demonstrate?
Answer and explanation

Answer: Decision logic over assumed trusted results. The switches provide inputs. They do not establish authenticity or validate a real credential.

Q4 · TransportWhich scope does this lesson cover?
Which scope does this lesson cover?
Answer and explanation

Answer: Protected HTTP MCP resources. MCP authorization has transport-specific scope; this lesson follows the HTTP resource-server case. [1]

In [6]: Sources

References and source links

  1. Model Context Protocol contributors. (Specification 2026-07-28). Authorization - Model Context Protocol.https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization
  2. Campbell, B., Bradley, J., & Tschofenig, H. (2020). RFC 8707: Resource Indicators for OAuth 2.0.https://www.rfc-editor.org/rfc/rfc8707.html
  3. Jones, M., & Hardt, D. (2012). RFC 6750: The OAuth 2.0 Authorization Framework: Bearer Token Usage.https://www.rfc-editor.org/rfc/rfc6750.txt
Source checks and provenance

Primary publisher pages and relevant passages checked on 13 Nov 2026. Source support is not independent expert fact verification. Main documentation can change; retrieved-body hashes, dates, version labels and saved revision IDs are in the audit download.

[1] Authorization - Model Context Protocol

Evidence: Token Handling; Error Handling. HTTP transport and token handling; stdio uses a different credential arrangement.

Public ResearchNode original 7467b89a07147fb5713bd8ab0a705b91
Revision 576ab5a15ec1e4ce1d73c9cf9b1b561e. Captured 2026-11-07.

[2] RFC 8707: Resource Indicators for OAuth 2.0

Evidence: RFC 8707 §1–2. Resource indicators bind the intended resource; a scope string alone is not that binding.

[3] RFC 6750: The OAuth 2.0 Authorization Framework: Bearer Token Usage

Evidence: RFC 6750 §3.1. Bearer-token errors; tokens are secrets. No token is entered or sent by this notebook.

Claim-to-evidence ledger ↓ · Review report ↓