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.2.0.tar.gz (9.7 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.2.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mcptrail-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ad7e6e8b5482f3f4c7daf9633f311fb9cd9c92dddb0591c465426059a2dcd0a2
MD5 7e8d3a25a83806cf602450c4dfef7fa4
BLAKE2b-256 f1a28bea4e52089e363f8ed8f376c90ac1a6d15084998ff518ff2f09580bcb82

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mcptrail-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4cc2b03e9586ce743ec6b925b92df7020e4a307492eb63a8bbe51baccb79c867
MD5 4ace1bcdfeeb44efd40a706e8ec71fe7
BLAKE2b-256 efc1ea57a48d970549a5a14a4f29b19834add0adaec98e2ba6c51c23db19c638

See more details on using hashes here.

Provenance

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