# metorial-anthropic
Anthropic (Claude) provider integration for Metorial - enables using Metorial tools with Claude models through Anthropic's tool calling API.
## Installation
```bash
pip install metorial-anthropic
# or
uv add metorial-anthropic
# or
poetry add metorial-anthropic
```
## Features
- 🤖 **Claude Integration**: Full support for Claude 3.5, Claude 3, and other Anthropic models
- 🛠️ **Tool Calling**: Native Anthropic tool format support
- 📡 **Session Management**: Automatic tool lifecycle handling
- 🔄 **Format Conversion**: Converts Metorial tools to Anthropic tool format
- ⚡ **Async Support**: Full async/await support
## Usage
### Basic Usage
```python
import asyncio
from anthropic import Anthropic
from metorial import Metorial
from metorial_anthropic import MetorialAnthropicSession
async def main():
# Initialize clients
metorial = Metorial(api_key="your-metorial-api-key")
anthropic = Anthropic(api_key="your-anthropic-api-key")
# Create session with your server deployments
async with metorial.session(["your-server-deployment-id"]) as session:
# Create Anthropic-specific wrapper
anthropic_session = MetorialAnthropicSession(session.tool_manager)
messages = [
{"role": "user", "content": "What are the latest commits?"}
]
# Remove duplicate tools by name (Anthropic requirement)
unique_tools = list({t["name"]: t for t in anthropic_session.tools}.values())
response = await anthropic.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=1024,
messages=messages,
tools=unique_tools
)
# Handle tool calls
tool_calls = [c for c in response.content if c.type == "tool_use"]
if tool_calls:
tool_response = await anthropic_session.call_tools(tool_calls)
messages.append({"role": "assistant", "content": response.content})
messages.append(tool_response)
# Continue conversation...
asyncio.run(main())
```
### Using Convenience Functions
```python
from metorial_anthropic import build_anthropic_tools, call_anthropic_tools
async def example_with_functions():
# Get tools in Anthropic format
tools = build_anthropic_tools(tool_manager)
# Call tools from Anthropic response
tool_response = await call_anthropic_tools(tool_manager, tool_calls)
```
## API Reference
### `MetorialAnthropicSession`
Main session class for Anthropic integration.
```python
session = MetorialAnthropicSession(tool_manager)
```
**Properties:**
- `tools`: List of tools in Anthropic format
**Methods:**
- `async call_tools(tool_calls)`: Execute tool calls and return user message
### `build_anthropic_tools(tool_mgr)`
Build Anthropic-compatible tool definitions.
**Returns:** List of tool definitions in Anthropic format
### `call_anthropic_tools(tool_mgr, tool_calls)`
Execute tool calls from Anthropic response.
**Returns:** User message with tool results
## Tool Format
Tools are converted to Anthropic's format:
```python
{
"name": "tool_name",
"description": "Tool description",
"input_schema": {
"type": "object",
"properties": {...},
"required": [...]
}
}
```
## Error Handling
```python
try:
tool_response = await anthropic_session.call_tools(tool_calls)
except Exception as e:
print(f"Tool execution failed: {e}")
```
Tool errors are returned as error messages in the response format.
## Dependencies
- `anthropic>=0.40.0`
- `metorial-mcp-session>=1.0.0`
- `typing-extensions>=4.0.0`
## License
MIT License - see [LICENSE](../../LICENSE) file for details.
Raw data
{
"_id": null,
"home_page": null,
"name": "metorial-anthropic",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "ai, anthropic, claude, llm, metorial",
"author": null,
"author_email": "Metorial Team <support@metorial.com>",
"download_url": "https://files.pythonhosted.org/packages/4f/28/643238c179b6e719eb1d2155c2836b60719ed5b6e46a07c1192e30d902cb/metorial_anthropic-1.0.0rc3.tar.gz",
"platform": null,
"description": "# metorial-anthropic\n\nAnthropic (Claude) provider integration for Metorial - enables using Metorial tools with Claude models through Anthropic's tool calling API.\n\n## Installation\n\n```bash\npip install metorial-anthropic\n# or\nuv add metorial-anthropic\n# or\npoetry add metorial-anthropic\n```\n\n## Features\n\n- \ud83e\udd16 **Claude Integration**: Full support for Claude 3.5, Claude 3, and other Anthropic models\n- \ud83d\udee0\ufe0f **Tool Calling**: Native Anthropic tool format support\n- \ud83d\udce1 **Session Management**: Automatic tool lifecycle handling\n- \ud83d\udd04 **Format Conversion**: Converts Metorial tools to Anthropic tool format\n- \u26a1 **Async Support**: Full async/await support\n\n## Usage\n\n### Basic Usage\n\n```python\nimport asyncio\nfrom anthropic import Anthropic\nfrom metorial import Metorial\nfrom metorial_anthropic import MetorialAnthropicSession\n\nasync def main():\n # Initialize clients\n metorial = Metorial(api_key=\"your-metorial-api-key\")\n anthropic = Anthropic(api_key=\"your-anthropic-api-key\")\n \n # Create session with your server deployments\n async with metorial.session([\"your-server-deployment-id\"]) as session:\n # Create Anthropic-specific wrapper\n anthropic_session = MetorialAnthropicSession(session.tool_manager)\n \n messages = [\n {\"role\": \"user\", \"content\": \"What are the latest commits?\"}\n ]\n \n # Remove duplicate tools by name (Anthropic requirement)\n unique_tools = list({t[\"name\"]: t for t in anthropic_session.tools}.values())\n \n response = await anthropic.messages.create(\n model=\"claude-3-5-sonnet-20241022\",\n max_tokens=1024,\n messages=messages,\n tools=unique_tools\n )\n \n # Handle tool calls\n tool_calls = [c for c in response.content if c.type == \"tool_use\"]\n if tool_calls:\n tool_response = await anthropic_session.call_tools(tool_calls)\n messages.append({\"role\": \"assistant\", \"content\": response.content})\n messages.append(tool_response)\n \n # Continue conversation...\n\nasyncio.run(main())\n```\n\n### Using Convenience Functions\n\n```python\nfrom metorial_anthropic import build_anthropic_tools, call_anthropic_tools\n\nasync def example_with_functions():\n # Get tools in Anthropic format\n tools = build_anthropic_tools(tool_manager)\n \n # Call tools from Anthropic response\n tool_response = await call_anthropic_tools(tool_manager, tool_calls)\n```\n\n## API Reference\n\n### `MetorialAnthropicSession`\n\nMain session class for Anthropic integration.\n\n```python\nsession = MetorialAnthropicSession(tool_manager)\n```\n\n**Properties:**\n- `tools`: List of tools in Anthropic format\n\n**Methods:**\n- `async call_tools(tool_calls)`: Execute tool calls and return user message\n\n### `build_anthropic_tools(tool_mgr)`\n\nBuild Anthropic-compatible tool definitions.\n\n**Returns:** List of tool definitions in Anthropic format\n\n### `call_anthropic_tools(tool_mgr, tool_calls)`\n\nExecute tool calls from Anthropic response.\n\n**Returns:** User message with tool results\n\n## Tool Format\n\nTools are converted to Anthropic's format:\n\n```python\n{\n \"name\": \"tool_name\",\n \"description\": \"Tool description\",\n \"input_schema\": {\n \"type\": \"object\",\n \"properties\": {...},\n \"required\": [...]\n }\n}\n```\n\n## Error Handling\n\n```python\ntry:\n tool_response = await anthropic_session.call_tools(tool_calls)\nexcept Exception as e:\n print(f\"Tool execution failed: {e}\")\n```\n\nTool errors are returned as error messages in the response format.\n\n## Dependencies\n\n- `anthropic>=0.40.0`\n- `metorial-mcp-session>=1.0.0`\n- `typing-extensions>=4.0.0`\n\n## License\n\nMIT License - see [LICENSE](../../LICENSE) file for details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Anthropic (Claude) provider for Metorial",
"version": "1.0.0rc3",
"project_urls": {
"Documentation": "https://metorial.com/docs",
"Homepage": "https://metorial.com",
"Repository": "https://github.com/metorial/metorial-enterprise"
},
"split_keywords": [
"ai",
" anthropic",
" claude",
" llm",
" metorial"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "ed7819dadc9657c09dcfcde8150e7705b31b19abd9e103034f9d5248e0f4411f",
"md5": "d80f10cc86ed1ca73fa9e776f0d40687",
"sha256": "b2cba93ec4c44d09920f007707d44158bba44130e55f45bc2abc20dfdc20bcb6"
},
"downloads": -1,
"filename": "metorial_anthropic-1.0.0rc3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d80f10cc86ed1ca73fa9e776f0d40687",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 4863,
"upload_time": "2025-07-26T12:37:19",
"upload_time_iso_8601": "2025-07-26T12:37:19.490472Z",
"url": "https://files.pythonhosted.org/packages/ed/78/19dadc9657c09dcfcde8150e7705b31b19abd9e103034f9d5248e0f4411f/metorial_anthropic-1.0.0rc3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "4f28643238c179b6e719eb1d2155c2836b60719ed5b6e46a07c1192e30d902cb",
"md5": "a39826c52a059fd2831630bced11372d",
"sha256": "c81023b63818d0d8bf125afc9ca2367574944207658e8aaa1e549fa520f2bf57"
},
"downloads": -1,
"filename": "metorial_anthropic-1.0.0rc3.tar.gz",
"has_sig": false,
"md5_digest": "a39826c52a059fd2831630bced11372d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 5786,
"upload_time": "2025-07-26T12:37:20",
"upload_time_iso_8601": "2025-07-26T12:37:20.869607Z",
"url": "https://files.pythonhosted.org/packages/4f/28/643238c179b6e719eb1d2155c2836b60719ed5b6e46a07c1192e30d902cb/metorial_anthropic-1.0.0rc3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-26 12:37:20",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "metorial",
"github_project": "metorial-enterprise",
"github_not_found": true,
"lcname": "metorial-anthropic"
}