---
title: Claudeでのツール使用
url: https://platform.claude.com/docs/ja/agents-and-tools/tool-use/overview
description: Claudeを外部ツールやAPIに接続します。ツールがどこで実行されるか、Claudeがいつツールを呼び出すか、そしてどのツールがタスクに適しているかを確認できます。
---

「tool use」（ツール使用、関数呼び出しとも呼ばれます）により、Claudeはあなたが定義した関数やAnthropicが提供する関数を呼び出すことができます。Claudeは、ユーザーのリクエストとツールの説明に基づいて、いつツールを呼び出すかを判断します。その後、あなたのアプリケーションが実行する（クライアントツール）か、Anthropicが実行する（サーバーツール）構造化された呼び出しを返します。

以下は、Anthropicが代わりに実行するサーバーツールである[Web検索ツール](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/web-search-tool)を使用した最小限の例です：

<CodeGroup>
  ```bash cURL
  curl https://api.anthropic.com/v1/messages \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2026-10-21" \
    -H "content-type: application/json" \
    -d '{
      "model": "claude-opus-5-5",
      "max_tokens": 4096,
      "tools": [{"type": "web_search_20260209", "name": "web_search"}],
      "messages": [{"role": "user", "content": "What is the latest on the Mars rover?"}]
    }'
  ```

  ```bash CLI
  ant messages create \
    --model claude-opus-5-5 \
    --max-tokens 4096 \
    --tool '{type: web_search_20260209, name: web_search}' \
    --message '{role: user, content: "What is the latest on the Mars rover?"}'
  ```

  ```python Python
  client = anthropic.Anthropic()
  response = client.messages.create(
      model="claude-opus-5-5",
      max_tokens=4096,
      tools=[{"type": "web_search_20260209", "name": "web_search"}],
      messages=[{"role": "user", "content": "What is the latest on the Mars rover?"}],
  )
  print(response.content)
  ```

  ```typescript TypeScript
  const client = new Anthropic();
  const response = await client.messages.create({
    model: "claude-opus-5-5",
    max_tokens: 4096,
    tools: [{ type: "web_search_20260209", name: "web_search" }],
    messages: [{ role: "user", content: "What is the latest on the Mars rover?" }]
  });
  console.log(response.content);
  ```

  ```csharp C#
  AnthropicClient client = new();

  var parameters = new MessageCreateParams
  {
      Model = Model.ClaudeOpus5_5,
      MaxTokens = 4096,
      Tools = [new ToolUnion(new WebSearchTool20260209())],
      Messages = [new UserMessageParam { Content = "What is the latest on the Mars rover?" }]
  };

  var message = await client.Messages.Create(parameters);
  Console.WriteLine(message.Content);
  ```

  ```go Go
  client := anthropic.NewClient()

  response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
  	Model:     anthropic.ModelClaudeOpus5_5,
  	MaxTokens: 4096,
  	Tools: []anthropic.ToolUnionParam{
  		{OfWebSearchTool20260209: &anthropic.WebSearchTool20260209Param{}},
  	},
  	Messages: []anthropic.MessageParam{
  		anthropic.NewUserMessage(anthropic.NewTextBlock("What is the latest on the Mars rover?")),
  	},
  })
  if err != nil {
  	log.Fatal(err)
  }
  fmt.Println(response.Content)
  ```

  ```java Java
  import com.anthropic.models.messages.WebSearchTool20260209;

  void main() {
      AnthropicClient client = AnthropicOkHttpClient.fromEnv();

      MessageCreateParams params = MessageCreateParams.builder()
          .model(Model.CLAUDE_OPUS_5_5)
          .maxTokens(4096L)
          .addTool(WebSearchTool20260209.builder().build())
          .addUserMessage("What is the latest on the Mars rover?")
          .build();

      Message response = client.messages().create(params);
      IO.println(response.content());
  }
  ```

  ```php PHP
  $client = new Client();

  $message = $client->messages->create(
      model: 'claude-opus-5-5',
      maxTokens: 4096,
      tools: [
          ['type' => 'web_search_20260209', 'name' => 'web_search'],
      ],
      messages: [
          ['role' => 'user', 'content' => 'What is the latest on the Mars rover?'],
      ],
  );

  echo $message;
  ```

  ```ruby Ruby
  client = Anthropic::Client.new

  message = client.messages.create(
    model: Anthropic::Model::CLAUDE_OPUS_5_5,
    max_tokens: 4096,
    tools: [{ type: "web_search_20260209", name: "web_search" }],
    messages: [{ role: "user", content: "What is the latest on the Mars rover?" }]
  )
  puts message.content
  ```
