Published
-
OAuth 2.1 PKCE Flow and MCP Authentication Authorization Practical Guide
OAuth 2.1 PKCE flow and MCP authentication authorization practical guide
1. Executive Summary
In practice, MCP server authentication and authorization can be easily understood as the flow of “The MCP server acts as a protected resource, obtains a token with OAuth 2.1 Authorization Code + PKCE, and uses that Bearer token to permit MCP tool calls.” In the latest published specifications of MCP, HTTP-based MCP servers publish Protected Resource Metadata, and clients are assumed to identify the authorization server by tracing Authorization Server Metadata and OIDC Discovery from there. OAuth 2.1 is still Internet-Draft as of May 2026, and is mainly organized based on the Authorization Code flow and PKCE. Source note: See MCP Authorization, draft-ietf-oauth-v2-1, RFC 7636, OpenID Connect Discovery 1.0, RFC 8414. With Claude’s remote connector, the user adds the connection destination URL and, if necessary, passes the OAuth client ID / secret to connect. According to Anthropic’s official information, remote MCP is handled via Anthropic’s cloud, and a custom client ID/secret can be set even if the server side does not have DCR. Source note: See Anthropic: Getting started with custom integrations using remote MCP and Anthropic’s connector configuration guide. The implementation points are as follows.
- The MCP server is not a “business API” but a “protected resource” and guides the authorization server with 401 responses and resource metadata.
- OIDC provider exposes
authorization_endpoint,token_endpoint, etc. through Authorization Server Metadata or OIDC Discovery. - The OAuth client receives the authorization code in the browser and exchanges tokens with
code_verifierof PKCE. - Claude plays this client role in the form of a remote connector. When setting up, the important things to consider are the “Connection URL”, “Client ID/Secret”, and “Required Scope”.
- Existing services that only have OpenAPI cannot be used as connection destinations for MCP clients. It is practical to wrap OpenAPI in an MCP server and receive OAuth 2.1 PKCE there. This is an inference from the specification that MCP is a standard for connecting to external systems and that clients connect to MCP servers. Source note: See MCP Authorization. The handling of OpenAPI-only is estimated based on this specification.
flowchart LR
U["User"] --> C["Claude-style MCP client"]
C --> M["MCP server"]
M --> PRM["Resource Metadata"]
C --> AS["Authorization server"]
AS --> TOK["Token endpoint"]
C -->|Bearer token| M
M --> API["Upstream API"]
2. Terms you should know first
MCP, OIDC, and OAuth have different roles. If you confuse this, the settings will be corrupted.
| Role | What it does | Typical entity |
|---|---|---|
| MCP Server | Publish Tools Resource Prompt. Acts as a protected resource in HTTP. | Self-made MCP server, MCP wrapper for business systems |
| OAuth authorization server | Responsible for issuing authorization codes, issuing tokens, and authenticating clients. | Auth0, Keycloak, Entra ID, Okta |
| OIDC provider | Add ID token and Discovery to OAuth. | Same as above. Often publishes OIDC Discovery |
| OAuth client | Initiates browser authorization and exchanges code for token. | Claude-based clients, original MCP clients |
| Resource Server | Validate access token and authorize API. | MCP Server, Upstream API, API Gateway |
| In the authorization chapter of the MCP specification, the HTTP server exposes Protected Resource Metadata, from which the client can find the authorization server’s metadata and proceed with authorization using the rules of OAuth 2.1. OAuth 2.1 itself is a draft, but it is organized around the Authorization Code and PKCE, and does not include implicit flows. | ||
| Source note: See MCP Authorization and draft-ietf-oauth-v2-1. |
3. Communication flow
The basic flow is Authorization Code + PKCE. The MCP server first returns 401, the client looks at the resource metadata, finds the authorization server, authorizes with the browser, passes the code to the token endpoint to get a token, and then makes MCP calls with the Bearer token attached. PKCE is a mechanism that prevents token exchange even if the authorization code via the browser is stolen, and was designed primarily for public clients. Source note: See RFC 7636 and draft-ietf-oauth-v2-1.
sequenceDiagram
participant User as User
participant Client as MCP client
participant MCP as MCP server
participant AS as Authorization Server / OIDC Provider
User->>Client: Run MCP tool
Client->>MCP: Request without token
MCP-->>Client: 401 + resource metadata
Client->>MCP: Fetch metadata
MCP-->>Client: Authorization server information
Client->>AS: discovery / authorization request
AS-->>User: Login and consent in browser
AS-->>Client: authorization code
Client->>AS: token request + PKCE code_verifier
AS-->>Client: access token
Client->>MCP: Retry with Bearer token
MCP-->>Client: Tool result
3.1 First response
When an MCP server receives unauthorized access to a protected endpoint, instead of simply ending with a 403, it returns resource metadata that includes authorization server information. In the MCP specification, it is through this metadata that the client takes the next discovery step. Source note: See MCP Authorization.
3.2 Discovering the authorization server
The client first looks at the Authorization Server Metadata based on the information obtained from the MCP server. If you have an OIDC provider, you can also use OIDC Discovery. Both convey information such as authorization endpoint, token endpoint, and issuer to the client. Source note: See RFC 8414 and OpenID Connect Discovery 1.0.
3.3 Authorization code with PKCE
The client prepares code_verifier and code_challenge and sends an authorization request. The user authenticates and consents on the IdP and receives an authorization code. The client sends the code and code_verifier to the token endpoint to obtain an access token. When organizing OAuth 2.1, this flow is the standard, and it is practical to treat PKCE as an essential premise.
Source note: See RFC 7636 and draft-ietf-oauth-v2-1.
3.4 MCP Tool Call
Subsequent MCP calls will be regular HTTP requests with a Bearer token attached. The MCP server verifies the signature, issuer, audience, and scope of the token and returns only authorized tools. The MCP server can directly view the contents of the token using JWT validation, or it can be used in conjunction with introspection, but in any case, it is important to have a design that does not give full authority to the token by just having it. This is a recommendation as a practical design for OAuth rather than a specification requirement for MCP. Source note: See MCP Authorization and RFC 6749.
4. What to set for which component?
4.1 MCP Server
The MCP server first decides what to make public as protected resources. In practice, the MCP server is not directly connected to the business system, but is often an authorization boundary placed in front of the business API. The following items are required as a minimum:
- Publishing Protected Resource Metadata
- Presentation of authorization server information
- Definition of scope to accept
- Validate access token
- Proper return classification of 401/403 The MCP specification assumes that HTTP-based servers will use this authorization metadata. In other words, the MCP server itself needs to be an API boundary that understands authorization, rather than a “tool server that doesn’t know OAuth.” Source note: See MCP Authorization.
4.2 OIDC provider / OAuth authorization server
On the authorization server side, set at least the following:
- Authorization endpoint -Token endpoint -Issuer
- Client registration policy
- Redirect URI permission -Scopes
- DCR or client metadata document if necessary The MCP specification assumes that clients can trace Authorization Server Metadata and OIDC Discovery. Therefore, the IdP must at least be able to return Discovery correctly. Source note: See RFC 8414 and OpenID Connect Discovery 1.0.
4.3 OAuth Client
The OAuth client is either the MCP client implementation itself or the authorization broker behind it. The following settings should be made. -client_id
- client_secret if needed -redirect URI
- Use scopes -PKCE support
- Handling of refresh token OAuth 2.1 assumes PKCE and is organized to use code flow safely even on public clients. There’s no reason to go with the old implicit flow. Source note: See draft-ietf-oauth-v2-1 and RFC 7636.
4.4 Claude-based clients
According to Anthropic’s official guide, you can add a connection destination to the remote MCP connector and set a custom client ID / secret as necessary. In other words, Claude acts as an OAuth client, at least in the context of the remote connector. The core of OAuth settings is “which client registration to use for this MCP server.” Source note: See Anthropic: Getting started with custom integrations using remote MCP and Anthropic’s connector configuration guide. The setting order in practice is as follows.
- Register the MCP server URL.
- Check the IdP from the resource metadata returned by the server.
- Register client_id on Claude side.
- Register client_secret if necessary.
- Agree on scope.
- Log in with your browser and agree.
- Once the token is saved, run the MCP tool.
4.5 Existing OpenAPI-only services
You need to be a little careful here. OpenAPI is an API description format, not an MCP. Therefore, existing services that only have OpenAPI usually cannot be connected to Claude’s MCP connector as is. In practice, one MCP server is installed, each OpenAPI operation is mapped to the MCP tool, and the MCP server is configured to receive OAuth 2.1 PKCE. This is an inference from the specification that MCP is a standard for connecting to external systems and that clients connect to MCP servers. Source note: See MCP Authorization. The handling of OpenAPI-only is estimated based on this specification.
flowchart TD
A["OpenAPI-only API"] --> B["MCP adapter/server"]
B --> C["OAuth 2.1 PKCE"]
C --> D["Claude / MCP client"]
B --> E["Business DB / internal API"]
With this configuration, OpenAPI operations can be exposed as tools as they are. Conversely, even if you add only authorization with OpenAPI, what the MCP client understands is the MCP tool schema, so a conversion layer is necessary.
5. Shortest understanding for beginners
In a nutshell, “Who is authenticating whom?” is as follows.
- The user instructs Claude that he/she wants to use this MCP tool.
- Claude accesses the MCP server.
- The MCP server replies, “Please check with OAuth whether the user can use it.”
- Claude opens the IdP screen and asks the user to log in.
- The IdP hands over a token to Claude saying, “This person can use this scope.”
- Claude accesses the MCP server again with the token.
- The MCP server returns the tool result if the token is correct. In short, the MCP server is the “entrance”, the OIDC provider is the “identity verification and consent”, and the OAuth client is the “person who collects the information on your behalf”.
6. Common pitfalls in practice
6.1 Ends with vague error without returning 401
If you return a 500 or a generic 403 when authorization is required, the client won’t know what to do. In MCP, it is meaningful to return resource metadata, so it is better to tell machine-readable information that authorization is required. Source note: See MCP Authorization.
6.2 Only OIDC Discovery is implemented
It is safe to make the MCP specification readable assuming both Authorization Server Metadata and OIDC Discovery. If only one is issued due to the IdP’s circumstances, client compatibility will deteriorate. Source note: See RFC 8414 and OpenID Connect Discovery 1.0.
6.3 Omit PKCE
Authorization codes without PKCE should be avoided in current practice. The direction of OAuth 2.1 is to require PKCE, which is a prerequisite for safely using code flow even on public clients. Source note: See draft-ietf-oauth-v2-1 and RFC 7636.
6.4 Scope design is too rough
read and write alone tend to be too much or too little for the actual MCP tool. It is better to narrow down your choices according to your work scope and actions, such as invoice:read, incident:close, and customer:search. This is not a mandatory specification, but a practical principle of least privilege.
6.5 I think OpenAPI is just MCP
OpenAPI is an API description, and MCP is a tool connection protocol. Since the roles are different, existing systems that only have OpenAPI must be designed with an MCP adapter in mind. This is an estimate based on a reinterpretation of the specifications. Source note: See MCP Authorization.
7. Recommended configuration
The easiest configuration to use is:
- Place the MCP server at the front.
- MCP server exposes Protected Resource Metadata.
- IdP returns OIDC Discovery.
- OAuth client uses Authorization Code + PKCE.
- For Claude-based clients, connect with remote connector and set client ID / secret if necessary.
- Wrap existing OpenAPI services with MCP adapter.
flowchart LR
subgraph "Client"
C["Claude / MCP Client"]
end
subgraph "Auth"
AS["OIDC / OAuth Server"]
end
subgraph "Resource"
M["MCP Server"]
A["OpenAPI Adapter"]
S["Existing Service"]
end
C -->|auth code + PKCE| AS
C -->|tool call + bearer token| M
M --> A --> S
With this configuration, it is easy to separate authorization responsibilities and it is easy to reuse it for MCP clients other than Claude.
8. Conclusion
For MCP’s OAuth 2.1 PKCE flow, it is easier to think about the roles separately than to remember detailed setting items. The MCP server is the protected resource, the OIDC provider is the issuer of authorization, and the OAuth client is the performer of browser authorization and token exchange. Claude-based clients can play the role of this client using a remote connector. Existing OpenAPI-only APIs are difficult to connect as is without an MCP adapter. In practice, the minimum configuration is Authorization Code + PKCE, fine-grained scope, explicit resource metadata, and the introduction of MCP adapter. Source note: See MCP Authorization, draft-ietf-oauth-v2-1, RFC 7636, Anthropic remote MCP.
Reference information
- Model Context Protocol - Authorization
- draft-ietf-oauth-v2-1
- RFC 7636: Proof Key for Code Exchange by OAuth Public Clients
- RFC 6749: The OAuth 2.0 Authorization Framework
- RFC 8414: OAuth 2.0 Authorization Server Metadata
- OpenID Connect Discovery 1.0
- Anthropic: Getting started with custom integrations using remote MCP
OAuth 2.1 PKCEフローとMCP認証認可の実務ガイド
1. エグゼクティブサマリー
MCPサーバーの認証認可は、実装上は「MCPサーバーが保護リソースとして振る舞い、OAuth 2.1 の Authorization Code + PKCE でトークンを取得し、その Bearer token で MCP ツール呼び出しを許可する」流れとして理解すると分かりやすい。MCPの最新公開仕様では、HTTP系のMCPサーバーは Protected Resource Metadata を公開し、クライアントはそこから Authorization Server Metadata と OIDC Discovery をたどって認可サーバーを特定する前提になっている。OAuth 2.1 は2026年5月時点でも Internet-Draft で、Authorization Code flow と PKCE を前提にする整理が主流である。
出典: MCP Authorization、draft-ietf-oauth-v2-1、RFC 7636、OpenID Connect Discovery 1.0、RFC 8414 を参照。Claude系の remote connector では、ユーザーは接続先URLを追加し、必要なら OAuth の client ID / secret を渡して接続する。Anthropic の公式案内では、remote MCP は Anthropic 側のクラウド経由で扱われ、サーバー側が DCR を持たない場合でも custom client ID / secret を設定できる。
出典: Anthropic: Getting started with custom integrations using remote MCP と Anthropic の connector 設定案内を参照。実装上の要点は次のとおりである。
- MCPサーバーは「業務API」ではなく「保護リソース」であり、401 応答と resource metadata で認可サーバーを案内する。
- OIDCプロバイダーは、Authorization Server Metadata か OIDC Discovery を通じて
authorization_endpointとtoken_endpointなどを公開する。 - OAuthクライアントは、ブラウザで認可コードを受け取り、PKCE の
code_verifierでトークン交換する。 - Claudeは、remote connector の形でこのクライアント役を担う。設定上は「接続先URL」「クライアントID/Secret」「必要なスコープ」が肝になる。
- OpenAPIだけを持つ既存サービスは、そのままでは MCP クライアントの接続先にはならない。MCPサーバーで OpenAPI をラップして、OAuth 2.1 PKCE をそこで受けるのが実装上自然である。これは MCP が外部システムへの接続標準であり、クライアントが MCP サーバーに接続するという仕様からの推定である。
flowchart LR
U["利用者"] --> C["Claude系MCPクライアント"]
C --> M["MCPサーバー"]
M --> PRM["Resource Metadata"]
C --> AS["認可サーバー"]
AS --> TOK["Token endpoint"]
C -->|Bearer token| M
M --> API["上流API"]
2. まず押さえるべき用語
MCP、OIDC、OAuthは役割が異なる。ここを混同すると設定が崩れる。
| 役割 | 何をするか | 典型的な実体 |
|---|---|---|
| MCPサーバー | ツール・リソース・プロンプトを公開する。HTTPでは保護リソースとして振る舞う。 | 自作MCPサーバー、業務システムのMCPラッパー |
| OAuth認可サーバー | 認可コード発行、トークン発行、クライアント認証を担う。 | Auth0、Keycloak、Entra ID、Okta |
| OIDCプロバイダー | OAuthにIDトークンやDiscoveryを加える。 | 同上。OIDC Discoveryを公開することが多い |
| OAuthクライアント | ブラウザ認可を開始し、コードをトークンに交換する。 | Claude系クライアント、独自MCPクライアント |
| リソースサーバー | アクセストークンを検証してAPIを許可する。 | MCPサーバー、上流API、API Gateway |
MCP仕様の認可章では、HTTPサーバーは Protected Resource Metadata を公開し、クライアントはそこから認可サーバーのメタデータを見つけ、OAuth 2.1 の規則で認可を進める。OAuth 2.1 自体は draft だが、Authorization Code と PKCE を中心に整理され、Implicit flow は採らない方向である。
出典: MCP Authorization と draft-ietf-oauth-v2-1 を参照。3. 通信の流れ
基本フローは Authorization Code + PKCE である。MCPサーバーが最初に 401 を返し、クライアントが resource metadata を見て認可サーバーを見つけ、ブラウザで認可し、コードを token endpoint に渡してトークンを得て、以後は Bearer token を付けて MCP 呼び出しを行う。PKCE は、ブラウザ経由の認可コードを奪われてもトークン交換を阻止するための仕組みで、public client を主対象に設計された。
出典: RFC 7636 と draft-ietf-oauth-v2-1 を参照。sequenceDiagram
participant User as 利用者
participant Client as MCPクライアント
participant MCP as MCPサーバー
participant AS as Authorization Server / OIDC Provider
User->>Client: MCPツール実行
Client->>MCP: リクエスト(トークンなし)
MCP-->>Client: 401 + resource metadata
Client->>MCP: metadata取得
MCP-->>Client: 認可サーバー情報
Client->>AS: discovery / authorization request
AS-->>User: ブラウザでログイン・同意
AS-->>Client: authorization code
Client->>AS: token request + PKCE code_verifier
AS-->>Client: access token
Client->>MCP: Bearer token付き再試行
MCP-->>Client: ツール結果
3.1 最初の応答
MCPサーバーは、保護されたエンドポイントに対して無認証アクセスが来たとき、単に 403 で終わるのではなく、認可サーバー情報を含む resource metadata を返す。MCP仕様では、このメタデータを通じてクライアントが次の発見ステップに進む。
出典: MCP Authorization を参照。3.2 認可サーバーの発見
クライアントは、MCPサーバーから得た情報をもとに、まず Authorization Server Metadata を見る。OIDCプロバイダーがあるなら OIDC Discovery も使える。どちらも、authorization endpoint、token endpoint、issuer などの情報をクライアントに伝える。
出典: RFC 8414 と OpenID Connect Discovery 1.0 を参照。3.3 PKCE付き認可コード
クライアントは、code_verifier と code_challenge を用意して認可リクエストを送る。ユーザーはIdP上で認証・同意し、認可コードを受ける。クライアントは token endpoint にコードと code_verifier を送り、アクセストークンを取得する。OAuth 2.1 の整理では、この流れが標準で、PKCEは必須前提として扱うのが実装上自然である。
3.4 MCPツール呼び出し
以後のMCP呼び出しは、Bearer token を付けた通常のHTTPリクエストになる。MCPサーバーはトークンの署名、issuer、audience、scope を検証し、許可されたツールだけを返す。トークンの中身をMCPサーバーがJWT検証で直接見てもよいし、introspection を併用してもよいが、どちらにせよ「トークンを持っているだけ」で全権限を与えない設計が重要である。これは MCP の仕様要件というより、OAuthの権限設計としての推奨である。
出典: MCP Authorization と RFC 6749 を参照。4. どのコンポーネントに何を設定するか
4.1 MCPサーバー
MCPサーバーは、まず「何を保護リソースとして公開するか」を決める。実務では、MCPサーバーがそのまま業務システムに直結するのではなく、業務APIの前に置かれる認可境界になることが多い。
最低限必要なのは次の項目である。
- Protected Resource Metadata の公開
- 認可サーバー情報の提示
- 受け入れる scope の定義
- access token の検証
- 401 / 403 の適切な返し分け
MCP仕様は、HTTPベースのサーバーでこの認可メタデータを使うことを前提にしている。つまり、MCPサーバー自身が「OAuthを知らないツールサーバー」ではなく、認可を理解するAPI境界である必要がある。
出典: MCP Authorization を参照。4.2 OIDCプロバイダー / OAuth認可サーバー
認可サーバー側では、少なくとも次を設定する。
- Authorization endpoint
- Token endpoint
- Issuer
- Client registration 方針
- Redirect URI 許可
- Scopes
- 必要なら DCR か client metadata document
MCP仕様は、クライアントが Authorization Server Metadata と OIDC Discovery をたどれることを前提にしている。したがって、IdPは少なくとも Discovery を正しく返せる必要がある。
出典: RFC 8414 と OpenID Connect Discovery 1.0 を参照。4.3 OAuthクライアント
OAuthクライアントは、MCPクライアントの実装そのものか、その背後にある認可ブローカーである。設定すべきものは次のとおり。
- client_id
- 必要なら client_secret
- redirect URI
- 使う scopes
- PKCE support
- refresh token の扱い
OAuth 2.1 では PKCE を前提にし、public client でも安全に code flow を使う方向に整理されている。古い implicit flow を採る理由はない。
出典: draft-ietf-oauth-v2-1 と RFC 7636 を参照。4.4 Claude系クライアント
Anthropic の公式案内では、remote MCP connector に接続先を追加し、必要に応じて custom client ID / secret を設定できる。つまり Claude 側は、少なくとも remote connector の文脈では OAuth クライアントとして振る舞う。OAuth設定の中心は「このMCPサーバーに対してどの client registration を使うか」である。
出典: Anthropic: Getting started with custom integrations using remote MCP と Anthropic の connector 設定案内を参照。実務での設定順は次の通りである。
- MCPサーバーのURLを登録する。
- サーバーが返す resource metadata から IdP を確認する。
- Claude 側に client_id を登録する。
- 必要なら client_secret を登録する。
- スコープを合意する。
- ブラウザでログインして同意する。
- token が保存されたら MCP ツールを実行する。
4.5 OpenAPI-onlyな既存サービス
ここは少し注意が必要である。OpenAPI は API の記述形式であって、MCP ではない。したがって、OpenAPIだけを持つ既存サービスは、通常そのままでは Claude の MCP connector の接続先にはならない。実装上は、MCPサーバーを一枚かませて OpenAPI の各 operation を MCP tool にマッピングし、そのMCPサーバーが OAuth 2.1 PKCE を受ける構成にする。これは MCP が外部システムへの接続標準であり、クライアントが MCP サーバーに接続するという仕様からの推定である。
出典: MCP Authorization を参照。OpenAPI-only の扱いはこの仕様を踏まえた推定である。flowchart TD
A["OpenAPI-only API"] --> B["MCP adapter/server"]
B --> C["OAuth 2.1 PKCE"]
C --> D["Claude / MCP client"]
B --> E["業務DB / 内部API"]
この構成にすると、OpenAPIの operation をそのままツールとして露出できる。逆に言うと、OpenAPIのまま認可だけを足しても、MCPクライアントが理解するのはMCPの tool schema であるため、その変換層が必要である。
5. 初学者向けの最短理解
「誰が誰を認証しているのか」を一言でいうと、次のようになる。
- 利用者は、Claude上で「このMCPツールを使いたい」と指示する。
- Claudeは、MCPサーバーにアクセスする。
- MCPサーバーは、「その利用者が使ってよいかは OAuth で確認して」と返す。
- Claudeは、IdPの画面を開いて利用者にログインしてもらう。
- IdPは、Claudeに「この人はこのスコープで使ってよい」とトークンを渡す。
- Claudeは、そのトークンを持ってMCPサーバーに再アクセスする。
- MCPサーバーは、トークンが正しければツール結果を返す。
MCPサーバーは「入口」、OIDCプロバイダーは「本人確認と同意」、OAuthクライアントは「代理で取りに行く人」である。
6. 実務でよくある落とし穴
6.1 401 を返さずに曖昧なエラーで終わる
認可が必要なのに 500 や汎用 403 で返すと、クライアントが何をすべきか分からない。MCPでは resource metadata を返す意味があるので、認可が必要なことを機械可読に伝える方がよい。
出典: MCP Authorization を参照。6.2 OIDC Discovery しか実装していない
MCP仕様は Authorization Server Metadata と OIDC Discovery の両方を前提に読めるようにしておくのが安全である。IdPの都合で片方しか出さないと、クライアント互換性が落ちる。
出典: RFC 8414 と OpenID Connect Discovery 1.0 を参照。6.3 PKCEを省略する
PKCEなしの認可コードは、今の実務では避けるべきである。OAuth 2.1 の方向性は PKCE 必須化であり、public client でも code flow を安全に使うための前提になっている。
出典: draft-ietf-oauth-v2-1 と RFC 7636 を参照。6.4 スコープ設計が粗すぎる
read と write だけでは、MCPツールの実体に対して過不足が出やすい。invoice:read、incident:close、customer:search のように、業務対象と行為に合わせて絞る方がよい。これは仕様の強制ではなく、最小権限の実務原則である。
6.5 OpenAPIをそのままMCPだと思う
OpenAPIは API 記述、MCPはツール接続プロトコルである。役割が違うので、OpenAPIしかない既存システムは MCP adapter を挟む前提で設計する必要がある。これは仕様の読み替えに基づく推定である。
出典: MCP Authorization を参照。7. 推奨構成
最も扱いやすい構成は次である。
- MCPサーバーを最前面に置く。
- MCPサーバーは Protected Resource Metadata を公開する。
- IdPは OIDC Discovery を返す。
- OAuthクライアントは Authorization Code + PKCE を使う。
- Claude系クライアントでは remote connector で接続し、必要なら client ID / secret を設定する。
- 既存のOpenAPIサービスは MCP adapter で包む。
flowchart LR
subgraph "Client"
C["Claude / MCP Client"]
end
subgraph "Auth"
AS["OIDC / OAuth Server"]
end
subgraph "Resource"
M["MCP Server"]
A["OpenAPI Adapter"]
S["Existing Service"]
end
C -->|auth code + PKCE| AS
C -->|tool call + bearer token| M
M --> A --> S
この構成なら、認可の責務が分離しやすく、Claude 以外の MCP クライアントにも再利用しやすい。
8. 結論
MCPのOAuth 2.1 PKCEフローは、細かい設定項目を覚えるより、役割を分けて考える方が早い。MCPサーバーは保護リソース、OIDCプロバイダーは認可の発行元、OAuthクライアントはブラウザ認可とトークン交換の実行者である。Claude系クライアントは remote connector でこのクライアント役を担える。OpenAPI-onlyな既存APIは、MCP adapter を挟まないとそのままでは接続しにくい。実務では、Authorization Code + PKCE、細粒度 scope、明示的な resource metadata、そしてMCP adapter の導入が最小構成になる。
出典: MCP Authorization、draft-ietf-oauth-v2-1、RFC 7636、Anthropic remote MCP を参照。参考情報
- Model Context Protocol - Authorization
- draft-ietf-oauth-v2-1
- RFC 7636: Proof Key for Code Exchange by OAuth Public Clients
- RFC 6749: The OAuth 2.0 Authorization Framework
- RFC 8414: OAuth 2.0 Authorization Server Metadata
- OpenID Connect Discovery 1.0
- Anthropic: Getting started with custom integrations using remote MCP