Skip to content

Improve MCP operability - #88399

Merged
steipete merged 2 commits into
mainfrom
codex/mcp-operability-hardening
May 30, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/mcp-operability-hardening

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • Add MCP status/probe/tools CLI support for transport inspection, live capability probing, and per-server tool selection.
  • Expose MCP resources/prompts through generated utility tools, with shared filtering, diagnostics, prompt-safe metadata handling, and inventory parity.
  • Harden bundled MCP runtime behavior around best-effort tool listing, list-changed cache invalidation, refresh diagnostics, request failure backoff, and config schema/help/docs.

Verification

  • pnpm test src/cli/mcp-cli.test.ts src/agents/agent-bundle-mcp-runtime.test.ts src/agents/agent-bundle-mcp-tools.materialize.test.ts src/config/schema.test.ts src/config/schema.help.quality.test.ts -- --reporter=verbose
  • .agents/skills/autoreview/scripts/autoreview --mode local
  • pnpm build
  • live CLI proof with a temp stdio MCP server: set/status/tools/show/probe verified stdio transport, toolFilter persistence, filtered tool projection, resources/prompts, and listChanged capabilities
  • git diff --check
  • pnpm docs:list
  • env -u OPENCLAW_TESTBOX pnpm check:changed

Real behavior proof

Behavior addressed: MCP operators can inspect configured transports without connecting, probe configured servers with live diagnostics, filter per-server tools, see resource/prompt utilities, and avoid stale or runaway failing MCP operations.
Real environment tested: local source checkout on macOS with the built OpenClaw CLI and a real temporary stdio MCP server process.
Exact steps or command run after this patch: built the CLI, configured a temp stdio MCP server with openclaw mcp set, checked openclaw mcp status --json, wrote a filter with openclaw mcp tools, verified config with openclaw mcp show --json, and connected with openclaw mcp probe --json.
Evidence after fix: probe reported one exposed tool, one filtered tool, resources=true, prompts=true, listChanged true for tools/resources/prompts, and projected tools ["live__search_docs"].
Observed result after fix: the filtered MCP tool remained available under a provider-safe OpenClaw tool name while admin and generated utility tools were hidden by the filter; status remained non-connecting.
What was not tested: remote Testbox changed-gate execution; the delegated Testbox checkout failed before checks with no merge base for origin/main...HEAD, while the same changed gate passed locally without Testbox delegation.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels May 30, 2026
@clawsweeper

clawsweeper Bot commented May 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed May 30, 2026, 2:41 PM ET / 18:41 UTC.

Summary
The branch adds MCP status/probe/tools CLI commands, per-server MCP tool filtering, MCP resource/prompt utility projection, runtime cache/backoff behavior, schema/help/docs, and tests.

PR surface: Source +866, Tests +784, Docs +34. Total +1684 across 16 files.

Reproducibility: yes. from source inspection: a configured mcp.servers.<name>.toolFilter.exclude is enforced in the embedded runtime catalog, while native CLI/Codex projection paths still build downstream MCP server config from the same user servers without applying or failing closed on that filter.

Review metrics: 1 noteworthy metric.

  • Public config surfaces: 1 added. mcp.servers.*.toolFilter becomes a persisted user-facing config contract, so backend and upgrade behavior should be settled before merge.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦞 diamond lobster
Patch quality: 🦪 silver shellfish
Result: blocked by patch quality or review findings.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Decide whether toolFilter is a global restriction or embedded-only metadata.
  • [P2] Add focused native projection coverage for the chosen contract.

Risk before merge

  • [P1] Operators may treat toolFilter as a least-privilege restriction, but native CLI/Codex projection paths can still expose the same server without that restriction.
  • [P1] The resource/prompt utility expansion increases the amount of untrusted MCP output available to the model, so the filter semantics should be settled before this broader surface ships.

Maintainer options:

  1. Settle and encode the filter contract (recommended)
    Decide whether toolFilter is global or embedded-only, then enforce, fail closed, or document that contract consistently before merge.
  2. Accept embedded-only semantics
    Maintainers can intentionally ship this as embedded-only if the config/help/docs make clear that native MCP backends do not enforce it as a restriction.
  3. Pause the broad MCP expansion
    If the contract decision is not ready, pause this PR and split lower-risk status/probe pieces from filter/resource/prompt projection work.

