Skip to main content

pi-mcp-py

An extension for zycode. It connects the MCP servers that an ACP client (an editor such as Zed) passes to the agent, and gives their tools to the model.

The agent itself has no MCP client. Without this package, the servers that the editor passes are not connected, and the agent says so. With it, the agent connects them.

Install it into the environment of the agent:

pip install pi-mcp-py

The package is on PyPI from the 0.6.0 release of pi-python. In a checkout of the repository, use pip install -e ./packages/pi-mcp.

Nothing else to set up. The servers come from the editor (Zed: context_servers in the settings). It needs pi-agent-core-lc 1.2.0 or later: the extensions are released with the core, so the floor of the package is the release it ships with. A core older than 0.6.0 does not hand over the servers of the client, and then the package logs a warning and does nothing.

What it does

  • Connects stdio, http (Streamable HTTP) and sse servers. One connection for each server and session. A server that does not start does not stop the session, nor the other servers.
  • Gives each tool to the model as mcp__<server>__<tool>. The prefix keeps an MCP tool from replacing a built-in tool of the same name. A name longer than 64 characters is cut and gets a hash at the end.
  • Tells the user when a server fails to start or is slow. It says nothing when all is well.
  • Connects a server again when it has stopped: the next tool call does it, at most 3 times in a row (a call that gets an answer starts the count again). A call that was already sent when the server died is not sent again, because the server may have run it. It fails with the reason.
  • /mcp shows the servers, their state and the number of tools. /mcp reconnect <name> connects one again, with no limit.
  • Ends every server process when the session ends (Windows and Linux).
  • Limits: a server may take 60 s to start and a call 120 s (see Settings). The first turn waits at most 10 s for a server that still starts. A tool result of more than 50 KB of text is cut, and a note says so.

Things to know

  • Permissions. A tool call is asked about in the ask mode of the CLI, unless the server marks the tool with a hint that says it is harmless (readOnlyHint). The hints are taken as the server gives them: you chose the server.
  • Environment of a stdio server. It gets the safe list of the MCP SDK, the proxy and certificate variables of the agent (HTTP_PROXY, SSL_CERT_FILE, ...), and the env of the editor. It does not get the other variables of the agent, the LLM keys among them. ${VAR} in a value is not expanded.
  • Secrets. The env, headers, args and url of a server are not written to a log, a notice, the /mcp output or an error text.
  • Logs. The stderr of a stdio server goes to <PI_HOME>/logs/mcp/<name>.log (PI_HOME is ~/.pi-python when it is not set). The file is appended to, and started over when it is larger than 512 KB. The text of the file is what the server wrote: it may hold what the server was given.
  • Servers on this machine. An http or sse server at localhost, 127.0.0.1 or ::1 is reached directly, not through the proxy of the system (httpx would send it there).
  • Not supported: MCP resources, prompts, sampling, roots, elicitation, OAuth, tools/list_changed, websocket servers.

Settings

Environment variables only:

Variable Default Meaning
PI_MCP_STARTUP_TIMEOUT 60 Seconds a server may take to start. Then it counts as failed.
PI_MCP_CALL_TIMEOUT 120 Seconds a tool call may take.
PI_MCP_EXPOSURE auto Tool exposure mode: auto (defer when codemode/tool_search is active and [codemode] defer_mcp is enabled), direct, or deferred (falls back to direct if no discovery tool is active).

The design is in docs/specs/2026-10-23-mcp-extension-design.md of the repository.

Metadata

Release files for pi-mcp-py 1.2.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 pi-mcp-py 1.2.0
File Size Uploaded Provenance Actions
pi_mcp_py-1.2.0.tar.gz 41.8 kB Without provenance Details for pi_mcp_py-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pi-mcp-py 1.2.0
File Interpreter ABI Platform Actions
pi_mcp_py-1.2.0-py3-none-any.whl Python 3 none any Details for pi_mcp_py-1.2.0-py3-none-any.whl

Total release size: 65.4 kB

Release files / pi_mcp_py-1.2.0.tar.gz

Download URL pi_mcp_py-1.2.0.tar.gz
Size 41.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5927054de94d2d9f364e15c3a336aab363806d91d31cb23c54e657c8370824f2
BLAKE2b-256 checksum
How to use checksums
4a43ac8302d11992dc3f3288b98fb7752c1915c0ad8f66010a898e54e204b04c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pi_mcp_py-1.2.0-py3-none-any.whl

Download URL pi_mcp_py-1.2.0-py3-none-any.whl
Size 23.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a38c4b5657297d1119efc50e2c1dc907b3bbea96dfe396dbe4b0c7c0dc0dae6a
BLAKE2b-256 checksum
How to use checksums
9f353b914264fa92e45ab87d41909e16bb6dd1bd2e40591d32e44c9393e35c05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for pi-mcp-py 1.2.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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