Skip to content

Idempotency keys on MCP write tools so a retried call does not write twice #407

Open

Description

@imshashank

Current status, September 22

Implementation is open in #455, with changes requested because an expired idempotency lease can repeat an already committed write. Keep this open until that retry case is fixed and tested.

Original requirements

The annotation work in #384 exposed that several write tools are honestly not idempotent: update_doc, move_doc and edit_doc_comment assign a fresh sync id and publish another update on every call, and add_comment or create_issue retried after a timeout produce a duplicate. Agents retry. That is the whole reason the hints exist.

What to build

  • Accept an optional idempotencyKey argument on every write tool. Scope it to the grant.
  • Store (grant, key, tool, response hash, response) with a short retention, a day is plenty.
  • A repeated call with the same key and same arguments returns the stored response and performs nothing. Same key with different arguments is refused with a clear error.
  • Document it in docs/mcp.md and in the tool descriptions so a client knows to send one.

Tests

Two create_issue calls with one key create one issue. A retried add_comment posts once. A key reused with different arguments is refused. A key from another grant is a different key.

The table is small and the change touches packages/mcp-server/src/tools/support.ts once, so this is a good self-contained piece for someone who wants to learn the MCP layer.

Activity

  1. added
    enhancement
    help wanted
    ready
    p2 medium
    area: mcp
    size: medium
    points: 5
    schema change
    on Sep 6, 2026
  2. added
    work in progress
    and removed
    help wanted
    ready
    on Sep 22, 2026
  3. github-actions commented on Nov 22, 2026

    @github-actions

    This issue has had no activity for 60 days, so it is being marked stale.

    If it still matters, say so and it stays open. Adding what you have
    learned since filing it helps more than a bump on its own. Otherwise it
    will close in 14 days, and closing is not a judgement, it just keeps the
    list honest about what is actually being worked on. Reopening is always
    fine.

  4. added
    stale
    on Nov 22, 2026
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

    area: mcpenhancementp2 mediumpoints: 5schema changesize: mediumstalework in progress

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions