Skip to content

fix(mcp): inject yes flag for npx servers - #5670

Merged
cv merged 4 commits into
NVIDIA:mainfrom
Abhi190702:fix/mcp-npx-stdio-handshake-timeout
Jul 10, 2026
Merged

cv merged 4 commits into
NVIDIA:mainfrom
Abhi190702:fix/mcp-npx-stdio-handshake-timeout

Conversation

@Abhi190702

@Abhi190702 Abhi190702 commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #5120.

This PR hardens NemoClaw's bundled OpenClaw runtime for MCP stdio servers launched through npx.

It adds a focused build-time compatibility patch for OpenClaw's MCP StdioClientTransport construction. When an MCP server command resolves to npx, npx.cmd, or a path-like equivalent, the patch automatically prepends -y unless the server args already include -y or --yes.

This prevents npx from blocking the MCP stdio initialize handshake with an interactive install prompt while preserving existing MCP server configs.


Why

On first use or with a cold npm cache, npx may prompt for package-install confirmation before running the MCP server package.

For MCP stdio transports, that prompt can block the same stdio channel OpenClaw expects to use for the JSON-RPC initialize handshake. As a result, the MCP server never replies to initialize, and OpenClaw eventually reports a startup timeout.

The observed failure mode is:

MCP server connection timed out after 30000ms

Adding -y is the smallest targeted fix because it:

  • keeps existing user MCP configs valid
  • avoids increasing the global startup timeout
  • avoids preinstalling arbitrary MCP packages
  • avoids changing non-npx MCP servers
  • preserves user-provided args
  • directly removes the interactive npx prompt from the stdio startup path

What changed

MCP npx argument normalization

Added scripts/patch-openclaw-mcp-npx.js.

The patch normalizes MCP server args only when the command resolves to npx.

Behavior:

  • npx gets -y prepended when missing
  • npx.cmd is supported for Windows-compatible command resolution
  • path-like commands ending in npx or npx.cmd are supported
  • existing -y is preserved
  • existing --yes is preserved
  • non-npx commands are left unchanged
  • args are not duplicated on repeated patch runs

Example:

{
  "command": "npx",
  "args": [
    "@modelcontextprotocol/server-filesystem",
    "/sandbox/.openclaw/workspace",
    "/tmp"
  ]
}

is started as:

npx -y @modelcontextprotocol/server-filesystem /sandbox/.openclaw/workspace /tmp

Fail-closed patching

The patch intentionally fails loudly if the expected bundled OpenClaw MCP transport shape is not found.

It also validates that the timeout diagnostic site includes the server-name and command context needed for the improved error message.

This avoids silently shipping an incomplete patch if the upstream bundled OpenClaw output changes.


Improved timeout diagnostics

MCP startup timeout diagnostics now include:

  • MCP server name
  • timeout duration in ms
  • redacted command context
  • an npx-specific hint when applicable

The command context is redacted to avoid leaking sensitive runtime details while still making the failure actionable.


Docker build integration

The Dockerfile now runs the patch after the bundled OpenClaw files exist and before later image setup/use.

The sandbox build-context staging was updated to include the patch script because the Dockerfile copies and executes it during image construction.


Regression coverage

Added test/openclaw-mcp-npx-patch.test.ts.

The tests cover:

  • npx receives -y when missing
  • npx.cmd receives -y when missing
  • path-like npx commands are supported
  • existing -y is not duplicated
  • existing --yes is not duplicated
  • non-npx commands are unchanged
  • patch output remains idempotent
  • timeout diagnostics include the required context
  • redaction behavior is preserved
  • failure behavior is fail-closed
  • actual patched fixture output executes in a VM and verifies the rewritten behavior

What this PR intentionally does not change

This PR does not:

  • increase the MCP startup timeout
  • preinstall MCP packages globally
  • modify MCP server configuration format
  • change non-npx MCP server behavior
  • alter sandbox permissions or MCP tool authorization
  • make real npm/network calls in tests
  • patch unrelated OpenClaw runtime behavior

Validation

Passed:

npm test -- --run test/openclaw-mcp-npx-patch.test.ts
npm run typecheck
npm_config_script_shell=/bin/bash npm run build:cli
node --check scripts/patch-openclaw-mcp-npx.js
git diff --check

Also passed targeted staging assertions for the sandbox build-context/onboarding test changes.


Notes

