modelcontextprotocol / modelcontextprotocol/conformance

Add conformance tests for Token Audience Validation (server-side)

Open
#78 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
127
Forks
101
Avg merge
6d 1h
Merged PRs (30d)
7

Description

Summary

The MCP authorization spec requires servers to validate that access tokens were issued specifically for them. This is a server-side requirement that ensures tokens cannot be reused across different MCP servers. The conformance test suite does not currently verify this behavior.

Approach

Server under test must integrate with our mock Authorization Server:

  1. Server configured to use mock AS's /.well-known/oauth-authorization-server
  2. Mock AS serves a JWKS endpoint for token verification
  3. Conformance suite issues JWTs signed with mock AS's key
  4. Test with correct/incorrect aud claims to verify server validates audience

The server can validate tokens either by:

  • Fetching the AS's public key (JWKS) and validating locally
  • Calling an introspection endpoint on the AS

Suggested Checks

Check: server-token-audience-validation

Spec: "MCP servers MUST validate that access tokens were issued specifically for them as the intended audience"

Send token with wrong aud claim → server should reject with 401.

Check: server-token-valid-accepted

Spec: "MCP servers, acting in their role as an OAuth 2.1 resource server, MUST validate access tokens"

Send token with correct aud claim → server should accept.

Exact Spec Language

Token Handling
Keyword Statement
MUST MCP servers, acting in their role as an OAuth 2.1 resource server, MUST validate access tokens
MUST MCP servers MUST validate that access tokens were issued specifically for them as the intended audience
Token Audience Binding and Validation
Keyword Statement
MUST MCP servers MUST validate that tokens presented to them were specifically issued for their use
Access Token Privilege Restriction
Keyword Statement
MUST MCP servers MUST validate access tokens before processing the request

Implementation Notes

Mock AS needs to:

  • Serve AS metadata with jwks_uri
  • Serve JWKS endpoint with public key
  • Issue JWTs with configurable aud claim

Test scenarios:

  1. Token with aud matching server URI → accepted
  2. Token with aud for different server → rejected (401)
  3. Token with missing aud → rejected (401)
  4. Expired token → rejected (401)

Spec References

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the conformance suite's mock Authorization Server integration and server request checks, then review how metadata, JWKS, and JWTs are currently handled. Add the named audience-validation checks and ensure the suite covers matching, wrong, and missing aud claims, plus expired tokens, with accepted requests succeeding and invalid tokens returning 401.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
authentication, security, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.