</CodeGroup>

ClaudeはAnthropicのインフラストラクチャ上で検索を実行し、引用付きの結果を同じレスポンスで返します。あなたが定義した関数をClaudeに呼び出させるには、`input_schema`を持つツールを渡し、Claudeが`tool_use`ブロックを返したときにその呼び出しを実行します。[クライアントツールの例](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/overview#how-tool-use-works)では、その往復処理を最初から最後まで示しています。詳細については、[ツールの定義](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/define-tools)と[ツール呼び出しの処理](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/handle-tool-calls)を参照してください。

## ツール使用の仕組み

ツールは主に、コードがどこで実行されるかによって異なります。**クライアントツール**（ユーザー定義ツールや、`bash`や`text_editor`などのAnthropic定義のスキーマを持つツールを含む）は、あなたのアプリケーション内で実行されます。Claudeは`stop_reason: "tool_use"`と1つ以上の`tool_use`ブロックで応答します。あなたのコードが操作を実行し、`tool_result`を返送します。**サーバーツール**（`web_search`、`web_fetch`、`code_execution`、`tool_search`など）はAnthropicのインフラストラクチャ上で実行されます。Claudeがあなたのクライアントツールのいずれかと同じ並列ツール呼び出しのグループ内でそのツールを呼び出さない限り、実行を処理することなく結果を直接確認できます（[停止理由とフォールバック](https://platform.claude.com/docs/ja/build-with-claude/handling-stop-reasons#tool-use)を参照）。

以下は、クライアントツールにおけるそのラウンドトリップの全体です。最初のリクエストで`get_weather`ツールを定義し、Claudeはそれを呼び出すことで質問に答えます。レスポンスには`tool_use`ブロックが含まれ、あなたのコードが検索を実行し、2番目のリクエストで結果を`tool_result`ブロックに入れて送り返すことで、Claudeが回答を返せるようになります。

<CodeGroup exclude="shell:cURL, shell:CLI">
  <CodeGroupItem language="cURL">
    このワークフローには、単一のシェルコマンドでは実現できないロジックが必要です。実行するには[Claude SDK](https://platform.claude.com/docs/ja/cli-sdks-libraries/overview)を使用してください。
  </CodeGroupItem>

  <CodeGroupItem language="CLI">
    このワークフローには、単一のシェルコマンドでは実現できないロジックが必要です。実行するには[Claude SDK](https://platform.claude.com/docs/ja/cli-sdks-libraries/overview)を使用してください。
  </CodeGroupItem>

  ```python Python
  client = anthropic.Anthropic()

  tools = [
      {
          "name": "get_weather",
          "description": "Get the current weather for a given location.",
          "input_schema": {
              "type": "object",
              "properties": {
                  "location": {
                      "type": "string",
                      "description": "City and state, e.g. San Francisco, CA",
                  }
              },
              "required": ["location"],
          },
      }
  ]
  messages = [{"role": "user", "content": "What's the weather in San Francisco?"}]

  # Claude は、ツール名とその引数を指定した tool_use ブロックで応答します。
  response = client.messages.create(
      model="claude-opus-5-5",
      max_tokens=1024,
      tools=tools,
      # 各ターンでのツール呼び出しは最大 1 回までにするよう求めます。
      tool_choice={"type": "auto", "disable_parallel_tool_use": True},
      messages=messages,
  )
  tool_use = next(block for block in response.content if block.type == "tool_use")
  print(f"Claude called {tool_use.name} with {json.dumps(tool_use.input)}")

  # ツールを実行し、その結果を tool_result ブロックで返します。
  weather = "15 degrees Celsius, partly cloudy"  # your weather lookup goes here
  messages += [
      {"role": "assistant", "content": response.content},
      {
          "role": "user",
          "content": [
              {"type": "tool_result", "tool_use_id": tool_use.id, "content": weather}
          ],
      },
  ]
  followup = client.messages.create(
      model="claude-opus-5-5",
      max_tokens=1024,
      tools=tools,
      tool_choice={"type": "auto", "disable_parallel_tool_use": True},
      messages=messages,
  )

  # Claude はその結果を使って元の質問に回答します。
  final_text = next(block for block in followup.content if block.type == "text")
  print(final_text.text)
  ```

  ```typescript TypeScript
  const client = new Anthropic();

  const tools: Anthropic.Tool[] = [
    {
      name: "get_weather",
      description: "Get the current weather for a given location.",
      input_schema: {
        type: "object",
        properties: {
          location: { type: "string", description: "City and state, e.g. San Francisco, CA" }
        },
        required: ["location"]
      }
    }
  ];
  const messages: Anthropic.MessageParam[] = [
    { role: "user", content: "What's the weather in San Francisco?" }
  ];

  // Claude は、ツール名とその引数を指定した tool_use ブロックで応答します。
  const response = await client.messages.create({
    model: "claude-opus-5-5",
    max_tokens: 1024,
    tools,
    // 各ターンで要求するツール呼び出しは最大 1 回までにします。
    tool_choice: { type: "auto", disable_parallel_tool_use: true },
    messages
  });
  const toolUse = response.content.find((block) => block.type === "tool_use")!;
  console.log(`Claude called ${toolUse.name} with ${JSON.stringify(toolUse.input)}`);

  // ツールを実行し、その結果を tool_result ブロックで返送します。
  const weather = "15 degrees Celsius, partly cloudy"; // your weather lookup goes here
  messages.push(
    { role: "assistant", content: response.content },
    {
      role: "user",
      content: [{ type: "tool_result", tool_use_id: toolUse.id, content: weather }]
    }
  );
  const followup = await client.messages.create({
    model: "claude-opus-5-5",
    max_tokens: 1024,
    tools,
    tool_choice: { type: "auto", disable_parallel_tool_use: true },
    messages
  });

  // Claude はその結果を使って元の質問に回答します。
  const finalText = followup.content.find((block) => block.type === "text")!;
  console.log(finalText.text);
  ```

  ```csharp C#
  AnthropicClient client = new();

  List<ToolUnion> tools =
  [
      new ToolUnion(new Tool()
      {
          Name = "get_weather",
          Description = "Get the current weather for a given location.",
          InputSchema = new InputSchema()
          {
              Properties = new Dictionary<string, JsonElement>
              {
                  ["location"] = JsonSerializer.SerializeToElement(new
                  {
                      type = "string",
                      description = "City and state, e.g. San Francisco, CA",
                  }),
              },
              Required = ["location"],
          },
      }),
  ];

  // 各ターンで要求するツール呼び出しは最大1つまでにします。
  var toolChoice = new ToolChoice(new ToolChoiceAuto { DisableParallelToolUse = true });

  const string userPrompt = "What's the weather in San Francisco?";

  // Claude は、ツール名とその引数を指定した tool_use ブロックで応答します。
  var response = await client.Messages.Create(new MessageCreateParams
  {
      Model = Model.ClaudeOpus5_5,
      MaxTokens = 1024,
      Tools = tools,
      ToolChoice = toolChoice,
      Messages = [new UserMessageParam { Content = userPrompt }],
  });
  ToolUseBlock? toolUse = null;
  foreach (var block in response.Content)
  {
      if (block.TryPickToolUse(out var picked))
      {
          toolUse = picked;
          break;
      }
  }
  Console.WriteLine($"Claude called {toolUse!.Name} with {JsonSerializer.Serialize(toolUse.Input)}");

  // ツールを実行し、その結果を tool_result ブロックで返送します。
  var weather = "15 degrees Celsius, partly cloudy";
  List<ContentBlockParam> toolResults =
  [
      new ContentBlockParam(new ToolResultBlockParam()
      {
          ToolUseID = toolUse.ID,
          Content = weather,
      }),
  ];
  var followup = await client.Messages.Create(new MessageCreateParams
  {
      Model = Model.ClaudeOpus5_5,
      MaxTokens = 1024,
      Tools = tools,
      ToolChoice = toolChoice,
      Messages =
      [
          new UserMessageParam { Content = userPrompt },
          new AssistantMessageParam { Content = response.Content.Select(block => new ContentBlockParam(block.Json)).ToList() },
          new UserMessageParam { Content = toolResults },
      ],
  });

  // Claude はその結果を使って元の質問に回答します。
  foreach (var block in followup.Content)
  {
      if (block.TryPickText(out var text))
      {
          Console.WriteLine(text.Text);
      }
  }
  ```

  ```go Go
  client := anthropic.NewClient()
  ctx := context.Background()

  tools := []anthropic.ToolUnionParam{
  	{OfTool: &anthropic.ToolParam{
  		Name:        "get_weather",
  		Description: anthropic.String("Get the current weather for a given location."),
  		InputSchema: anthropic.ToolInputSchemaParam{
  			Properties: map[string]any{
  				"location": map[string]any{
  					"type":        "string",
  					"description": "City and state, e.g. San Francisco, CA",
  				},
  			},
  			Required: []string{"location"},
  		},
  	}},
  }
  // 各ターンで要求するツール呼び出しは最大 1 つにします。
  toolChoice := anthropic.ToolChoiceUnionParam{
  	OfAuto: &anthropic.ToolChoiceAutoParam{DisableParallelToolUse: anthropic.Bool(true)},
  }
  messages := []anthropic.MessageParam{
  	anthropic.NewUserMessage(anthropic.NewTextBlock("What's the weather in San Francisco?")),
  }

  // Claude は、ツール名とその引数を指定した tool_use ブロックで応答します。
  response, err := client.Messages.New(ctx, anthropic.MessageNewParams{
  	Model:      anthropic.ModelClaudeOpus5_5,
  	MaxTokens:  1024,
  	Tools:      tools,
  	ToolChoice: toolChoice,
  	Messages:   messages,
  })
  if err != nil {
  	log.Fatal(err)
  }
  var toolUse anthropic.ContentBlockUnion
  for _, block := range response.Content {
  	if block.Type == "tool_use" {
  		toolUse = block
  		break
  	}
  }
  fmt.Printf("Claude called %s with %s\n", toolUse.Name, string(toolUse.Input))

  // ツールを実行し、その結果を tool_result ブロックで返送します。
  weather := "15 degrees Celsius, partly cloudy"
  var assistantContent []anthropic.ContentBlockParamUnion
  for _, block := range response.Content {
  	assistantContent = append(assistantContent, block.ToParam())
  }
  messages = append(messages,
  	anthropic.NewAssistantMessage(assistantContent...),
  	anthropic.NewUserMessage(anthropic.NewToolResultBlock(toolUse.ID, weather, false)),
  )
  followup, err := client.Messages.New(ctx, anthropic.MessageNewParams{
  	Model:      anthropic.ModelClaudeOpus5_5,
  	MaxTokens:  1024,
  	Tools:      tools,
  	ToolChoice: toolChoice,
  	Messages:   messages,
  })
  if err != nil {
  	log.Fatal(err)
  }

  // Claude はその結果を使って元の質問に回答します。
  for _, block := range followup.Content {
  	if block.Type == "text" {
  		fmt.Println(block.Text)
  	}
  }
  ```

  ```java Java
  import com.anthropic.core.JsonValue;
  import com.anthropic.models.messages.ContentBlockParam;
  // ...
  import com.anthropic.models.messages.Tool;
  import com.anthropic.models.messages.Tool.InputSchema;
  import com.anthropic.models.messages.ToolChoiceAuto;
  import com.anthropic.models.messages.ToolResultBlockParam;
  import com.anthropic.models.messages.ToolUseBlock;
  // ...

  void main() {
      AnthropicClient client = AnthropicOkHttpClient.fromEnv();

      Tool weatherTool = Tool.builder()
          .name("get_weather")
          .description("Get the current weather for a given location.")
          .inputSchema(InputSchema.builder()
              .properties(JsonValue.from(Map.of(
                  "location", Map.of(
                      "type", "string",
                      "description", "City and state, e.g. San Francisco, CA"
                  )
              )))
              .required(List.of("location"))
              .build())
          .build();

      // 各ターンで要求するツール呼び出しは最大1つにします。
      ToolChoiceAuto toolChoice = ToolChoiceAuto.builder()
          .disableParallelToolUse(true)
          .build();

      String userPrompt = "What's the weather in San Francisco?";

      // Claude は、ツール名とその引数を指定した tool_use ブロックで応答します。
      Message response = client.messages().create(MessageCreateParams.builder()
          .model(Model.CLAUDE_OPUS_5_5)
          .maxTokens(1024L)
          .addTool(weatherTool)
          .toolChoice(toolChoice)
          .addUserMessage(userPrompt)
          .build());
      ToolUseBlock toolUse = response.content().stream()
          .flatMap(block -> block.toolUse().stream())
          .findFirst()
          .orElseThrow();
      IO.println("Claude called " + toolUse.name() + " with " + toolUse._input());

      // ツールを実行し、その結果を tool_result ブロックで返送します。
      String weather = "15 degrees Celsius, partly cloudy";
      Message followup = client.messages().create(MessageCreateParams.builder()
          .model(Model.CLAUDE_OPUS_5_5)
          .maxTokens(1024L)
          .addTool(weatherTool)
          .toolChoice(toolChoice)
          .addUserMessage(userPrompt)
          .addMessage(response)
          .addUserMessageOfContentBlockParams(List.of(ContentBlockParam.ofToolResult(
              ToolResultBlockParam.builder()
                  .toolUseId(toolUse.id())
                  .content(weather)
                  .build())))
          .build());

      // Claude はその結果を使って元の質問に回答します。
      followup.content().stream()
          .flatMap(block -> block.text().stream())
          .forEach(textBlock -> IO.println(textBlock.text()));
  }
  ```

  ```php PHP
  use Anthropic\Messages\ToolChoiceAuto;

  $client = new Client();

  $tools = [
      [
          'name' => 'get_weather',
          'description' => 'Get the current weather for a given location.',
          'input_schema' => [
              'type' => 'object',
              'properties' => [
                  'location' => [
                      'type' => 'string',
                      'description' => 'City and state, e.g. San Francisco, CA',
                  ],
              ],
              'required' => ['location'],
          ],
      ],
  ];
  $userMessage = ['role' => 'user', 'content' => "What's the weather in San Francisco?"];

  // 各ターンで要求するツール呼び出しは最大1回までにします。
  $toolChoice = ToolChoiceAuto::with(disableParallelToolUse: true);

  // Claude は、ツール名とその引数を指定した tool_use ブロックで応答します。
  $response = $client->messages->create(
      model: 'claude-opus-5-5',
      maxTokens: 1024,
      tools: $tools,
      toolChoice: $toolChoice,
      messages: [$userMessage],
  );
  $toolUse = null;
  foreach ($response->content as $block) {
      if ($block->type === 'tool_use') {
          $toolUse = $block;
          break;
      }
  }
  printf("Claude called %s with %s\n", $toolUse->name, json_encode($toolUse->input));

  // ツールを実行し、その結果を tool_result ブロックで返送します。
  $weather = '15 degrees Celsius, partly cloudy';
  $followup = $client->messages->create(
      model: 'claude-opus-5-5',
      maxTokens: 1024,
      tools: $tools,
      toolChoice: $toolChoice,
      messages: [
          $userMessage,
          ['role' => 'assistant', 'content' => $response->content],
          [
              'role' => 'user',
              'content' => [
                  [
                      'type' => 'tool_result',
                      'tool_use_id' => $toolUse->id,
                      'content' => $weather,
                  ],
              ],
          ],
      ],
  );

  // Claude はその結果を使って元の質問に回答します。
  foreach ($followup->content as $block) {
      if ($block->type === 'text') {
          echo $block->text, "\n";
      }
  }
  ```

  ```ruby Ruby
  client = Anthropic::Client.new

  tools = [
    {
      name: "get_weather",
      description: "Get the current weather for a given location.",
      input_schema: {
        type: "object",
        properties: {
          location: {type: "string", description: "City and state, e.g. San Francisco, CA"}
        },
        required: ["location"]
      }
    }
  ]
  messages = [{role: "user", content: "What's the weather in San Francisco?"}]

  # Claude は、ツール名とその引数を指定した tool_use ブロックで応答します。
  response = client.messages.create(
    model: Anthropic::Model::CLAUDE_OPUS_5_5,
    max_tokens: 1024,
    tools: tools,
    # 各ターンで要求するツール呼び出しは最大 1 つにします。
    tool_choice: {type: "auto", disable_parallel_tool_use: true},
    messages: messages
  )
  tool_use = response.content.find { |block| block.type == :tool_use }
  puts "Claude called #{tool_use.name} with #{JSON.generate(tool_use.input)}"

  # ツールを実行し、その結果を tool_result ブロックで返送します。
  weather = "15 degrees Celsius, partly cloudy"
  messages += [
    {role: "assistant", content: response.content},
    {
      role: "user",
      content: [
        {type: "tool_result", tool_use_id: tool_use.id, content: weather}
      ]
    }
  ]
  followup = client.messages.create(
    model: Anthropic::Model::CLAUDE_OPUS_5_5,
    max_tokens: 1024,
    tools: tools,
    tool_choice: {type: "auto", disable_parallel_tool_use: true},
    messages: messages
  )

  # Claude はその結果を使って元の質問に回答します。
  final_text = followup.content.find { |block| block.type == :text }
  puts final_text.text
  ```
</CodeGroup>

```text Output wrap
Claude called get_weather with {"location": "San Francisco, CA"}
The current weather in San Francisco is 15 degrees Celsius with partly cloudy skies.
```

[ツール呼び出しの処理](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/handle-tool-calls)では、結果のフォーマットやエラーの通知を含む各ステップを詳しく説明しています。[並列ツール使用](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/parallel-tool-use)では、複数のツールを一度に呼び出すレスポンスについて説明しています。この往復処理を自分で書く手間を省くには、[ツールランナー](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/tool-runner)を使用してください。SDKがツールを実行し、結果を自動的に返送します。

エージェントループや各アプローチをいつ選択すべきかを含む完全な概念モデルについては、[ツール使用の仕組み](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/how-tool-use-works)を参照してください。

「Model Context Protocol」、すなわちMCPのサーバーに接続するには、[MCPコネクター](https://platform.claude.com/docs/ja/agents-and-tools/mcp-connector)を参照してください。独自のMCPクライアントを構築するには、Model Context Protocolガイドの[MCPクライアントの構築](https://modelcontextprotocol.io/docs/develop/build-client)を参照してください。

## Claudeがツールを使用するタイミング

デフォルトの`tool_choice`である`{"type": "auto"}`では、Claudeは各ターンでツールを呼び出すか直接応答するかを判断します。リクエストがそのツールの説明された機能に対応し、かつ回答がまだコンテキスト内にない場合にツールを呼び出します。安定した知識、創造的なタスク、会話的なターンに対しては直接応答します。

この境界はシステムプロンプトを通じて調整可能です。期待したときにClaudeがツールを呼び出さない場合、`"Use the tools to investigate before responding."`のような軽い指示でツール使用が増加します。`"Always call a tool first before responding."`のようなより強い形式はさらに後押しします。逆に、`"Use your judgment about whether to call a tool or respond directly."`はトリガー動作を控えめに保ちます。

プロンプトに頼るのではなくツール呼び出しを必須にするには、[`tool_choice`](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/define-tools#forcing-tool-use)を設定してください。

<Tip>
  **厳密なツール使用でスキーマ準拠を保証する**

  カスタムツール定義に`strict: true`を追加すると、Claudeのツール呼び出しが常にスキーマに正確に一致することが保証されます。[厳密なツール使用](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/strict-tool-use)を参照してください。
</Tip>

各サーバーツールのページでは、それぞれのトリガー境界についてより詳しく説明しています。

<Accordion title="必須パラメータが不足している場合">
  ユーザーのプロンプトにツールのすべての必須パラメータを埋めるのに十分な情報が含まれていない場合、Claude Opusはパラメータが不足していることを認識してそれを尋ねる可能性がはるかに高くなります。Claude Sonnetは、特にツールリクエストを出力する前に考えるよう促された場合には尋ねるかもしれません。しかし、妥当な値を推測することもあります。

  例えば、`location`パラメータを必要とする`get_weather`ツールがある場合、場所を指定せずにClaudeに「天気はどうですか？」と尋ねると、Claude（特にClaude Sonnet）はあなたが提供しなかった値を推測するかもしれません。

  ```json JSON
  {
    "type": "tool_use",
    "id": "toolu_01A09q90qw90lq917835lq9",
    "name": "get_weather",
    "input": { "location": "New York, NY", "unit": "fahrenheit" }
  }
  ```

  この動作は保証されておらず、特により曖昧なプロンプトや能力の低いモデルではなおさらです。
</Accordion>

## ツールを選択する

`type`文字列、バージョン、ベータヘッダーについては、[ツールリファレンス](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/tool-reference)を参照してください。

### 独自のツール

あなたが定義するツールでは、スキーマを記述し、アプリケーションが各呼び出しを実行します。

<CardGroup cols={2}>
  <Card title="ツールの定義" icon="hammer" href="https://platform.claude.com/docs/ja/agents-and-tools/tool-use/define-tools">
    ツールスキーマを指定し、説明を書き、Claudeがいつツールを呼び出すかを制御します。
  </Card>

  <Card title="ツール呼び出しの処理" icon="arrows-left-right" href="https://platform.claude.com/docs/ja/agents-and-tools/tool-use/handle-tool-calls">
    `tool_use`ブロックを解析し、`tool_result`レスポンスをフォーマットし、エラーを処理します。
  </Card>
</CardGroup>

### Anthropicスキーマのクライアントツール

Anthropicがスキーマを公開し、Claudeをそのスキーマで訓練しています。各呼び出しの実行と`tool_result`の返送は引き続きあなたのアプリケーションが行います。

<CardGroup cols={2}>
  <Card title="メモリツール" icon="brain" href="https://platform.claude.com/docs/ja/agents-and-tools/tool-use/memory-tool">
    あなたが管理するファイルに、会話をまたいで情報を保存および取得します。
  </Card>

  <Card title="Bashツール" icon="terminal" href="https://platform.claude.com/docs/ja/agents-and-tools/tool-use/bash-tool">
    状態を維持する永続的なセッションでシェルコマンドを実行します。
  </Card>

  <Card title="テキストエディタツール" icon="edit" href="https://platform.claude.com/docs/ja/agents-and-tools/tool-use/text-editor-tool">
    テキストファイルを表示および変更して、コードをデバッグ、修正、改善します。
  </Card>

  <Card title="コンピュータ使用ツール" icon="computer" href="https://platform.claude.com/docs/ja/agents-and-tools/tool-use/computer-use-tool">
    デスクトップ環境でスクリーンショットを撮り、マウスとキーボードを操作します。
  </Card>

  <Card title="ブラウザ使用ツール" icon="browser" href="https://platform.claude.com/docs/ja/agents-and-tools/tool-use/browser-use-tool">
    独自のブラウザ環境でWebページをナビゲート、閲覧、操作します。
  </Card>
</CardGroup>

### サーバーツール

サーバーツールはAnthropicのインフラストラクチャ上で実行され、あなたのアプリケーションにハンドラーコードは不要です。それらが共有する仕組みについては、[サーバーツール](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/server-tools)を参照してください。

<CardGroup cols={2}>
  <Card title="Web検索ツール" icon="magnifying-glass" href="https://platform.claude.com/docs/ja/agents-and-tools/tool-use/web-search-tool">
    知識のカットオフ以降の情報を、引用元付きでWeb検索します。
  </Card>

  <Card title="Webフェッチツール" icon="download" href="https://platform.claude.com/docs/ja/agents-and-tools/tool-use/web-fetch-tool">
    指定したWebページやPDFドキュメントの全内容を取得します。
  </Card>

  <Card title="コード実行ツール" icon="code" href="https://platform.claude.com/docs/ja/agents-and-tools/tool-use/code-execution-tool">
    サンドボックス化されたコンテナでPythonやBashのコードを実行し、データを分析してファイルを生成します。
  </Card>

  <Card title="アドバイザーツール" icon="lightbulb" href="https://platform.claude.com/docs/ja/agents-and-tools/tool-use/advisor-tool">
    より高速な実行モデルが、生成の途中でより高い知能を持つアドバイザーモデルに相談できるようにします。
  </Card>

  <Card title="ツール検索ツール" icon="library" href="https://platform.claude.com/docs/ja/agents-and-tools/tool-use/tool-search-tool">
    オンデマンドでツールを発見して読み込むことで、数千のツールを扱います。
  </Card>

  <Card title="MCPコネクター" icon="link" href="https://platform.claude.com/docs/ja/agents-and-tools/mcp-connector">
    別途MCPクライアントを用意せずに、Messages APIからリモートMCPサーバーに接続します。
  </Card>
</CardGroup>

<Note>
  [Claude Managed Agents](https://platform.claude.com/docs/ja/managed-agents/overview)は、Claudeがセッション内で自律的に使用する組み込みツールセットを提供します。そのツールセットと、Managed Agentsでカスタムツールを追加する方法については、[ツール](https://platform.claude.com/docs/ja/managed-agents/tools)ページを参照してください。
</Note>

## 料金

「tool use」（ツール使用）リクエストの料金は、以下に基づいて決まります。

1. モデルに送信される入力トークンの総数（`tools` パラメータ内のものを含む）。
2. 生成される出力トークンの数。
3. サーバーサイドツールの場合、追加の使用量ベースの料金（例えば、ウェブ検索は実行された検索ごとに課金されます）。

クライアントサイドツールは他の Claude API リクエストと同じ料金体系ですが、サーバーサイドツールはその具体的な使用状況に応じて追加料金が発生する場合があります。

ツール使用による追加トークンは、以下から発生します。

* API リクエスト内の `tools` パラメータ（ツール名、説明、スキーマ）
* API リクエストおよびレスポンス内の `tool_use` コンテンツブロック
* API リクエスト内の `tool_result` コンテンツブロック

`tools` を使用すると、API はツール使用を有効にするための特別な「system prompt」（システムプロンプト）もモデルに自動的に含めます。各モデルに必要なツール使用トークン数は、以下の表に記載されています（前述の追加トークンは除きます）。この表は、少なくとも1つのツールを提供することを前提としています。`tools` を提供しない場合、ツール選択が `none` のときは追加のシステムプロンプトトークンは0になります。

| Model                                                                                                                                                                  | Tool use system prompt tokens: auto, none | Tool use system prompt tokens: any, tool |
| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------- | :--------------------------------------- |
| Claude Opus 5.5                                                                                                                                                        | 286 tokens                                |                                          |
| Claude Opus 5                                                                                                                                                          | 286 tokens                                | 406 tokens                               |
| Claude Opus 4.8                                                                                                                                                        | 290 tokens                                | 410 tokens                               |
| Claude Opus 4.7                                                                                                                                                        | 675 tokens                                | 804 tokens                               |
| Claude Opus 4.6                                                                                                                                                        | 497 tokens                                | 589 tokens                               |
| Claude Opus 4.5                                                                                                                                                        | 496 tokens                                | 588 tokens                               |
| Claude Opus 4.1 ([retired, except on Claude Models on Google Cloud (Google managed) and Bedrock](https://platform.claude.com/docs/ja/about-claude/model-deprecations)) | 313 tokens                                | 315 tokens                               |
| Claude Opus 4 ([retired, except on Claude Models on Google Cloud (Google managed)](https://platform.claude.com/docs/ja/about-claude/model-deprecations))               | 313 tokens                                | 315 tokens                               |
| Claude Sonnet 5.5                                                                                                                                                      | 286 tokens                                |                                          |
| Claude Sonnet 5                                                                                                                                                        | 354 tokens                                | 474 tokens                               |
| Claude Sonnet 4.6                                                                                                                                                      | 497 tokens                                | 589 tokens                               |
| Claude Sonnet 4.5                                                                                                                                                      | 496 tokens                                | 588 tokens                               |
| Claude Sonnet 4 ([retired, except on Claude Models on Google Cloud (Google managed) and Bedrock](https://platform.claude.com/docs/ja/about-claude/model-deprecations)) | 313 tokens                                | 315 tokens                               |
| Claude Haiku 5.5                                                                                                                                                       | 286 tokens                                | 406 tokens                               |
| Claude Haiku 4.5                                                                                                                                                       | 496 tokens                                | 588 tokens                               |

* **auto, none:** The count when tool\_choice is auto or none.
* **any, tool:** The count when tool\_choice is any or tool.
* **Retired:** May still be available on other cloud platforms. See [Model deprecations](https://platform.claude.com/docs/ja/about-claude/model-deprecations) for more.

これらのトークン数は通常の入力トークンおよび出力トークンに加算され、リクエストの総コストが計算されます。

現在のモデルごとの価格については、[モデル概要](https://platform.claude.com/docs/ja/models/overview#latest-models-comparison)の表を参照してください。

ツール使用プロンプトを送信すると、他のAPIリクエストと同様に、レスポンスには報告される`usage`メトリクスに入力トークン数と出力トークン数の両方が含まれます。

一部のサーバーツールでは、トークンに加えて使用量ベースの料金が発生します。料金については、[Web検索ツールの使用量と料金](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/web-search-tool#usage-and-pricing)および[コード実行ツールの使用量と料金](https://platform.claude.com/docs/ja/agents-and-tools/tool-use/code-execution-tool#usage-and-pricing)を参照してください。

## 次のステップ

<CardGroup cols={3}>
  <Card href="https://platform.claude.com/docs/ja/agents-and-tools/tool-use/how-tool-use-works" title="ツール使用の仕組み" icon="compass">
    ツール使用のループ、ツールが実行される場所、そして文章の代わりにツールを使用すべきタイミングを理解します。
  </Card>

  <Card href="https://platform.claude.com/docs/ja/agents-and-tools/tool-use/build-a-tool-using-agent" title="チュートリアル：ツールを使用するエージェントを構築する" icon="graduation-cap">
    単一のツール呼び出しから本番環境対応のエージェントループまでのガイド付きウォークスルーです。
  </Card>

  <Card href="https://platform.claude.com/docs/ja/agents-and-tools/tool-use/tool-reference" title="ツールリファレンス" icon="book">
    Anthropicが提供するツールの一覧と、オプションのツール定義プロパティのリファレンスです。
  </Card>
</CardGroup>
