惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Announcements
Recent Announcements
Microsoft Security Blog
Microsoft Security Blog
Microsoft Azure Blog
Microsoft Azure Blog
J
Java Code Geeks
D
DataBreaches.Net
U
Unit 42
P
Proofpoint News Feed
I
InfoQ
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
博客园 - Franky
博客园_首页
IT之家
IT之家
博客园 - 叶小钗
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
阮一峰的网络日志
阮一峰的网络日志

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Bridge the gap between your IdP and the MCP World
Vlastimil El · 2026-05-15 · via DEV Community

So you've got your corporate IdP (Keycloak, Auth0, Okta, Azure AD, whatever) and now you want your MCP servers to use it for auth. You point Claude Code or Cursor at it, aaand... things break. Scope explosions on the consent screen, missing PKCE defaults, clients demanding Dynamic Client Registration your IdP doesn't serve the way MCP expects. Sound familiar?

The problem

The MCP Authorization spec expects certain OAuth behaviors that most enterprise IdPs don't provide out of the box:

  • MCP clients expect open Dynamic Client Registration. Most IdPs either don't expose it or lock it behind admin credentials.
  • MCP clients tend to request all announced scopes. This isn't required by the spec -- it's just how most clients (Claude Code, Cursor, others) behave in practice. They read scopes_supported from discovery and request all of them. Your Keycloak announces 15 internal scopes? Congrats, users now see a consent screen from hell -- or the request gets rejected outright if client is not pre-approved for some announced scope.
  • Many clients add offline_access unconditionally. Again, not a spec requirement -- just a common client behavior to ensure they get refresh tokens. This becomes a problem when your IdP restricts long-lived refresh tokens or requires client pre-approval for that scope.
  • Discovery metadata needs filtering. IdPs expose dozens of OIDC fields (CIBA, device flow, logout endpoints...) that are irrelevant noise for MCP and can confuse clients.

You could customize your IdP, but that's a maintenance rabbit hole -- especially when you need the same IdP for non-MCP and legacy apps.

Enter mcp-auth-adapter

mcp-auth-adapter is a thin, stateless Node.js proxy that sits between your MCP clients and your existing IdP. It doesn't issue tokens or handle authentication -- all the real work stays on your IdP. It just makes the OAuth dance MCP-compatible.

What it does

Filtered discovery -- Serves /.well-known/ IdP metadata with only the fields MCP clients actually need. Injects safe defaults (PKCE S256, authorization_code grant) when your IdP's metadata is incomplete, and own functionality where needed.

Open DCR endpoint -- POST /register hands out a fixed, pre-configured client_id so MCP clients can self-register. No IdP-side DCR needed.

Scope filtering -- Control what scopes reach your IdP. Strip offline_access, remove internal scopes, or use an allowlist:

# Only these scopes will ever reach the upstream IdP
MCP_PROXY_AUTH_SCOPES_PRESERVED=openid,api.read,api.write

Enter fullscreen mode Exit fullscreen mode

CIMD support (experimental) -- The MCP spec defaults to Client ID Metadata Documents for client identification, but it's an emerging IETF draft (not yet RFC) and no major IdP supports it natively today. This adapter bridges that gap -- it accepts CIMD-style client_id URLs from MCP clients, validates the metadata documents, and maps them to real upstream client_ids your IdP understands. So you get CIMD compatibility without waiting for your IdP vendor to implement it.

Observability built in -- Prometheus metrics at /metrics, structured logging, health probes for k8s.

Deploy it in 30 seconds

Grab the container image and go:

docker run -d --name mcp-auth-adapter \
  -p 3000:3000 \
  -e MCP_BASE_URL=https://mcp-auth.example.com \
  -e MCP_UPSTREAM_SSO_URL=https://sso.example.com/auth/realms/external \
  -e MCP_PROXY_DCR_CLIENT_ID=mcp-client \
  ghcr.io/velias/mcp-auth-adapter:latest

Enter fullscreen mode Exit fullscreen mode

That's it. Three env vars for a basic setup:

  • MCP_BASE_URL -- the public URL where this adapter lives
  • MCP_UPSTREAM_SSO_URL -- your IdP's issuer URL
  • MCP_PROXY_DCR_CLIENT_ID -- a public client pre-registered at your IdP

Then point your MCP server's authorization_servers to MCP_BASE_URL and clients will discover everything via .well-known.

Typical production config

For a real deployment you'll probably want scope control too:

MCP_BASE_URL=https://mcp-auth.example.com
MCP_UPSTREAM_SSO_URL=https://sso.example.com/auth/realms/external
MCP_PROXY_DCR_CLIENT_ID=mcp-client
MCP_WELL_KNOWN_SCOPES_SUPPORTED=openid,api.read,api.write
MCP_PROXY_AUTH_SCOPES_REMOVED=offline_access

Enter fullscreen mode Exit fullscreen mode

This controls both sides: what clients see in discovery and what actually reaches your IdP.

What it doesn't do

This adapter is intentionally minimal:

  • No token issuing -- tokens come from your IdP, always
  • No user database -- stateless, nothing to back up
  • No rate limiting -- put it behind your existing reverse proxy / WAF
  • No CORS -- designed for redirect-based flows, not browser fetch calls

Who is this for?

If you're running MCP servers (or planning to) and have an existing OAuth/OIDC provider, this saves you from bending your IdP config to accommodate MCP client quirks. Works with Keycloak, Auth0, Okta, Azure AD/Entra, Google Identity -- anything that serves standard OIDC discovery.

Tested with Claude Code, Claude Desktop, Cursor IDE, Cursor Agent, Gemini CLI, VS Code, and more.

Wrapping up

MCP is moving fast, and auth is one of those things that should just work but often doesn't when you try to connect real-world IdPs to real-world MCP clients. Instead of fighting your IdP config or waiting for vendors to catch up with emerging standards like CIMD, drop a lightweight adapter in between and move on to building the actual MCP tools your users care about.

If you hit rough edges or have ideas, open an issue -- the project is young and feedback shapes the roadmap.


Apache 2.0 licensed. PRs welcome.

GitHub: github.com/velias/mcp-auth-adapter