Skip to content

fix(mcp): use the dispatched tool namespace for health checks - #4023

Merged
haelyra merged 1 commit into
affaan-m:mainfrom
rudycelekli:fix/mcp-health-canonical-target
Nov 19, 2026
Merged

haelyra merged 1 commit into
affaan-m:mainfrom
rudycelekli:fix/mcp-health-canonical-target

Conversation

@rudycelekli

Copy link
Copy Markdown
Contributor

What Changed

The health hook identifies native MCP calls from their mcp__server__tool name before checking explicit adapter fields. Generic adapters can still provide their target as before.

Why This Change

I found this while inspecting the hook's target resolution. With a native mcp__deployment__lookup__status call whose tool schema also defines server and tool arguments, the failure hook wrote health state to the server named in the arguments. A subsequent preflight could inherit that wrong server's backoff. The test drives both registered event paths and demonstrates that backoff and tool labels now stay attached to the dispatched MCP endpoint.

Testing Done

  • The new regression recorded a failure for reporting before the fix. Afterward, the failure and subsequent preflight were correctly attributed to deployment and lookup__status.
  • ECC_TEST_ONLY=hooks/mcp-health-check.test.js npm test passed the validators and 36 selected checks on macOS, Node 22.23.5. The suite also covers explicit targets for generic adapters and truncated payloads.
  • git diff --check passed. Full unfiltered suite status is unverified on Node 22.

Type of Change

  • fix: Bug fix

Codex assisted with the reproducer, implementation, tests, and description.

@ecc-tools

ecc-tools Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / Security Evidence

Commit: b64e30be6c1e73375c7210aa5d9f78374c63d82e

Security scanner evidence required (action_required)

Detected 1 security-sensitive predictive risk signal(s) without scanner evidence.

Mode: enforce

Findings:

  • Security-sensitive changes may ship without scanner evidence: The PR touches billing, secrets, auth, webhooks, agent, or CI-sensitive surfaces without adding obvious security scanner, code scanning, or security-focused validation evidence. (2 security-sensitive paths changed; 0 security scanner or security-focused validation artifacts changed)

Touched security-sensitive paths:

  • scripts/hooks/mcp-health-check.js
  • tests/hooks/mcp-health-check.test.js

Expected evidence:

  • Security scanner, code scanning, secret scanning, dependency/security review, or focused security regression output.
  • SARIF/code-scanning upload or equivalent pass/fail gate for the changed surface.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / PR Risk Taxonomy

Commit: b64e30be6c1e73375c7210aa5d9f78374c63d82e

PR taxonomy review recommended (neutral)

Detected 2 PR taxonomy bucket(s): Security Evidence, CI/CD Recommendation.

Scanned 2 changed file(s).

Roadmap taxonomy buckets:

Security Evidence

Security-sensitive changes should carry explicit scanner, code-scanning, or focused regression evidence.

Signals:

  • Security-sensitive changes may ship without scanner evidence
  • 0 security-sensitive path(s) changed

Paths:

  • scripts/hooks/mcp-health-check.js
  • tests/hooks/mcp-health-check.test.js

CI/CD Recommendation

CI, dependency, coverage, and contract signals should be routed into follow-up checks or verification work.

Signals:

  • 1 CI or workflow path(s) changed

Paths:

  • tests/hooks/mcp-health-check.test.js

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / Reference Set Readiness

Commit: b64e30be6c1e73375c7210aa5d9f78374c63d82e

Reference set readiness gaps detected (neutral)

Reference evidence present for 1/7 areas (14%) across 2 changed file(s).

This check is based on files changed in this PR. Repository-level readiness is still reported by /ecc-tools analyze comments and generated manifests.

Area Status Evidence / Next Step
Deep analyzer corpus Missing Add analyzer fixture, golden, benchmark, or reference-set files that can catch analyzer regressions.
RAG/evaluator comparison Missing Add retrieval or evaluator reference-set comparison fixtures with expected ranking behavior.
PR salvage/review corpus Missing Add stale-PR, review-thread, reopen-flow, or salvage reference cases for queue cleanup automation.
Discussion triage corpus Missing Add public discussion triage fixtures, golden cases, or reference sets for informational, answered, and no-response classifications.
Harness compatibility Present tests/hooks/mcp-health-check.test.js
Security evidence Missing Attach security evidence such as SBOMs, SARIF, audit reports, or AgentShield evidence packs.
CI failure-mode evidence Missing Add captured CI failure logs, dry-run fixtures, or troubleshooting docs for common workflow failure modes.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / Hosted Promotion Readiness

Commit: b64e30be6c1e73375c7210aa5d9f78374c63d82e

Hosted promotion readiness passed (success)

No hosted promotion evidence gaps detected across 2 changed file(s); 0 corpus scenarios had matching evidence.

This check compares PR file changes against the evaluator/RAG promotion corpus in src/analyzers/fixtures/evaluator-rag-corpus.ts.
Hosted output scoring inspected 0 completed cached hosted job results.

