Repository navigation
fix(mcp): hide policy-denied plugin tools from ACP sessions [AI] - #136546
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 2, 2026, 6:17 PM ET / 22:17 UTC. ClawSweeper reviewWhat this changesThe PR applies a managed ACP session’s effective tool policy when exposing plugin tools through the MCP bridge, hiding denied tools and rejecting their calls. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 5 items remain The patch follows the canonical effective-policy pipeline and its focused test covers denied discovery and direct invocation. This maintainer-authored, protected PR should remain open for a maintainer to verify that the prior requested managed-ACPX process trace (or an explicit skip) is satisfied before merge. Priority: P1 Review scores
Verification
How this fits togetherThe plugin-tools MCP bridge starts a local MCP server for ACP sessions and supplies plugin tools to its discovery and call handlers. ACPX injects the managed session identity into that child process, which now resolves and filters tools using the agent’s policy. flowchart LR
A[Managed ACPX session] --> B[Session identity environment]
B --> C[Plugin tools MCP bridge]
C --> D[Effective agent policy]
D --> E[Plugin tool discovery]
E --> F[Policy-filtered tool registry]
F --> G[MCP list and call requests]
Decision needed
Why: The provided PR body shows focused mocked handler coverage, while the prior completed review specifically required process-boundary evidence; later comment contents are not available in this review projection. Before merge
Agent review detailsSecurityNone. PR surfaceSource +44, Tests +70. Total +114 across 2 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the shared policy resolver and pipeline, then land after a maintainer verifies a redacted managed-ACPX MCP trace showing denied tools are neither listed nor executed while an allowed tool works, or accepts a documented skip. Do we have a high-confidence way to reproduce the issue? No high-confidence live reproduction is available in the supplied review material. Current source and the focused regression make the missing managed-agent policy filter reproducible at the owner boundary, but not through a real ACPX child process here. Is this the best way to solve the issue? Yes: reusing the canonical effective-policy resolver and ordered pipeline is the maintainable owner-boundary fix rather than adding a bridge-specific matcher. The remaining question is process-level proof, not the filtering design. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 55a60de5e7db. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
88ba8f8 to
9c92d02
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
drobison00
left a comment
There was a problem hiding this comment.
Mira · claude-opus-5 · via @drobison00
APPROVE. The bug is real on current main, the fix sits at the correct owner boundary (it reuses the canonical policy pipeline rather than reimplementing filtering inside the bridge), and I could not construct a bypass. Verified at head 9c92d022 by reading the changed module plus its callers, callees, and the policy owner — not diff-only.
Independently reproduced, not taken on faith
I reverted only src/mcp/plugin-tools-serve.ts to its pre-PR state (6a802e9a378), kept the new test, and re-ran the suite:
× plugin tools MCP server > enforces global and managed-agent plugin tool policy
→ expected { tools: [ { …(3) }, { …(3) } ] } to match object { Object (tools) }
Test Files 1 failed (1)
Tests 1 failed | 20 passed (21)
It fails for exactly the right reason — discovery lists both tools, i.e. the agent-denied plugin_denied is exposed — and the other 20 pass, so the regression is targeted rather than incidental. At head the full file passes 21/21.
Why this is the right fix, not merely a plausible one
- Owner boundary.
resolveEffectiveToolPolicy+buildDefaultToolPolicyPipelineSteps+applyToolPolicyPipelineare the canonical layered-policy owner; the bridge now consumes them instead of hand-rolling a second policy path. No duplicate policy is introduced. - Enforcement covers dispatch, not just listing.
createPluginToolsMcpHandlersbuildstoolMapfrom the same filtered array it lists (plugin-tools-handlers.ts:77-80), so a denied tool yieldsUnknown tooland its executor is never invoked — the test asserts both. The automations alias fallback (:96-98) can only resolve to an entry already in that map, so it is not an escape hatch. - The pre-filter cannot silently over-restrict.
collectExplicitAllowlist/collectExplicitDenylistare unions across layers, so threading the agent layer into discovery bounds only widens the allow set and narrows the deny set; the ordered pipeline does the real narrowing afterward. stripPluginOnlyAllowlistdoes not de-fang the filter. I checkedanalyzeAllowlistByToolTypespecifically because every step sets that flag and this bridge serves only plugin tools: it returnspolicyunchanged and affects warning text alone, so the allow-filter survives intact.- The identity input fails closed.
resolveToolsMcpSessionContextthrows when a session key is present without a derivable owner, or when the encoded owner and explicit owner disagree — the server exits rather than serving unfiltered tools.extensions/acpx/src/runtime.ts:767-805injects the session key and--openclaw-agent-idinto the managed plugin-tools server, so the managed ACP path actually reaches the new code. - Exact-head CI: 113 check runs, 0 failures.
Non-blocking notes
byProviderlayers are resolved but never applied.resolveEffectiveToolPolicyreturnsglobalProviderPolicy/agentProviderPolicy/providerProfile, and the bridge passes nomodelProvider/modelId— correctly, since it cannot know the ACP backend's model — so those layers stay inert here. A deny expressed only undertools.byProviderstill will not hide a plugin tool on this bridge. Worth one line in the PR body as a known limit so it is a decision rather than an oversight.- User impact is slightly broader than "denied tools disappear." Because the agent layer is now applied, an operator whose
agents.<id>.tools.allownames only core tools (no plugin entries, nogroup:plugins) will find plugin tools vanish from managed ACP sessions. That is the correct semantics and matches the agent path, but it is a visible behavior change worth a release-note sentence. - Test fidelity nit. The mocked tools carry no plugin metadata, so
getPluginToolMetareturnsundefinedand the pipeline classifies them as core tools — meaning the new test exercises name-based policy only, never plugin-group expansion (group:plugins, plugin-id entries), which is the allowlist shape most likely on a plugin-only bridge. Production is fine (real tools get meta from the WeakMap set insrc/plugins/tools.ts), but a follow-up case with metadata attached would close the gap that matters most here. - Sibling surfaces checked, no one-sided fix.
openclaw-tools-serve.tsserves two host-selected ring-zero tools rather than the plugin registry (and hard-requires the session key), andnode-claude-skill-runtime.tsserves only the workshop tool — neither exposes the plugin registry, so this invariant does not leave a matching hole behind. The remaining asymmetry is intentional: this bridge tolerates an absent session key to preserve the documented standalone/agentless use, which means a hand-wired plugin-tools server under a non-managed name still gets global policy only.
* refs/remotes/origin/main: fix(plugins): reject unverifiable pinned npm installs (#136725) improve(ui): lift sidebar section headers on hover and mark online owners (#136985) test(cron): reuse isolated run suite hooks (#137341) test(channels): reuse shared indexed call guards (#137350) fix(ui): sidebar header controls read misaligned after the + button lost its border (#137317) fix(qa-channel): preserve conversation kind for implicit actions (#137343) fix: target the source checkout in Control UI repair commands (#137354) chore: reduce CI job count and database test overhead (#137352) fix(ios): preserve chat live edge across keyboard transitions (#136660) refactor(control-ui): consolidate mention inbox requests (#137375) fix(openai): preserve ChatGPT HTTP status for retry pacing (#137146) fix(mcp): hide policy-denied plugin tools from ACP sessions [AI] (#136546) test(queue): reuse shared deferred fixtures (#137338) fix(gateway): repair the Gateway E2E shard (browser suite project, skill resource argv, Codex diagnostic) (#137358)
…nclaw#136546) * fix(mcp): enforce managed agent plugin tool policy * fix(mcp): satisfy plugin policy lint * Note: Managed ACP sessions now honor per-agent plugin-tool allowlists. Agents with restrictive core-only allowlists no longer expose plugin tools unless an applicable tool name, plugin ID, group:plugins, or * is explicitly allowed.
What Problem This Solves
Addresses an issue where a managed ACP session could list and call plugin tools excluded by its configured agent tool policy when the optional plugin-tools MCP bridge was enabled.
Why This Change Was Made
The bridge now resolves effective policy from the canonical managed-agent session context, reuses the standard profile/global/agent policy pipeline, bounds plugin discovery with the combined allow/deny rules, and applies the same ordered policy to the final MCP tool registry. The existing standalone agentless path is unchanged.
User Impact
Policy-denied plugin tools no longer appear in managed ACP tool discovery and direct calls to them are rejected, while permitted plugin tools remain available.
Evidence
73aee804eb910a8fc2e2a3b5757539db8703ad5a.node scripts/run-vitest.mjs src/mcp/plugin-tools-serve.test.tspassed 21 tests.git diff --checkpassed.codex-rs/codex-mcp/src/rmcp_client.rs:610andcodex-rs/codex-mcp/src/connection_manager.rs:856: discovery usestools/list, and dispatch usestools/call.AI-assisted implementation; source, dependency behavior, and tests were inspected directly.