Skip to content

fix: use bare madar MCP launcher#502

Merged
mohanagy merged 2 commits into
nextfrom
fix/windows-mcp-command-shape
Jun 3, 2026
Merged

fix: use bare madar MCP launcher#502
mohanagy merged 2 commits into
nextfrom
fix/windows-mcp-command-shape

Conversation

@mohanagy
Copy link
Copy Markdown
Owner

@mohanagy mohanagy commented Jun 3, 2026

Summary

  • switch generated Claude and Cursor MCP configs from version-pinned npx launchers to bare madar serve --stdio
  • keep VS Code Copilot's direct CLI-path wiring unchanged
  • clarify the docs distinction between manual registry npx usage and repo-local installed MCP configs

Testing

  • npm run test:run -- tests/unit/install.test.ts tests/unit/doctor.test.ts tests/unit/install-docs.test.ts
  • npm run typecheck
  • npm run build
  • CI=1 npm run test:run
  • npm pack --dry-run

Summary by CodeRabbit

  • Documentation
    • Clarified MCP server configuration documentation for AI agent setups
  • Refactor
    • Simplified generated configuration to use direct CLI invocation instead of version-pinned packages

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

Warning

Review limit reached

@mohanagy, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 99 minutes and 46 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ef9bf060-21af-4f8d-b621-cf620d3aae53

📥 Commits

Reviewing files that changed from the base of the PR and between b29541f and a36e15a.

📒 Files selected for processing (1)
  • docs/reference/cli-and-mcp.md
📝 Walkthrough

Walkthrough

This PR replaces the version-pinned npx-based MCP server invocation approach with direct madar serve --stdio CLI invocation in generated Claude and Cursor configurations. The refactoring removes readPackageName infrastructure, simplifies installMcpServer by removing the nodePlatform parameter, updates three call sites, and adjusts all related tests and documentation accordingly.

Changes

MCP stdio server invocation refactor

Layer / File(s) Summary
Remove npx-based import and helper function
src/infrastructure/install.ts
readPackageName import removed and local helper function deleted to eliminate the dependency on the npx package specifier pathway.
Refactor MCP server installation logic
src/infrastructure/install.ts
installMcpServer function signature simplified by removing nodePlatform parameter. Command/args construction replaced with direct serve --stdio invocation using either a resolved CLI path (VS Code only) or the default madar name, and the config entry is updated to use the new command/args values.
Update call sites to remove platform parameter
src/infrastructure/install.ts
Three call sites (installCopilotMcp, cursorInstall, claudeInstall) updated to invoke the refactored installMcpServer without passing process.platform.
Update tests for bare madar command configuration
tests/unit/install.test.ts
Claude MCP test replaced to assert bare madar command with explicit serve --stdio arguments. New Cursor MCP test added asserting the same bare command pattern targeting out/graph.json.
Update CLI and MCP documentation
docs/reference/cli-and-mcp.md
Documentation clarified to describe direct madar serve --stdio invocation in generated Claude and Cursor MCP configurations instead of version-pinned npx launcher.

Possibly related PRs

  • mohanagy/madar#250: Updates src/infrastructure/install.ts and tests/unit/install.test.ts to change MCP stdio server command/args generation from npx-style launchers toward direct local madar CLI invocation with new/updated installer tests.
  • mohanagy/madar#438: Adds validation/CI that the checked-in docs/mcp-registry/server.json uses the same madar serve --stdio + graph_path argument model consistent with this PR's direct invocation approach.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 No more pinned versions in the air,
