MCPSERV.CLUB
QuantGeekDev

MCP Oauth2.1 Server

MCP Server

OAuth 2.1 Authorization Server for Model Context Protocol

Stale(55)
7stars
2views
Updated Sep 25, 2025

About

A reference implementation of an MCP authorization server that supports OAuth 2.1, using Cognito or Keycloak as providers. It validates the mcp:access scope and can be tested locally with ngrok for secure HTTPS endpoints.

Capabilities

Resources
Access data sources
Tools
Execute functions
Prompts
Pre-built templates
Sampling
AI model interactions

Overview

The MCP OAuth 2.1 Server is a reference implementation that brings the latest Authorization spec updates to Model Context Protocol (MCP) workflows. By exposing a fully‑fledged OAuth 2.1 authorization endpoint, it allows AI assistants to obtain short‑lived access tokens that grant scoped access to MCP resources. This solves the long‑standing challenge of securely delegating AI agents to external services without exposing user credentials or relying on insecure client‑side flows.

For developers building AI‑powered applications, the server provides a standard, interoperable way to authenticate and authorize requests from an assistant. Instead of hard‑coding API keys or embedding sensitive data in the client, developers can issue a token that carries only the permissions needed for a particular task—such as reading a specific resource or invoking a tool. The server’s support for both Amazon Cognito and Keycloak gives teams flexibility to choose a cloud‑managed or self‑hosted identity provider, while the scope validation () guarantees that tokens are tightly scoped to the MCP domain.

Key capabilities include:

  • OAuth 2.1 compliance: The server adheres to the latest draft, ensuring that only HTTPS endpoints are used and that token lifetimes can be finely controlled.
  • Dynamic resource discovery: Clients can query the server to learn which resources are available and what scopes they require, enabling automatic generation of consent prompts.
  • Scope validation: Tokens are issued only if the requested scope matches , preventing over‑privileged access.
  • Multi‑provider support: Cognito and Keycloak integration means the same MCP client can work across cloud environments or on-premise setups.

Typical use cases involve AI assistants that need to read, write, or transform data in external databases, invoke third‑party APIs, or trigger workflows in CI/CD pipelines. For example, a conversational agent could request access to a customer‑support ticketing system, receive an OAuth 2.1 token scoped to that service, and then perform CRUD operations—all while keeping the user’s credentials secure. Similarly, a data‑analysis bot could obtain temporary access to a data lake, run queries, and return insights without exposing any long‑term credentials.

Integrating the MCP OAuth 2.1 Server into an AI workflow is straightforward from a developer’s perspective. The assistant first discovers the authorization endpoint via MCP discovery, then initiates an OAuth flow (e.g., Authorization Code with PKCE). Once the token is received, it can be attached to subsequent MCP requests as a bearer credential. The server’s clear separation of authentication and resource logic also means that developers can swap out identity providers or adjust scope policies without touching the assistant’s core code. This modularity, combined with strict scope enforcement, gives teams a robust, secure foundation for building AI applications that interact safely with external services.