A full Docker image build was not run in this local environment. The patch is intentionally fail-closed, so if the bundled OpenClaw MCP transport output changes shape, the Docker build should fail loudly instead of silently producing an incomplete runtime patch.

Signed-off-by: Abhijeet Ranjan abhijeet.r1907@gmail.com

Summary by CodeRabbit

  • New Features

    • MCP servers launched via npx now automatically start in non-interactive mode (-y/--yes injection).
    • Improved MCP timeout errors now include server/command context and redacted sensitive CLI arguments.
  • Infrastructure

    • Docker image builds now run an OpenClaw MCP stdio patch during build to normalize npx behavior.
    • Sandbox staging now includes the new MCP patch script.
  • Tests

    • Added a dedicated test suite covering npx detection/normalization, injected transport changes, idempotency, end-to-end CLI behavior, and failure when expected targets are missing.

@copy-pr-bot

copy-pr-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 356f3d30-0415-4d9d-b10f-5395c3990833

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a build-time OpenClaw patch that prepends -y to npx-backed MCP commands and replaces timeout diagnostics with contextual, secret-redacted messages. Docker image wiring, sandbox staging, unit tests, integration tests, and failure-path tests are included.

Changes

OpenClaw MCP npx normalization patch

Layer / File(s) Summary
Patch helpers and result contracts
scripts/patch-openclaw-mcp-npx.mts
Defines patch constants and helpers for npx detection, argument normalization, secret redaction, command formatting, and timeout messages.
Bundle transformation and CLI
scripts/patch-openclaw-mcp-npx.mts
Injects a custom stdio transport, rewrites timeout diagnostics, scans OpenClaw bundles, applies idempotent patches, and exposes the CLI.
Build image and staging integration
Dockerfile, src/lib/sandbox/build-context.ts
Copies the patch script into the image and optimized build context, then runs it against the bundled OpenClaw distribution.
Behavior and staging validation
test/openclaw-mcp-npx-patch.test.ts, test/sandbox-build-context.test.ts
Tests normalization, redaction, rewriting, idempotency, CLI execution, VM behavior, failure handling, and staged-script presence.

Estimated code review effort: 4 (Complex) | ~50 minutes

Sequence Diagram(s)

sequenceDiagram
  actor DockerBuild as Docker Build
  participant PatchScript as patch-openclaw-mcp-npx.mts
  participant OpenClawDist as OpenClaw dist
  participant MCP as MCP stdio transport

  DockerBuild->>PatchScript: Run patch against OpenClaw dist
  PatchScript->>OpenClawDist: Scan and rewrite bundled JavaScript
  PatchScript->>OpenClawDist: Inject npx normalization and timeout helpers
  OpenClawDist-->>PatchScript: Write patched files
  PatchScript-->>DockerBuild: Return patch status
  MCP->>MCP: Normalize npx args with -y
  MCP-->>MCP: Report contextual redacted timeout message
Loading

Suggested reviewers: cv, ericksoa

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding the npx yes-flag patch for MCP servers.
Linked Issues check ✅ Passed The patch directly addresses #5120 by normalizing npx launches with -y/--yes and adding supporting diagnostics/tests.
Out of Scope Changes check ✅ Passed All changes support the npx MCP timeout fix, build integration, or regression tests; no unrelated scope is evident.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@Abhi190702
Abhi190702 force-pushed the fix/mcp-npx-stdio-handshake-timeout branch 2 times, most recently from 2f5970d to 1ba644b Compare June 23, 2026 12:25
npx-backed MCP servers can block on a cold package resolution prompt before the MCP initialize handshake completes. When that happens, the prompt consumes the stdio channel that should carry JSON-RPC and OpenClaw reports a generic startup timeout.

Patch the bundled OpenClaw MCP stdio transport during the image build so npx commands receive -y unless -y or --yes is already present. The patch leaves non-npx commands untouched, fails closed on unexpected source shapes, and rewrites timeout diagnostics to include the server name, timeout, redacted command context, and an npx-specific remediation hint.

Add focused tests that execute the patched output and verify idempotency, non-npx behavior, --yes handling, redaction, and build-context staging.

Fixes NVIDIA#5120

Signed-off-by: Abhijeet Ranjan <abhijeet.r1907@gmail.com>
@Abhi190702
Abhi190702 force-pushed the fix/mcp-npx-stdio-handshake-timeout branch from 1ba644b to a28d568 Compare June 23, 2026 12:33
@wscurran wscurran added area: integrations Third-party service integration behavior bug-fix PR fixes a bug or regression integration: openclaw OpenClaw integration behavior labels Jun 23, 2026
@wscurran

Copy link
Copy Markdown
Contributor

✨ Thanks for the proposed fix that adds a build-time compatibility patch for OpenClaw's MCP StdioClientTransport to automatically prepend the -y flag when npx is detected. This proposes a way to prevent npx from blocking the MCP stdio initialize handshake with an interactive install prompt while preserving existing MCP server configs.


Related open issues:

@Abhi190702
Abhi190702 marked this pull request as ready for review June 23, 2026 16:06
@Abhi190702

Copy link
Copy Markdown
Contributor Author

Thanks for taking a look.

I kept the PR focused on the npx stdio-handshake timeout path from #5120. The patch is intentionally fail-closed and covered by targeted tests for idempotency, -y / --yes, non-npx behavior, redacted diagnostics, and fixture-level patched output.

Happy to adjust the approach if you’d prefer this handled differently from the build-time compatibility patch.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (2)
Dockerfile (1)

517-525: 🩺 Stability & Availability | 🔵 Trivial

Run the Dockerfile-specific E2E set before merge.

This patch is build-layer behavior, so validate via real image build/runtime jobs (cloud-e2e, sandbox-survival-e2e, hermes-e2e, rebuild-openclaw-e2e, openclaw-tui-chat-correlation-e2e) using the provided gh workflow run nightly-e2e.yaml ... command.