Next step before merge

  • [P1] A maintainer should decide the intended toolFilter contract before an author or automation chooses between global enforcement, fail-closed native projection, or embedded-only documentation.

Security
Needs attention: The concrete security concern is the filter contract gap: operators may rely on it as a least-privilege boundary while native projections can bypass it.

Review findings

  • [P1] Enforce toolFilter before native MCP projection — src/config/zod-schema.ts:360-366
Review details

Best possible solution:

Land the feature only after the filter contract is explicitly settled and encoded in code, docs, and tests across embedded and native MCP projection paths.

Do we have a high-confidence way to reproduce the issue?

Yes from source inspection: a configured mcp.servers.<name>.toolFilter.exclude is enforced in the embedded runtime catalog, while native CLI/Codex projection paths still build downstream MCP server config from the same user servers without applying or failing closed on that filter.

Is this the best way to solve the issue?

No: the feature direction is useful, but the current implementation is not the best merge shape until the public filter contract is enforced consistently or explicitly scoped.

Full review comments:

  • [P1] Enforce toolFilter before native MCP projection — src/config/zod-schema.ts:360-366
    This introduces mcp.servers.<name>.toolFilter as a public config field, but the native CLI/Codex projection paths still pass the same server definitions into downstream MCP backends without applying the include/exclude list or failing closed. A user who excludes admin_* can still expose those tools outside the embedded runtime, so please either enforce the filter globally or scope this config to embedded-only before publishing it.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 6399b6a4455d.

Label changes

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦞 diamond lobster and patch quality is 🦪 silver shellfish.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P2: This is a normal-priority MCP feature/config change with meaningful but bounded operator-facing impact.
  • merge-risk: 🚨 compatibility: The PR adds a persisted MCP config surface whose behavior can differ across runtime/projection paths.
  • merge-risk: 🚨 security-boundary: Operators may use MCP tool filters as least-privilege restrictions, so bypassing them in native projections can expose tools the user meant to hide.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦞 diamond lobster and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body includes after-fix live CLI proof from a local source checkout with a temporary stdio MCP server, including status/show/probe output and observed filtered tool projection.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix live CLI proof from a local source checkout with a temporary stdio MCP server, including status/show/probe output and observed filtered tool projection.
Evidence reviewed

PR surface:

Source +866, Tests +784, Docs +34. Total +1684 across 16 files.

View PR surface stats
Area Files Added Removed Net
Source 10 901 35 +866
Tests 4 793 9 +784
Docs 2 37 3 +34
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 16 1731 47 +1684

Security concerns:

  • [medium] Tool filters are not a consistent least-privilege boundary — src/config/zod-schema.ts:360
    The PR exposes per-server MCP filtering in config/docs, but sibling native projections do not enforce the same filter, so a hidden tool can still be available through another MCP backend path.
    Confidence: 0.88

Acceptance criteria:

  • [P1] pnpm test src/agents/cli-runner/bundle-mcp.user-config.test.ts src/agents/cli-runner/bundle-mcp.codex.test.ts src/agents/codex-mcp-config.test.ts src/agents/agent-bundle-mcp-runtime.test.ts src/cli/mcp-cli.test.ts -- --reporter=verbose.
  • [P1] pnpm build.

What I checked:

  • Repository policy: Root policy marks config/default additions and provider/plugin behavior as compatibility-sensitive, and says whole decision surfaces and sibling runtimes should be reviewed for one-sided fixes. (AGENTS.md:26, 6399b6a4455d)
  • New public config surface: The PR adds mcp.servers.*.toolFilter to the config schema with include/exclude lists, making it a persisted user-facing contract. (src/config/zod-schema.ts:360, 881acc6d70cd)
  • Embedded path enforces filters: The embedded session MCP runtime reads the filter and only projects tools that pass shouldExposeMcpTool. (src/agents/agent-bundle-mcp-runtime.ts:585, 881acc6d70cd)
  • Native CLI projection remains unfiltered: The CLI backend path still loads the merged MCP config and applies it to downstream native MCP config without applying the include/exclude filter or failing closed. (src/agents/cli-runner/bundle-mcp.ts:171, 881acc6d70cd)
  • Codex app-server projection remains unfiltered: The Codex thread-config projection iterates normalized user MCP servers and normalizes each server into mcp_servers without applying toolFilter. (src/agents/cli-runner/bundle-mcp-codex.ts:81, 881acc6d70cd)
  • Diff sanity: Whitespace diff check passed for the PR range inspected locally. (881acc6d70cd)

