mcp-oauth-server-next
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
MCP OAuth Server — Next.js, Stateless PoC
A proof-of-concept Model Context Protocol server deployed on Vercel that requires OAuth 2.0 before any tool can be called. It demonstrates the full authentication flow Claude Code runs automatically: discovery → Dynamic Client Registration → PKCE authorization → Bearer token.
Live: https://mcp-oauth-server-next.vercel.app
Tool: get_current_day — returns today's date.
Hard requirement: completely stateless
There is no database and no in-memory map — not even for clients, auth codes, or tokens. Every OAuth artifact is a self-contained, HMAC-SHA256-signed token that any serverless instance can mint and verify from the shared secret alone:
Artifact | What it encodes | TTL |
|
| none |
authorization code |
| 10 min |
access token |
| 1 hour |
See lib/tokens.ts. The format is base64url(json) . base64url(hmac).
Accepted security tradeoffs (PoC only)
The signing secret and the
demo/democredentials are hardcoded and public (lib/config.ts).Authorization codes are not single-use — statelessness means there is nowhere to record consumption, so the short TTL bounds replay instead.
No token revocation, no refresh tokens, single demo user.
Related MCP server: connect-claude
How it works
Claude Code This server (Next.js App Router)
─────────── ───────────────────────────────────────────
POST /api/mcp (no token) ───────► 401 + WWW-Authenticate: resource_metadata=…
GET /.well-known/oauth-protected-resource ──► { resource, authorization_servers }
GET /.well-known/oauth-authorization-server ► { *_endpoint, S256, … }
POST /api/oauth/register ───────► signed client_id (DCR, RFC 7591)
GET /api/oauth/authorize ───────► accept page (facts vs. self-reported client_name)
POST /api/oauth/authorize ───────► login page (demo / demo)
POST /api/oauth/authorize ───────► 302 redirect_uri?code=…&state=…
POST /api/oauth/token ───────► verify PKCE → signed access_token
POST /api/mcp (Bearer) ───────► JSON-RPC: initialize / tools/list / tools/callRelevant specs: RFC 9728 (protected resource metadata), RFC 8414 (AS metadata), RFC 7591 (DCR), RFC 7636 (PKCE).
Project layout
app/
page.tsx landing page
api/mcp/route.ts protected MCP JSON-RPC endpoint
api/oauth/register/route.ts Dynamic Client Registration
api/oauth/authorize/route.ts accept page + login page + code issuance
api/oauth/token/route.ts code → access token (+ PKCE)
api/well-known/oauth-protected-resource/ RFC 9728 doc
api/well-known/oauth-authorization-server/ RFC 8414 doc
lib/
config.ts hardcoded settings (URL, secret, credentials, TTLs)
tokens.ts sign() / verify() — the statelessness primitive
pkce.ts S256 verification
test/
e2e.mjs full-flow test against the live deployment/.well-known/* URLs are served via rewrites in next.config.js (Next.js
ignores dot-prefixed folders inside app/).
Connect from Claude Code
claude mcp add --transport http mcp-oauth https://mcp-oauth-server-next.vercel.app/api/mcpClaude Code runs the whole flow for you; sign in with demo / demo when the
browser opens.
Test
npm test # runs against the live Vercel deployment
MCP_BASE_URL=http://localhost:3000 npm test # or a local `npm run dev`The test exercises discovery, DCR, the PKCE authorize + token exchange, the three MCP methods, and the negative cases (bad password, bad PKCE verifier, invalid token).
Develop / deploy
npm install
npm run dev # http://localhost:3000Deploy by importing the repo into Vercel — no environment variables required.
Everything is hardcoded in lib/config.ts; if you fork to a different domain,
update BASE_URL there.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
The Stytch MCP server is a reference implementation that demonstrates remote MCP server authentication and authorization using Stytch Connected Apps. It provides OAuth 2.1-compliant authorization (including PKCE), Dynamic Client Registration, and validates Stytch-issued access tokens to enable AI agents to securely interact with external services through permissioned access, supporting scopes like openid, email, profile, and manage:project_data.
Demo banking MCP server: accounts, transactions and payments. OAuth 2.1 with DPoP.
MCP server for verifying EUDI/Talao wallet data via OIDC4VP (pull) for AI agents.
MCP server for Argo RPG Platform — connects AI assistants to campaign data via OAuth2
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables Claude to manage TickTick tasks and projects via OAuth 2.1 with PKCE authentication.10MIT
- FlicenseNot gradedqualityDmaintenanceMCP server scaffold that exposes stubbed tools for listing, searching, and summarizing sources, with built-in OAuth 2.1 authorization flow for Claude integration.-
- FlicenseNot gradedqualityDmaintenanceA proof-of-concept MCP server implementing OAuth 2.1 authorization with CIMD client registration and PKCE, demonstrating protected resource access and step-up authentication.-
- FlicenseNot gradedqualityBmaintenanceA simple HTTP-based MCP server that provides demo tools (get_test_string, echo, check_maintenance), greeting prompts, and test resources, with optional OAuth 2.1 support.-