MCP Server with GitHub OAuth
Model Context Protocol (MCP) サーバー + Github OAuth
これは、Github OAuth を組み込み、リモート MCP 接続をサポートする Model Context Protocol (MCP) サーバーです。
自身の Cloudflare アカウントにデプロイし、独自の Github OAuth クライアントアプリを作成すれば、構築の基盤となる完全に機能するリモート MCP サーバーが手に入ります。ユーザーは GitHub アカウントでサインインすることで、あなたの MCP サーバーに接続できるようになります。
これは、workers-oauth-provider ライブラリを使用して、Cloudflare にデプロイされた MCP サーバーに他の OAuth プロバイダーを統合する方法のリファレンス例として使用できます。
この MCP サーバー(Cloudflare Workers で動作)は以下の役割を果たします:
MCP クライアントに対する OAuth サーバー として機能
実際の OAuth サーバー(この場合は GitHub)に対する OAuth クライアント として機能
はじめに
リポジトリを直接クローンし、依存関係をインストールします: npm install。
あるいは、以下のコマンドラインを使用して、ローカルマシン上にリモート MCP サーバーを作成することもできます:
npm create cloudflare@latest -- my-mcp-server --template=cloudflare/ai/demos/remote-mcp-github-oauth本番環境向け
新しい GitHub OAuth App を作成します:
Homepage URL には
https://mcp-github-oauth.<your-subdomain>.workers.devを指定しますAuthorization callback URL には
https://mcp-github-oauth.<your-subdomain>.workers.dev/callbackを指定しますクライアント ID を控え、クライアントシークレットを生成します。
Wrangler を介してシークレットを設定します
wrangler secret put GITHUB_CLIENT_ID
wrangler secret put GITHUB_CLIENT_SECRET
wrangler secret put COOKIE_ENCRYPTION_KEY # add any random string here e.g. openssl rand -hex 32KV 名前空間のセットアップ
KV 名前空間を作成します:
wrangler kv:namespace create "OAUTH_KV"Wrangler ファイルを KV ID で更新します
デプロイとテスト
MCP サーバーをデプロイして、workers.dev ドメインで利用できるようにします
wrangler deploy
Inspector を使用してリモートサーバーをテストします:
npx @modelcontextprotocol/inspector@latesthttps://mcp-github-oauth.<your-subdomain>.workers.dev/sse を入力して接続をクリックします。認証フローを完了すると、ツールが動作していることが確認できます:
これでリモート MCP サーバーがデプロイされました!
アクセス制御
この MCP サーバーは認証に GitHub OAuth を使用します。認証されたすべての GitHub ユーザーは、「add」や「userInfoOctokit」のような基本的なツールにアクセスできます。
「generateImage」ツールは、ALLOWED_USERNAMES 設定にリストされている特定の GitHub ユーザーに制限されています:
// Add GitHub usernames for image generation access
const ALLOWED_USERNAMES = new Set([
'yourusername',
'teammate1'
]);Claude Desktop からリモート MCP サーバーにアクセスする
Claude Desktop を開き、Settings -> Developer -> Edit Config に移動します。これにより、Claude がアクセスできる MCP サーバーを制御する設定ファイルが開きます。
内容を以下の設定に置き換えてください。Claude Desktop を再起動すると、OAuth ログインページが表示されるブラウザウィンドウが開きます。認証フローを完了して、Claude に MCP サーバーへのアクセスを許可してください。アクセスを許可すると、ツールが使用可能になります。
{
"mcpServers": {
"math": {
"command": "npx",
"args": [
"mcp-remote",
"https://mcp-github-oauth.<your-subdomain>.workers.dev/sse"
]
}
}
}インターフェースにツール(🔨 の下)が表示されたら、Claude にそれらを使用するように依頼できます。例:「math ツールを使って 23 と 19 を足してくれますか?」。Claude がツールを呼び出し、MCP サーバーによって生成された結果を表示するはずです。
ローカル開発向け
MCP サーバーを反復開発およびテストしたい場合は、ローカル開発で行うことができます。これには、GitHub 上で別の OAuth アプリを作成する必要があります:
Homepage URL には
http://localhost:8788を指定しますAuthorization callback URL には
http://localhost:8788/callbackを指定しますクライアント ID を控え、クライアントシークレットを生成します。
プロジェクトのルートに
.dev.varsファイルを作成し、以下を記述します:
GITHUB_CLIENT_ID=your_development_github_client_id
GITHUB_CLIENT_SECRET=your_development_github_client_secret開発とテスト
サーバーをローカルで実行し、http://localhost:8788 で利用できるようにします
wrangler dev
ローカルサーバーをテストするには、Inspector に http://localhost:8788/sse を入力して接続をクリックします。プロンプトに従うと、「List Tools」ができるようになります。
Claude およびその他の MCP クライアントの使用
Claude を使用してリモート MCP サーバーに接続する場合、いくつかのエラーメッセージが表示されることがあります。これは、Claude Desktop がまだリモート MCP サーバーを完全にはサポートしていないため、混乱することがあるからです。MCP サーバーが接続されているかどうかを確認するには、Claude インターフェースの右下にある 🔨 アイコンにカーソルを合わせます。そこにツールが表示されるはずです。
Cursor およびその他の MCP クライアントの使用
Cursor を MCP サーバーに接続するには、Type に「Command」を選択し、Command フィールドにコマンドと引数のフィールドを結合して入力します(例: npx mcp-remote https://<your-worker-name>.<your-subdomain>.workers.dev/sse)。
Cursor は HTTP+SSE サーバーをサポートしていますが、認証はサポートしていないため、引き続き mcp-remote を使用する必要があることに注意してください(また、HTTP サーバーではなく STDIO サーバーを使用する必要があります)。
Windsurf などの他の MCP クライアントに MCP サーバーを接続するには、クライアントの設定ファイルを開き、Claude のセットアップに使用したものと同じ JSON を追加して、MCP クライアントを再起動します。
Related MCP server: GitHub MCP Server
仕組み
ライセンス
このプロジェクトは GPL-3.0 ライセンスの下でライセンスされています。詳細は LICENSE ファイルを参照してください。
OAuth プロバイダー
OAuth プロバイダーライブラリは、Cloudflare Workers 用の完全な OAuth 2.1 サーバー実装として機能します。トークンの発行、検証、管理など、OAuth フローの複雑さを処理します。このプロジェクトでは、以下の二重の役割を果たします:
サーバーに接続する MCP クライアントの認証
GitHub の OAuth サービスへの接続管理
KV ストレージへのトークンおよび認証状態の安全な保存
Durable MCP
Durable MCP は、Cloudflare の Durable Objects を使用して基本 MCP 機能を拡張し、以下を提供します:
MCP サーバーの永続的な状態管理
リクエスト間での認証コンテキストの安全な保存
this.propsを介した認証済みユーザー情報へのアクセスユーザー ID に基づく条件付きツール利用のサポート
MCP Remote
MCP Remote ライブラリを使用すると、サーバーは Inspector などの MCP クライアントによって呼び出せるツールを公開できます。これは以下を行います:
クライアントとサーバー間の通信プロトコルを定義
ツールを定義するための構造化された方法を提供
リクエストとレスポンスのシリアル化および逆シリアル化を処理
クライアントとサーバー間の Server-Sent Events (SSE) 接続を維持
This server cannot be installed
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
- AlicenseBqualityAmaintenanceA Model Context Protocol server for Git repository interaction and automation. This server provides tools to read, search, and manipulate Git repositories via Large Language Models.1289,977MIT
- FlicenseBqualityDmaintenanceA Model Context Protocol server that enables AI models to interact with GitHub's API, allowing for repository creation and management with descriptions, topics, and website URLs through natural language commands.11
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that supports remote connections and authenticates users via GitHub OAuth, allowing them to access tools based on their GitHub identity.
- FlicenseNot gradedqualityNot gradedmaintenanceModel Context Protocol server that enables interaction with GitHub repositories, issues, pull requests, and search functionality through natural language.1
Related MCP Connectors
A MCP server built for developers enabling Git based project management with project and personal…
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
An MCP server that gives your AI access to the source code and docs of all public github repos
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/byjit/cloudflare-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server