Skip to main content

metano-agent-sdk

Instrument a Python AI agent for Metano. The SDK reports session traces, model calls, tool calls and your MCP server inventory, and it enforces guardrail policy at runtime.

It works with LangChain, CrewAI and the OpenAI Agents SDK through adapters that instrument automatically, and with any other framework, or none at all, through the core API.

  • Python ≥ 3.10. The core has no dependencies; framework adapters are optional extras.
  • Apache-2.0
  • Telemetry is fail-open: the SDK never raises into, blocks, or delays your agent. If Metano is unreachable, events are dropped and your agent keeps running.
  • Prompt, response, and tool bodies are not sent in full by default. You get a short excerpt plus a hash. Opt in with capture_content=True.

Install

pip install metano-agent-sdk

Add the extra for your framework:

Extra Installs For
langchain langchain-core recording LangChain and LangGraph runs
langchain-agents langchain 1.x the guardrail middleware for create_agent
crewai crewai 1.x recording and guarding CrewAI crews and flows
openai-agents openai-agents recording and guarding the OpenAI Agents SDK
a2a a2a-sdk carrying session context across agent-to-agent calls
mcp wrapt recording calls made with the official mcp client
pip install 'metano-agent-sdk[langchain]'

Configure

Create an API key on the API Keys page of the Metano portal (requires the Admin role), then set it in your agent's environment:

export METANO_API_KEY=mo_...

That is all a production agent needs. The key names the deployment that issued it, so the SDK works out where to send telemetry on its own.

Quick start

import metano_agent_sdk as metano

metano.init(agent_name="refund-bot")  # API key from $METANO_API_KEY

with metano.session() as s:
    s.prompt("How many refunds are pending?")

    with s.llm_call(model="claude-sonnet-5", provider="anthropic") as call:
        answer = my_llm(...)                         # your real LLM client
        call.usage(tokens_in=18, tokens_out=120)     # feeds cost and token rollups

    with s.tool_call("warehouse.query", kind="mcp", server="warehouse",
                     tool_input={"sql": "select ..."}) as tool:
        tool.output(my_query(...))                   # your real tool call

metano.shutdown()  # flush buffered telemetry before a short-lived process exits

The agent then appears under AI Agents in the portal, marked as an SDK agent, with each session on its timeline.

Always call shutdown()

Telemetry is batched and sent from a background thread so it never slows your agent down. A short-lived process that exits without metano.shutdown() (or await metano.ashutdown()) can lose the events still in its buffer.

Frameworks

Pass your framework to init() and run your agent unchanged:

metano.init(agent_name="research-bot", framework="langchain")
agent.invoke(inputs)            # recorded automatically
metano.init(agent_name="research-bot", framework="crewai")
crew.kickoff(inputs={...})      # recorded and guarded automatically
metano.init(agent_name="research-bot", framework="openai-agents")
agent = Agent(...)              # construct agents AFTER init()
await Runner.run(agent, "...")

For enforcement in a LangChain create_agent agent, add the middleware (langchain-agents extra):

from langchain.agents import create_agent
from metano_agent_sdk.langchain_middleware import MetanoGuardrailMiddleware

agent = create_agent(model=..., tools=[...], middleware=[MetanoGuardrailMiddleware()])

To record tool calls made through the official mcp client (mcp extra):

from metano_agent_sdk.mcp import enable_mcp_capture

enable_mcp_capture()

Environment variables

Variable Purpose
METANO_API_KEY Your Metano API key. Required.
METANO_INGEST_URL Override where telemetry is sent.
METANO_GATEWAY_URL Override the LLM gateway address.
METANO_MCP_GATEWAY_URL Override the MCP gateway address.

Each override is optional; an explicit argument to init() wins over the environment.

Documentation

Full setup guides for each framework, guardrails and the LLM and MCP gateways are in the Metano documentation, linked from the portal's API Keys page.

License

Apache-2.0. See LICENSE and NOTICE.

Metadata

Release files for metano-agent-sdk 0.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metano-agent-sdk 0.7.1
File Size Uploaded Provenance
metano_agent_sdk-0.7.1.tar.gz 122.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for metano-agent-sdk 0.7.1
File Interpreter ABI Platform
metano_agent_sdk-0.7.1-py3-none-any.whl Python 3 none any Details

Total release size: 256.1 kB

Release files / metano_agent_sdk-0.7.1.tar.gz

Download URL metano_agent_sdk-0.7.1.tar.gz
Size 122.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d2575f82e0f178b246790f0d9b50578c3259159e5948baf54f222401c892ecf2
BLAKE2b-256 checksum
How to use checksums
84e8d9a5a3c880e556bcc7198e06ec581cd8da51fc1c86f087899936c241be28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / metano_agent_sdk-0.7.1-py3-none-any.whl

Download URL metano_agent_sdk-0.7.1-py3-none-any.whl
Size 134.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c44dfae21afe36228bf5bacb551246ac6305ef1b1e71a83013f5e8483cc219d2
BLAKE2b-256 checksum
How to use checksums
a936db6b1bae78f133a4b8bb14685272563b8a1c9b6706906d8da3239f71a598
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for metano-agent-sdk 0.7.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Release history Release notifications | RSS feed

This release

0.7.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page