Skip to content

Commit 8681e57

Browse files
piero-dev25claude
andcommitted
fix(mcp): register toolkits via registerToolkit (outer McpServer), not self-providing McpServer.toolkit
Root-cause (confirmed at effect source): McpServer.toolkit(x) = Layer.effectDiscard(registerToolkit(x)).pipe(Layer.provide(McpServer.layer)) (effect McpServer.js:951) — it SELF-PROVIDES its own McpServer.layer, so each declarative toolkit registration (preview + generation, incl. generate_3d) registers into a throwaway McpServer the HTTP transport (layerHttp) never serves. The fork's /mcp then exposes an empty tools/list and no harness tool reaches agents. Switch both declarative registrations to `Layer.effectDiscard(McpServer.registerToolkit(x))` — which leaves McpServer an OUTER requirement, discharged from the transport's served instance via the existing `Layer.provideMerge(McpTransportLive)` — matching the manual registerPreviewSnapshot/registerInspectGeneration registrations. STATUS: necessary + correct (all 79 MCP unit tests still pass, tsgo clean), but NOT yet confirmed sufficient LIVE — the one desktop re-test was a flaky no-harness-connection turn and a direct /mcp tools/list probe couldn't catch a live agent. A deeper memo-fork (ancestor-provide of a single McpServer across transport+registrations) may still be required, plus a PRODUCTION-topology test (build the real McpHttpServer.layer, assert the served server lists generate_3d) — the existing McpHttpServer.test.ts builds an ancestor-McpServer topology, NOT the production provideMerge(layerHttp) one, which is exactly why this shipped undetected. Tracked in task pingdotgg#155. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01AJELkERZpuwwe4zS4iXj27
1 parent 5d4955d commit 8681e57

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

‎apps/server/src/mcp/McpHttpServer.ts‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,19 @@ const registerPreviewSnapshot = Effect.fn("McpHttpServer.registerPreviewSnapshot
219219
});
220220
});
221221

222-
const PreviewStandardToolkitRegistrationLive = McpServer.toolkit(PreviewStandardToolkit).pipe(
223-
Layer.provide(PreviewStandardToolkitHandlersLive),
224-
);
222+
// Use `McpServer.registerToolkit` (leaves `McpServer` an OUTER requirement,
223+
// discharged from the transport's served instance via `Layer.provideMerge(
224+
// McpTransportLive)` below) — NOT `McpServer.toolkit`, which self-provides its
225+
// OWN `McpServer.layer` (effect McpServer.ts:951: `toolkit = t =>
226+
// effectDiscard(registerToolkit(t)).pipe(provide(McpServer.layer))`). With
227+
// `toolkit`, the tools register into a throwaway McpServer instance that the
228+
// HTTP transport never serves, so `/mcp` returns an EMPTY tools/list and NO
229+
// harness tool (preview or generation) reaches any agent. Matches the manual
230+
// `registerPreviewSnapshot`/`registerInspectGeneration` registrations, which
231+
// already correctly require the outer McpServer.
232+
const PreviewStandardToolkitRegistrationLive = Layer.effectDiscard(
233+
McpServer.registerToolkit(PreviewStandardToolkit),
234+
).pipe(Layer.provide(PreviewStandardToolkitHandlersLive));
225235

226236
const PreviewSnapshotRegistrationLive = Layer.effectDiscard(registerPreviewSnapshot()).pipe(
227237
Layer.provide(PreviewSnapshotToolkitHandlersLive),
@@ -385,9 +395,11 @@ const registerInspectGeneration = Effect.fn("McpHttpServer.registerInspectGenera
385395
},
386396
);
387397

388-
const GenerationStandardToolkitRegistrationLive = McpServer.toolkit(GenerationStandardToolkit).pipe(
389-
Layer.provide(GenerationStandardToolkitHandlersLive),
390-
);
398+
// registerToolkit (outer McpServer), NOT McpServer.toolkit (self-provides a
399+
// throwaway instance) — see PreviewStandardToolkitRegistrationLive's comment.
400+
const GenerationStandardToolkitRegistrationLive = Layer.effectDiscard(
401+
McpServer.registerToolkit(GenerationStandardToolkit),
402+
).pipe(Layer.provide(GenerationStandardToolkitHandlersLive));
391403

392404
/** Exported (not just used by `GenerationToolkitRegistrationLive` below) so
393405
* `registerInspectGeneration`'s own image-block-assembly/degrade-on-failure

0 commit comments

Comments
 (0)