As per path instructions, Dockerfile changes are only testable with a real container build and include that exact E2E recommendation set.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Dockerfile` around lines 517 - 525, The Dockerfile changes involving the
OpenClaw MCP npx patch require validation through a real container build and
runtime. Before merging this PR, run the Dockerfile-specific E2E test jobs to
ensure the patch works correctly: cloud-e2e, sandbox-survival-e2e, hermes-e2e,
rebuild-openclaw-e2e, and openclaw-tui-chat-correlation-e2e. Execute these jobs
using the gh workflow run nightly-e2e.yaml command to verify the build-layer
behavior and patch application are functioning as expected.

Source: Path instructions

scripts/patch-openclaw-mcp-npx.mts (1)

236-251: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Dead fallback branches that would emit invalid JS if ever reached.

buildTimeoutReplacement only ever returns a string starting with nemoClawMcpTimeoutMessage( or throws, so the startsWith("nemoClawMcpTimeoutMessage(") checks on lines 240 and 248 are always true and the else returns on lines 241 and 249 are unreachable. Worse, that dead code is itself broken: ${TIMEOUT_HINT} is interpolated into a double-quoted JS string literal, and TIMEOUT_HINT contains "-y", so the produced output would have unescaped quotes and fail to parse. Recommend dropping the dead branches to avoid a future foot-gun.

♻️ Simplify the .concat / + replacements
   text = text.replace(
     /"MCP server connection timed out after "\.concat\(([^,]+),\s*"ms"\)/g,
-    (_match: string, expression: string, offset: number) => {
-      const replacement = buildTimeoutReplacement(source, expression, offset);
-      if (replacement.startsWith("nemoClawMcpTimeoutMessage(")) return replacement;
-      return `"MCP server connection timed out after ".concat(${expression}, "ms. ${TIMEOUT_HINT}")`;
-    },
+    (_match: string, expression: string, offset: number) =>
+      buildTimeoutReplacement(source, expression, offset),
   );
   text = text.replace(
     /"MCP server connection timed out after "\s*\+\s*([^+]+?)\s*\+\s*"ms"/g,
-    (_match: string, expression: string, offset: number) => {
-      const replacement = buildTimeoutReplacement(source, expression, offset);
-      if (replacement.startsWith("nemoClawMcpTimeoutMessage(")) return replacement;
-      return `"MCP server connection timed out after " + ${expression.trim()} + "ms. ${TIMEOUT_HINT}"`;
-    },
+    (_match: string, expression: string, offset: number) =>
+      buildTimeoutReplacement(source, expression, offset),
   );
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/patch-openclaw-mcp-npx.mts` around lines 236 - 251, The two
replacement handlers in the text.replace calls are checking if the
buildTimeoutReplacement result starts with "nemoClawMcpTimeoutMessage(" and only
returning it if true, with fallback returns that are unreachable dead code.
Since buildTimeoutReplacement only ever returns a string starting with
"nemoClawMcpTimeoutMessage(" or throws an error, remove the if-startsWith checks
from both handlers (the one handling the .concat pattern and the one handling
the + operator pattern) and simply return the replacement directly from
buildTimeoutReplacement in each case.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@Dockerfile`:
- Around line 517-525: The Dockerfile changes involving the OpenClaw MCP npx
patch require validation through a real container build and runtime. Before
merging this PR, run the Dockerfile-specific E2E test jobs to ensure the patch
works correctly: cloud-e2e, sandbox-survival-e2e, hermes-e2e,
rebuild-openclaw-e2e, and openclaw-tui-chat-correlation-e2e. Execute these jobs
using the gh workflow run nightly-e2e.yaml command to verify the build-layer
behavior and patch application are functioning as expected.

In `@scripts/patch-openclaw-mcp-npx.mts`:
- Around line 236-251: The two replacement handlers in the text.replace calls
are checking if the buildTimeoutReplacement result starts with
"nemoClawMcpTimeoutMessage(" and only returning it if true, with fallback
returns that are unreachable dead code. Since buildTimeoutReplacement only ever
returns a string starting with "nemoClawMcpTimeoutMessage(" or throws an error,
remove the if-startsWith checks from both handlers (the one handling the .concat
pattern and the one handling the + operator pattern) and simply return the
replacement directly from buildTimeoutReplacement in each case.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c80c05bf-f89a-4c9e-b3a2-7dd4f38c030f

📥 Commits

Reviewing files that changed from the base of the PR and between 6571684 and 1d4f34a.

📒 Files selected for processing (5)
  • Dockerfile
  • scripts/patch-openclaw-mcp-npx.mts
  • src/lib/sandbox/build-context.ts
  • test/openclaw-mcp-npx-patch.test.ts
  • test/sandbox-build-context.test.ts

@cv cv added the v0.0.80 label Jul 9, 2026
@prekshivyas prekshivyas self-assigned this Jul 9, 2026
@cv cv added the needs: rebase PR needs rebase or conflict resolution label Jul 9, 2026
@cv

cv commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

This PR is currently conflicted, and commit a28d568c is not GitHub Verified. Please publish a conflict-free branch with a fully Verified history; if the published branch cannot be rewritten safely, open a fresh PR from a clean compliant branch.

# Conflicts:
#	Dockerfile
#	src/lib/sandbox/build-context.ts
#	test/sandbox-build-context.test.ts
@prekshivyas prekshivyas removed the needs: rebase PR needs rebase or conflict resolution label Jul 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

E2E Target Results — ❌ Some jobs failed

Run: 29103669399
Workflow ref: tmp/e2e/pr-5670-mcp-npx-a87ecb5cc
Requested targets: mcp-bridge,mcp-bridge-dev,rebuild-openclaw,sandbox-survival,hermes-e2e,openclaw-tui-chat-correlation,cloud-onboard
Requested jobs: (default — all default-enabled free-standing jobs; explicit-only jobs openshell-gateway-auth-contract, mcp-bridge-dev, hermes-gpu-startup, sandbox-rlimits-connect, and jetson-nvmap-gpu are skipped unless selected)
Summary: 2 passed, 5 failed, 0 cancelled, 0 skipped

Job Result
cloud-onboard ❌ failure
hermes-e2e ✅ success
mcp-bridge ❌ failure
mcp-bridge-dev ✅ success
openclaw-tui-chat-correlation ❌ failure
rebuild-openclaw ❌ failure
sandbox-survival ❌ failure

Failed jobs: cloud-onboard, mcp-bridge, openclaw-tui-chat-correlation, rebuild-openclaw, sandbox-survival. Check run artifacts for logs.

Patch OpenClaw StdioClientTransport bundles even when they omit the timeout diagnostic.

Timeout-message rewrites still fail closed when that diagnostic is present but unknown.

Add regression coverage for transport-only bundles.

Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>
@prekshivyas

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions

Copy link
Copy Markdown
Contributor

E2E Target Results — ❌ Some jobs failed

Run: 29105481092
Workflow ref: tmp/e2e/pr-5670-mcp-npx-c482db14e
Requested targets: mcp-bridge,mcp-bridge-dev,rebuild-openclaw,sandbox-survival,cloud-onboard,openclaw-tui-chat-correlation,hermes-e2e
Requested jobs: (default — all default-enabled free-standing jobs; explicit-only jobs openshell-gateway-auth-contract, mcp-bridge-dev, hermes-gpu-startup, sandbox-rlimits-connect, and jetson-nvmap-gpu are skipped unless selected)
Summary: 6 passed, 1 failed, 0 cancelled, 0 skipped

Job Result
cloud-onboard ✅ success
hermes-e2e ✅ success
mcp-bridge ❌ failure
mcp-bridge-dev ✅ success
openclaw-tui-chat-correlation ✅ success
rebuild-openclaw ✅ success
sandbox-survival ✅ success

Failed jobs: mcp-bridge. Check run artifacts for logs.

@github-actions

Copy link
Copy Markdown
Contributor

E2E Target Results — ✅ All selected jobs passed

Run: 29106517570
Workflow ref: tmp/e2e/pr-5670-mcp-npx-c482db14e
Requested targets: mcp-bridge
Requested jobs: (default — all default-enabled free-standing jobs; explicit-only jobs openshell-gateway-auth-contract, mcp-bridge-dev, hermes-gpu-startup, sandbox-rlimits-connect, and jetson-nvmap-gpu are skipped unless selected)
Summary: 1 passed, 0 failed, 0 cancelled, 0 skipped

Job Result
mcp-bridge ✅ success

@prekshivyas

Copy link
Copy Markdown
Collaborator

Exact-head follow-up at c482db14e: fixed the OpenClaw patcher Docker-build failure by allowing transport-only MCP bundles without timeout diagnostics while keeping timeout rewrites fail-closed. Local validation passed focused Vitest (openclaw-mcp-npx-patch, sandbox-build-context), Biome lint/format, git diff --check, typecheck:cli, and pre-push. GitHub Verified signature is valid, branch checks are green, and CodeRabbit re-review command completed. E2E coverage: run 29105481092 passed mcp-bridge-dev, rebuild-openclaw, hermes-e2e, cloud-onboard, sandbox-survival, and openclaw-tui-chat-correlation; the stable mcp-bridge leg hit a live route/reload race unrelated to the npx patch, then passed on the same exact head in rerun 29106517570. Requesting review/approval.

@cv
cv merged commit d643898 into NVIDIA:main Jul 10, 2026
188 of 192 checks passed
cv pushed a commit that referenced this pull request Jul 11, 2026
## Summary

Release-prep documentation for **v0.0.80**. Adds the `## v0.0.80`
section to `docs/about/release-notes.mdx` summarizing user-facing
changes since v0.0.79, each bullet linking to the relevant deeper page.

