Context
During the resolution of the identity binding race condition in #10181 (merged via PR #10182), we successfully implemented a self-heal hook inside ai/mcp/server/memory-core/Server.mjs directly on the CallToolRequestSchema dispatch path. However, we could not add a unit test for this specific logic because simulating the "node added to SQLite after first binding attempt" scenario requires the full MCP Server harness (MCP protocol transport + dispatch path), which no current test exercises.
The Problem
Our current test coverage (e.g., MailboxService.spec.mjs) primarily tests the underlying service logic in isolation, mocking or bypassing the actual MCP transport layer. We currently lack a dedicated test scaffolding that exercises the CallToolRequestSchema dispatch path end-to-end within the unit testing harness. This prevents us from testing transport-layer middleware, dispatch hooks, and context-scoping mechanics reliably.
The Architectural Reality
The ai/mcp/server/*/Server.mjs classes handle the raw MCP protocol. We need a Playwright testing fixture/utility that can stand up an instance of the MCP Server in-memory, mock the Stdio/WebSocket transport streams, and allow test files to dispatch CallToolRequestSchema requests exactly as the IDE/Claude Desktop would.
The Fix
- Create a reusable MCP test harness utility (likely in
test/playwright/unit/ai/mcp/utils/ or similar).
- The harness should instantiate a target
Server class, attach a mock transport, and provide an API for sending JSON-RPC messages and asserting on the responses.
- Implement the first consuming test: migrate or add the scenario from #10181 to verify the
CallToolRequestSchema self-heal logic end-to-end.
Acceptance Criteria
Out of Scope
- We are not replacing existing service-level unit tests.
- We are not building a full E2E system testing against live Claude Desktop instances. This is purely for the Playwright unit testing layer.
Related
- Resolves the missing test AC from #10181
- PR #10182 (shipped the fix that needs this test)
Origin Session ID: 984150f3-3aab-4a25-b623-d6e7472b4dd3
Context During the resolution of the identity binding race condition in #10181 (merged via PR #10182), we successfully implemented a self-heal hook inside
ai/mcp/server/memory-core/Server.mjsdirectly on theCallToolRequestSchemadispatch path. However, we could not add a unit test for this specific logic because simulating the "node added to SQLite after first binding attempt" scenario requires the full MCP Server harness (MCP protocol transport + dispatch path), which no current test exercises.The Problem Our current test coverage (e.g.,
MailboxService.spec.mjs) primarily tests the underlying service logic in isolation, mocking or bypassing the actual MCP transport layer. We currently lack a dedicated test scaffolding that exercises theCallToolRequestSchemadispatch path end-to-end within the unit testing harness. This prevents us from testing transport-layer middleware, dispatch hooks, and context-scoping mechanics reliably.The Architectural Reality The
ai/mcp/server/*/Server.mjsclasses handle the raw MCP protocol. We need a Playwright testing fixture/utility that can stand up an instance of the MCP Server in-memory, mock the Stdio/WebSocket transport streams, and allow test files to dispatchCallToolRequestSchemarequests exactly as the IDE/Claude Desktop would.The Fix
test/playwright/unit/ai/mcp/utils/or similar).Serverclass, attach a mock transport, and provide an API for sending JSON-RPC messages and asserting on the responses.CallToolRequestSchemaself-heal logic end-to-end.Acceptance Criteria
McpTestHarnessutility is created that can instantiate and interact with an MCP server via mocked transport.CallToolRequestSchemapayloads and capturing the results/errors.Server.spec.mjsor similar) is created formemory-corethat successfully uses the harness.Out of Scope
Related
Origin Session ID: 984150f3-3aab-4a25-b623-d6e7472b4dd3