Metorial Python SDK - Core
The core package for the official Python SDK for Metorial - Connect your AI agents to any MCP server with a single line of code.
Sign up for a free account to get started.
Installation
pip install metorial
Quick Start
pip install metorial anthropic
import asyncio
from metorial import Metorial, MetorialAnthropic
from anthropic import AsyncAnthropic
metorial = Metorial(api_key="your-metorial-api-key")
anthropic = AsyncAnthropic(api_key="your-anthropic-api-key")
async def main():
async def session_handler(session):
messages = [{"role": "user", "content": "What's the latest news on Hacker News?"}]
for _ in range(10):
response = await anthropic.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
messages=messages,
tools=session["tools"]
)
tool_calls = [b for b in response.content if b.type == "tool_use"]
if not tool_calls:
print(response.content[0].text)
break
tool_responses = await session["callTools"](tool_calls)
messages.append({"role": "assistant", "content": response.content})
messages.append(tool_responses)
await session["closeSession"]()
await metorial.with_provider_session(
MetorialAnthropic,
{"serverDeployments": [{"serverDeploymentId": "your-server-deployment-id"}]},
session_handler
)
asyncio.run(main())
Session Options
Streaming Mode
When using streaming with tool calls, enable the streaming flag:
await metorial.with_provider_session(
metorial_provider,
{
"serverDeployments": [...],
"streaming": True, # Required for streaming with tool calls
},
session_handler
)
Closing Sessions
Always close your session when done to free up resources:
async def session_handler(session):
tools = session["tools"]
close_session = session["closeSession"]
# Use tools...
# When finished, close the session
await close_session()
Session Object
The session object passed to your callback provides:
async def session_handler(session):
tools = session["tools"] # Tool definitions formatted for your provider
call_tools = session["callTools"] # Execute tools and get responses
close_session = session["closeSession"] # Close the session when done (always call this!)
Error Handling
from metorial import MetorialAPIError
try:
await metorial.with_provider_session(...)
except MetorialAPIError as e:
print(f"API Error: {e.message} (Status: {e.status})")
except Exception as e:
print(f"Unexpected error: {e}")
License
MIT License - see LICENSE file for details.
Support
Metadata
Release files for metorial-core 1.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| metorial_core-1.0.12.tar.gz | 32.0 kB | With provenance | Details for metorial_core-1.0.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| metorial_core-1.0.12-py3-none-any.whl | Python 3 | none | any | Details for metorial_core-1.0.12-py3-none-any.whl |
Total release size: 78.5 kB
Release files / metorial_core-1.0.12.tar.gz
| Download URL | metorial_core-1.0.12.tar.gz |
|---|---|
| Size | 32.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1b787124b41edcb1f632d5e7d1e6256cc41739f50ba1386a029f5a4281624905
|
|
BLAKE2b-256 checksum How to use checksums |
5021bf6dd5225e3347de4d877871afe69204c49d2fc7067c3a735fdbde475e94
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 23, 2025.
Transparency logRelease files / metorial_core-1.0.12-py3-none-any.whl
| Download URL | metorial_core-1.0.12-py3-none-any.whl |
|---|---|
| Size | 46.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1f5ed3e080133141193783ec39e52672476a396d6985275f9497d214416a66ca
|
|
BLAKE2b-256 checksum How to use checksums |
f51397eb25fd02b4961eb9c83d076b33ba0d8e0a26ee1b3401065bef5b3a9370
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 23, 2025.
Transparency logSecurity for metorial-core 1.0.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for metorial_core-1.0.12.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 23, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.