Remote MCP Server with Bearer Auth

by huanshenyi
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

Cloudflare上のリモートMCPサーバー

OAuth ログインを備えた Cloudflare Workers でリモート MCP サーバーを起動して実行してみましょう。

ローカルで開発する

# clone the repository git clone git@github.com:cloudflare/ai.git # install dependencies cd ai npm install # run locally npx nx dev remote-mcp-server-bearer-auth

ブラウザでhttp://localhost:8787/を開くことができるはずです。

MCPインスペクターをサーバーに接続します

新しい MCP API を調べるには、 MCP Inspectorを使用できます。

  • npx @modelcontextprotocol/inspectorで起動します。
  • インスペクター内で、トランスポート タイプをSSEに切り替え、接続する MCP サーバーの URL としてhttp://localhost:8787/sseを入力します。
  • ベアラートークンを追加し、「接続」をクリックします
  • 「リストツール」をクリック
  • 「getToken」ツールを実行すると、インスペクタで設定したAuthorizationヘッダーが返されます。

Claude DesktopをローカルMCPサーバーに接続します

"remote-example": { "command": "npx", "args": [ "mcp-remote", "http://localhost:8787/sse", "--header", "Authorization: Bearer {token}" ] }

Cloudflareにデプロイする

npm run deploy

リモート MCP クライアントから新しく展開したリモート MCP サーバーを呼び出す

上記の「ローカルで開発する」と同じように、MCP インスペクターを実行します。

npx @modelcontextprotocol/inspector@latest

次に、接続先の MCP サーバーの URL として、インスペクターにワーカーのworkers.dev URL (例: worker-name.account-name.workers.dev/sse ) を入力し、「接続」をクリックします。

リモートMCPクライアントからMCPサーバーに接続できました。上記のようにベアラートークンを渡すことができます。

Claude DesktopをリモートMCPサーバーに接続します

TODO: mcp-remoteプロキシへの任意のヘッダーをサポートする必要があります

デバッグ

何か問題が発生した場合は、Claude を再起動するか、次のコマンドを使用してコマンド ラインで MCP サーバーに直接接続してみると役立つことがあります。

npx mcp-remote http://localhost:8787/sse

まれに、 ~/.mcp-authに追加されたファイルを消去すると解決する場合があります。

rm -rf ~/.mcp-auth
-
security - not tested
F
license - not found
-
quality - not tested

OAuth ログインとベアラー トークン認証をサポートする Cloudflare Workers ベースの MCP サーバー実装。Claude Desktop や MCP Inspector などの MCP クライアントからの安全な接続を可能にします。

  1. Develop locally
    1. Connect the MCP inspector to your server
      1. Connect Claude Desktop to your local MCP server
        1. Deploy to Cloudflare
          1. Call your newly deployed remote MCP server from a remote MCP client
            1. Connect Claude Desktop to your remote MCP server
              1. Debugging
                ID: 4e543ehreg