Skip to content

Workitems MCP tools fail without an explicit session_id in Claude Code #942

Description

@alexeyzimarev

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions