A community-driven registry for Claude, Cursor, Windsurf, Cline & more. Not affiliated with Anthropic.
Are you the author? Sign in to claim
MCP Server Authorization Example with AWS Cognito
This repository demonstrates how to secure a Model Context Protocol (MCP) server using OAuth 2.1 authorization flows, implemented entirely with Node.js and Express.js. While this example uses AWS Cognito as the backing authorization server, the implementation is provider-agnostic and can work with any OAuth 2.1 compliant authorization server.
Based on the MCP Authorization Specification (version 2025-11-25), this project showcases:
This implementation follows OAuth 2.1 standards to ensure compatibility with any compliant authorization server:
The new MCP Authorization Specification introduces a clean separation between Resource Servers and Authorization Servers, making it easier to integrate with existing identity providers like AWS Cognito, Okta, Auth0, and others.
Key components of the specification:
Protected Resource Metadata (PRM) document
/.well-known/oauth-protected-resourceDiscovery Process
OAuth 2.1 Authorization
Client Registration Priority (MCP 2025-11-25)
client_id_metadata_document_supported: true)Dynamic Client Registration (DCR)
Client ID Metadata Documents (CIMD)
client_idThis implementation showcases how to apply these concepts in a provider-agnostic way. The example uses AWS Cognito with custom Dynamic Client Registration through API Gateway endpoints and Lambda functions, but the core OAuth flow works with any compliant authorization server.
Client → MCP Server → Authorization Server (e.g., AWS Cognito)
(Resource Server) (OAuth 2.1 Provider)
For detailed overview, see the Architecture Overview.
Diagrams:
This implementation includes support for OAuth 2.1 Dynamic Client Registration, allowing clients to:
The DCR flow works as follows:
Implementation Note: AWS Cognito does not natively support Dynamic Client Registration as specified in OAuth 2.0 DCR (RFC7591). This implementation bridges this gap by using:
This approach allows us to maintain compliance with the MCP specification's DCR recommendation while leveraging AWS Cognito for robust authentication and authorization.
Security Note: This implementation uses anonymous DCR without additional authentication. For production environments, consider adding:
See our DCR Security Recommendations to enhance the security of the registration process.
The MCP Authorization Specification (2025-11-25) introduced Client ID Metadata Documents as the recommended client registration method. CIMD allows a client to use an HTTPS URL as its client_id, with the URL hosting a JSON document describing the client's OAuth metadata.
http://localhost:3003/client-metadata.json)client_id{
"client_id": "http://localhost:3003/client-metadata.json",
"redirect_uris": ["http://localhost:3003/callback"],
"client_name": "MCP CIMD Demo Client",
"grant_types": ["authorization_code"],
"response_types": ["code"],
"token_endpoint_auth_method": "none"
}
AWS Cognito does not natively support Client ID Metadata Documents, just as it doesn't natively support DCR. This implementation bridges CIMD transparently through the MCP server's authorization proxy:
client_id_metadata_document_supported: true in authorization server metadataauthorization_endpoint and token_endpoint in metadata to point to itselfclient_id:
client_id (pre-registered or DCR): requests are passed through to Cognito unchangedThe metadata-client has zero custom code for CIMD — it simply uses its metadata URL as client_id with standard OAuth endpoints, just like any spec-compliant client. All bridging is handled server-side.
The authorization proxy includes:
client_id validation (must match the metadata URL exactly)Note: In development, http://localhost URLs are permitted. Production deployments must use HTTPS.
Clone the repository
git clone https://github.com/empires-security/mcp-oauth2-aws-cognito.git
cd mcp-oauth2-aws-cognito
Install dependencies for clients and server
npm run install:all
Deploy AWS resources
npm run deploy
Review generated .env files in:
src/client/.envsrc/auto-client/.envsrc/metadata-client/.envsrc/mcp-server/.env.env.example filesStart all services (server + 3 clients)
npm run dev
Visit http://localhost:3000 to test the pre-registered client OAuth flow
Sign Up for a New User
Click the "Fetch MCP Data" button to make an authenticated request to the MCP server
Visit http://localhost:3002 to test the DCR flow (auto-discovery client with Dynamic Client Registration)
Visit http://localhost:3003 to test the CIMD flow (Client ID Metadata Document client)
npm run cleanup
For detailed setup instructions, see the Setup Guide.
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
MCP server integration for DaVinci Resolve Studio
mcp-language-server gives MCP enabled clients access semantic tools like get definition, references, rename, and diagnos
Run Claude Code as an MCP server so any agent can delegate coding tasks to it
Browser automation using accessibility snapshots instead of screenshots