Produced via `nemoclaw-contributor-update-docs` (pre-tag path): scanned
`v0.0.79..HEAD`, applied the docs skip list (no violations), and
confirmed the 8 commits that already shipped in-PR docs are complete. No
new pages needed.

## Source summary

- #6507 -> `docs/about/release-notes.mdx`: Hermes v0.18 + Slack Block
Kit (rich rendering, digest-pinned base image).
- #6584 / #6616 -> `docs/about/release-notes.mdx`: host-local OpenRouter
runtime attribution adapter (port `11437`,
`NEMOCLAW_OPENROUTER_RUNTIME_ADAPTER_PORT`) and native Deep Agents
`openrouter` provider.
- #6210 / #6292 -> `docs/about/release-notes.mdx`: host corporate proxy
CA import into sandbox trust (`NEMOCLAW_CORPORATE_CA_BUNDLE`,
`NEMOCLAW_CORPORATE_CA_IMPORT`).
- #6624 / #6623 / #6656 -> `docs/about/release-notes.mdx`:
release-matched base-image selection, surfaced cluster-image build
diagnostics, preserved Nemotron profile registration.
- #6629 / #6637 -> `docs/about/release-notes.mdx`: bare `connect`
default-sandbox behavior and route-probe hardening.
- #6634 / #6626 / #6596 / #5569 / #6610 / #6655 ->
`docs/about/release-notes.mdx`: onboarding/recovery preservation,
stale-gateway-PID fix, installer backup message, vLLM label on managed
platforms.
- #6578 / #5670 -> `docs/about/release-notes.mdx`: automatic Hermes
light terminal skin and non-interactive `npx` MCP server startup.

## Verification

`npm run docs`: 0 errors, all internal links resolve (2 pre-existing
hidden-page warnings). `_build/` variants for OpenClaw, Hermes, and Deep
Agents all regenerate with the v0.0.80 section.

Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Documentation**
  * Added release notes for v0.0.80.
  * Documented Hermes upgrades, including Slack Block Kit rendering.
  * Added details on OpenRouter traffic routing and attribution headers.
