Skip to content

feat: coupon tools in the stdio MCP server, behind their own agent key - #54

Draft
sonpiaz wants to merge 1 commit into
mainfrom
feat/mcp-coupon-tools
Draft

sonpiaz wants to merge 1 commit into
mainfrom
feat/mcp-coupon-tools

Conversation

@sonpiaz

@sonpiaz sonpiaz commented Oct 19, 2026

Copy link
Copy Markdown
Member

What

Unit G3 of the BTO coupon dogfood spec (R7, Codex + Claude ĐẠT): three tools in @affitor/mcp that call the coupon API.

  • affitor_create_coupon → POST /api/v1/coupons, affitor_lock_coupon → POST /api/v1/coupons/:id/lock, affitor_get_coupon → GET /api/v1/coupons/:id.
  • Separate credential family: only AFFITOR_AGENT_KEY, only when AFFITOR_MCP_COUPONS=1. The program-key tools (AFFITOR_API_KEY, AFFITOR_MCP_WRITE) are unchanged. Neither key ever falls back to the other; the server starts with the agent key alone.
  • Strict inputs mirroring the API (no program/account/key fields); idempotency_key is sent only as the Idempotency-Key header. Descriptions say to retry with the same key and payload; a 409 is never a reason to try a new key.
  • A 202 or held/pending body is returned as pending (never as an active code). Errors carry only the HTTP status, the stable error.code and retry info.
  • registerTools keeps its signature; registerCouponTools is a new export.
  • 0.2.4: package.json, server.json packages[npm].version, CHANGELOG, README. server.json lists AFFITOR_AGENT_KEY (secret) and AFFITOR_MCP_COUPONS, and makes AFFITOR_API_KEY optional. The top-level registry version is untouched.

Only the six G3 files change (plus the lockfile version line). No SDK change, no remote /mcp change, no publish.

Draft until

The CMS coupon API unit (p492) passes review: these tools call that API. Nothing is published from this PR.

Checks

  • Build + vitest 61/61 (the spec's credential matrix, wire contract, strict-input rejection, annotations/descriptions, registerTools unchanged, server.json/package.json version equality).
  • tsc --noEmit 0 errors.
  • Real stdio tools/list: agent key + COUPONS=1 only → the 3 coupon tools; both keys + both flags → the 10 tools.

🤖 Generated with Claude Code

Adds affitor_create_coupon, affitor_lock_coupon and affitor_get_coupon (coupon
dogfood spec R7, unit G3). They use only AFFITOR_AGENT_KEY and appear only with
AFFITOR_MCP_COUPONS=1; the legacy program-key tools and their AFFITOR_MCP_WRITE
switch are unchanged, and neither key falls back to the other. The server can
start with the agent key alone. Create and lock send the caller's
idempotency_key as the Idempotency-Key header; a 202 or held body is returned as
pending, errors carry only the status and stable code. registerTools keeps its
signature; registerCouponTools is a new export. @affitor/mcp 0.2.4; server.json
lists the new env vars and makes the program key optional.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant