feat: sync enabledMcpjsonServers from mcp.json#75
Conversation
Derives enabledMcpjsonServers in settings.local.json from the keys in .ruler/mcp.json so removed servers (e.g. Linear, Figma, Beeper) are automatically cleaned up on `make sync`.
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Updates the mcp-sync Make target to keep Claude CLI settings.local.json in sync with .ruler/mcp.json, specifically ensuring enabledMcpjsonServers reflects the current set of MCP servers and avoids stale entries.
Changes:
- Extracts
.mcpServerskeys from.ruler/mcp.jsonviajq. - Updates
enabledMcpjsonServersin each target directory’ssettings.local.json(when present) duringmcp-sync.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| jq --argjson keys "$$keys" '.enabledMcpjsonServers = $$keys' "$$settings" > "$$settings.tmp" && \ | ||
| mv "$$settings.tmp" "$$settings"; \ | ||
| echo "Updated enabledMcpjsonServers in $$settings"; \ |
There was a problem hiding this comment.
The jq ... > "$settings.tmp" && mv ...; echo "Updated..." sequence will print the success message even when jq fails (because echo runs unconditionally after the && list), and the recipe will still exit 0. Consider making the echo conditional on success and failing the target on error (e.g., include the echo in the && chain or use an if ...; then ...; else ...; exit 1; fi block; also clean up the temp file on failure).
| jq --argjson keys "$$keys" '.enabledMcpjsonServers = $$keys' "$$settings" > "$$settings.tmp" && \ | |
| mv "$$settings.tmp" "$$settings"; \ | |
| echo "Updated enabledMcpjsonServers in $$settings"; \ | |
| if jq --argjson keys "$$keys" '.enabledMcpjsonServers = $$keys' "$$settings" > "$$settings.tmp" && \ | |
| mv "$$settings.tmp" "$$settings"; then \ | |
| echo "Updated enabledMcpjsonServers in $$settings"; \ | |
| else \ | |
| echo "Failed updating enabledMcpjsonServers in $$settings"; \ | |
| rm -f "$$settings.tmp"; \ | |
| exit 1; \ | |
| fi; \ |
| exit 1; \ | ||
| fi; \ | ||
| done | ||
| @keys=$$(jq -c '.mcpServers | keys' $(MCP_SRC)); \ |
There was a problem hiding this comment.
keys=$$(jq ...) will not cause the recipe to fail if jq errors (shell assignment returns success), which can lead to enabledMcpjsonServers being set to an empty/invalid value. Add explicit error handling for the jq invocation (e.g., ... || exit 1) and consider using jq -e/-c with a safe default like .mcpServers // {} | keys if mcpServers might be absent.
| @keys=$$(jq -c '.mcpServers | keys' $(MCP_SRC)); \ | |
| @tmp_keys_file=$$(mktemp); \ | |
| if jq -e -c '.mcpServers // {} | keys' $(MCP_SRC) > "$$tmp_keys_file"; then \ | |
| keys=$$(cat "$$tmp_keys_file"); \ | |
| rm -f "$$tmp_keys_file"; \ | |
| else \ | |
| echo "Error: failed to parse .mcpServers from $(MCP_SRC)"; \ | |
| rm -f "$$tmp_keys_file"; \ | |
| exit 1; \ | |
| fi; \ |
Summary
enabledMcpjsonServersinsettings.local.jsonfrom the keys in.ruler/mcp.jsonduringmcp-syncmcp.jsonTest plan
make mcp-syncand verify~/.claude/settings.local.jsonenabledMcpjsonServersmatchesmcp.jsonkeyssettings.local.jsondoesn't exist in a target dir🤖 Generated with Claude Code
Summary by cubic
mcp-sync now sets enabledMcpjsonServers in settings.local.json from the server keys in .ruler/mcp.json to keep local settings aligned and clean up removed servers. If a target dir has no settings.local.json, the sync skips it without changes.
Written for commit 48c605e. Summary will update on new commits.