Calling any kcap-workitems MCP tool without session_id inside a hooked Claude Code session fails with:
No session id: pass session_id explicitly or run inside a kcap-hooked session (KCAP_SESSION_ID or CODEX_THREAD_ID).
The session is hooked and recorded, so the message reads as a hook failure. It is not:
- The SessionStart hook exports
KCAP_SESSION_ID into CLAUDE_ENV_FILE, which Claude Code applies only to Bash tool invocations.
- MCP servers are spawned once at startup from Claude Code's own environment and never see that file. Checked with
ps -E on a live kcap mcp workitems process: it carries CLAUDE_CODE_SESSION_ID and CLAUDE_PROJECT_DIR but no KCAP_SESSION_ID.
McpWorkItemsServer.ResolveSessionId reads only KCAP_SESSION_ID / CODEX_THREAD_ID, so in Claude Code the ambient path can never succeed. If KCAP_SESSION_ID happens to be exported in the shell that launched Claude Code, the server silently attaches the parent session instead.
HarnessRequesterContext already resolves the session from CLAUDE_CODE_SESSION_ID with the nested-harness guard, but only the flows MCP server uses it.
Fix: make the workitems server fall back to HarnessRequesterContext, and correct the tool descriptions and error text that promise a KCAP_SESSION_ID default.
Seen in session 9cf9a3fb37e94d3fb226dbd7b464d2aa; reproduced in 6b311e86378e41d3863421b7288897e6.
Calling any kcap-workitems MCP tool without
session_idinside a hooked Claude Code session fails with:The session is hooked and recorded, so the message reads as a hook failure. It is not:
KCAP_SESSION_IDintoCLAUDE_ENV_FILE, which Claude Code applies only to Bash tool invocations.ps -Eon a livekcap mcp workitemsprocess: it carriesCLAUDE_CODE_SESSION_IDandCLAUDE_PROJECT_DIRbut noKCAP_SESSION_ID.McpWorkItemsServer.ResolveSessionIdreads onlyKCAP_SESSION_ID/CODEX_THREAD_ID, so in Claude Code the ambient path can never succeed. IfKCAP_SESSION_IDhappens to be exported in the shell that launched Claude Code, the server silently attaches the parent session instead.HarnessRequesterContextalready resolves the session fromCLAUDE_CODE_SESSION_IDwith the nested-harness guard, but only the flows MCP server uses it.Fix: make the workitems server fall back to
HarnessRequesterContext, and correct the tool descriptions and error text that promise aKCAP_SESSION_IDdefault.Seen in session 9cf9a3fb37e94d3fb226dbd7b464d2aa; reproduced in 6b311e86378e41d3863421b7288897e6.