Skip to content

fix: MCP startup no longer duplicates the plugin's hooks (0.52.1) - #68

Merged
Shahinyanm merged 1 commit into
masterfrom
fix/auto-install-respects-plugin
Sep 13, 2026
Merged

Shahinyanm merged 1 commit into
masterfrom
fix/auto-install-respects-plugin

Conversation

@Shahinyanm

Copy link
Copy Markdown
Member

Problem — with token-pilot installed as a plugin and also registered as an npm MCP
server, every start of the npm copy wrote its hooks into the project's
.claude/settings.json, beside the hooks the plugin already provides. Each hook then
ran twice and the event log double-counted. On the machine this was found on, 28
project settings files had a duplicate set; eight of them had been committed to git by
stage-everything commits, carrying absolute paths that only exist on that machine.

install-hook has refused this case since v0.33.0, but the check lives in the CLI
command. startServer calls installHook directly (src/index.ts:886), so the
refusal never ran on the path that actually writes.

Fix — the isTokenPilotPluginEnabled check moves into installHook, next to the
existing CLAUDE_PLUGIN_ROOT one, so every caller gets it. Existing duplicates are left
alone: an entry in a tracked settings file is the repo owner's call. The session-start
warning flags them in whichever project is open, and uninstall-hook removes them.

Verified — a new installer test, red before the fix. Installer tests now point HOME at
an empty dir, so the machine's own ~/.claude/settings.json cannot leak into them.
Full suite green, tsc --noEmit clean, build clean.

With token-pilot installed as a plugin and also registered as an npm MCP
server, every start of the npm copy wrote its hooks into the project's
.claude/settings.json next to the plugin's, so every hook ran twice.
install-hook has refused this since v0.33.0, but the refusal lived in the
CLI; startServer calls installHook directly and never saw it. The check
now sits in installHook, so every caller gets it.

Installer tests point HOME at an empty dir so the machine's own
~/.claude/settings.json cannot leak into them.
@Shahinyanm
Shahinyanm merged commit 20dbc47 into master Sep 13, 2026
3 checks passed
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