Claude の Model Context Protocol (MCP) コネクタ機能により、Messages API から直接リモート MCP サーバーに接続でき、別の MCP クライアントを実装する必要がありません。
現在のバージョン: この機能にはベータヘッダーが必要です: "anthropic-beta": "mcp-client-2025-11-20"
以前のバージョン (mcp-client-2025-04-04) は廃止予定です。下記の廃止予定バージョンのドキュメントを参照してください。
MCP コネクタは 2 つのコンポーネントを使用します:
mcp_servers 配列): サーバー接続の詳細 (URL、認証) を定義tools 配列): 有効にするツールと設定方法を設定この例は、デフォルト設定で MCP サーバーのすべてのツールを有効にします:
mcp_servers 配列内の各 MCP サーバーは接続の詳細を定義します:
{
"type": "url",
"url": "https://example-server.modelcontextprotocol.io/sse",
"name": "example-mcp",
"authorization_token": "YOUR_TOKEN"
}| プロパティ | 型 | 必須 | 説明 |
|---|---|---|---|
type | string | はい | 現在は "url" のみがサポートされています |
url | string | はい | MCP サーバーの URL。https:// で始まる必要があります |
name | string | はい | この MCP サーバーの一意の識別子。tools 配列内の正確に 1 つの MCPToolset によって参照される必要があります。 |
authorization_token | string | いいえ | MCP サーバーで必要な場合の OAuth 認可トークン。MCP 仕様を参照してください。 |
MCPToolset は tools 配列に存在し、MCP サーバーのどのツールが有効になるか、およびそれらがどのように設定されるかを設定します。
{
"type": "mcp_toolset",
"mcp_server_name": "example-mcp",
"default_config": {
"enabled": true,
"defer_loading": false
},
"configs": {
"specific_tool_name": {
"enabled": true,
"defer_loading": true
}
}
}| プロパティ | 型 | 必須 | 説明 |
|---|---|---|---|
type | string | はい | "mcp_toolset" である必要があります |
mcp_server_name | string | はい | mcp_servers 配列で定義されたサーバー名と一致する必要があります |
default_config | object | いいえ | このセット内のすべてのツールに適用されるデフォルト設定。configs 内の個別のツール設定がこれらのデフォルトをオーバーライドします。 |
configs | object | いいえ | ツール単位の設定オーバーライド。キーはツール名、値は設定オブジェクトです。 |
cache_control |
各ツール (default_config または configs で設定されているかどうかに関わらず) は以下のフィールドをサポートしています:
| プロパティ | 型 | デフォルト | 説明 |
|---|---|---|---|
enabled | boolean | true | このツールが有効かどうか |
defer_loading | boolean | false | true の場合、ツールの説明は最初はモデルに送信されません。ツール検索ツールで使用されます。 |
設定値は以下の優先度 (高から低) でマージされます:
configs 内のツール固有の設定default_config例:
{
"type": "mcp_toolset",
"mcp_server_name": "google-calendar-mcp",
"default_config": {
"defer_loading": true
},
"configs": {
"search_events": {
"enabled": false
}
}
}結果:
search_events: enabled: false (configs から)、defer_loading: true (default_config から)enabled: true (システムデフォルト)、defer_loading: true (default_config から)最もシンプルなパターン - サーバーのすべてのツールを有効にします:
{
"type": "mcp_toolset",
"mcp_server_name": "google-calendar-mcp",
}デフォルトとして enabled: false を設定し、特定のツールを明示的に有効にします:
{
"type": "mcp_toolset",
"mcp_server_name": "google-calendar-mcp",
"default_config": {
"enabled": false
},
"configs": {
"search_events": {
"enabled": true
},
"create_event": {
"enabled": true
}
}
}デフォルトですべてのツールを有効にし、不要なツールを明示的に無効にします:
{
"type": "mcp_toolset",
"mcp_server_name": "google-calendar-mcp",
"configs": {
"delete_all_events": {
"enabled": false
},
"share_calendar_publicly": {
"enabled": false
}
}
}ホワイトリストと各ツールのカスタム設定を組み合わせます:
{
"type": "mcp_toolset",
"mcp_server_name": "google-calendar-mcp",
"default_config": {
"enabled": false,
"defer_loading": true
},
"configs": {
"search_events": {
"enabled": true,
"defer_loading": false
},
"list_events": {
"enabled": true
}
}
}この例では:
search_events は defer_loading: false で有効になりますlist_events は defer_loading: true で有効になります (default_config から継承)API は以下の検証ルールを適用します:
mcp_server_name は mcp_servers 配列で定義されたサーバーと一致する必要がありますmcp_servers で定義されたすべての MCP サーバーは正確に 1 つの MCPToolset によって参照される必要がありますconfigs 内のツール名が MCP サーバーに存在しない場合、バックエンド警告がログに記録されますが、エラーは返されません (MCP サーバーはツール可用性が動的である可能性があります)Claude が MCP ツールを使用する場合、レスポンスには 2 つの新しいコンテンツブロックタイプが含まれます:
{
"type": "mcp_tool_use",
"id": "mcptoolu_014Q35RayjACSWkSj4X2yov1",
"name": "echo",
"server_name": "example-mcp",
"input": { "param1": "value1", "param2": "value2" }
}{
"type": "mcp_tool_result",
"tool_use_id": "mcptoolu_014Q35RayjACSWkSj4X2yov1",
"is_error": false,
"content": [
{
"type": "text",
"text": "Hello"
}
]
}mcp_servers に複数のサーバー定義を含め、tools 配列に各サーバーに対応する MCPToolset を含めることで、複数の MCP サーバーに接続できます:
{
"model": "claude-sonnet-4-5",
"max_tokens": 1000,
"messages": [
{
"role": "user",
"content": "Use tools from both mcp-server-1 and mcp-server-2 to complete this task"
}
],
"mcp_servers": [
{
"type": "url",
"url": "https://mcp.example1.com/sse",
"name": "mcp-server-1",
"authorization_token": "TOKEN1"
},
{
"type": "url",
"url": "https://mcp.example2.com/sse",
"name": "mcp-server-2",
"authorization_token": "TOKEN2"
}
],
"tools": [
{
"type": "mcp_toolset",
"mcp_server_name": "mcp-server-1"
},
{
"type": "mcp_toolset",
"mcp_server_name": "mcp-server-2",
"default_config": {
"defer_loading": true
}
}
]
}OAuth 認証が必要な MCP サーバーの場合、アクセストークンを取得する必要があります。MCP コネクタベータは MCP サーバー定義で authorization_token パラメータを渡すことをサポートしています。
API コンシューマーは OAuth フローを処理し、API 呼び出しの前にアクセストークンを取得し、必要に応じてトークンをリフレッシュすることが期待されます。
MCP インスペクタは、テスト目的でアクセストークンを取得するプロセスをガイドできます。
次のコマンドでインスペクタを実行します。マシンに Node.js がインストールされている必要があります。
npx @modelcontextprotocol/inspector左側のサイドバーで、「Transport type」に対して「SSE」または「Streamable HTTP」を選択します。
MCP サーバーの URL を入力します。
右側の領域で、「Need to configure authentication?」の後の「Open Auth Settings」ボタンをクリックします。
「Quick OAuth Flow」をクリックし、OAuth 画面で認可します。
インスペクタの「OAuth Flow Progress」セクションのステップに従い、「Authentication complete」に到達するまで「Continue」をクリックします。
access_token 値をコピーします。
MCP サーバー設定の authorization_token フィールドに貼り付けます。
上記のいずれかの OAuth フローを使用してアクセストークンを取得したら、MCP サーバー設定で使用できます:
{
"mcp_servers": [
{
"type": "url",
"url": "https://example-server.modelcontextprotocol.io/sse",
"name": "authenticated-server",
"authorization_token": "YOUR_ACCESS_TOKEN_HERE"
}
]
}OAuth フローの詳細な説明については、MCP 仕様の認可セクションを参照してください。
廃止予定の mcp-client-2025-04-04 ベータヘッダーを使用している場合は、このガイドに従って新しいバージョンにマイグレーションしてください。
mcp-client-2025-04-04 から mcp-client-2025-11-20 に変更tools 配列内の MCPToolset オブジェクトに移動しました**前 (廃止予定):
{
"model": "claude-sonnet-4-5",
"max_tokens": 1000,
"messages": [...],
"mcp_servers": [
{
"type": "url",
"url": "https://mcp.example.com/sse",
"name": "example-mcp",
"authorization_token": "YOUR_TOKEN",
"tool_configuration": {
"enabled": true,
"allowed_tools": ["tool1", "tool2"]
}
}
]
}**後 (現在):
{
"model": "claude-sonnet-4-5",
"max_tokens": 1000,
"messages": [...],
"mcp_servers": [
{
"type": "url",
"url": "https://mcp.example.com/sse",
"name": "example-mcp",
"authorization_token": "YOUR_TOKEN"
}
],
"tools": [
{
"type": "mcp_toolset",
"mcp_server_name": "example-mcp",
"default_config": {
"enabled": false
},
"configs": {
"tool1": {
"enabled": true
},
"tool2": {
"enabled": true
}
}
}
]
}| 古いパターン | 新しいパターン |
|---|---|
tool_configuration なし (すべてのツールが有効) | default_config または configs なしの MCPToolset |
tool_configuration.enabled: false | default_config.enabled: false を持つ MCPToolset |
tool_configuration.allowed_tools: [...] | default_config.enabled: false と configs で特定のツールが有効な MCPToolset |
このバージョンは廃止予定です。上記のマイグレーションガイドを使用して mcp-client-2025-11-20 にマイグレーションしてください。
MCP コネクタの以前のバージョンは、ツール設定を MCP サーバー定義に直接含めていました:
{
"mcp_servers": [
{
"type": "url",
"url": "https://example-server.modelcontextprotocol.io/sse",
"name": "example-mcp",
"authorization_token": "YOUR_TOKEN",
"tool_configuration": {
"enabled": true,
"allowed_tools": ["example_tool_1", "example_tool_2"]
}
}
]
}| プロパティ | 型 | 説明 |
|---|---|---|
tool_configuration | object | 廃止予定: tools 配列内の MCPToolset を使用してください |
tool_configuration.enabled | boolean | 廃止予定: MCPToolset 内の default_config.enabled を使用してください |
tool_configuration.allowed_tools | array | 廃止予定: MCPToolset 内の configs を使用したホワイトリストパターンを使用してください |
curl https://api.anthropic.com/v1/messages \
-H "Content-Type: application/json" \
-H "X-API-Key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "anthropic-beta: mcp-client-2025-11-20" \
-d '{
"model": "claude-sonnet-4-5",
"max_tokens": 1000,
"messages": [{"role": "user", "content": "What tools do you have available?"}],
"mcp_servers": [
{
"type": "url",
"url": "https://example-server.modelcontextprotocol.io/sse",
"name": "example-mcp",
"authorization_token": "YOUR_TOKEN"
}
],
"tools": [
{
"type": "mcp_toolset",
"mcp_server_name": "example-mcp"
}
]
}'| object |
| いいえ |
| このツールセットのキャッシュブレークポイント設定 |