No evaluator corpus scenarios matched this PR.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • MCP health checks now correctly identify the server and tool from MCP-prefixed tool names when explicit server or tool fields are also present.
    • Health-check results now reflect the identified server, including when reporting an unhealthy tool.

The MCP health check now parses native MCP tool names before checking explicit server and tool fields. Tests verify the resolved target in post-failure state and pre-use blocking behavior.

Changes: MCP Target Resolution

Layer / File(s) Summary
Resolve MCP targets and verify health-check behavior
scripts/hooks/mcp-health-check.js, tests/hooks/mcp-health-check.test.js
extractMcpTarget parses MCP-prefixed names before using explicit fields. Tests verify that the parsed server determines recorded state and pre-use blocking when the fields conflict.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • affaan-m/ECC#3932: This PR scopes the MCP health cache to the resolved server identity, which is connected to this change’s MCP target resolution.
Merge Risk: Minimal · up to b64e3

MCP health-check failures are now attributed to the dispatched server and tool rather than to conflicting argument fields. The change is small and tested, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: MCP health checks now use the dispatched tool namespace (mcp__server__tool) instead of explicit server/tool fields. The raw summary confirms that extractMcpTarget now …
Description check Passed The description states the change: the health hook identifies native MCP calls from their mcp__server__tool name before explicit adapter fields. It explains the bug (health state written to the server…
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.
Full details: Title check

Explanation

The title names the main change: MCP health checks now use the dispatched tool namespace (mcp__server__tool) instead of explicit server/tool fields. The raw summary confirms that extractMcpTarget now parses the MCP-prefixed name first, so the title matches the changeset. It is specific and concise.

Full details: Description check

Explanation

The description states the change: the health hook identifies native MCP calls from their mcp__server__tool name before explicit adapter fields. It explains the bug (health state written to the server named in arguments), the regression test, and the testing done. It matches the changeset.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: affaan-m/ECC
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 3f14a10
  • Layers: Repository YAML
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 8137e422-b119-420e-9176-0d4d137ada85
Commits

Reviewing files that changed from the base of the PR and between 3f14a10 and b64e30b.

Files selected for processing: 2

  • scripts/hooks/mcp-health-check.js
  • tests/hooks/mcp-health-check.test.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Recent review details

Context from checks skipped due to timeout: 2

  • GitHub Check: Greptile Review
  • GitHub Check: CodeRabbit
Additional context used

Code guidelines: 11

.cursor/rules/typescript-security.md — auto-discovered
.agents/skills/coding-standards/SKILL.md — Agent Skill
AGENTS.md — auto-discovered
.cursor/rules/typescript-coding-style.md — auto-discovered
.agents/skills/ecc-conventions/SKILL.md — Agent Skill
.claude/rules/node.md — auto-discovered
.cursor/rules/common-patterns.md — auto-discovered
.cursor/rules/kotlin-testing.md — auto-discovered
.cursor/rules/python-coding-style.md — auto-discovered
.cursor/rules/swift-patterns.md — auto-discovered
.cursor/rules/common-testing.md — auto-discovered
Path-based instructions: 13

Focus on command injection, unsafe subprocess usage, path traversal, SSRF, secret exposure, and missing tests for new CLI behavior.

CodeRabbit configuration file

Files:

  • scripts/hooks/mcp-health-check.js
Source excerpt:

CodeRabbit inference engine (.cursor/rules/typescript-security.md)

Files:

  • scripts/hooks/mcp-health-check.js
  • tests/hooks/mcp-health-check.test.js
Source excerpt: Source excerpt: Source excerpt: Source excerpt: Source excerpt:

CodeRabbit inference engine (.agents/skills/coding-standards/SKILL.md)

Files:

  • scripts/hooks/mcp-health-check.js
  • tests/hooks/mcp-health-check.test.js
Source excerpt: **Immutability (CRITICAL):** Always create new objects, never mutate.

CodeRabbit inference engine (AGENTS.md)

Files:

  • scripts/hooks/mcp-health-check.js
  • tests/hooks/mcp-health-check.test.js
Source excerpt: Use spread operator for immutable updates: Source excerpt: Use async/await with try-catch: Source excerpt: Use Zod for schema-based validation: Source excerpt: No `console.log` statements in production code Source excerpt: U...

CodeRabbit inference engine (.cursor/rules/typescript-coding-style.md)

Files:

  • scripts/hooks/mcp-health-check.js
  • tests/hooks/mcp-health-check.test.js
Source excerpt: Follow *.test.js naming pattern

CodeRabbit inference engine (.agents/skills/ecc-conventions/SKILL.md)

Files:

  • tests/hooks/mcp-health-check.test.js
Source excerpt: `scripts/` — Node.js utilities, hooks.

CodeRabbit inference engine (.claude/rules/node.md)

Files:

  • scripts/hooks/mcp-health-check.js
Source excerpt: `tests/` — Mirror the `scripts/` structure.

CodeRabbit inference engine (.claude/rules/node.md)

Files:

  • tests/hooks/mcp-health-check.test.js
Source excerpt: Encapsulate data access behind a consistent interface: Define standard operations: findAll, findById, create, update, delete Concrete implementations handle storage details (database, API, file, etc.) Business logic depends...

CodeRabbit inference engine (.cursor/rules/common-patterns.md)

Files:

  • scripts/hooks/mcp-health-check.js
  • tests/hooks/mcp-health-check.test.js
Source excerpt: Use **Kotest** with spec styles (StringSpec, FunSpec, BehaviorSpec) and **MockK** for mocking.

CodeRabbit inference engine (.cursor/rules/kotlin-testing.md)

Files:

  • scripts/hooks/mcp-health-check.js
  • tests/hooks/mcp-health-check.test.js
Source excerpt: Follow **PEP 8** conventions Source excerpt: Use **type annotations** on all function signatures Source excerpt: Prefer immutable data structures: Source excerpt: **black** for code formatting Source excerpt: **isort** for i...

CodeRabbit inference engine (.cursor/rules/python-coding-style.md)

Files:

  • scripts/hooks/mcp-health-check.js
  • tests/hooks/mcp-health-check.test.js
Source excerpt: Define small, focused protocols.

CodeRabbit inference engine (.cursor/rules/swift-patterns.md)

Files:

  • scripts/hooks/mcp-health-check.js
  • tests/hooks/mcp-health-check.test.js
Source excerpt: Test Types (ALL required): **Unit Tests** - Individual functions, utilities, components **Integration Tests** - API endpoints, database operations **E2E Tests** - Critical user flows (framework chosen per language)

CodeRabbit inference engine (.cursor/rules/common-testing.md)

Files:

  • scripts/hooks/mcp-health-check.js
  • tests/hooks/mcp-health-check.test.js

@greptile-apps

greptile-apps Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

MCP health checks now take the server and tool from the dispatched native tool name before checking adapter fields.

  • MCP health checks follow the dispatched server and tool.

Validation: all 36 checks in tests/hooks/mcp-health-check.test.js passed. Two Windows-only checks were skipped on Linux. No actionable issues found.

Reviews (1) · Last reviewed commit: "fix(mcp): use the dispatched tool namesp..." · Reviewed by Greptile

@haelyra
haelyra merged commit daa113b into affaan-m:main Nov 19, 2026
4 checks passed
@haelyra

haelyra commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Thank you for using the dispatched MCP tool namespace in health checks. We merged your original commit history through #4048 so the related changes could be tested together.

The resulting main commit fbb1a85c59a8468c96454fc5b48cf7e4f8f79b55 passed CI, CodeQL, and Supply-Chain Watch. Thank you for helping improve ECC!

montjeffrey added a commit to montjeffrey/ECC that referenced this pull request Nov 27, 2026
A well-formed mcp__<server>__<tool> name already names the server
before any argument is read (affaan-m#4023). This covers the paths that still
let a tool argument or a non-string value choose the probed server:

- A tool name that starts with mcp__ but does not parse (mcp__foo,
  mcp____tool, mcp__) no longer falls back to tool_input.server,
  mcp_server or connector; those are the MCP tool's own arguments.
- Explicit server values must be strings matching the server-id
  pattern. An object was stringified, so a generic wrapper call such
  as call_mcp with tool_input.server = {host: 'x'} logged
  "[object Object]".
- In truncated input, server and tool values found by regex anywhere
  in the raw text are passed as tool_input, so they are not trusted
  for an mcp__ name that does not parse.

The pattern is now one SERVER_ID_PATTERN constant, also used by
resolveServerConfig() and reconnectCommand(). tool_input.* is still
honored for generic wrapper tools whose name is not an mcp__ name.
Claude Code only emits well-formed mcp__<server>__<tool> names, and
^mcp__ keeps generic wrapper tools out, so this is defensive.
montjeffrey added a commit to montjeffrey/ECC that referenced this pull request Nov 27, 2026
A well-formed mcp__<server>__<tool> name already names the server
before any argument is read (affaan-m#4023). This covers the paths that still
let a tool argument or a non-string value choose the probed server:

- A tool name that starts with mcp__ but does not parse (mcp__foo,
  mcp____tool, mcp__) no longer falls back to tool_input.server,
  mcp_server or connector; those are the MCP tool's own arguments.
- Explicit server values must be strings matching the server-id
  pattern. An object was stringified, so a generic wrapper call such
  as call_mcp with tool_input.server = {host: 'x'} logged
  "[object Object]".
- In truncated input, server and tool values found by regex anywhere
  in the raw text are passed as tool_input, so they are not trusted
  for an mcp__ name that does not parse.

The pattern is now one SERVER_ID_PATTERN constant, also used by
resolveServerConfig() and reconnectCommand(). tool_input.* is still
honored for generic wrapper tools whose name is not an mcp__ name.
Claude Code only emits well-formed mcp__<server>__<tool> names, and
^mcp__ keeps generic wrapper tools out, so this is defensive.
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