modelcontextprotocol / modelcontextprotocol/python-sdk

Using /.well-known/ OAuth endpoints behind custom path on GKE

オープン
#1,335 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

auth enhancement good first issue needs decision P2 question
主要言語
Python
スター
24.3k
フォーク
4k
平均マージ
1日 1時間
マージ済み PR(30日)
31

説明

Question

I am running a simple MCP server (built with FastMCP) behind a gateway on GKE with an custom path defined by an HttpRoute. I am attempting to use the /.well-known/ endpoints for OAuth authentication and authorization. Unfortunately, it seems that the routes for the /.well-known/ endpoints; as well as the other OAuth endpoints /authorize, /token, /register, and /revoke, are all hardcoded in the MCP SDK within mcp/server/auth/routes.py within the create_auth_routes() function.

So, for example...

If my MCP server is deployed at https://{my-gateway}/custom/path/
However, the well-known endpoints are pointing to https://{my-gateway}/.well-known/*, which are obviously returning 404 Not Found responses.

When starting my server, I am passing the 'path' parameter in the mcp.run() command. Using my example above, my run command would look like -- mcp.run(transport="http", host="0.0.0.0", port=8080, path="/custom/path/mcp"). However, this path parameter seems to have zero effect on the OAuth well-known endpoints.

So, the question is... Is this expected behavior, and if so, how should we run MCP servers that use well-knonw OAuth endpoints behind API Proxies (Apigee, APIM, etc) or GKE Gateways that require a custom path?

Additional Context

mcp version -- 1.13.1
fastmcp version -- 2.11.4.dev128+5b433f5

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

mcp/server/auth/routes.py の create_auth_routes() から始め、mcp.run() に渡されたパスが well-known ルートと OAuth ルートにどのように適用されるかを追跡します。GKE について説明されているカスタムパスでのデプロイを再現し、そのうえで SDK がルートプレフィックスをサポートしているか、または文書化する結果で必要なゲートウェイ設定を説明すべきかを判断します。動作とサポートされているセットアップが明確になれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
kubernetes, python
領域
api, authentication, cloud
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。