Skip to content

feat: add mcp-sync target to Makefile#35

Merged
shunkakinoki merged 2 commits into
mainfrom
shunkakinoki/sync-mcp-servers
Oct 4, 2025
Merged

feat: add mcp-sync target to Makefile#35
shunkakinoki merged 2 commits into
mainfrom
shunkakinoki/sync-mcp-servers

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Oct 4, 2025

Copy link
Copy Markdown
Owner

Changes Made

  • Added mcp-sync target to sync MCP configurations from .ruler/mcp.json to CLI tools
  • Added MCP_SRC and MCP_TARGET_DIRS variables to define source and target directories
  • Integrated mcp-sync into prepare target for automatic syncing during project setup

Technical Details

  • Copies .ruler/mcp.json to ~/.cursor, ~/.claude, and ~/.codex directories
  • Ensures all CLI tools use the same MCP server configuration
  • Fails gracefully if source file is not found

Testing

  • Manually tested make mcp-sync command
  • Verified files are copied to target directories
  • Confirmed integration with make prepare

Usage

# Sync MCP configs manually
make mcp-sync

# Or as part of prepare
make prepare

🤖 Generated with Claude Code by Claude Sonnet 4.5


Summary by cubic

Adds a Makefile target mcp-sync that syncs .ruler/mcp.json to local CLI tool directories, and runs during make prepare to keep all tools on the same MCP config.

  • New Features
    • Syncs .ruler/mcp.json to ~/.cursor, ~/.claude, and ~/.codex.
    • Adds MCP_SRC and MCP_TARGET_DIRS for configurable source/targets.
    • Fails early with a clear message if the source file is missing.

- Add MCP_SRC and MCP_TARGET_DIRS variables
- Add mcp-sync target to copy .ruler/mcp.json to all CLI tool directories
- Integrate mcp-sync into prepare target for automatic syncing
Copilot AI review requested due to automatic review settings October 4, 2025 22:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds MCP (Model Control Protocol) configuration synchronization functionality to the Makefile, enabling automatic syncing of MCP server configurations from a central source to multiple CLI tool directories.

  • Adds mcp-sync target to copy .ruler/mcp.json to CLI tool configuration directories
  • Defines source and target directory variables for MCP configuration management
  • Integrates MCP syncing into the existing prepare target for automatic setup

@coderabbitai

coderabbitai Bot commented Oct 4, 2025

Copy link
Copy Markdown

Warning

Rate limit exceeded

@shunkakinoki has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 54 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between eeee08a and aa8d962.

📒 Files selected for processing (1)
  • Makefile (2 hunks)
📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Automatic synchronization of MCP configuration to supported CLI tools.
    • Multi-target support ensures configuration is propagated across all relevant tool directories.
    • Integration into the prepare workflow for streamlined setup.
  • Chores

    • Enhanced sync process with per-target directory creation and clearer success/failure messages for more reliable setup feedback.
    • Updated command synchronization to copy the unified configuration file across all targets.

Walkthrough

The Makefile adds MCP_SRC and MCP_TARGET_DIRS variables, introduces a new phony mcp-sync target, wires prepare to run mcp-sync, and updates commands-sync to iterate over MCP_TARGET_DIRS, ensuring target directory creation and copying MCP_SRC to each as mcp.json with success/failure messaging.

Changes

Cohort / File(s) Summary of Changes
Build system: Make targets and variables
Makefile
Added MCP_SRC and MCP_TARGET_DIRS variables; introduced phony target mcp-sync to validate and copy MCP config to multiple CLI tool directories; updated prepare to depend on mcp-sync; modified commands-sync to iterate over MCP_TARGET_DIRS, create directories, copy MCP_SRC to mcp.json, and emit status messages.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant Make as make
  participant mcp as mcp-sync (target)
  participant sh as Shell
  participant T1 as TargetDir[1..N]

  Dev->>Make: make prepare
  Make->>mcp: invoke as dependency
  mcp->>sh: validate MCP_SRC exists
  alt MCP_SRC missing
    sh-->>Dev: error message
    mcp-->>Make: non-zero exit
  else MCP_SRC present
    loop for each dir in MCP_TARGET_DIRS
      mcp->>sh: mkdir -p <dir>
      mcp->>sh: cp MCP_SRC -> <dir>/mcp.json
      sh-->>mcp: per-target success/failure message
    end
    mcp-->>Make: success
  end
  Make-->>Dev: prepare complete (includes mcp-sync)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I thump my paws: sync, sync, hooray!