* Documented improved proxy certificate handling and sandbox
reliability.
* Highlighted enhanced connection defaults, route-probing safeguards,
onboarding recovery, and terminal/MCP startup behavior.
  * Added references to relevant user-guide documentation.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Hadar301 pushed a commit to Hadar301/NemoClaw-OpenShift that referenced this pull request Jul 12, 2026
## Summary

Fixes NVIDIA#5120.

This PR hardens NemoClaw's bundled OpenClaw runtime for MCP stdio
servers launched through `npx`.

It adds a focused build-time compatibility patch for OpenClaw's MCP
`StdioClientTransport` construction. When an MCP server command resolves
to `npx`, `npx.cmd`, or a path-like equivalent, the patch automatically
prepends `-y` unless the server args already include `-y` or `--yes`.

This prevents `npx` from blocking the MCP stdio initialize handshake
with an interactive install prompt while preserving existing MCP server
configs.

---

## Why

On first use or with a cold npm cache, `npx` may prompt for
package-install confirmation before running the MCP server package.

For MCP stdio transports, that prompt can block the same stdio channel
OpenClaw expects to use for the JSON-RPC `initialize` handshake. As a
result, the MCP server never replies to `initialize`, and OpenClaw
eventually reports a startup timeout.

The observed failure mode is:

```text
MCP server connection timed out after 30000ms
```

Adding `-y` is the smallest targeted fix because it:

* keeps existing user MCP configs valid
* avoids increasing the global startup timeout
* avoids preinstalling arbitrary MCP packages
* avoids changing non-`npx` MCP servers
* preserves user-provided args
* directly removes the interactive `npx` prompt from the stdio startup
path

---

## What changed

### MCP `npx` argument normalization

Added `scripts/patch-openclaw-mcp-npx.js`.

The patch normalizes MCP server args only when the command resolves to
`npx`.

Behavior:

* `npx` gets `-y` prepended when missing
* `npx.cmd` is supported for Windows-compatible command resolution
* path-like commands ending in `npx` or `npx.cmd` are supported
* existing `-y` is preserved
* existing `--yes` is preserved
* non-`npx` commands are left unchanged
* args are not duplicated on repeated patch runs

Example:

```json
{
  "command": "npx",
  "args": [
    "@modelcontextprotocol/server-filesystem",
    "/sandbox/.openclaw/workspace",
    "/tmp"
  ]
}
```

is started as:

```text
npx -y @modelcontextprotocol/server-filesystem /sandbox/.openclaw/workspace /tmp
```

---

### Fail-closed patching

The patch intentionally fails loudly if the expected bundled OpenClaw
MCP transport shape is not found.

It also validates that the timeout diagnostic site includes the
server-name and command context needed for the improved error message.

This avoids silently shipping an incomplete patch if the upstream
bundled OpenClaw output changes.

---

### Improved timeout diagnostics

MCP startup timeout diagnostics now include:

* MCP server name
* timeout duration in ms
* redacted command context
* an `npx`-specific hint when applicable

The command context is redacted to avoid leaking sensitive runtime
details while still making the failure actionable.

---

### Docker build integration

The Dockerfile now runs the patch after the bundled OpenClaw files exist
and before later image setup/use.

The sandbox build-context staging was updated to include the patch
script because the Dockerfile copies and executes it during image
construction.

---

### Regression coverage

Added `test/openclaw-mcp-npx-patch.test.ts`.

The tests cover:

* `npx` receives `-y` when missing
* `npx.cmd` receives `-y` when missing
* path-like `npx` commands are supported
* existing `-y` is not duplicated
* existing `--yes` is not duplicated
* non-`npx` commands are unchanged
* patch output remains idempotent
* timeout diagnostics include the required context
* redaction behavior is preserved
* failure behavior is fail-closed
* actual patched fixture output executes in a VM and verifies the
rewritten behavior

---

## What this PR intentionally does not change

This PR does not:

* increase the MCP startup timeout
* preinstall MCP packages globally
* modify MCP server configuration format
* change non-`npx` MCP server behavior
* alter sandbox permissions or MCP tool authorization
* make real npm/network calls in tests
* patch unrelated OpenClaw runtime behavior

---

## Validation

Passed:

```text
npm test -- --run test/openclaw-mcp-npx-patch.test.ts
npm run typecheck
npm_config_script_shell=/bin/bash npm run build:cli
node --check scripts/patch-openclaw-mcp-npx.js
git diff --check
```

Also passed targeted staging assertions for the sandbox
build-context/onboarding test changes.

---

## Notes

A full Docker image build was not run in this local environment. The
patch is intentionally fail-closed, so if the bundled OpenClaw MCP
transport output changes shape, the Docker build should fail loudly
instead of silently producing an incomplete runtime patch.

Signed-off-by: Abhijeet Ranjan <abhijeet.r1907@gmail.com>

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* MCP servers launched via npx now automatically start in
non-interactive mode (`-y/--yes` injection).
* Improved MCP timeout errors now include server/command context and
redacted sensitive CLI arguments.

* **Infrastructure**
* Docker image builds now run an OpenClaw MCP stdio patch during build
to normalize npx behavior.
  * Sandbox staging now includes the new MCP patch script.

* **Tests**
* Added a dedicated test suite covering npx detection/normalization,
injected transport changes, idempotency, end-to-end CLI behavior, and
failure when expected targets are missing.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Abhijeet Ranjan <abhijeet.r1907@gmail.com>
Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>
Co-authored-by: Prekshi Vyas <prekshiv@nvidia.com>
Hadar301 pushed a commit to Hadar301/NemoClaw-OpenShift that referenced this pull request Jul 12, 2026
## Summary

Release-prep documentation for **v0.0.80**. Adds the `## v0.0.80`
section to `docs/about/release-notes.mdx` summarizing user-facing
changes since v0.0.79, each bullet linking to the relevant deeper page.

Produced via `nemoclaw-contributor-update-docs` (pre-tag path): scanned
`v0.0.79..HEAD`, applied the docs skip list (no violations), and
confirmed the 8 commits that already shipped in-PR docs are complete. No
new pages needed.

## Source summary

- NVIDIA#6507 -> `docs/about/release-notes.mdx`: Hermes v0.18 + Slack Block
Kit (rich rendering, digest-pinned base image).
- NVIDIA#6584 / NVIDIA#6616 -> `docs/about/release-notes.mdx`: host-local OpenRouter
runtime attribution adapter (port `11437`,
`NEMOCLAW_OPENROUTER_RUNTIME_ADAPTER_PORT`) and native Deep Agents
`openrouter` provider.
- NVIDIA#6210 / NVIDIA#6292 -> `docs/about/release-notes.mdx`: host corporate proxy
CA import into sandbox trust (`NEMOCLAW_CORPORATE_CA_BUNDLE`,
`NEMOCLAW_CORPORATE_CA_IMPORT`).
- NVIDIA#6624 / NVIDIA#6623 / NVIDIA#6656 -> `docs/about/release-notes.mdx`:
release-matched base-image selection, surfaced cluster-image build
diagnostics, preserved Nemotron profile registration.
- NVIDIA#6629 / NVIDIA#6637 -> `docs/about/release-notes.mdx`: bare `connect`
default-sandbox behavior and route-probe hardening.
- NVIDIA#6634 / NVIDIA#6626 / NVIDIA#6596 / NVIDIA#5569 / NVIDIA#6610 / NVIDIA#6655 ->
`docs/about/release-notes.mdx`: onboarding/recovery preservation,
stale-gateway-PID fix, installer backup message, vLLM label on managed
platforms.
- NVIDIA#6578 / NVIDIA#5670 -> `docs/about/release-notes.mdx`: automatic Hermes
light terminal skin and non-interactive `npx` MCP server startup.

## Verification

`npm run docs`: 0 errors, all internal links resolve (2 pre-existing
hidden-page warnings). `_build/` variants for OpenClaw, Hermes, and Deep
Agents all regenerate with the v0.0.80 section.

Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Documentation**
  * Added release notes for v0.0.80.
  * Documented Hermes upgrades, including Slack Block Kit rendering.
  * Added details on OpenRouter traffic routing and attribution headers.
* Documented improved proxy certificate handling and sandbox
reliability.
* Highlighted enhanced connection defaults, route-probing safeguards,
onboarding recovery, and terminal/MCP startup behavior.
  * Added references to relevant user-guide documentation.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: integrations Third-party service integration behavior bug-fix PR fixes a bug or regression integration: openclaw OpenClaw integration behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Openclaw MCP server connection timed out after 30000ms v0.0.60-v0.0.62

4 participants