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
    ガイド

    SDK内のMCP

    Model Context Protocolサーバーを使用してClaude Codeをカスタムツールで拡張する

    概要

    Model Context Protocol(MCP)サーバーは、Claude Codeをカスタムツールと機能で拡張します。MCPは外部プロセスとして実行したり、HTTP/SSE経由で接続したり、SDKアプリケーション内で直接実行したりできます。

    設定

    基本設定

    プロジェクトルートの.mcp.jsonでMCPサーバーを設定します:

    TypeScript
    {
      "mcpServers": {
        "filesystem": {
          "command": "npx",
          "args": ["@modelcontextprotocol/server-filesystem"],
          "env": {
            "ALLOWED_PATHS": "/Users/me/projects"
          }
        }
      }
    }
    Python
    {
      "mcpServers": {
        "filesystem": {
          "command": "python",
          "args": ["-m", "mcp_server_filesystem"],
          "env": {
            "ALLOWED_PATHS": "/Users/me/projects"
          }
        }
      }
    }

    SDK内でのMCPサーバーの使用

    import { query } from "@anthropic-ai/claude-agent-sdk";
    
    for await (const message of query({
      prompt: "List files in my project",
      options: {
        mcpServers: {
          "filesystem": {
            command: "npx",
            args: ["@modelcontextprotocol/server-filesystem"],
            env: {
              ALLOWED_PATHS: "/Users/me/projects"
            }
          }
        },
        allowedTools: ["mcp__filesystem__list_files"]
      }
    })) {
      if (message.type === "result" && message.subtype === "success") {
        console.log(message.result);
      }
    }

    トランスポートタイプ

    stdioサーバー

    stdin/stdout経由で通信する外部プロセス:

    // .mcp.json設定
    {
      "mcpServers": {
        "my-tool": {
          "command": "node",
          "args": ["./my-mcp-server.js"],
          "env": {
            "DEBUG": "${DEBUG:-false}"
          }
        }
      }
    }

    HTTP/SSEサーバー

    ネットワーク通信を使用するリモートサーバー:

    // SSEサーバー設定
    {
      "mcpServers": {
        "remote-api": {
          "type": "sse",
          "url": "https://api.example.com/mcp/sse",
          "headers": {
            "Authorization": "Bearer ${API_TOKEN}"
          }
        }
      }
    }
    
    // HTTPサーバー設定
    {
      "mcpServers": {
        "http-service": {
          "type": "http",
          "url": "https://api.example.com/mcp",
          "headers": {
            "X-API-Key": "${API_KEY}"
          }
        }
      }
    }

    SDK MCPサーバー

    アプリケーション内で実行されるインプロセスサーバー。カスタムツールの作成に関する詳細情報については、カスタムツールガイドを参照してください:

    リソース管理

    MCPサーバーは、Claudeがリストアップして読み取ることができるリソースを公開できます:

    import { query } from "@anthropic-ai/claude-agent-sdk";
    
    // 利用可能なリソースをリストアップ
    for await (const message of query({
      prompt: "What resources are available from the database server?",
      options: {
        mcpServers: {
          "database": {
            command: "npx",
            args: ["@modelcontextprotocol/server-database"]
          }
        },
        allowedTools: ["mcp__list_resources", "mcp__read_resource"]
      }
    })) {
      if (message.type === "result") console.log(message.result);
    }

    認証

    環境変数

    // 環境変数を使用した.mcp.json
    {
      "mcpServers": {
        "secure-api": {
          "type": "sse",
          "url": "https://api.example.com/mcp",
          "headers": {
            "Authorization": "Bearer ${API_TOKEN}",
            "X-API-Key": "${API_KEY:-default-key}"
          }
        }
      }
    }
    
    // 環境変数を設定
    process.env.API_TOKEN = "your-token";
    process.env.API_KEY = "your-key";

    OAuth2認証

    クライアント内でのOAuth2 MCP認証は現在サポートされていません。

    エラーハンドリング

    MCP接続の失敗を適切に処理します:

    import { query } from "@anthropic-ai/claude-agent-sdk";
    
    for await (const message of query({
      prompt: "Process data",
      options: {
        mcpServers: {
          "data-processor": dataServer
        }
      }
    })) {
      if (message.type === "system" && message.subtype === "init") {
        // MCPサーバーのステータスをチェック
        const failedServers = message.mcp_servers.filter(
          s => s.status !== "connected"
        );
        
        if (failedServers.length > 0) {
          console.warn("Failed to connect:", failedServers);
        }
      }
      
      if (message.type === "result" && message.subtype === "error_during_execution") {
        console.error("Execution failed");
      }
    }

    関連リソース

    • カスタムツールガイド - SDK MCPサーバーの作成に関する詳細ガイド
    • TypeScript SDKリファレンス
    • Python SDKリファレンス
    • SDK権限
    • 一般的なワークフロー
    • SDK内でのMCPサーバーの使用
    • stdioサーバー
    • HTTP/SSEサーバー
    • SDK MCPサーバー
    • OAuth2認証
    © 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