Learning resourcesReviewed · Anthropic

Give Claude custom tools

Give Claude custom tools is a guide for Python and TypeScript developers adding functions to Claude agents, but several approval and output features require TypeScript. It explains tool schemas, in-process MCP servers, access controls, error handling and rich results.

Researched 23 Nov 2026

In short.

Give Claude custom tools is a guide for developers connecting Claude agents to their own functions and APIs, but Python and TypeScript differ in approval controls and supported results. It provides weather and unit-conversion examples, explains how tool availability differs from permission, and documents important output-handling caveats. Runtime behavior, performance and operating costs are not assessed.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage is the complete supplied page at [https://code.claude.com/docs/en/agent-sdk/custom-tools.md], including its examples, tables and language-specific notices. Linked documentation, the documentation index, SDK source code and external services are outside this scope. No code was executed. Runtime compatibility, performance, production reliability, costs and reuse rights remain unassessed or unknown where the page does not establish them.

The overview

Identity

The resource is the Claude Agent SDK documentation page Give Claude custom tools [https://code.claude.com/docs/en/agent-sdk/custom-tools.md]. It teaches developers to expose application functions through an MCP server running inside their application process. The page is a tutorial and feature reference, rather than a standalone application or downloadable integration.

Assessment

The documented approach is a good fit for an application already using the Claude Agent SDK that needs access to its own APIs, databases or domain logic without running a separate MCP server process. The guide connects tool definition to registration, permissions, result handling and call inspection. It provides implementation guidance, while leaving complete environment setup and production reliability unestablished.

Users

Python and TypeScript developers building Claude-based applications are the main audience. Beginners need familiarity with asynchronous functions, dependencies and basic data schemas to adapt the examples. Experienced developers will find useful details about approval callbacks, tool discovery, machine-readable results and differences between the language implementations.

Capabilities

The guide covers custom functions with validated arguments, optional parameters, enums and handler-defined defaults. Examples retrieve weather data and perform unit conversions. Tools can return text, images, embedded resources and resource links, subject to the language limitations described later.

It also covers pre-approving calls, restricting built-in tools, TypeScript policies for requesting approval or denying calls, and annotations that describe tool behavior. Tool search is documented as enabled by default: Claude initially sees compact tool names and loads full schemas when needed. TypeScript can keep schemas loaded with alwaysLoad.

Using it

Requirements

The examples use claude_agent_sdk in Python and @anthropic-ai/claude-agent-sdk in TypeScript. TypeScript schemas use Zod. Python examples making HTTP requests use httpx, with installation commands supplied. Network access is needed for the weather examples, while the converter handler performs local calculations.

Per-tool permission_policy configuration is TypeScript-only and requires Agent SDK v0.3.301 or later. The page does not establish minimum Python or Node.js versions, a complete SDK installation procedure, authentication requirements or account eligibility.

Mechanism

Each tool has a name, description, input schema and asynchronous handler. Claude uses the description and schema to choose a tool and supply arguments; the handler receives validated arguments and performs the operation. TypeScript uses tool(), while Python uses the @tool decorator. createSdkMcpServer or create_sdk_mcp_server groups the tools into an in-process server registered with query().

Handlers return content blocks and can signal failure using isError in TypeScript or is_error in Python. Uncaught handler exceptions become error results containing the raw exception message, and the agent loop continues. Catching errors lets the handler provide a more useful message. This does not guarantee overall query success: the examples separately catch query-level failures.

Setup

Define the tool, place it in a server and register that server through mcpServers in TypeScript or mcp_servers in Python. Pre-approval uses a qualified name such as mcp__weather__get_temperature, with the server component taken from the registration key. For optional arguments, mark the schema field optional and implement the default in the handler. Python's simple name-to-type dictionary makes every key required; the full JSON Schema form supports optional parameters by leaving them out of required and applying defaults with args.get().

Configure availability and permission separately. The tools option controls built-in availability; tools: [] removes all built-ins while leaving MCP tools available. allowedTools pre-approves eligible calls, and omitting a tool from that list sends its calls through the permission flow rather than removing it.

For TypeScript always_ask or always_deny policies, add tool policy entries to the configuration object returned by createSdkMcpServer. In auto or plan permission mode, the page says to explicitly set destructiveHint to true for always_ask tools to prevent classifier approval from replacing the callback.

Example

The weather example defines get_temperature with latitude and longitude arguments, requests current Fahrenheit temperature from Open-Meteo, and returns text to Claude. A second tool adds hourly precipitation probability with an optional hours argument defaulting to 12.

The unit converter illustrates a handler without an external API request. It constrains the category to length, temperature or weight, supports explicitly listed conversion pairs, and returns an error for unsupported pairs. Its query examples inspect tool-use messages before printing the final answer, showing how developers can observe whether a tool was called. These are documented examples; execution results are not established.

Assessment & evidence

Limitations

Python's in-process @tool decorator forwards only content and is_error, so it does not return structuredContent. Python also drops audio blocks and binary resource blocks with warnings. Resource links are flattened to text, and the Python resourceLinks key is not produced for in-process tools.

TypeScript handles several results differently. When structuredContent is supplied, Claude receives that JSON plus image and resource blocks, but text blocks in content do not reach Claude. Audio is saved to disk and represented by a file path. Images require inline base64 bytes; returning a remote image requires fetching and encoding it in the handler.

Annotations describe behavior rather than enforce it. A readOnlyHint does not prevent a handler from writing, even though it controls eligibility for parallel read-only calls. The page supplies no benchmarks, load results or production deployment evidence.

Reasoning

The main adoption question is whether the chosen language supports the required outputs and approval behavior. Simple text-returning functions are demonstrated in both languages. Applications needing structured JSON from Python in-process tools encounter a documented limitation, while TypeScript users must account for text suppression when structuredContent is present. These differences make the guide especially useful before committing to a tool-result format or approval design.

Alternatives

For Python tools that need structuredContent, the page recommends running a standalone MCP server. For integrations already available through external servers, such as filesystem, GitHub or Slack connections, it points to the MCP connection guide [https://code.claude.com/docs/en/agent-sdk/mcp.md]. These are alternatives identified by the page; it supplies no comparison with competing agent SDKs.

Evidence

The evidence is the complete documentation page at [https://code.claude.com/docs/en/agent-sdk/custom-tools.md]. It contains explanatory text, configuration tables and Python and TypeScript examples. Those materials establish documented behavior, without establishing successful execution, performance or deployment outcomes.

Access & freshness

Costs

The page provides no prices, usage allowances or total operating-cost estimate. Costs for Claude usage, application hosting and external APIs are unknown from this evidence. The in-process design does not establish that an application using it is free to operate.

Rights

The supplied page states no licence or redistribution terms for its text or example code. SDK licensing and third-party API terms are also not established here. Reuse and redistribution rights remain unknown from this source.

Freshness

The source snapshot was captured on 2026-11-23 at 03:27:03.108 UTC. The page supplies no publication date, last-updated date or overall SDK version pin. Its explicit minimum-version statement applies to TypeScript permission_policy support: v0.3.301 or later. Compatibility of every example with a particular installed SDK version is not assessed.

Actions

Choose the language after checking required result formats and approval controls. Start with the unit converter to inspect tool calls without adding an external API dependency, then introduce one application-specific operation. Verify argument validation, optional defaults, error messages and approval callbacks under the intended SDK version and permission mode. Confirm authentication, running costs and reuse terms separately, because this page does not establish them.

Evidence for this report

selected-page.txtselected · checked 2026-11-23