Skip to content

Wire normalizeMcpCommand into mcp_command_mismatch detector#41

Closed
Conalh wants to merge 1 commit into
migrate-jsonc-locators-to-agent-gov-corefrom
wire-mcp-normalizer-via-agent-gov-core
Closed

Wire normalizeMcpCommand into mcp_command_mismatch detector#41
Conalh wants to merge 1 commit into
migrate-jsonc-locators-to-agent-gov-corefrom
wire-mcp-normalizer-via-agent-gov-core

Conversation

@Conalh
Copy link
Copy Markdown
Owner

@Conalh Conalh commented May 22, 2026

Summary

Closes the PolicyMesh audit's mcp_command_mismatch false-positive class. Two surfaces that differ only in cosmetically neutral ways (npx -y <pkg> vs npx <pkg>, .cmd suffix, flag reordering) no longer produce a high-severity finding.

What changed

  • McpServer gains a canonicalIdentity: string field, computed by agent-gov-core@v0.1.2's normalizeMcpCommand from (command, args, url). Both the JSON and Codex TOML parsers populate it.
  • detectMcpCommandMismatch groups by canonicalIdentity instead of the raw joined command string. The finding message still uses command so the diff stays human-readable and actionable.
  • Env is deliberately omitted from canonicalIdentity. Env drift is reported by mcp_env_mismatch; including env here would have surfaced two findings for one issue (and broke mcp-env-value-mismatch).

Regression test

New fixture test/fixtures/mcp-command-neutral-flag-equivalence/ — root MCP runs npx -y @modelcontextprotocol/server-github@1.2.3, Cursor runs the same without -y. The new test CLI does not flag mcp_command_mismatch on neutral -y flag drift between surfaces asserts the post-fix behavior. I verified it fails on the pre-fix engine and passes here.

This locks the audit finding closed: if anyone reverts the canonical-identity grouping in engine.ts, CI catches it.

Stack

Stacked on #40 (JSONC migration). Merge that first; PR base will retarget to main automatically.

Test plan

  • npm test — 39 tests pass, including the new regression
  • CI green
  • After merge, monitor any consumer self-dogfood workflow for unexpected mcp_command_mismatch deltas

🤖 Generated with Claude Code

Closes the false-positive class flagged in the PolicyMesh audit:
two surfaces that differ only in cosmetically neutral ways
(`npx -y <pkg>` vs `npx <pkg>`, `.cmd` vs unsuffixed, flag
reordering) were being reported as high-severity command mismatches.

What changed
- McpServer gains a `canonicalIdentity: string` field, computed by
  agent-gov-core@v0.1.2's normalizeMcpCommand from (command, args,
  url). Both the JSON and Codex TOML parsers populate it.
- `detectMcpCommandMismatch` now groups by `canonicalIdentity` instead
  of the raw joined `command` string. The human-readable command list
  in the finding message still uses `command` so the finding stays
  actionable.
- Env is deliberately omitted from `canonicalIdentity`. Env drift has
  its own detector (mcp_env_mismatch); including env here would have
  surfaced two findings for what users perceive as one issue (and
  broke the mcp-env-value-mismatch fixture test).

Regression test pinned
`mcp-command-neutral-flag-equivalence` fixture: root MCP runs
`npx -y @modelcontextprotocol/server-github@1.2.3`, Cursor runs the
same without `-y`. Before this change the audit emitted a
high-severity mcp_command_mismatch finding; after it emits none. Test
'CLI does not flag mcp_command_mismatch on neutral -y flag drift
between surfaces' asserts the post-fix behavior — it fails on the
pre-fix engine, passes here.

39 PolicyMesh tests pass. Stacked on #40 (JSONC migration); merge
that one first.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Conalh Conalh deleted the branch migrate-jsonc-locators-to-agent-gov-core May 22, 2026 14:07
@Conalh Conalh closed this May 22, 2026
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