도구 검색 도구를 사용하면 Claude가 필요에 따라 도구를 검색하고 로드하여 수백 또는 수천 개의 도구로 작업할 수 있습니다. 모든 도구 정의를 미리 "context window"(컨텍스트 윈도우)에 로드하는 대신, Claude는 도구 카탈로그(도구 이름, 설명, 인수 이름, 인수 설명 포함)를 검색하고 필요한 도구만 로드합니다.
모든 도구 정의를 미리 로드하면 도구 라이브러리가 커짐에 따라 두 가지 문제가 발생합니다:
도구 검색은 Claude API에서 일반적으로 사용할 수 있습니다. 지원되는 모델은 모델 호환성을 참조하세요.
도구 검색이 해결하는 확장 문제에 대한 배경 정보는 Advanced tool use를 참조하세요. 도구 검색의 온디맨드 로딩은 Effective context engineering에서 설명하는 더 광범위한 적시(just-in-time) 검색 원칙의 한 사례이기도 합니다.
도구 검색은 서버 측 도구로 실행되지만, 자체 클라이언트 측 도구 검색을 구현할 수도 있습니다. 자세한 내용은 사용자 정의 도구 검색 구현을 참조하세요.
이 기능에 대한 피드백은 피드백 양식을 통해 공유해 주세요.
이 기능은 Zero Data Retention (ZDR)의 적용 대상입니다. 조직에 ZDR 계약이 체결되어 있는 경우, 이 기능을 통해 전송된 데이터는 API 응답이 반환된 후 저장되지 않습니다.
Amazon Bedrock에서 서버 측 도구 검색은 Converse API가 아닌 InvokeModel API를 통해서만 사용할 수 있습니다.
Claude Platform on AWS에서 서버 측 도구 검색은 Claude API와 동일하게 작동합니다. Claude Platform on AWS는 Anthropic Messages API를 직접 사용하므로 InvokeModel과 Converse의 구분이 없습니다.
두 도구 검색 변형 모두 다음 모델에서 사용할 수 있습니다:
| 모델 | 도구 버전 |
|---|---|
| Claude Fable 5 (claude-fable-5) | tool_search_tool_regex_20251119, tool_search_tool_bm25_20251119 |
| Claude Mythos 5 (claude-mythos-5) | tool_search_tool_regex_20251119, tool_search_tool_bm25_20251119 |
| Claude Opus 4.8 (claude-opus-4-8) | tool_search_tool_regex_20251119, tool_search_tool_bm25_20251119 |
| Claude Opus 4.7 (claude-opus-4-7) | tool_search_tool_regex_20251119, tool_search_tool_bm25_20251119 |
| Claude Opus 4.6 (claude-opus-4-6) | tool_search_tool_regex_20251119, tool_search_tool_bm25_20251119 |
| Claude Sonnet 4.6 (claude-sonnet-4-6) | tool_search_tool_regex_20251119, tool_search_tool_bm25_20251119 |
| Claude Opus 4.5 (claude-opus-4-5-20251101) | tool_search_tool_regex_20251119, tool_search_tool_bm25_20251119 |
| Claude Sonnet 4.5 (claude-sonnet-4-5-20250929) | tool_search_tool_regex_20251119, tool_search_tool_bm25_20251119 |
| Claude Haiku 4.5 (claude-haiku-4-5-20251001) | tool_search_tool_regex_20251119, tool_search_tool_bm25_20251119 |
Claude Opus 4.1 및 이전 모델은 도구 검색 도구를 지원하지 않습니다.
도구 검색에는 두 가지 변형이 있습니다:
tool_search_tool_regex_20251119): Claude가 정규식 패턴을 구성하여 도구를 검색합니다.tool_search_tool_bm25_20251119): Claude가 자연어 쿼리를 사용하여 도구를 검색합니다.도구 검색 도구를 활성화하면:
tools 목록에 도구 검색 도구(예: tool_search_tool_regex_20251119 또는 tool_search_tool_bm25_20251119)를 포함합니다.tools 배열에 모든 도구 정의를 제공하고, 미리 로드하지 않아야 하는 도구에 defer_loading: true를 설정합니다. 일반적으로 도구 검색 도구 자체를 포함하여 최소 하나의 도구는 지연되지 않은 상태로 유지해야 합니다.tool_reference 블록으로 반환합니다(기본적으로 최대 5개).다음 예제는 도구 검색 도구와 두 개의 지연된 도구를 포함합니다:
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-opus-4-8",
max_tokens=2048,
messages=[{"role": "user", "content": "What is the weather in San Francisco?"}],
tools=[
{"type": "tool_search_tool_regex_20251119", "name": "tool_search_tool_regex"},
{
"name": "get_weather",
"description": "Get the weather at a specific location",
"input_schema": {
"type": "object",
"properties": {
"location": {"type": "string"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
},
"required": ["location"],
},
"defer_loading": True,
},
{
"name": "search_files",
"description": "Search through files in the workspace",
"input_schema": {
"type": "object",
"properties": {
"query": {"type": "string"},
"file_types": {"type": "array", "items": {"type": "string"}},
},
"required": ["query"],
},
"defer_loading": True,
},
],
)
print(response)Claude는 카탈로그를 검색하고 get_weather를 발견한 후 호출합니다. 응답은 stop_reason: "tool_use"로 끝납니다. 도구 호출 처리에서와 같이 발견된 도구를 실행하고 tool_result를 반환하세요. 응답 형식은 반환되는 블록과 다음에 보내야 할 내용을 보여줍니다.
도구 검색 도구에는 두 가지 변형이 있습니다:
{
"type": "tool_search_tool_regex_20251119",
"name": "tool_search_tool_regex"
}{
"type": "tool_search_tool_bm25_20251119",
"name": "tool_search_tool_bm25"
}Regex 변형 쿼리 형식: 자연어가 아닌 Python 정규식
tool_search_tool_regex_20251119를 사용하면 Claude는 자연어 쿼리가 아닌 Python re.search() 패턴을 작성합니다. 매칭은 대소문자를 구분하지 않습니다. 일반적인 패턴은 다음과 같습니다:
"weather": "weather"를 포함하는 도구 이름 및 설명과 일치"get_.*_data": get_user_data 및 get_weather_data와 같은 도구와 일치"database.*query|query.*database": 두 단어 순서 모두와 일치최대 패턴 길이: 200자
BM25 변형 쿼리 형식: 자연어
tool_search_tool_bm25_20251119를 사용하면 Claude는 자연어 쿼리로 검색합니다. 최대 쿼리 길이: 500자.
defer_loading: true를 추가하여 도구를 온디맨드 로딩 대상으로 표시하세요:
{
"name": "get_weather",
"description": "Get current weather for a location",
"input_schema": {
"type": "object",
"properties": {
"location": { "type": "string" },
"unit": { "type": "string", "enum": ["celsius", "fahrenheit"] }
},
"required": ["location"]
},
"defer_loading": true
}defer_loading은 요청에서 보내는 내용이 아니라 컨텍스트 윈도우에 들어가는 내용을 제어합니다:
tools 배열에 모든 도구의 전체 정의를 여전히 보내야 합니다. API는 검색을 실행하고 tool_reference 블록을 확장하기 위해 서버 측에서 이를 필요로 합니다.defer_loading이 없는 도구는 즉시 컨텍스트에 로드됩니다.defer_loading: true가 있는 도구는 Claude가 검색을 통해 발견할 때만 로드됩니다.defer_loading: true를 설정하지 마세요.두 도구 검색 변형(regex 및 bm25) 모두 도구 이름, 설명, 인수 이름, 인수 설명을 검색합니다.
내부적으로 API는 지연된 도구를 시스템 프롬프트 접두사에서 제외합니다. Claude가 도구 검색을 통해 지연된 도구를 발견하면, API는 대화에 tool_reference 블록을 인라인으로 추가한 다음 Claude에 전달하기 전에 전체 도구 정의로 확장합니다. 접두사는 변경되지 않으므로 프롬프트 캐싱이 유지됩니다. strict 모드(도구 호출 출력이 스키마와 일치하도록 제약하는 규칙)의 문법은 전체 도구 세트에서 구축되므로, defer_loading과 strict 모드는 문법 재컴파일 없이 함께 작동합니다.
Claude가 도구 검색 도구를 사용하면 응답에 다음 블록 유형이 포함됩니다:
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "I'll search for tools to help with the weather information."
},
{
"type": "server_tool_use",
"id": "srvtoolu_01ABC123",
"name": "tool_search_tool_regex",
"input": {
"pattern": "weather"
}
},
{
"type": "tool_search_tool_result",
"tool_use_id": "srvtoolu_01ABC123",
"content": {
"type": "tool_search_tool_search_result",
"tool_references": [{ "type": "tool_reference", "tool_name": "get_weather" }]
}
},
{
"type": "text",
"text": "I found a weather tool. Let me get the weather for San Francisco."
},
{
"type": "tool_use",
"id": "toolu_01XYZ789",
"name": "get_weather",
"input": { "location": "San Francisco", "unit": "fahrenheit" }
}
],
"stop_reason": "tool_use"
}server_tool_use: 도구 검색 도구에 대한 Claude의 호출입니다. 검색은 Anthropic 서버에서 실행됩니다. srvtoolu_... ID에 대해 tool_result를 절대 반환하지 마세요.tool_search_tool_result: 중첩된 tool_search_tool_search_result 객체에 있는 검색 결과입니다. 메시지 기록에 그대로 유지하세요.tool_references: 발견된 도구를 가리키는 tool_reference 객체의 배열입니다. API가 Claude를 위해 이를 확장합니다. 직접 확장할 필요가 없습니다.tool_use: 발견된 도구에 대한 Claude의 호출입니다. 표준 도구 사용과 동일하게 실행하고 tool_result를 반환하세요.API는 tool_reference 블록을 Claude에 표시하기 전에 전체 도구 정의로 자동 확장합니다. tools 매개변수에 일치하는 모든 도구 정의를 제공하는 한, 이 확장을 직접 처리할 필요가 없습니다.
다음 요청에서 server_tool_use 및 tool_search_tool_result 블록을 포함하여 어시스턴트의 콘텐츠를 변경 없이 다시 전달하세요. 발견된 도구에 대한 tool_result를 사용자 메시지에 추가하고, 검색 도구와 모든 지연된 정의를 포함한 동일한 tools 배열을 보내세요. srvtoolu_... ID에 대해 tool_result를 반환하지 마세요. API가 요청을 거부합니다. API는 대화 기록 전체에서 tool_reference 블록을 확장하므로, Claude는 다시 검색하지 않고도 이후 턴에서 발견된 도구를 재사용할 수 있습니다. 아무것도 일치하지 않는 검색은 오류가 아니라 빈 tool_references 배열이 있는 tool_search_tool_search_result를 반환합니다.
도구가 MCP 커넥터를 통해 MCP 서버에서 제공되는 경우, 개별 도구 정의에 defer_loading을 설정하지 않습니다. 대신 전체 서버에 대해 mcp_toolset 항목의 default_config에 한 번 설정하거나, configs에서 도구별로 설정하세요. MCP 도구 세트 구성을 참조하세요.
사용자 정의 도구에서 tool_reference 블록을 반환하여 자체 도구 검색 로직(예: 임베딩 또는 시맨틱 검색 사용)을 구현할 수 있습니다. Claude가 사용자 정의 검색 도구를 호출하면, 콘텐츠 배열에 tool_reference 블록이 포함된 표준 tool_result를 반환하세요:
{
"type": "tool_result",
"tool_use_id": "toolu_your_tool_id",
"content": [{ "type": "tool_reference", "tool_name": "discovered_tool_name" }]
}참조된 모든 도구는 최상위 tools 매개변수에 해당하는 도구 정의가 있어야 하며, 일반적으로 defer_loading: true로 설정됩니다. 이를 통해 임베딩 기반 검색과 같이 기본 제공 변형이 제공하지 않는 검색 방법을 사용할 수 있으며, API는 반환된 tool_reference 블록을 동일한 방식으로 확장합니다.
응답 형식 섹션에 표시된 tool_search_tool_result 형식은 Anthropic의 기본 제공 도구 검색에서 내부적으로 사용하는 서버 측 형식입니다. 사용자 정의 클라이언트 측 구현의 경우, 앞의 예제에 표시된 대로 항상 tool_reference 콘텐츠 블록이 포함된 표준 tool_result 형식을 사용하세요.
임베딩을 사용하는 전체 예제는 임베딩을 사용한 도구 검색 레시피를 참조하세요.
도구 사용 예제는
도구 검색과 함께 작동합니다. Claude가 지연된 도구를 발견하면 API는
해당 정의와 함께 input_examples를 확장합니다.
이러한 오류는 API가 요청을 처리하지 못하게 합니다:
모든 도구가 지연됨:
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "At least one tool must have defer_loading=false. All tools cannot be deferred."
}
}도구 정의 누락:
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "Tool reference 'unknown_tool' not found in available tools"
}
}실행 중 도구 검색 작업이 실패하면 API는 본문에 오류가 포함된 200 응답을 반환합니다:
{
"type": "tool_search_tool_result",
"tool_use_id": "srvtoolu_01ABC123",
"content": {
"type": "tool_search_tool_result_error",
"error_code": "invalid_tool_input",
"error_message": "Invalid regular expression pattern: missing ) at position 1"
}
}error_code 필드에는 네 가지 가능한 값이 있습니다:
invalid_tool_input: 검색 입력이 유효하지 않음. 예를 들어 잘못된 형식의 정규식 패턴 또는 200자 제한을 초과하는 패턴unavailable: 검색을 실행할 수 없음. 예를 들어 시간 초과 또는 서비스를 사용할 수 없는 경우too_many_requests: 도구 검색 작업에 대한 속도 제한 초과execution_time_exceeded: 검색이 실행 시간 제한을 초과함defer_loading이 프롬프트 캐싱을 유지하는 방법은 프롬프트 캐싱과 함께 도구 사용을 참조하세요.
defer_loading: true가 있는 도구는 cache_control도 함께 가질 수 없습니다. API가 400을 반환합니다. 캐시 중단점은 지연되지 않은 도구에 설정하세요.
스트리밍이 활성화되면 스트림의 일부로 도구 검색 이벤트를 받게 됩니다:
event: content_block_start
data: {"type": "content_block_start", "index": 1, "content_block": {"type": "server_tool_use", "id": "srvtoolu_xyz789", "name": "tool_search_tool_regex"}}
// Search pattern streamed
event: content_block_delta
data: {"type": "content_block_delta", "index": 1, "delta": {"type": "input_json_delta", "partial_json": "{\"pattern\":\"weather\"}"}}
// Pause while search executes
// Search results streamed
event: content_block_start
data: {"type": "content_block_start", "index": 2, "content_block": {"type": "tool_search_tool_result", "tool_use_id": "srvtoolu_xyz789", "content": {"type": "tool_search_tool_search_result", "tool_references": [{"type": "tool_reference", "tool_name": "get_weather"}]}}}
// Claude continues with discovered toolsMessages Batches API에 도구 검색 도구를 포함할 수 있습니다.
defer_loading: true가 있는 도구 10,000개다음 중 하나라도 해당되면 도구 검색을 사용하세요:
도구 검색 없는 표준 도구 호출은 도구가 10개 미만이거나, 모든 요청에서 모든 도구가 사용되거나, 도구 정의가 작은 경우(총 100 토큰 미만)에 더 적합합니다.
github_, slack_) 한 번의 검색으로 전체 그룹이 일치하도록 하세요.도구 검색은 별도의 서버 도구로 측정되지 않습니다. 응답의 usage.server_tool_use 객체에는 도구 검색 필드가 없으며, 검색이 컨텍스트에 로드하는 도구 정의는 다른 도구 정의와 마찬가지로 입력 토큰으로 계산됩니다.
애플리케이션에서 메모리 도구의 파일 작업을 구현하여 Claude가 대화 전반에 걸쳐 정보를 저장하고 검색할 수 있도록 하세요.
Anthropic 제공 도구 디렉터리 및 선택적 도구 정의 속성에 대한 참조입니다.
지연 로딩으로 MCP 도구 세트를 구성하세요.
턴 간에 도구 정의를 캐시하고 캐시를 무효화하는 요소를 이해하세요.
도구 스키마를 지정하고, 효과적인 설명을 작성하고, Claude가 도구를 호출하는 시점을 제어하세요.
Was this page helpful?