Loading...
    • 開発者ガイド
    • API リファレンス
    • MCP
    • リソース
    • リリースノート
    Search...
    ⌘K

    はじめの一歩

    Claudeの紹介クイックスタート

    モデルと料金

    モデル概要モデルの選択Claude 4.5の新機能Claude 4.5への移行モデルの廃止予定価格設定

    Claudeで構築する

    機能概要Messages API の使用コンテキストウィンドウプロンプトのベストプラクティス

    機能

    プロンプトキャッシングコンテキスト編集拡張思考ストリーミングメッセージバッチ処理引用多言語サポートトークンカウント埋め込みビジョンPDFサポートFiles API検索結果Google Sheetsアドオン

    ツール

    概要ツール使用の実装方法トークン効率的なツール使用細粒度ツールストリーミングBashツールコード実行ツールコンピュータ使用ツールテキストエディタツールWeb fetch toolウェブ検索ツールメモリツール

    エージェントスキル

    概要クイックスタートスキル作成のベストプラクティスAPIでエージェントスキルを使用する

    Agent SDK

    概要Agent SDK リファレンス - TypeScriptPython SDK

    ガイド

    ストリーミング入力権限の処理セッション管理Agent SDKのホスティングシステムプロンプトの変更SDK内のMCPカスタムツールSDKにおけるサブエージェントSDKでのスラッシュコマンドSDK内のエージェントスキルコストと使用量の追跡Todo リストSDK のプラグイン

    API内のMCP

    MCPコネクタリモートMCPサーバー

    Claude on 3rd-party platforms

    Amazon BedrockVertex AI

    プロンプトエンジニアリング

    概要プロンプトジェネレータープロンプトテンプレートの使用プロンプト改善ツール明確で直接的な指示例(マルチショットプロンプト)を使用してClaudeの動作を導くClaudeに考えさせる(CoT)XMLタグを使用Claudeに役割を与える(システムプロンプト)Claudeの応答を事前入力複雑なプロンプトのチェーン化長文コンテキストのヒント拡張思考のヒント

    テストと評価

    成功基準を定義するテストケースを開発する評価ツールの使用レイテンシの削減

    ガードレールを強化

    幻覚を減らす出力の一貫性を高めるジェイルブレイクの軽減handle-streaming-refusalsプロンプトリークの削減Claudeのキャラクターを維持

    管理とモニタリング

    Admin API概要使用量とコストAPIClaude Code Analytics API
    Console
    API内のMCP

    MCPコネクタ

    Claude's Model Context Protocol (MCP) connector feature enables you to connect to remote MCP servers directly from the Messages API without a separate MCP client.

    ClaudeのModel Context Protocol(MCP)コネクタ機能により、別途MCPクライアントを使用することなく、Messages APIから直接リモートMCPサーバーに接続できます。

    この機能にはベータヘッダーが必要です:"anthropic-beta": "mcp-client-2025-04-04"

    主な機能

    • 直接API統合:MCPクライアントを実装することなくMCPサーバーに接続
    • ツール呼び出しサポート:Messages APIを通じてMCPツールにアクセス
    • OAuth認証:認証されたサーバー用のOAuth Bearerトークンをサポート
    • 複数サーバー:単一のリクエストで複数のMCPサーバーに接続

    制限事項

    • MCP仕様の機能セットのうち、現在はツール呼び出しのみがサポートされています。
    • サーバーはHTTPを通じて公開されている必要があります(Streamable HTTPとSSEトランスポートの両方をサポート)。ローカルSTDIOサーバーには直接接続できません。
    • MCPコネクタは現在Amazon BedrockとGoogle Vertexではサポートされていません。

    Messages APIでのMCPコネクタの使用

    リモートMCPサーバーに接続するには、Messages APIリクエストにmcp_serversパラメータを含めます:

    cURL
    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-04-04" \
      -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"
          }
        ]
      }'
    TypeScript
    import { Anthropic } from '@anthropic-ai/sdk';
    
    const anthropic = new Anthropic();
    
    const response = await anthropic.beta.messages.create({
      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",
        },
      ],
      betas: ["mcp-client-2025-04-04"],
    });
    Python
    import anthropic
    
    client = anthropic.Anthropic()
    
    response = client.beta.messages.create(
        model="claude-sonnet-4-5",
        max_tokens=1000,
        messages=[{
            "role": "user",
            "content": "What tools do you have available?"
        }],
        mcp_servers=[{
            "type": "url",
            "url": "https://mcp.example.com/sse",
            "name": "example-mcp",
            "authorization_token": "YOUR_TOKEN"
        }],
        betas=["mcp-client-2025-04-04"]
    )

    MCPサーバー設定

    mcp_servers配列内の各MCPサーバーは以下の設定をサポートします:

    {
      "type": "url",
      "url": "https://example-server.modelcontextprotocol.io/sse",
      "name": "example-mcp",
      "tool_configuration": {
        "enabled": true,
        "allowed_tools": ["example_tool_1", "example_tool_2"]
      },
      "authorization_token": "YOUR_TOKEN"
    }

    フィールドの説明

    プロパティタイプ必須説明
    typestringはい現在は"url"のみがサポートされています
    urlstringはいMCPサーバーのURL。https://で始まる必要があります
    namestringはいこのMCPサーバーの一意の識別子。mcp_tool_callブロックでサーバーを識別し、モデルに対してツールを区別するために使用されます。
    tool_configurationobjectいいえツール使用を設定
    tool_configuration.enabledbooleanいいえこのサーバーからのツールを有効にするかどうか(デフォルト:true)
    tool_configuration.allowed_toolsarrayいいえ許可するツールを制限するリスト(デフォルトでは、すべてのツールが許可されます)
    authorization_tokenstringいいえMCPサーバーで必要な場合のOAuth認証トークン。MCP仕様を参照してください。

    レスポンスコンテンツタイプ

    ClaudeがMCPツールを使用する場合、レスポンスには2つの新しいコンテンツブロックタイプが含まれます:

    MCPツール使用ブロック

    {
      "type": "mcp_tool_use",
      "id": "mcptoolu_014Q35RayjACSWkSj4X2yov1",
      "name": "echo",
      "server_name": "example-mcp",
      "input": { "param1": "value1", "param2": "value2" }
    }

    MCPツール結果ブロック

    {
      "type": "mcp_tool_result",
      "tool_use_id": "mcptoolu_014Q35RayjACSWkSj4X2yov1",
      "is_error": false,
      "content": [
        {
          "type": "text",
          "text": "Hello"
        }
      ]
    }

    複数のMCPサーバー

    mcp_servers配列に複数のオブジェクトを含めることで、複数の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"
        }
      ]
    }

    認証

    OAuth認証が必要なMCPサーバーの場合、アクセストークンを取得する必要があります。MCPコネクタベータは、MCPサーバー定義でauthorization_tokenパラメータを渡すことをサポートしています。 API利用者は、API呼び出しを行う前にOAuthフローを処理してアクセストークンを取得し、必要に応じてトークンを更新することが期待されています。

    テスト用のアクセストークンの取得

    MCPインスペクターは、テスト目的でアクセストークンを取得するプロセスをガイドできます。

    1. 以下のコマンドでインスペクターを実行します。マシンにNode.jsがインストールされている必要があります。

      npx @modelcontextprotocol/inspector
    2. 左側のサイドバーで、「Transport type」に対して「SSE」または「Streamable HTTP」のいずれかを選択します。

    3. MCPサーバーのURLを入力します。

    4. 右側のエリアで、「Need to configure authentication?」の後にある「Open Auth Settings」ボタンをクリックします。

    5. 「Quick OAuth Flow」をクリックし、OAuth画面で認証します。

    6. インスペクターの「OAuth Flow Progress」セクションの手順に従い、「Authentication complete」に到達するまで「Continue」をクリックします。

    7. access_tokenの値をコピーします。

    8. 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仕様の認証セクションを参照してください。

    • Messages APIでのMCPコネクタの使用
    • MCPサーバー設定
    • MCPツール使用ブロック
    • MCPツール結果ブロック
    • 複数のMCPサーバー
    © 2025 ANTHROPIC PBC

    Products

    • Claude
    • Claude Code
    • Max plan
    • Team plan
    • Enterprise plan
    • Download app
    • Pricing
    • Log in

    Features

    • Claude and Slack
    • Claude in Excel

    Models

    • Opus
    • Sonnet
    • Haiku

    Solutions

    • AI agents
    • Code modernization
    • Coding
    • Customer support
    • Education
    • Financial services
    • Government
    • Life sciences

    Claude Developer Platform

    • Overview
    • Developer docs
    • Pricing
    • Amazon Bedrock
    • Google Cloud’s Vertex AI
    • Console login

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Company

    • Anthropic
    • Careers
    • Economic Futures
    • Research
    • News
    • Responsible Scaling Policy
    • Security and compliance
    • Transparency

    Help and security

    • Availability
    • Status
    • Support center

    Terms and policies

    • Privacy policy
    • Responsible disclosure policy
    • Terms of service: Commercial
    • Terms of service: Consumer
    • Usage policy

    Products

    • Claude
    • Claude Code
    • Max plan
    • Team plan
    • Enterprise plan
    • Download app
    • Pricing
    • Log in

    Features

    • Claude and Slack
    • Claude in Excel

    Models

    • Opus
    • Sonnet
    • Haiku

    Solutions

    • AI agents
    • Code modernization
    • Coding
    • Customer support
    • Education
    • Financial services
    • Government
    • Life sciences

    Claude Developer Platform

    • Overview
    • Developer docs
    • Pricing
    • Amazon Bedrock
    • Google Cloud’s Vertex AI
    • Console login

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Company

    • Anthropic
    • Careers
    • Economic Futures
    • Research
    • News
    • Responsible Scaling Policy
    • Security and compliance
    • Transparency

    Help and security

    • Availability
    • Status
    • Support center

    Terms and policies

    • Privacy policy
    • Responsible disclosure policy
    • Terms of service: Commercial
    • Terms of service: Consumer
    • Usage policy
    © 2025 ANTHROPIC PBC