Skip to main content

Python SDK for agent-mesh — governance mesh for AI agent tool calls

Project description

agent-mesh Python SDK

Governance mesh for AI agent tool calls. Wraps any Python function with policy enforcement, human approval, and tracing via agent-mesh.

Install

pip install agent-mesh
pip install agent-mesh[anthropic]  # with Claude API support

Quick start

Direct client

from agent_mesh import AgentMesh

mesh = AgentMesh("http://localhost:9090", agent="my-agent")

# Check what's available
tools = mesh.tools()
health = mesh.health()

# Policy check only (POST /decide) — no execution
decision = mesh.decide("filesystem.write_file", {"path": "/tmp/x"})
print(decision.action)  # allow | deny | human_approval

# Full proxy (POST /tool/{name}) — policy + execute + trace
decision = mesh.call_tool("filesystem.read_file", {"path": "/tmp/data.txt"})
print(decision.result)

# Manage grants
mesh.create_grant("filesystem.*", "30m")
mesh.revoke_grant("grant-id")

GovernedToolkit (Claude API)

from agent_mesh import GovernedToolkit

toolkit = GovernedToolkit(agent="my-agent")

@toolkit.tool
def get_weather(city: str) -> str:
    """Get current weather for a city."""
    return fetch_weather(city)

@toolkit.tool
def send_email(to: str, subject: str, body: str) -> str:
    """Send an email."""
    return smtp_send(to, subject, body)

# Generate tools[] for Claude API
schemas = toolkit.schemas()

# Process tool_use blocks with governance
response = client.messages.create(model="claude-sonnet-4-6", tools=schemas, ...)
results = toolkit.process_response([b.model_dump() for b in response.content])

The toolkit:

  1. schemas() — generates the tools[] array from Python function signatures
  2. process_response() — intercepts tool_use blocks, checks policy via agent-mesh, executes locally if allowed
  3. execute() — single tool call with governance

Prerequisites

agent-mesh daemon running:

agent-mesh serve --config config.yaml

API

AgentMesh(url, agent, timeout)

Method Description
decide(name, args) Evaluate policy without executing
call_tool(name, args) Execute tool through governance (proxy)
tools() List available tools
approvals() List pending approvals
approve(id) / deny(id) Resolve approval
grants() List active grants
create_grant(tools, duration) Create temporal grant
health() / is_healthy() Check mesh status

GovernedToolkit(agent, url)

Method Description
@toolkit.tool Decorator to register a function
schemas() Generate Claude API tools array
execute(name, input) Governed execution
process_response(content) Process Claude response blocks

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flux7_mesh-0.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flux7_mesh-0.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file flux7_mesh-0.1.0.tar.gz.

File metadata

  • Download URL: flux7_mesh-0.1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for flux7_mesh-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a03b42513b84642c7fa4c8b64d966b1f7b69482d2df7ad2d7128561f8bfba444
MD5 3a205fd62553ae3a99ee0138e8726647
BLAKE2b-256 2ec46c52dee3c338137e0f556e15265c4a0082e65fe8f39afd1387c89be218b3

See more details on using hashes here.

File details

Details for the file flux7_mesh-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: flux7_mesh-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for flux7_mesh-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 046778f5d30a41dfa24cbb1db16943756d60f6cb721046cd6c9e3c41b00d715c
MD5 387dd35e569729c89524fa9b1871dbd0
BLAKE2b-256 d09931ba498d43549eec2746217a1c15e8356ddf928e36ea04d1f2d988a77eb0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page