WFDASH-WEBAPP/src/app
SJCoetz fd07b514ab fix(mcp): handle initialize/notifications/initialized/ping handshake
WFDASH /api/mcp previously only handled tools/list and tools/call,
which is fine for our internal curl-based testing but broke every
spec-compliant MCP client (Hermes, Claude Desktop, Cursor, mcp-cli).

The MCP protocol requires a three-step handshake before tools/list:
  1. client → server: initialize
  2. server → client: result with protocolVersion, capabilities, serverInfo
  3. client → server: notifications/initialized (notification, no response)

Before this fix, step 1 got HTTP 404 with error.code -32601, which
MCP clients interpret as 'this isn't an MCP server' and terminate
the session. Symptom: configured servers show 'CONFIGURED' in the
Hermes WebUI but '0 tools', with the runtime logging
'unhandled errors in a TaskGroup ... Session terminated'.

Three new handlers, each with the right response shape:

  initialize          → 200 + plain result {protocolVersion, capabilities, serverInfo}
  notifications/initialized → 204 + empty body (notification, no envelope)
  ping                → 200 + result {}

Critical: the initialize response uses a PLAIN object for result,
not the content/text envelope that our jsonRpcOk helper wraps
tools/list and tools/call results in. Using jsonRpcOk here would
have left the handshake broken in a subtler way.

Four new Vitest cases:
  - initialize returns server info (regression: 2026-08-04)
  - initialize echoes client-provided protocolVersion (forward compat)
  - notifications/initialized returns 204
  - ping returns {}

Bug report with full timeline + lessons: see
docs/bugs/2026-08-04-mcp-initialize-handshake-missing.md
(same commit series; pushed separately as the second commit).

All 46 tests pass.

Co-authored-by: Orca <help@stably.ai>
2026-08-05 01:53:02 +02:00
..
(app) feat(quotes): move completed+all to dedicated /quotes/archive page 2026-08-04 20:25:13 +02:00
(auth) feat: collection-map updates, todays-stops, quote/approval rework, buyer-tasks, e2e 2026-08-03 09:33:45 +02:00
api fix(mcp): handle initialize/notifications/initialized/ping handshake 2026-08-05 01:53:02 +02:00
favicon.ico feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
globals.css feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
layout.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
offline.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
page.tsx feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00