MLD-1307 - Auto-run plugin mcp.json align - #50
Open
arielamitjfrog wants to merge 6 commits into
Open
Conversation
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wire Claude Code SessionStart / FileChanged hooks so installed-plugin
.mcp.jsonfiles are auto-aligned through@jfrog/agent-guard --align-plugin-mcps.claude-align-plugin-mcps.mjs- Claude adapter: spawnnpx @jfrog/agent-guard --align-plugin-mcps --format hook-session-start|hook-file-changed, passthrough stdout (watchPaths / systemMessage / additionalContext owned by agent-guard), never fail the session.claude-register-align-watch-paths.mjs- fast SessionStart companion: emit FileChangedwatchPathsforinstalled_plugins.json/known_marketplaces.jsonbefore the slower npx align finishes, so mid-session plugin installs are watched while Agent Guard is still downloading.hooks/hooks.json- register both on SessionStart; re-run align on FileChanged when those metadata files change.Discovery + rewrite stay in agent-guard (
--align-plugin-mcps). This PR only owns Claude hook UX, env forwarding, soft-fail, and early watchPath registration.Goal
Assumptions
This adapter does not rewrite
mcp.jsonitself and does not invent Claude hook payload shapes. Agent Guard owns discovery, transform, and hook stdout. The Claude plugin must:npx --yes --registry <...> @jfrog/agent-guard --align-plugin-mcps --format hook-...JF_PROJECT->--project,CLAUDE_CONFIG_DIR->--claude-config-dir,JFROG_AGENT_GUARD_REPO-> npx registry + agent-guard--registryJF_AGENT_ALIGN_PLUGIN_MCPS_DISABLE=1(no-op, no stdout)Remote MCP entries remain agent-guard's concern (never rewritten there).
Happy flow
SessionStart:
claude-register-align-watch-paths.mjsprints Claude SessionStart JSON withwatchPathsfor~/.claude/plugins/installed_plugins.jsonandknown_marketplaces.json (or $CLAUDE_CONFIG_DIR/plugins/...).claude-align-plugin-mcps.mjs session-startruns agent-guard with--format hook-session-start..mcp.jsonpaths, rewrites stdio MCPs to launch via Agent Guard, and prints Claude hook stdout (watchPaths + optional reload guidance).FileChanged (matcher:
installed_plugins.json|known_marketplaces.json):claude-align-plugin-mcps.mjsfile-changed runs with--format hook-file-changed.Idempotency / drift (owned by agent-guard; adapter just re-invokes):
Kill switch:
JF_AGENT_ALIGN_PLUGIN_MCPS_DISABLE=1-> both hooks exit 0 with no stdout / no spawn.Non-happy flows
Expected behavior / exit (adapter always exit 0):
JF_PROJECT-> still invoke agent-guard (no--project); agent-guard decides whether project is required for rewrite (exit 0).JFROG_AGENT_GUARD_REPO-> used for bothnpx --registryand agent-guard--registry.