feat: native MCP client support and retire Prolog-RLM backend #136

Merged
lost-rob0t merged 17 commits from feature/mcp-client-support-current into master 2026-08-22 04:01:40 +00:00
lost-rob0t commented 2026-08-22 03:04:10 +00:00 (Migrated from github.com)

What changed

This PR carries Zara's native MCP client implementation onto current master and removes the half-alive Prolog-RLM runtime integration.

MCP client

  • uses the official Model Context Protocol Python SDK v2 (mcp>=2,<3);
  • one async MCPServerActor owns each server session and transport lifecycle;
  • supports stdio and Streamable HTTP;
  • discovers tools, resources, resource templates, and prompts;
  • namespaces MCP tools and registers them in Zara's existing LangChain tool registry;
  • supports capability refresh/list-change subscriptions;
  • bounds connect/request timeouts and propagates cancellation;
  • isolates failed servers and reconnects only for future operations;
  • never automatically replays a possibly effectful failed call;
  • closes actors and child transports during agent/runtime shutdown;
  • adds zara mcp add/remove/enable/disable/list/status/inspect/tools/resources/prompts management commands.

Prolog-RLM retirement

Removed the external/experimental RLM path from Zara while preserving Zara's normal SWI-Prolog command reasoning and console support:

  • removed the prolog-rlm Nix input and lockfile node;
  • removed ZARA_PROLOG_RLM_ROOT / ZARA_RLM_SIDECAR package and dev-shell wiring;
  • removed the selectable prolog_rlm runtime backend; LangGraph is the canonical conversational backend;
  • removed the RLM sidecar, Python backend adapter, live smoke, backend/protocol tests, benchmark, and backend documentation;
  • removed RLM-specific CI gates;
  • added a regression proving a stale agent.backend = prolog_rlm configuration fails closed.

The roadmap separately marks RLM work as not planned for Zara. Plain Prolog remains part of Zara.

Adversarial verification

The MCP test corpus includes real local stdio and Streamable HTTP fixture servers, multi-server namespacing/isolation, discovery and execution, crash/reconnect behavior, timeout and caller cancellation, child-process reaping, config validation, diagnostics redaction, and Agent -> normal tool-loop integration.

MCP and httpx2 are hard E2E test dependencies rather than importorskip escape hatches, and failure-path tests require Zara's typed MCPRequestError instead of accepting arbitrary exceptions.

A review found that literal MCP header/environment secrets could be persisted to mcp.toml with umask-dependent permissions. The managed config writer now forces mode 0600 on creation and every rewrite, with a regression test that first loosens the file to 0644 and verifies Zara repairs it.

Exact-head GitHub Actions plus the packaged Nix build are required before merge.

Non-goals

  • no MCP server implementation in Zara;
  • no legacy HTTP+SSE transport for new MCP servers;
  • no second tool registry;
  • no automatic replay of failed MCP effects;
  • no RLM runtime/backend in Zara.
## What changed This PR carries Zara's native MCP client implementation onto current `master` and removes the half-alive Prolog-RLM runtime integration. ### MCP client - uses the official Model Context Protocol Python SDK v2 (`mcp>=2,<3`); - one async `MCPServerActor` owns each server session and transport lifecycle; - supports stdio and Streamable HTTP; - discovers tools, resources, resource templates, and prompts; - namespaces MCP tools and registers them in Zara's existing LangChain tool registry; - supports capability refresh/list-change subscriptions; - bounds connect/request timeouts and propagates cancellation; - isolates failed servers and reconnects only for future operations; - never automatically replays a possibly effectful failed call; - closes actors and child transports during agent/runtime shutdown; - adds `zara mcp` add/remove/enable/disable/list/status/inspect/tools/resources/prompts management commands. ### Prolog-RLM retirement Removed the external/experimental RLM path from Zara while preserving Zara's normal SWI-Prolog command reasoning and console support: - removed the `prolog-rlm` Nix input and lockfile node; - removed `ZARA_PROLOG_RLM_ROOT` / `ZARA_RLM_SIDECAR` package and dev-shell wiring; - removed the selectable `prolog_rlm` runtime backend; LangGraph is the canonical conversational backend; - removed the RLM sidecar, Python backend adapter, live smoke, backend/protocol tests, benchmark, and backend documentation; - removed RLM-specific CI gates; - added a regression proving a stale `agent.backend = prolog_rlm` configuration fails closed. The roadmap separately marks RLM work as not planned for Zara. Plain Prolog remains part of Zara. ## Adversarial verification The MCP test corpus includes real local stdio and Streamable HTTP fixture servers, multi-server namespacing/isolation, discovery and execution, crash/reconnect behavior, timeout and caller cancellation, child-process reaping, config validation, diagnostics redaction, and Agent -> normal tool-loop integration. MCP and `httpx2` are hard E2E test dependencies rather than `importorskip` escape hatches, and failure-path tests require Zara's typed `MCPRequestError` instead of accepting arbitrary exceptions. A review found that literal MCP header/environment secrets could be persisted to `mcp.toml` with umask-dependent permissions. The managed config writer now forces mode `0600` on creation and every rewrite, with a regression test that first loosens the file to `0644` and verifies Zara repairs it. Exact-head GitHub Actions plus the packaged Nix build are required before merge. ## Non-goals - no MCP server implementation in Zara; - no legacy HTTP+SSE transport for new MCP servers; - no second tool registry; - no automatic replay of failed MCP effects; - no RLM runtime/backend in Zara.
Sign in to join this conversation.
No description provided.