Skip to content

docs(mcp): document OAuth2 security for the MCP server with Symfony#2306

Merged
soyuka merged 1 commit into
api-platform:4.3from
soyuka:docs/mcp-oauth-4.3
Jun 15, 2026
Merged

docs(mcp): document OAuth2 security for the MCP server with Symfony#2306
soyuka merged 1 commit into
api-platform:4.3from
soyuka:docs/mcp-oauth-4.3

Conversation

@soyuka

@soyuka soyuka commented Jun 15, 2026

Copy link
Copy Markdown
Member

Summary

Documents how to secure the API Platform MCP server with OAuth2 using the Symfony Security component, applied to the MCP guide (core/mcp.md).

The key takeaway: no MCP-specific security layer is neededsymfony/security-bundle already has everything. The /mcp endpoint is plain HTTP (JSON-RPC), so it's protected upstream like any other route.

What's covered

New section "Securing the MCP Server with OAuth2 (Symfony)" describing the MCP authorization / RFC 9728 discovery flow and the four pieces it requires:

  1. A stateless firewall + access-token handler (oidc discovery with Keycloak, plus an oauth2 introspection variant for opaque tokens).
  2. An AttributesBasedUserProviderInterface mapping token claims to roles.
  3. A public /.well-known/oauth-protected-resource metadata endpoint.
  4. A WWW-Authenticate challenge listener (RFC 9728 §5.1) completing the discovery loop.

Plus an optional OpenAPI SecurityScheme decorator to advertise the OAuth2 flow in Swagger UI.

Code examples are derived from a working API Platform + Keycloak deployment and validated against modelcontextprotocol/inspector.

@soyuka soyuka force-pushed the docs/mcp-oauth-4.3 branch from 5ffab9c to 36a18d1 Compare June 15, 2026 09:24
Add a "Securing the MCP Server with OAuth2 (Symfony)" section to the MCP
guide. Covers the RFC 9728 discovery flow and the four pieces needed to
secure the /mcp endpoint with the Symfony Security component, with no
MCP-specific security layer:

- a stateless firewall + access token handler (oidc discovery, with an
  oauth2 introspection variant for opaque tokens);
- an AttributesBasedUserProviderInterface mapping token claims to roles;
- a public /.well-known/oauth-protected-resource metadata endpoint;
- a WWW-Authenticate challenge listener completing the discovery loop.

Also shows an optional OpenAPI SecurityScheme decorator to advertise the
OAuth2 flow in Swagger UI.
@soyuka soyuka force-pushed the docs/mcp-oauth-4.3 branch from 36a18d1 to 7011ee1 Compare June 15, 2026 09:38
@soyuka soyuka merged commit 7c6fcc4 into api-platform:4.3 Jun 15, 2026
3 checks passed
@soyuka soyuka deleted the docs/mcp-oauth-4.3 branch June 15, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant