Skip to content

fix(mcp): dedupe blocked stdio env warnings - #128102

Merged
vincentkoc merged 3 commits into
openclaw:mainfrom
gaoanze888:gaoanze888/mcp-dedupe-blocked-env-warnings
Aug 23, 2026
Merged

vincentkoc merged 3 commits into
openclaw:mainfrom
gaoanze888:gaoanze888/mcp-dedupe-blocked-env-warnings

Conversation

@gaoanze888

@gaoanze888 gaoanze888 commented Aug 23, 2026 •

Copy link
Copy Markdown

Closes #92474

What Problem This Solves

MCP servers configured with blocked stdio environment keys such as PYTHONPATH
could log the same safety warning on every transport resolution, flooding
gateway logs even though the key was still removed.

Fix

The shared transport resolver keeps the existing blocked-key filter and routes
the warning through its bounded process-local cache. The cache identity is the
JSON encoding of the raw [serverName, key] tuple, so different pairs cannot
collide through delimiter text. Sanitization remains limited to log output.

This is the resolver-owned fix: callers that use the default warning behavior
share the same dedupe boundary, while callers that explicitly pass
logWarnings: false remain silent.

Evidence

Exact head: 7842329d69a14a5e21ccfb3f40e9b92fbf399a6f

  • Fresh max-P1 autoreview with gpt-5.6-sol at high reasoning: clean, no
    actionable P0/P1 findings.
  • Sanitized direct AWS Crabbox proof used a fresh head-bound checkout, public
    networking, no Tailscale, no hydrated credentials, and no IAM role
    credentials.
  • A full package build completed before the proof imported the emitted
    dist/mcp-transport-config-*.js resolver chunk.
  • Focused resolver test: 13/13 passed.
  • Exact-head changed gate: exit 0, including core and core-test typechecks,
    formatting, lint, dead-code, boundary, and repository guards.
  • Targeted oxfmt --check and git diff --check: passed.
  • Hosted exact-head CI: 207 success, 47 skipped, 1 neutral, no failures
    or pending checks.

Sanitized unmocked resolver transcript:

old head c4e94b27f3b23796d920b254b01e129266452158:
  resolutions=7 warning_count=4 empty_env_count=7

fixed built dist 7842329d69a14a5e21ccfb3f40e9b92fbf399a6f:
  resolutions=7 warning_count=5 empty_env_count=7

The seven resolutions cover:

  • the same server/key pair three times;
  • another server with the same key;
  • the original server with another blocked key;
  • the previously colliding raw pairs (svc, LD_A:LD_B) and
    (svc:LD_A, LD_B).

The old delimiter identity aliases the final two pairs and emits only four
warnings. The built fixed resolver emits five distinct warnings, while every
blocked value is removed (env={} in all seven results).

Caller Audit

Not every inspection caller uses logWarnings: false. Selected bundle and
OAuth request paths suppress warnings, while src/cli/mcp-cli.ts,
src/agents/mcp-config-mutation.ts, src/agents/mcp-auth-profile.ts, and
src/agents/mcp-transport.ts use the resolver's default warning behavior.
Resolver-boundary dedupe therefore covers the shared warning owner without
adding caller policy or changing global logger behavior.

Scope

  • Whole PR production: +22/-6 (net +16) for the bounded resolver-owned
    dedupe state.
  • Whole PR tests: +66/-0.
  • Collision repair relative to the previously reviewed head: production
    +1/-1 (net 0); tests +23/-1.
  • No config/default, SDK, protocol, migration, dependency, capacity,
    lifecycle, reset, or logger-policy changes.
  • No persistent data-model change; the cache is bounded process-local state.

Punchcard-Session: quiet-valley-harbor-ep

AI-assisted implementation; I reviewed the changed code and validation output.

@clawsweeper

clawsweeper Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Aug 23, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 23, 2026
@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 3:20 AM ET / 07:20 UTC.

ClawSweeper review

What this changes

The PR deduplicates blocked stdio environment-variable warnings once per MCP server/key pair per process while still removing unsafe keys.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: current main still emits the blocked-env warning for every resolver call, while this PR moves deduplication to the shared resolver and preserves the safety filter. Likely related people: ClawSweeper (low-confidence current-source provenance).

Priority: P2
Reviewed head: 7842329d69a14a5e21ccfb3f40e9b92fbf399a6f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused resolver-owner repair with collision coverage and credible exact-head terminal proof.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body supplies an exact-head, sanitized built-resolver terminal transcript showing five distinct warnings across seven resolutions while all seven blocked environments remain empty.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body supplies an exact-head, sanitized built-resolver terminal transcript showing five distinct warnings across seven resolutions while all seven blocked environments remain empty.
Evidence reviewed 6 items Current-main defect: Current main directly calls logWarn from the dropped-environment callback on every transport resolution; there is no dedupe state at this owner boundary.
Resolver is the shared owner: The stdio normalizer reports each filtered key through onDroppedEnv, and the live transport factory consumes the resolver’s sanitized output; caller-local suppression would miss paths.
Patch preserves the security filter: The PR only routes the existing dropped-key callback through a bounded cache keyed by the raw JSON tuple, while mcp-config-shared continues to remove dangerous inherited environment names.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/agents/mcp-transport-config.test.ts -t "warns once per blocked stdio env key and server"

Result: FAIL (partial) — step 2 expect_output warns once per blocked stdio env key and server: expected terminal output was not visible within 30 seconds: "warns once per blocked stdio env key and server"

node scripts/run-vitest.mjs src/agents/mcp-transport-config.test.ts -t "warns once per blocked stdio env key and server"
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128102-oPSj1B/target$ node scripts/run-vitest.mjs src/agents/mcp-transport-config.test.ts -t "warns once per bl
ocked stdio env key and server"
node scripts/run-vitest.mjs src/agents/mcp-transport-config.test.ts -t "warns once per blocked stdio env key and server"
[test] starting test/vitest/vitest.agents-core.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128102-oPSj1B/target

 ✓  agents-core  src/agents/mcp-transport-config.test.ts (13 tests | 12 skipped) 91ms

 Test Files  1 passed (1)
      Tests  1 passed | 12 skipped (13)
   Start at  07:21:32
   Duration  1.49s (transform 1.12s, setup 936ms, import 104ms, tests 91ms, environment 0ms)

[test] passed 1 Vitest shard in 7.49s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128102-oPSj1B/target$ node scripts/run-vitest.mjs src/agents/mcp-transport-config.test.ts -t "warns once per bl
ocked stdio env key and server"
[test] starting test/vitest/vitest.agents-core.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128102-oPSj1B/target

 ✓  agents-core  src/agents/mcp-transport-config.test.ts (13 tests | 12 skipped) 46ms

 Test Files  1 passed (1)
      Tests  1 passed | 12 skipped (13)
   Start at  07:21:39
   Duration  750ms (transform 357ms, setup 435ms, import 37ms, tests 46ms, environment 0ms)

[test] passed 1 Vitest shard in 6.67s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128102-oPSj1B/target$




















Assertions:

  • FAIL expect_output: warns once per blocked stdio env key and server

How this fits together

MCP server configuration passes through a shared transport resolver before OpenClaw starts a stdio, SSE, or HTTP transport. For stdio servers, the resolver drops unsafe environment keys, logs the operator-facing warning, and passes the sanitized environment to startup.

flowchart LR
  A[MCP server configuration] --> B[Transport resolver]
  B --> C[Stdio environment safety filter]
  C --> D[Bounded warning dedupe]
  C --> E[Sanitized launch configuration]
  D --> F[Gateway or CLI logs]
  E --> G[MCP transport startup]
Loading

Before merge

  • Resolve merge risk (P1) - Production code grows by net 16 lines for a bounded 4,096-entry process-local cache; the resolver-local helper is the smallest clear place to combine raw-key identity with sanitized logging.
  • Complete next step (P2) - The open PR already contains the focused repair; no separate repair job is warranted.
Agent review details

Security

None.

PR surface

Source +16, Tests +66. Total +82 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 22 6 +16
Tests 1 66 0 +66
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 88 6 +82

Review metrics

Metric Value Why it matters
Production versus test LOC production +22/-6 (net +16); tests +66/-0 (net +66) The production growth is limited to the shared bounded warning cache and helper; tests cover repetition, distinct pairs, collision safety, and retained sanitization.

Stored data model

Persistent data-model change detected: serialized state: src/agents/mcp-transport-config.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #92474
Summary: This PR is a concrete candidate fix for the linked recurring blocked-stdio warning report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the bounded JSON-tuple dedupe at the resolver boundary, preserving the existing dropped-key filter and explicit silent callers.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the bounded JSON-tuple dedupe at the resolver boundary, preserving the existing dropped-key filter and explicit silent callers.

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

