ADR-0039: In-house MCP client conforming to the MCP transports
- **Status:** Proposed - **Date:** 2026-10-25 - **Related:** [ADR-0006](0006-mcp-architecture.md) ("Official MCP SDK + registry pattern"), [ADR-0036](0036-agent-managed-skills-and-mcp-servers.md), [AD
2 min read
This is a migrated reference document from the original Anvio source repo. Content is preserved as-is; canonical documentation lives in the sections above in the sidebar.
Original path: docs/adr/0039-in-house-mcp-client.md
- Status: Proposed
- Date: 2026-10-25
- Related: ADR-0006 ("Official MCP SDK + registry pattern"), ADR-0036, ADR-0037, audit phase 3 finding G-33, post-refactoring fix PR-02
Context
ADR-0006 decided on "Official MCP SDK + registry pattern". The registry pattern was implemented (packages/integrations/src/integration-registry.ts). The client side was not built on the official SDK:
packages/integrations/src/mcp-stdio-client.tsandmcp-http-client.tsare hand-written JSON-RPC clients.@modelcontextprotocol/sdkis a dependency only ofpackages/runtimes(vendor-runtime integration), not ofpackages/integrations.
Being hand-written caused a real defect. The stdio client used Content-Length framing, while the MCP stdio transport is newline-delimited JSON. As a result, no official-SDK server could initialize (audit phase 3 G-33). PR #118 (PR-02) fixed the framing and added an E2E test against a server built with the official SDK (tests/integration/e2e/mcp-approval.e2e.integration.spec.ts, MCP-01..05).
This ADR records the de facto decision so that ADR-0006 does not describe the code incorrectly. It is Proposed: the code matches it, but the owners have not decided whether to keep the in-house client or migrate to the SDK client.
Decision (proposed)
- Keep the in-house stdio and HTTP clients.
- Conformance is defined by the MCP transport specification, not by the SDK. Two things guard it:
- NDJSON framing, with
Content-Lengthframes still accepted for older servers; - the official-SDK E2E fixture.
- NDJSON framing, with
- Any future migration to
@modelcontextprotocol/sdkclient classes must keep theMcpBridgesurface (listTools,callTool,close,invalidate) unchanged.
Consequences
- Protocol drift (new MCP spec revisions) must be tracked manually, so the E2E fixture is the regression guard.
- ADR-0006 receives a reconciliation note pointing here. Its status is not changed until this ADR is accepted or rejected.
Alternatives
- Migrate to the SDK client now. Larger change; fixes drift risk structurally. Not chosen in a documentation-only phase.
Last updated on
ADR-0038: Position Anvio as an extensible multi-agent platform; keep local-by-default deployment
- **Status:** Accepted - **Date:** 2026-10-25 - **Deciders:** Repository owner (stated in the Phase 5 documentation directive) - **Amends:** [ADR-0007](0007-local-first-architecture.md). Only its prod
Architecture Decision Records
ADRs record **why** the architecture is the way it is. Numbers are stable and never reused. A decision that changes gets a new ADR; the old one is marked superseded or amended and keeps its original t