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.1.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.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mcptrail-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 1fc1b200f476db5aed292900e1b06fb85044c38ccc2eb96e242c4d8f8172daa1
MD5 965c088798e31f38eb8d2f5bcb8e3a45
BLAKE2b-256 d911d2fbece2cc8cb12ff75b145878ea4bfc3507cd038b44aa864595a9f2e1f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcptrail-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: mcptrail-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 027c10c1480b58548e4abaa6ed2973dd5f11d96b6e58bc5a711ef8d29223ba0a
MD5 228e0703999b878568a5553ab20398dc
BLAKE2b-256 52d9123a5378cde06513855e20b13aa4d796f78dc22d90578c15eeea8bfa128a

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcptrail-0.1.1-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