Skip to main content

Python SDK for the MCP Trail management API (/api/v1).

Project description

mcptrail (Python SDK)

Python SDK for the MCP Trail management API (/api/v1) — govern guardian servers and policies as code. Runtime-dependency-free (stdlib only).

Install

pip install mcptrail

Usage

from mcptrail import McpTrailClient, McpProxyClient

# Token resolution: explicit token=... -> MCPTRAIL_TOKEN env.
# base_url defaults to the cloud; set it when self-hosting.
client = McpTrailClient(token="mg_mgmt_...")

# Provision a server (bearer token is returned ONCE)
created = client.servers.create(
    display_name="GitHub",
    slug="github",
    upstream_mcp_url="https://api.githubcopilot.com/mcp",
)

# Policy as code
client.servers.set_tool_policy("github", "delete_repository", "hitl")
client.servers.set_dlp_mode("github", "block")

# Read audit, resolve approvals
page = client.audit.list(scope="github", limit=100)
for pending in client.hitl.list():
    client.hitl.resolve(pending.id, "approve")

Calling a guarded tool (data plane)

proxy = McpProxyClient(slug="github", token="mg_live_...")  # per-server token
result = proxy.call_tool("get_issue", {"number": 42})

Tokens

  • Servers / CI: mint a scoped management API key in the dashboard (/dashboard/api-keys); pass as token= or MCPTRAIL_TOKEN. Data-plane calls use the per-server token (MCPTRAIL_PROXY_TOKEN).
  • Errors raise McpTrailApiError (status/code) or, for the proxy, McpProxyError (JSON-RPC code).

Mirrors @mcptrail/sdk and is generated against openapi/mcptrail.yaml.

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

mcptrail-0.1.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

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

mcptrail-0.1.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mcptrail-0.1.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mcptrail-0.1.0.tar.gz
Algorithm Hash digest
SHA256 73bc53b6526906455b1241368a0fbd72542f806be4651ea1a33c9e8b6e515ac1
MD5 5775799a3084f92ace4fe39526c588c2
BLAKE2b-256 b96ae1a1ad0179bdf606080eb3f2958aad3dd7a131e48f48c2638170974a0017

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcptrail-0.1.0.tar.gz:

Publisher: sdk-publish.yml on Blabigo/mcp-guard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: mcptrail-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mcptrail-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3f8004e0576acf5e47f3679e85623302e657f1f4240230b39a597b07288be69a
MD5 3a4ab1b39f11f9ca0076cedceaf8f948
BLAKE2b-256 6c6a98136cc1c525794666d2475522d3cedd4286096af64528265c4cca457ca6

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcptrail-0.1.0-py3-none-any.whl:

Publisher: sdk-publish.yml on Blabigo/mcp-guard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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