Repository navigation
Commit 34c11d9
authored
feat(extensions): give extensions the MCP servers a client passes, a way to tell the user, and turn barriers (#35)
The agent still has no MCP client and does not read mcp.json. The user chose
an optional extension package (pi-mcp-py) that connects the servers a client
passes in session/new, session/load and session/resume. Core, harness and CLI
only get the data and the hooks that such an extension needs.
Data and hooks:
- ClientMcpServer (pi_agent_core.extensions): one server as plain data. The
fields that can hold a token (command, args, env, url, headers) are
repr=False.
- ExtensionAPI.client_mcp_servers and claim_client_mcp_servers(names).
AgentHarness.set_client_mcp_servers() takes the list before the extensions
load; unclaimed_client_mcp_servers says which servers nobody took over.
- ExtensionAPI.notify(text) shows one line to the user (NoticeEvent, an agent
message in ACP). The model does not see it and the session does not save it.
- ExtensionAPI.register_cleanup(callback): the public name of what the bridge
already had.
- ExtensionAPI.add_turn_barrier(wait): the harness awaits it before it builds
the tool list of a turn. A wait that is cancelled leaves the phase idle.
- HarnessBridge has four more members; test doubles must add them.
CLI:
- client_mcp.py turns the ACP models into records and hands them to the harness
on session/new, load, resume and the reopen of a blank session.
- The notice about ignored MCP servers names only the servers nobody claimed,
and its text is correct for one server and for many. With the pi-mcp entry
point installed it does not tell the user to install anything.
- initialize offers http and sse servers only when the pi-mcp entry point is
installed (package metadata only; nothing is imported). The wire shape is the
same as before when it is not.
- A line from notify() waits until the deferred setup has advertised the
commands (the client drops earlier updates, zed#60199), then goes out in order.
- prompt() waits for the turn barriers and lets session/cancel, closing the
session and opening it again end the wait.
Fix: a session that the client opened again (a second session/load, Zed's
Retry) built a new harness and dropped the old one without close(), so the
cleanup callbacks of its extensions never ran. The new harness now replaces
the old one first, and the old one is closed.
Design: docs/specs/2026-10-23-mcp-extension-design.md1 parent fa4887b commit 34c11d9
21 files changed
Lines changed: 2610 additions & 99 deletions
File tree
- docs/specs
- packages
- pi-agent-cli
- pi_agent_cli
- tests
- pi-agent-harness
- pi_agent_harness
- tests
- pi-dynamic-workflows/tests
- pi_agent_core
- extensions
- tests
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
682 | 682 | | |
683 | 683 | | |
684 | 684 | | |
685 | | - | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
686 | 688 | | |
687 | 689 | | |
688 | 690 | | |
| |||
691 | 693 | | |
692 | 694 | | |
693 | 695 | | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
694 | 701 | | |
695 | 702 | | |
696 | 703 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
66 | 75 | | |
67 | 76 | | |
68 | 77 | | |
| |||
115 | 124 | | |
116 | 125 | | |
117 | 126 | | |
118 | | - | |
| 127 | + | |
| 128 | + | |
119 | 129 | | |
120 | 130 | | |
121 | 131 | | |
| |||
0 commit comments