mcp-oauth2-token-provider
mcp-oauth2-token-provider
AI IDEとリモートMCPエンドポイント間の認証付きプロキシとして機能する、汎用MCP(Model Context Protocol)サーバーです。OAuth2のclient_credentialsグラントによるトークン生成を内部的に処理し、プロキシされるすべてのリクエストにベアラートークンを透過的に注入します。
機能
透過的なOAuth2プロキシ — トークンの取得、キャッシュ、自動更新を行います
動的なツール検出 — ハードコードされたツールスキーマは不要。リモートMCPエンドポイントからツールを検出します
401時の自動リトライ — セッション中にトークンが期限切れになった場合、更新して1回だけリトライします
起動時ヘルスチェック — 接続前にリモートMCPが到達可能か検証し、問題があれば明確なエラーメッセージとともに即座に失敗します
トークンの永続化 — トークンを
~/.oauth2-token-provider/token.jsonにディスクへキャッシュし、プロセス再起動後も存続させますコード内の設定ゼロ — すべての設定は環境変数で行います
SSEおよびJSONレスポンスに対応 — リモートからのStreamable HTTPとプレーンなJSON-RPCの両方を処理します
Related MCP server: MCP OAuth Proxy
インストール
npx mcp-oauth2-token-providerまたはグローバルにインストール:
npm install -g mcp-oauth2-token-providerKiro / VS Code MCPでの使用方法
.kiro/settings/mcp.json(または同等のファイル)に追加します:
{
"mcpServers": {
"my-remote-server": {
"command": "npx",
"args": ["mcp-oauth2-token-provider"],
"env": {
"REMOTE_MCP_URL": "https://your-server.com/mcp",
"OAUTH2_TOKEN_URL": "https://your-sso.com/token.oauth2",
"OAUTH2_CLIENT_ID": "your-client-id",
"OAUTH2_CLIENT_SECRET": "your-client-secret"
}
}
}
}環境変数
変数 | 必須 | 説明 |
| 必須 | プロキシ先のリモートMCPエンドポイントURL |
| 必須 | OAuth2トークンエンドポイント(client_credentialsグラント) |
| 必須 | OAuth2クライアントID |
| 必須 | OAuth2クライアントシークレット |
| 任意 | Basic認証のユーザー名(デュアルクレデンシャルSSO用) |
| 任意 | Basic認証のパスワード(デュアルクレデンシャルSSO用) |
動作の仕組み
AI IDE ←stdio→ [mcp-oauth2-token-provider] ←HTTP+Bearer→ [Remote MCP Server]
│
├─ Acquires OAuth2 token (client_credentials)
├─ Caches in memory + ~/.oauth2-token-provider/token.json
├─ Injects Bearer header on every request
├─ Auto-refreshes on expiry (60s safety margin)
└─ Retries once on 401 with fresh token起動時に、リモートMCPエンドポイントが到達可能か検証します(MCP
initializeを送信)リモートに到達できない場合は、エラーで終了します(IDEに"Failed"ステータスが表示されます)
正常な場合は、stdioを介してIDEに接続し、リモートからツールを検出します
すべてのツール呼び出しは、ベアラートークンとともに透過的にプロキシされます
トークンキャッシュ
トークンは2つのレイヤーでキャッシュされます:
インメモリ — 最速ですが、プロセス再起動で失われます
ディスク上 —
~/.oauth2-token-provider/token.jsonに保存され、再起動後も存続します
トークンは以下の場合に更新されます:
有効期限の60秒前になったとき
リモートから401レスポンスを受信したとき
デュアルクレデンシャルSSO(オプション)
一部のSSOプロバイダーでは、次の両方が必要です:
リクエストボディ内の
client_id+client_secretサービスアカウントの認証情報を使ったBasic認証ヘッダー
このパターンを有効にするには、OAUTH2_BASIC_USERNAMEとOAUTH2_BASIC_PASSWORDを設定します。
ライセンス
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceProxies MCP requests from Cursor IDE to a custom HTTP server, enabling custom tool integrations.121ISC
- Alicense-qualityBmaintenanceActs as a secure OAuth 2.0/2.1 proxy gateway for MCP servers, enabling integration with Claude and ChatGPT platforms.12MIT
- Alicense-qualityCmaintenanceAuthenticating reverse proxy for MCP servers providing credential isolation, OAuth2 token management, and composite tool aggregation.BSD Zero Clause
- Alicense-qualityCmaintenanceProvides a Streamable HTTP MCP proxy for VS Code Copilot and Claude Code, using JWT client assertion to securely access NetSuite APIs.MIT
Related MCP Connectors
MCP server for Argo RPG Platform — connects AI assistants to campaign data via OAuth2
MCP server for verifying EUDI/Talao wallet data via OIDC4VP (pull) for AI agents.
MCP Hub: AI service discovery, per-user OAuth, and multi-service workflow orchestration
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/codezerowork/mcp-oauth2-token-provider'
If you have feedback or need assistance with the MCP directory API, please join our Discord server