Cut
Shrink the MCP server module by generating tool input schemas from the zod schemas already defined in the same file, and by rendering each result shape once.
Findings
- shrink: about 700 lines of hand-written JSON Schema in
MCP_TOOL_DEFINITIONS (src/interfaces/mcp/server.ts:389) restate the zod schemas defined 250 lines above. zod is ^4.6.5, so keep the name / description / annotations table and generate inputSchema with z.toJSONSchema(Schema). Compare the generated schema against the hand-written one for every tool before deleting (a snapshot test that fails on drift is acceptable), and keep any description strings the zod schemas lack by adding .describe() to them.
- shrink:
formatReflectXml and printReflectResult render the same ReflectResult twice, and the explore result is formatted inline in two more places (src/interfaces/mcp/server.ts:1993). One renderer with a format switch (~120 lines).
- shrink:
extractSessionId regex-scrapes the session id back out of the XML this process just serialised (src/interfaces/mcp/dispatch.ts:131). Return it on ToolResult instead (~10 lines).
- shrink: worker-pool knobs never tuned in production:
hangMultiplier, readyTimeoutMs, generation counters, three custom Error classes, finishInflight(slot) whose slot is void-ed, respawn(reason) whose reason is void-ed (src/interfaces/mcp/worker-pool.ts:56, ~90 lines). Keep the timeout plus respawn-on-exit; keep the 2x-timeout kill documented in CLAUDE.md.
Verification
npm run build and npm run test:run green before and after. tests/interfaces/mcp/tool-schemas*.test.ts (or equivalent) proves every tool's generated inputSchema is equivalent to the previous hand-written one. The Hermes plugin checker (interfaces/hermes-plugin/tests) still sees 16 tools.
Cut
Shrink the MCP server module by generating tool input schemas from the zod schemas already defined in the same file, and by rendering each result shape once.
Findings
MCP_TOOL_DEFINITIONS(src/interfaces/mcp/server.ts:389) restate the zod schemas defined 250 lines above. zod is^4.6.5, so keep the name / description / annotations table and generateinputSchemawithz.toJSONSchema(Schema). Compare the generated schema against the hand-written one for every tool before deleting (a snapshot test that fails on drift is acceptable), and keep anydescriptionstrings the zod schemas lack by adding.describe()to them.formatReflectXmlandprintReflectResultrender the sameReflectResulttwice, and the explore result is formatted inline in two more places (src/interfaces/mcp/server.ts:1993). One renderer with a format switch (~120 lines).extractSessionIdregex-scrapes the session id back out of the XML this process just serialised (src/interfaces/mcp/dispatch.ts:131). Return it onToolResultinstead (~10 lines).hangMultiplier,readyTimeoutMs, generation counters, three custom Error classes,finishInflight(slot)whoseslotisvoid-ed,respawn(reason)whosereasonisvoid-ed (src/interfaces/mcp/worker-pool.ts:56, ~90 lines). Keep the timeout plus respawn-on-exit; keep the 2x-timeout kill documented inCLAUDE.md.Verification
npm run buildandnpm run test:rungreen before and after.tests/interfaces/mcp/tool-schemas*.test.ts(or equivalent) proves every tool's generatedinputSchemais equivalent to the previous hand-written one. The Hermes plugin checker (interfaces/hermes-plugin/tests) still sees 16 tools.