Just madar serve with simple flair,
Direct invocation, clean and bright,
MCP wiring gets it right!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: use bare madar MCP launcher' directly and clearly summarizes the main change: switching from version-pinned npx launchers to a bare madar CLI launcher.
Description check ✅ Passed The description covers all required sections: summary of changes, testing steps with specific commands, and addresses the PR checklist items (docs updated, tests updated, focused change).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/windows-mcp-command-shape

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/reference/cli-and-mcp.md`:
- Line 46: Update the sentence to reflect that the installer writes the absolute
project-specific path (constructed with join(projectDir, 'out', 'graph.json'))
into the generated MCP args rather than the literal relative path
"out/graph.json"; mention that the MCP configs call madar serve --stdio with
that absolute path written by the installer (the code that builds the path uses
join and projectDir when assembling the MCP args).

In `@src/infrastructure/install.ts`:
- Around line 1603-1605: The generated installer config must bind Claude/Cursor
to the installer package instance instead of always using PRIMARY_CLI_BIN_NAME;
change how directCliPath is determined so it uses
findPackageCliPath(packageRoot) whenever packageRoot is provided (not only when
isVscode), then set command = directCliPath ? process.execPath :
PRIMARY_CLI_BIN_NAME and args = directCliPath ? [directCliPath, ...cliArgs] :
cliArgs so the produced config references the package-root CLI. Update the
variables directCliPath, command and args accordingly (use findPackageCliPath,
packageRoot, process.execPath, PRIMARY_CLI_BIN_NAME, cliArgs).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 47830f44-e071-4b50-b606-7e169515a578

📥 Commits

Reviewing files that changed from the base of the PR and between 1f2bb15 and b29541f.

📒 Files selected for processing (3)
  • docs/reference/cli-and-mcp.md
  • src/infrastructure/install.ts
  • tests/unit/install.test.ts

Comment thread docs/reference/cli-and-mcp.md Outdated
Comment on lines 1603 to +1605
const directCliPath = isVscode ? findPackageCliPath(packageRoot) : undefined
const command = directCliPath ? process.execPath : npxCommand
const args = directCliPath ? [directCliPath, 'serve', '--stdio', graphPath] : npxArgs
const command = directCliPath ? process.execPath : PRIMARY_CLI_BIN_NAME
const args = directCliPath ? [directCliPath, ...cliArgs] : cliArgs
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot Jun 3, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Keep Claude/Cursor bound to the installer's CLI, not whatever madar is on PATH.

These lines now ignore packageRoot for non-Copilot targets and always write command: "madar". That means the generated Claude/Cursor config no longer points at the same package instance that ran the install; it will pick up some other madar on PATH, or fail if none is available. That’s a real runtime regression from the previous package-root/version-bound flow.

Proposed fix
-  const directCliPath = isVscode ? findPackageCliPath(packageRoot) : undefined
+  const directCliPath = findPackageCliPath(packageRoot)
   const command = directCliPath ? process.execPath : PRIMARY_CLI_BIN_NAME
   const args = directCliPath ? [directCliPath, ...cliArgs] : cliArgs
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/infrastructure/install.ts` around lines 1603 - 1605, The generated
installer config must bind Claude/Cursor to the installer package instance
instead of always using PRIMARY_CLI_BIN_NAME; change how directCliPath is
determined so it uses findPackageCliPath(packageRoot) whenever packageRoot is
provided (not only when isVscode), then set command = directCliPath ?
process.execPath : PRIMARY_CLI_BIN_NAME and args = directCliPath ?
[directCliPath, ...cliArgs] : cliArgs so the produced config references the
package-root CLI. Update the variables directCliPath, command and args
accordingly (use findPackageCliPath, packageRoot, process.execPath,
PRIMARY_CLI_BIN_NAME, cliArgs).

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I intentionally left this as the bare madar command for Claude/Cursor. The user explicitly asked us to stop writing npx.cmd / version-pinned launchers into the generated repo-local MCP config and to use madar only as the command. Rebinding Claude/Cursor to process.execPath + <packageRoot cli path> would avoid npx, but it would also change the generated contract away from the requested madar launcher. VS Code Copilot keeps its existing direct CLI-path behavior because that integration already had a separate contract before this change.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@mohanagy, understood — the bare madar launcher for Claude/Cursor is an explicit design choice to move away from version-pinned launchers, with the expectation that madar is available on the user's PATH. VS Code Copilot retains the direct-CLI-path contract because it predates this change and has a different integration model. I'll stand down on this one.


✏️ Learnings added
Learnt from: mohanagy
Repo: mohanagy/madar PR: 502
File: src/infrastructure/install.ts:1603-1605
Timestamp: 2026-06-03T22:17:35.181Z
Learning: In `src/infrastructure/install.ts`, the `installMcpServer` function intentionally uses the bare `madar` binary name (PRIMARY_CLI_BIN_NAME) as the MCP server command for Claude and Cursor targets. This is a deliberate design choice to avoid version-pinned `npx` launchers in generated repo-local MCP configs. VS Code Copilot (target === 'copilot') retains the older direct CLI-path wiring via `findPackageCliPath(packageRoot)` and `process.execPath` because it has a separate pre-existing contract. Do not suggest rebinding Claude/Cursor to `process.execPath + packageRoot CLI path`.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: mohanagy
Repo: mohanagy/madar PR: 343
File: tests/unit/compare-install-regression-fixture.test.ts:14-35
Timestamp: 2026-05-26T23:30:56.261Z
Learning: In the Madar codebase, "degraded" measurement validity state (install verified but no Madar MCP invocation) is covered by unit tests in `tests/unit/compare-native-agent.test.ts`. The regression fixture in `tests/unit/compare-install-regression-fixture.test.ts` is intentionally scoped to the no-install vs with-install A/B pair only, and also asserts `madar_mcp_call_count` for those two arms.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mohanagy mohanagy merged commit 51e0412 into next Jun 3, 2026
7 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