Skip to main content

Prism MCP for Python

Consuming Model Context Protocol servers as Prism tools, across an explicit trust boundary. The Python port of particle-academy/prism-mcp.

Zero runtime dependencies. Python 3.10+.

pip install prism-ai-mcp
from prism_mcp import Client, TrustPolicy

docs = Client(
    "docs",
    my_transport,
    trust=TrustPolicy.allowing(["search"], pins={"search": "sha256:3f1c…"}),
)

tools = docs.list_tools()
result = docs.call_tool(tools[0], {"query": "rate limits"})

print(result.text)

my_transport is a callable that sends a TransportRequest (method, params, headers) to the server and returns the decoded result. The package opens no connections itself.

Trust

A tool list is not data the model summarises; it is instructions the model follows. So nothing is offered until you say what you trust.

  • TrustPolicy.undeclared() is the default. list_tools() raises server_not_trusted instead of returning the server's tools.
  • TrustPolicy.allowing([...]) offers only the named tools. allowing([]) is a declaration too, and offers nothing.
  • TrustPolicy.allowing_every_tool() offers every tool, including ones the server adds later.
  • Pins. Pass pins={name: digest}. ToolDefinition.digest() covers the tool's name, title, description and input schema, so a server that rewrites a description after you trusted it is refused with tool_definition_changed.

A gate callable (server, tool, arguments) -> bool is asked before every call; returning False raises tool_denied. The default allows every call that trust admitted, and deny_all refuses them all.

Results

Every result passes through a ResultGuard before it reaches you:

  • A result over max_bytes (65,536 by default) raises result_too_large instead of being truncated.
  • The text is wrapped in an <untrusted-tool-output> tag with a random id per result, so the server's output cannot close the wrapper.
  • A filter callable (server, tool, text) -> text runs before framing, if you pass one.

The wrapper makes a prompt injection harder. It does not make one impossible, and the guard does not scan the text for injection strings.

Mirrored parameters

A tool's schema can mark an argument with x-mcp-header, which copies the model's value into an Mcp-Param-* request header. A tool whose annotations break the rules (an invalid header name, two arguments mirrored to the same header) is left out of list_tools() rather than repaired.

Protocol

The client speaks MCP 2026-07-28, the stateless revision. Earlier revisions open with an initialize handshake and a session, which this client does not implement. is_stateless_protocol(version) tells the two apart.

Errors

Every failure is an McpError with a stable code: server_not_trusted, tool_definition_changed, tool_denied, result_too_large, mirrored_parameter_refused, unsupported_protocol_version, protocol_failure, tool_call_failed, server_not_configured.

Parity

prism-parity's mcp-tool-digest corpus pins tool digests against the PHP reference and the TypeScript port, so a pin computed in one language holds in the others.

One case is not in that corpus: a schema containing an integral float such as 1.0 digests differently here than in PHP and TypeScript. For such a tool, compute the pin in Python.

License

MIT. See LICENSE.

Release files for prism-ai-mcp 0.1.0

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

Source distribution (sdist)

Source distribution for prism-ai-mcp 0.1.0
File Size Uploaded
prism_ai_mcp-0.1.0.tar.gz 11.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for prism-ai-mcp 0.1.0
File Interpreter ABI Platform
prism_ai_mcp-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.8 kB

Release files / prism_ai_mcp-0.1.0.tar.gz

Download URL prism_ai_mcp-0.1.0.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
45b22e793908b2eac36397fe0d9ddbd9951da8d1d34eae8c606bb3c86eeacdcd
BLAKE2b-256 checksum
How to use checksums
69b232f4362d2fbad042dae3f016fd28b79ad475acef96c6e744567c78b4e67b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release files / prism_ai_mcp-0.1.0-py3-none-any.whl

Download URL prism_ai_mcp-0.1.0-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
241825953cb6b505d0c827eec1563699998adf31c8060f049e774269e6f9549c
BLAKE2b-256 checksum
How to use checksums
5d498d8f724b1d2f6437daada42d625f8d5830c7709eb41d6d9ce4a4dd113b97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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