Skip to content

fix(generator): don't re-inject the MCP route scaffold over live routes#53

Merged
mhenrixon merged 1 commit into
mainfrom
fix/mcp-route-sync-idempotency
Jul 4, 2026
Merged

fix(generator): don't re-inject the MCP route scaffold over live routes#53
mhenrixon merged 1 commit into
mainfrom
fix/mcp-route-sync-idempotency

Conversation

@mhenrixon

Copy link
Copy Markdown
Owner

Summary

docs_kit:install --sync re-injected the commented /mcp route scaffold into sites that had already opted in with live routes. add_mcp_route used plain Thor route, which only skips byte-identical lines — a live post "/mcp" => "docs_kit/mcp#create", as: :mcp never matches the commented template line, so every sync accumulated more commented noise above the real routes.

Fix: guard on the endpoint with the existing route_present? helper (matches docs_kit/mcp#create in any quote style, live or commented) — the same tolerance the other routes already have via route_once.

Found dogfooding 1.0.3 into pgbus (mhenrixon/pgbus#271) and phlex-reactive (mhenrixon/phlex-reactive#157) — both hit it and had the noise reverted locally.

Test Coverage

  • New spec: a site with live /mcp routes (own style, , as: :mcp suffix) gets NO commented scaffold on --sync, and docs_kit/mcp#create appears exactly once.

Verification

  • bundle exec rspec — 716/716 (82 generator examples)
  • bundle exec rubocop — no offenses

https://claude.ai/code/session_01FPQb6z3YwcKRMbvoJhdxnX

…live routes

add_mcp_route drew the commented /mcp scaffold with plain Thor `route`,
which only skips byte-identical lines — a site that opted in has LIVE
routes in its own style (`, as: :mcp`, single quotes) that never match,
so every --sync run re-injected the commented noise. Guard on the
endpoint via route_present? instead (matches docs_kit/mcp#create in any
form, live or commented).

Found dogfooding 1.0.3 into pgbus + phlex-reactive — both hit it.

Claude-Session: https://claude.ai/code/session_01FPQb6z3YwcKRMbvoJhdxnX
@mhenrixon mhenrixon merged commit 057146e into main Jul 4, 2026
5 checks passed
@mhenrixon mhenrixon deleted the fix/mcp-route-sync-idempotency branch July 4, 2026 14:42
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