github / github/copilot-cli

MCP Oauth fails when the server metadata URL is redirected

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

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

area:authentication area:mcp
主要言語
Shell
スター
11.2k
フォーク
1.9k
平均マージ
14時間 16分
マージ済み PR(30日)
6

説明

Describe the bug

When the .well-known/openid-configuration is behind an http redirect, authentication fails with:

Authentication failed: MCPOAuthError: Incompatible authorization server: authorization server advertised an issuer that does not match the URL its metadata was discovered from (RFC 8414 §3.3); refusing to connect

I believe that copilot-cli checks the issuer against the original URL instead of the redirected URL. Note that RFC 8414 states that the issuer must match "the URL used to retrieve the metadata," which strictly speaking is the redirection target, not the source.

Affected version

GitHub Copilot CLI 1.0.83.

Steps to reproduce the behavior
  1. Run an MCP server on a different server from its OAuth authorization server, e.g. https://my.mcp.server vs https://my.oauth.server
  2. Configure the MCP server so that https://my.mcp.server/.well-known/openid-configuration returns an HTTP 301 redirect to https://my.oauth.server/.well-known/openid-configuration
  3. Configure the OAuth server so that https://my.oauth.server/.well-known/openid-configuration specifies https://my.oauth.server as the issuer
  4. In copilot-cli, type /mcp add FooBar, select type HTTP, remote server URL https://my.mcp.server, and the client ID when asked
Expected behavior

Copilot should ask to authenticate, then open the authentication URL in my browser (or display the authentication code and URL so that I can copy-paste them in my browser), then complete the authentication flow.

Additional context

This may be related to #4480 except that in #4480, the Atlassian MCP server gave the wrong issuer, whereas here the issuer is correct for the real URL and copilot-cli is checking against the wrong URL.

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

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

はじめの一歩

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

調査の方向性

MCP サーバーの .well-known/openid-configuration が 301 リダイレクトを返すようにして失敗を再現し、その後、/mcp add HTTP フローで使用される issuer 検証を追跡します。リダイレクト先 URL の issuer がその最終 URL と一致する場合に、その URL のメタデータが受け入れられ、認証がブラウザまたは表示された認証コードまで進めば完了です。

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

評価

技術スタック
shell
領域
authentication, cli, security
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
55/100

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

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