Yes—current main’s dropped-env callback directly logs on every resolution, and the exact-head terminal transcript demonstrates the changed bounded-warning behavior; no local execution was performed because this is a read-only review.

Is this the best way to solve the issue?

Yes—the shared resolver is the narrowest owner because stdio normalization reports dropped keys there and several runtime and CLI callers use it; caller-local suppression would be incomplete.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 352095882e60.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies an exact-head, sanitized built-resolver terminal transcript showing five distinct warnings across seven resolutions while all seven blocked environments remain empty.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body supplies an exact-head, sanitized built-resolver terminal transcript showing five distinct warnings across seven resolutions while all seven blocked environments remain empty.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The PR fixes repeated operator warnings from MCP configuration without changing startup safety behavior or transport delivery.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body supplies an exact-head, sanitized built-resolver terminal transcript showing five distinct warnings across seven resolutions while all seven blocked environments remain empty.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies an exact-head, sanitized built-resolver terminal transcript showing five distinct warnings across seven resolutions while all seven blocked environments remain empty.

Evidence

What I checked:

  • Current-main defect: Current main directly calls logWarn from the dropped-environment callback on every transport resolution; there is no dedupe state at this owner boundary. (src/agents/mcp-transport-config.ts:217, 352095882e60)
  • Resolver is the shared owner: The stdio normalizer reports each filtered key through onDroppedEnv, and the live transport factory consumes the resolver’s sanitized output; caller-local suppression would miss paths. (src/agents/mcp-stdio.ts:50, 7842329d69a1)
  • Patch preserves the security filter: The PR only routes the existing dropped-key callback through a bounded cache keyed by the raw JSON tuple, while mcp-config-shared continues to remove dangerous inherited environment names. (src/agents/mcp-transport-config.ts:66, 7842329d69a1)
  • Regression coverage: The added test proves repeated pairs warn once, distinct servers and keys still warn, delimiter-colliding tuples remain distinct, and every blocked value is removed. (src/agents/mcp-transport-config.test.ts:122, 7842329d69a1)
  • Exact-head behavior proof: The PR body includes a sanitized built-resolver terminal transcript for 7842329: seven resolutions produce five distinct warnings and seven empty environments. (7842329d69a1)
  • History provenance: Available-checkout blame attributes the current per-resolution warning callback to aca83ac; the checkout is shallow, so earlier feature history could not be resolved locally. (src/agents/mcp-transport-config.ts:219, aca83ac00c7b)

Likely related people:

  • ClawSweeper: The available current-main blame attributes the existing per-resolution warning callback to this commit; shallow history prevents stronger original-feature attribution. (role: current-source contributor; confidence: low; commits: aca83ac00c7b; files: src/agents/mcp-transport-config.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (5 earlier review cycles)
  • reviewed 2026-08-23T03:56:36.818Z sha adfb8df7ab83d97810dfbdb46536b2dfd8083ede :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-23T04:41:03.205Z sha adfb8df7ab83d97810dfbdb46536b2dfd8083ede :: needs real behavior proof before merge. :: [P2] Encode the warning pair without delimiter collisions
  • reviewed 2026-08-23T05:45:22.351Z sha c4e94b2 :: needs real behavior proof before merge. :: [P2] Encode the warning pair without delimiter collisions
  • reviewed 2026-08-23T06:07:21.768Z sha c4e94b2 :: needs changes before merge. :: [P2] Encode the warning pair without delimiter collisions
  • reviewed 2026-08-23T06:40:14.116Z sha 7842329 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Aug 23, 2026
gaoanze and others added 2 commits August 23, 2026 13:38
@vincentkoc
vincentkoc force-pushed the gaoanze888/mcp-dedupe-blocked-env-warnings branch from adfb8df to c4e94b2 Compare August 23, 2026 05:39
@vincentkoc vincentkoc self-assigned this Aug 23, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 23, 2026
Punchcard-Session: quiet-valley-harbor-ep
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 23, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 23, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 23, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 23, 2026
@vincentkoc
vincentkoc merged commit 87d49a3 into openclaw:main Aug 23, 2026
283 of 284 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 24, 2026
* fix(mcp): dedupe blocked stdio env warnings

* test(mcp): cover warning dedupe boundaries

Punchcard-Session: clear-willow-orchard-hd

* fix(mcp): encode warning dedupe identity

Punchcard-Session: quiet-valley-harbor-ep

---------

Co-authored-by: gaoanze <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: PYTHONPATH in MCP stdio env config floods gateway journal with per-spawn warnings

2 participants