New paths set for MCP’s ballet.
From one small seed to dirs in line,
mcp.json hops—copy time!
Prepare now cues the gentle flow—
a rabbit nods: “All set. Let’s go.” 🐇📦

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly and concisely describes the primary change, stating that a new “mcp-sync” target was added to the Makefile, matching the main modification in the PR.
Description Check ✅ Passed The description directly relates to the changeset by detailing the addition of the mcp-sync target, variable declarations, integration into the prepare target, testing steps, and usage examples, making it clearly on-topic.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Reorganizes the Makefile to separate root targets from commands, improving readability and maintainability.

Introduces a new `sync` target that consolidates the `commands-sync` and `mcp-sync` targets for a cleaner workflow.
@shunkakinoki
shunkakinoki enabled auto-merge (squash) October 4, 2025 22:37

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
Makefile (1)

17-20: Use $(MAKE) for recursive invocations.

make spawns a fresh instance that drops MAKEFLAGS/variables; $(MAKE) preserves the caller’s context. Since we’re adding a new recursive call here, let’s switch both lines for consistency.

-	@make commands-copy
-	@make mcp-sync
+	@$(MAKE) commands-copy
+	@$(MAKE) mcp-sync
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b140aa5 and eeee08a.

📒 Files selected for processing (1)
  • Makefile (2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/{Makefile*,Dockerfile*}

📄 CodeRabbit inference engine (CLAUDE.md)

Include Makefiles and Dockerfiles in lint/check pipelines as infrastructure artifacts.

Include Makefiles and Dockerfiles in lint/format checks

Files:

  • Makefile
Makefile*

📄 CodeRabbit inference engine (.cursor/rules/ruler_cursor_instructions.mdc)

Include Makefile* in linting/quality checks scope.

Files:

  • Makefile
**/Makefile*

📄 CodeRabbit inference engine (GEMINI.md)

Include Makefiles in linting/formatting scope where applicable

Files:

  • Makefile
{Makefile*,Dockerfile*}

📄 CodeRabbit inference engine (AGENT.md)

Include Makefiles and Dockerfiles in linting/formatting scope where applicable.

Files:

  • Makefile

Comment thread Makefile
Comment on lines +37 to +50
.PHONY: mcp-sync
mcp-sync: ## Sync MCP configuration from .ruler/mcp.json to CLI tools.
@if [ ! -f $(MCP_SRC) ]; then \
echo "Error: $(MCP_SRC) not found"; \
exit 1; \
fi
@for target in $(MCP_TARGET_DIRS); do \
if mkdir -p $$target && cp $(MCP_SRC) $$target/mcp.json; then \
echo "Synced $(MCP_SRC) → $$target/mcp.json"; \
else \
echo "Failed syncing $(MCP_SRC) → $$target/mcp.json"; \
exit 1; \
fi; \
done

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Quote MCP paths to keep the sync target working in directories with spaces.

If this repo lives in a directory whose path contains spaces (common on macOS, e.g. “~/Projects/My Rules”), [ ! -f $(MCP_SRC) ] and the subsequent cp $(MCP_SRC) $$target/mcp.json will split the path and fail, causing make mcp-sync / make prepare to error. Please quote both the existence check and the copy/mkdir calls.

-	@if [ ! -f $(MCP_SRC) ]; then \
+	@if [ ! -f "$(MCP_SRC)" ]; then \
@@
-		if mkdir -p $$target && cp $(MCP_SRC) $$target/mcp.json; then \
+		if mkdir -p "$$target" && cp "$(MCP_SRC)" "$$target/mcp.json"; then \
🤖 Prompt for AI Agents
In Makefile around lines 37 to 50, path variables are not quoted so filenames
with spaces break the existence check and copy; change the test and filesystem
commands to quote variables: use [ ! -f "$(MCP_SRC)" ] for the existence check,
mkdir -p "$$target" and cp "$(MCP_SRC)" "$$target/mcp.json" (and quote $$target
in the echo messages if you choose) so the loop and copy work when paths contain
spaces.

@shunkakinoki
shunkakinoki merged commit aebdd26 into main Oct 4, 2025
2 checks passed
@shunkakinoki
shunkakinoki deleted the shunkakinoki/sync-mcp-servers branch October 4, 2025 22:37

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

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.

2 participants