Skip to content

test(mcp): add cross-generator field-stripping contract tests - #2010

Merged
dyoshikawa merged 2 commits into
mainfrom
resolve-issue-1659-mcp-field-stripping-contract
Jun 23, 2026
Merged

test(mcp): add cross-generator field-stripping contract tests#2010
dyoshikawa merged 2 commits into
mainfrom
resolve-issue-1659-mcp-field-stripping-contract

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

Summary

Adds the cross-generator MCP contract tests requested in #1659, hardening the MCP export paths universally.

RulesyncMcp.getMcpServers() omits the rulesync-source-only fields (targets, description, exposed) plus the codex-only envVars field, and every non-codex tool MCP generator builds its output from getMcpServers(). These tests pin that contract so a future generator that bypasses the canonical stripping is caught.

Changes

  • Parametric non-codex leak contract: it.each(toolMcpFactories) (excluding codexcli) builds a RulesyncMcp whose server carries targets/description/exposed/envVars and asserts none of those field names or canary values leak into the emitted getFileContent() — format-agnostic, covering all 28 non-codex generators (global-only tools like augmentcode are driven in global mode).
  • Cursor source-preservation assertion: verifies the rulesync source retains all four fields verbatim while the Cursor emit strips them, keeping only the real MCP server config.

Codex is the deliberate exception (it reads envVars directly to emit [mcp_servers.<name>.env]).

Verification

  • pnpm cicheck passes; the new file adds 29 passing tests. Test-only — no production changes were needed (all generators already strip correctly).

Closes #1659

cm-dyoshikawa and others added 2 commits June 22, 2026 21:02
Harden the MCP export paths universally (#1659): a parameterized contract test asserts that every non-codex MCP generator strips the rulesync-source-only fields (targets, description, exposed) and the codex-only envVars field from its emitted config, plus a dedicated Cursor source-preservation test verifying the fields survive in the rulesync source but are stripped at emit. Codex is the deliberate exception (it reads envVars directly). Test-only; no production changes — all 28 non-codex generators already strip correctly via RulesyncMcp.getMcpServers().

Closes #1659

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Fix the critical review finding: the test called fromRulesyncMcp without mocking process.cwd()/getHomeDirectory(), so read-or-initialize generators wrote real files into the repo root (.config/, .rovodev/, etc.) and failed CI's git-diff checks. Use setupTestDirectory + mock process.cwd() (project scope) and getHomeDirectory() (global scope) so all writes are isolated and cleaned up. Also add a symmetric description key-name probe (review finding #5).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dyoshikawa

Copy link
Copy Markdown
Owner Author

Thanks — merging. Adds cross-generator MCP field-stripping contract tests (parametric non-codex leak contract + Cursor source-preservation), closing #1659.

@dyoshikawa
dyoshikawa merged commit 7fc13f0 into main Jun 23, 2026
8 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-1659-mcp-field-stripping-contract branch June 23, 2026 04:15
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.

Test: add cross-generator contract tests for MCP field stripping

2 participants