Likely related people:

  • steipete: Current-main blame and log history for the MCP merge/projection helpers point to Peter Steinberger's recent commit on this area, independent of this PR author signal. (role: recent area contributor; confidence: high; commits: 4df27b96261e; files: src/agents/bundle-mcp-config.ts, src/agents/codex-mcp-config.ts, src/agents/agent-bundle-mcp-runtime.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 374a0905dc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/config/zod-schema.ts
Comment on lines 357 to +364
z.union([z.string().register(sensitive), z.number(), z.boolean()]).register(sensitive),
)
.optional(),
toolFilter: z
.object({
include: z.array(z.string().trim().min(1)).min(1).optional(),
exclude: z.array(z.string().trim().min(1)).min(1).optional(),
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Apply MCP filters outside embedded runtime

When mcp.servers.<name>.toolFilter is set, it is only enforced in the embedded createSessionMcpRuntime path; the same cfg.mcp.servers entries are still projected to CLI/app-server MCP backends through loadMergedBundleMcpConfig/Codex thread config without applying the include/exclude list. In those contexts a filtered server still exposes all of its MCP tools (or relies on a downstream client ignoring this OpenClaw-only key), which defeats the new config contract for users who configure the filter as a tool restriction. Please either apply the filter before projecting to these backends or fail closed/document that those backends cannot enforce it.

Useful? React with 👍 / 👎.

@steipete
steipete force-pushed the codex/mcp-operability-hardening branch from 374a090 to 7ccf32d Compare May 30, 2026 17:54
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels May 30, 2026
@steipete
steipete force-pushed the codex/mcp-operability-hardening branch from 7ccf32d to 8da3b79 Compare May 30, 2026 18:27
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels May 30, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Verification before merge:

Behavior addressed: MCP operability hardening: status/probe/tools CLI, per-server tool filters, resource/prompt utility projection, listChanged invalidation, request-failure backoff, metadata sanitization, and docs.

Real environment tested: local macOS source checkout plus GitHub Actions on PR branch.

Exact steps or command run after this patch:

  • pnpm test src/shared/number-coercion.test.ts src/agents/auth-profiles/usage.test.ts src/cli/mcp-cli.test.ts src/agents/agent-bundle-mcp-runtime.test.ts src/agents/agent-bundle-mcp-tools.materialize.test.ts -- --reporter=verbose
  • pnpm lint
  • pnpm tsgo:prod
  • pnpm build
  • git diff --check origin/main...HEAD
  • GitHub Actions run 26691733977, run 26691733980, run 26691733985, dependency guard run 26691733226, real behavior proof run 26691861563

Evidence after fix: focused local tests passed 3 Vitest shards with 124 tests; local lint, prod types, build, and whitespace check passed. GitHub Actions passed dependency-guard, real behavior proof, changed-path scan, security high lanes including mcp-process-tool-boundary, critical quality config/network lanes, build, lint, prod types, test types, guards, docs, dependency checks, gateway-core, plugin-sdk, and the MCP-adjacent Node shards.

Observed result after fix: required check dependency-guard is green on head 881acc6.

What was not tested: checks-node-agentic-commands-doctor still hits the existing 5-minute no-output watchdog after doctor-config-flow.include-warning; the same exact doctor shard was reproduced locally and stalls at the same point, and the PR diff does not touch src/commands/doctor*, src/infra*, or test/vitest/vitest.commands*. checks-node-core-runtime-infra-state remained pending after the doctor failure while its sibling infra-process lane passed; the PR diff does not touch infra state files.

@steipete
steipete merged commit 99ce71d into main May 30, 2026
112 of 116 checks passed
@steipete
steipete deleted the codex/mcp-operability-hardening branch May 30, 2026 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant