SuperAPIAI Directory

anthropic-tools

github.com · AI agents

Anthropic's browser automation via MCP.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsAPI

About this tool

This project is a Python SDK for tool use / function calling released by Anthropic, used to work with Anthropic models and external tools. It should first be made clear that the repository has issued a deprecation notice and is no longer maintained, and the official recommendation is to switch to the official API implementation described in https://docs.anthropic.com/en/docs/build-with-claude/tool-use . At the same time, the project is in the Alpha stage and is only a research preview; the official party does not promise continued support, and it is not suitable for production environments. Production-ready function calling support was about to be added to the Anthropic API at that time.

Main capabilities and usage:

  1. Environment preparation. The Anthropic API Key needs to be set as an environment variable; if accessing Claude through AWS Bedrock, then set the corresponding Bedrock environment variable instead. Optional: if you need to test the Brave search tool, set the Brave API Key as an environment variable. Then create a Python virtual environment and install the dependencies.

  2. Core architecture. The project provides two main classes: BaseTool and ToolUser. BaseTool is used to define a single tool; inherit from this class and implement the use_tool() method. When instantiating, you need to pass in name (the tool name), description (a description of the tool's function for Claude to read), and parameters (the parameters accepted by the tool), and pay attention to their respective formats. ToolUser accepts a list of tools composed of BaseTool subclasses; after creating an instance, call the use_tools() method and pass in a prompt to use these tools. When the execution mode is set to "automatic", the function is executed automatically; the default "manual" mode returns the function arguments to the client, and the client executes them itself. If accessing Claude through AWS Bedrock, the first_party parameter needs to be set to False (default True); when using Bedrock, this SDK only supports claude 2.1 (anthropic.claude-v2:1).

  3. Structured messages format. The project introduces a new structured input/output format, namely a Python list composed of message dictionaries, intended to mimic the Messages API format. A single message dictionary may contain multiple fields, but will not contain all fields at the same time. Among them, tool_inputs is a list of dictionaries, where each dictionary uses the 'tool_name' key to indicate the tool to use and the 'tool_arguments' key to indicate the arguments passed to that tool; a tool_inputs message may also carry content (which may be an empty string, or may contain the assistant's content before the tool call requestcontent), messages are rendered to Claude in the order {content}{tool_inputs}. Official note: although tool_arguments are validated before being returned, it is still recommended to perform an additional check before executing the function, to guard against malicious or invalid arguments; this can also be done inside the use_tools method. tool_outputs is likewise a list of dictionaries, using the 'tool_name' key to indicate the tool and the 'tool_result' key to indicate the result; it is strongly recommended (though not required) to provide tool_outputs only for the tool_inputs that were requested, and to keep them in the same order as tool_inputs; tool_outputs messages must not carry content, otherwise an error will be raised. If Claude requests a nonexistent tool or the arguments are invalid, parsing should stop, and instead of sending tool_outputs, a message with a descriptive tool_error should be returned to Claude.

  4. Differences in execution modes. automatic mode handles all of Claude's tool_inputs messages on your behalf, executes tools on the inputs, passes errors to Claude, and so on, stopping and returning the next message only when Claude has not issued a tool-use request (that is, when it returns a message with role='assistant'). This mode is easy to get started with, but it hides the intermediate process, so the user cannot validate arguments themselves before calling use_tool(), cannot control with fine granularity the errors passed back to Claude, and cannot see the intermediate tool_inputs and tool_outputs messages that are generated. manual mode retains the above capabilities: after calling use_tools(), it stops at the next message (for example, a tool_inputs message), and the user provides tool_outputs and passes in a new set of messages to continue. The project also demonstrates how to write a lightweight function that, in manual mode, automatically parses Claude's response and generates a new message list, returning a dictionary containing next_action (indicating whether the next step should ask the user or automatically pass back the tool result) and messages (the latest message list).

  5. Built-in tools and examples. The project includes multiple commonly used tools built on the same primitives, such as search or SQL, making them easier to use. The examples folder provides common use cases and examples of more advanced usage, EXAMPLES.md contains operational guidance, including: letting Claude access an API, letting Claude call a SQL database, and letting Claude search across multiple data sources.

Limitations and status: the repository is deprecated and no longer maintained; the SDK is an Alpha research preview, with no support commitment, and is not for production use; in the Bedrock scenario only claude 2.1 is supported; tool_outputs must not contain content; argument validation is not guaranteed to be complete, and you need to check it yourself before execution. Other content not mentioned in the materials is not yet provided.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools