Skip to content

fix(mcp): target OpenClaw workspace config - #8646

Open
deepujain wants to merge 12 commits into
NVIDIA:mainfrom
deepujain:fix/8326-openclaw-http-mcp-config
Open

fix(mcp): target OpenClaw workspace config#8646
deepujain wants to merge 12 commits into
NVIDIA:mainfrom
deepujain:fix/8326-openclaw-http-mcp-config

Conversation

@deepujain

@deepujain deepujain commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Store and inspect OpenClaw HTTP MCP registrations in the sandbox workspace project configuration. This prevents an existing workspace-level mcporter.json entry from taking precedence over NemoClaw's managed HTTP registration and sending the agent down an npx installation path.

Related Issue

Fixes #8326

Changes

  • Use /sandbox/.openclaw/workspace as the explicit mcporter root for registration, inspection, and removal.
  • Write managed registrations at project scope so mcporter resolves the same configuration OpenClaw uses.
  • Inspect project, XDG, and legacy home configuration layers before cleanup, preserving every layer if any entry has drifted.
  • Remove all matching NemoClaw-owned layers and verify the effective registration no longer resolves.
  • Keep persisted bridge status resilient when an agent definition is no longer available.
  • Add command-contract, layered ownership, lifecycle, and crash-consistency coverage.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification: This restores the existing managed HTTP MCP behavior without changing the CLI or configuration interface.
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification:
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Documentation Writer Review

  • Documentation writer subagent reviewed the completed changes
  • Result: no-docs-needed
  • Evidence: The final diff aligns internal mcporter scope/root handling with the existing OpenClaw workspace contract; no documented interface changes.
  • Agent: Codex Desktop

DGX Station Hardware Evidence

  • Tested on DGX Station
  • Tested commit: Not applicable; scripts/prepare-dgx-station-host.sh is unchanged.
  • Station profile/scenario: Not applicable.
  • Result: Not applicable.
  • Supporting evidence: Not applicable.

Verification

  • PR description includes a Signed-off-by: line and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run validate:pr passed after refreshing origin/main when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — 89 adapter, status, ownership, lifecycle, marker-recovery, and crash-consistency tests passed.
  • Applicable broad gate passed — repository commit hooks, plugin, JS-config, CLI pre-push typechecks, and the 89-test lifecycle suite passed at contributor head 0dd3d5a26; exact head 3e450c631 adds only the verified upstream branch update.
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Deepak Jain deepujain@gmail.com

@copy-pr-bot

copy-pr-bot Bot commented Aug 9, 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 Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The OpenClaw Mcporter adapter now resolves normalized workspace roots from agent configuration. Registration, inspection, verification, and removal use the resolved root. Registration uses project scope. Tests cover lifecycle behavior, layered configuration, drift protection, recovery paths, and custom workspaces.

Changes

OpenClaw Mcporter workspace targeting

Layer / File(s) Summary
Workspace root and inspection contract
src/lib/actions/sandbox/mcp-bridge-adapter-status.ts, src/lib/actions/sandbox/mcp-bridge-adapters.ts, src/lib/actions/sandbox/mcp-bridge-state.ts, src/lib/actions/sandbox/mcp-bridge-status.ts
Adds normalized OpenClaw root helpers and agent configuration-directory resolution. Inspection commands pass the selected root with --root.
Registration and removal command targeting
src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.ts
Registration, verification, and removal derive the agent-specific root. Registration uses project scope. Removal handles layered configuration paths, ownership checks, absent entries, command failures, and post-removal verification.
Stateful lifecycle validation
src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.test.ts, test/mcp-add-crash-consistency.test.ts, test/mcp-bridge-destroy-marker-recovery.test.ts, test/mcp-destroy-lifecycle.test.ts
Stateful fakes and updated mocks validate lifecycle operations, command arguments, drift protection, recovery paths, layered configuration handling, and custom workspace roots.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant OpenClawAdapter
  participant AgentConfig
  participant Mcporter
  OpenClawAdapter->>AgentConfig: resolve configuration directory
  AgentConfig-->>OpenClawAdapter: normalized workspace root
  OpenClawAdapter->>Mcporter: register with --root and project scope
  Mcporter-->>OpenClawAdapter: registration result
  OpenClawAdapter->>Mcporter: inspect with --root
  Mcporter-->>OpenClawAdapter: server configuration
  OpenClawAdapter->>Mcporter: remove owned configuration with --root
  Mcporter-->>OpenClawAdapter: removal result
Loading

Possibly related PRs

Suggested labels: area: integrations, bug-fix

🚥 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
Linked Issues check ✅ Passed The adapter now targets the OpenClaw workspace root and project scope for HTTP MCP registration, addressing issue [#8326].
Out of Scope Changes check ✅ Passed The changes support workspace registration, layered cleanup, status resilience, and related lifecycle tests for issue [#8326].
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: targeting the OpenClaw workspace configuration for MCP handling.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.test.ts (1)

38-45: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert observed mcporter arguments instead of generated shell text.

These assertions inspect command strings with toContain. They do not prove that the spawned mcporter process receives --root or that the add command receives --scope project.

Use the fake executable to record process.argv. Execute registration, inspection, and removal. Assert the observed arguments and the resulting workspace configuration.

As per path instructions, tests should prove observable behavior through the public boundary instead of source-text shape.

Also applies to: 167-177

🤖 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 `@src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.test.ts` around lines 38
- 45, Replace the command-string toContain assertions in the registration test
with fake-executable argv recording. Exercise registration, inspection, and
removal through the public adapter boundary, then assert the recorded mcporter
arguments include the expected --root and --scope project values, along with the
resulting workspace configuration. Apply the same change to the assertions
around the additional referenced section.

Source: Path instructions

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

Inline comments:
In `@src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.test.ts`:
- Around line 106-113: Update the fake executable’s config handling in the test
so it locates the "config" argument and branches only on the immediately
following subcommand, rather than using process.argv.includes("get") or
includes("remove"). Preserve the existing get and remove responses while
ensuring server names and option values cannot select either branch.

---

Nitpick comments:
In `@src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.test.ts`:
- Around line 38-45: Replace the command-string toContain assertions in the
registration test with fake-executable argv recording. Exercise registration,
inspection, and removal through the public adapter boundary, then assert the
recorded mcporter arguments include the expected --root and --scope project
values, along with the resulting workspace configuration. Apply the same change
to the assertions around the additional referenced section.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8900d768-c117-4ee1-ae03-3e3661793485

📥 Commits

Reviewing files that changed from the base of the PR and between 5429cec and d4e9360.

📒 Files selected for processing (3)
  • src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.test.ts
  • src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.ts
  • src/lib/actions/sandbox/mcp-bridge-adapter-status.ts

Comment thread src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.test.ts Outdated
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — No blocking findings reported

Advisor assessment: No blocking advisor findings reported
Next action: No advisor follow-up needed.
Findings: 0 blockers · 0 warnings · 0 suggestions

Model lanes

  • GPT-5.6 Terra (primary): Completed · medium confidence · 0 blockers · 0 warnings · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Failed

Second-opinion terminology and E2E selections are advisory. Live E2E does not run automatically for pull requests.

2 semantic terminology decisions

Terminology decisions are advisory. They affect the assessment only when a separate finding identifies concrete semantic impact.

  • established — state directory at src/lib/actions/sandbox/mcp-bridge-state.ts:36: Keep `state directory`; it is the established controlled term for persistent project or runtime state.
  • define — project root at src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.ts:29: Keep `project root` with the existing mcporter-specific context in the comments to distinguish it from the repository project root.

E2E guidance

Advisory only. A maintainer can dispatch the default E2E suite against this exact revision.

Recommended E2E: full-e2e, hermes-e2e, onboard-repair, onboard-resume

2 optional E2E recommendations
  • mcp-bridge
  • ubuntu-repo-cloud-openclaw

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

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

Actionable comments posted: 1

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

Inline comments:
In `@src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.test.ts`:
- Around line 196-198: Strengthen the config-get assertion in the migration test
by inspecting every matching entry in observedArgs and requiring the complete
argument list to use OPENCLAW_MCPORTER_ROOT, the expected config get subcommand,
server, and --json arguments. Preserve the test’s verification that config get
occurs while ensuring inspect and removal lifecycle paths use the authoritative
replacement root.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 52b69d26-4726-48ee-a703-3559874aeb2c

📥 Commits

Reviewing files that changed from the base of the PR and between d4e9360 and bb2427a.

📒 Files selected for processing (1)
  • src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.test.ts

Comment thread src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.test.ts Outdated

@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 (1)
src/lib/actions/sandbox/mcp-bridge-status.ts (1)

113-117: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the shared agent-config helper in status checks.

src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.ts already uses getAgentConfigDir(entry.agent), but this status path still reads loadAgent(entry.agent).configPaths.dir directly. Use the shared helper so status and lifecycle operations use one authoritative config-directory resolution path.

Proposed change
-          openClawMcporterRoot(loadAgent(entry.agent).configPaths.dir),
+          openClawMcporterRoot(getAgentConfigDir(entry.agent)),

Import getAgentConfigDir from ./mcp-bridge-state.

As per path instructions, all in-scope callers must use one authoritative path during migration.

🤖 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 `@src/lib/actions/sandbox/mcp-bridge-status.ts` around lines 113 - 117, Update
the status command construction around buildOpenClawMcporterInspectCommand to
use getAgentConfigDir(entry.agent) from ./mcp-bridge-state instead of
loadAgent(entry).configPaths.dir, adding the required import and preserving the
existing openClawMcporterRoot flow.

Source: Path instructions

🤖 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 `@src/lib/actions/sandbox/mcp-bridge-status.ts`:
- Around line 113-117: Update the status command construction around
buildOpenClawMcporterInspectCommand to use getAgentConfigDir(entry.agent) from
./mcp-bridge-state instead of loadAgent(entry).configPaths.dir, adding the
required import and preserving the existing openClawMcporterRoot flow.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 831ea71d-f28e-4f59-a38d-e6bd2652f5f9

📥 Commits

Reviewing files that changed from the base of the PR and between bb2427a and e8e6775.

📒 Files selected for processing (6)
  • src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.test.ts
  • src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.ts
  • src/lib/actions/sandbox/mcp-bridge-adapter-status.ts
  • src/lib/actions/sandbox/mcp-bridge-adapters.ts
  • src/lib/actions/sandbox/mcp-bridge-state.ts
  • src/lib/actions/sandbox/mcp-bridge-status.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.test.ts

@cv cv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.ts:96 removes only the project definition selected by --root. Existing NemoClaw releases wrote managed entries to mcporter's home scope. mcporter@0.7.3 merges home and project configurations, but config remove modifies only the resolved project file. After an upgrade or restart creates the project entry, removal deletes that entry and exposes the stale home entry again. NemoClaw can then remove its registry, provider, and policy state while OpenClaw still discovers the server; adding the same name again can also fail. Ownership-check and remove both the project entry and any matching legacy home entry, while preserving a drifted user-owned entry. Add a layered-config regression test that seeds a legacy home entry, registers the project entry, removes it, and proves effective lookup is absent and both owned entries are gone.

@deepujain

Copy link
Copy Markdown
Contributor Author

Cleanup now checks project and legacy home layers before changing either one, removes every owned copy, and verifies the effective entry is gone. Drifted entries remain untouched.

@deepujain

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 9, 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.

@deepujain

Copy link
Copy Markdown
Contributor Author

Default XDG cleanup is covered now too: with XDG_CONFIG_HOME unset, the managed entry under ~/.config/mcporter is removed and effective lookup is verified absent. @coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

@deepujain, I will review the updated default-XDG cleanup coverage and the related changes.

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

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

Actionable comments posted: 1

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

Inline comments:
In `@src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.test.ts`:
- Around line 254-257: Update the test around
buildOpenClawMcporterInspectCommand to capture the result of runWithoutXdg,
assert its exit status is 0, and then assert the trimmed stdout equals "absent".
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 753fdc40-9516-405e-8eca-1433c89211ca

📥 Commits

Reviewing files that changed from the base of the PR and between 908a34b and 11b2e25.

📒 Files selected for processing (2)
  • src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.test.ts
  • src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.ts

Comment thread src/lib/actions/sandbox/mcp-bridge-adapter-openclaw.test.ts Outdated
@deepujain

Copy link
Copy Markdown
Contributor Author

The default-XDG inspection now asserts both a successful exit and the expected absent result. @coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

@deepujain I will review the updated default-XDG inspection assertions and the related changes.

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

@deepujain
deepujain force-pushed the fix/8326-openclaw-http-mcp-config branch from 3a00e31 to 0ec1259 Compare August 9, 2026 14:03
@deepujain

Copy link
Copy Markdown
Contributor Author

Rebased on current main. The 89 lifecycle tests and CLI typecheck still pass. @coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

@deepujain, I will review the changes after the rebase.

⚠️ Action not completed

No files to review.

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.

@deepujain
deepujain force-pushed the fix/8326-openclaw-http-mcp-config branch from 0ec1259 to 8c488c6 Compare August 9, 2026 14:05
Comment on lines +260 to +268
fs.writeFileSync(
configState,
JSON.stringify({
name: "github",
transport: "http",
baseUrl: "https://api.githubcopilot.com/mcp/",
headers: normalizedHeaders,
}),
);
Comment on lines +269 to +277
fs.writeFileSync(
homeConfigState,
JSON.stringify({
name: "github",
transport: "http",
baseUrl: "https://user.example.test/mcp",
headers: normalizedHeaders,
}),
);
Fixes NVIDIA#8326

Signed-off-by: Deepak Jain <deepujain@gmail.com>
Signed-off-by: Deepak Jain <deepujain@gmail.com>
Signed-off-by: Deepak Jain <deepujain@gmail.com>
Signed-off-by: Deepak Jain <deepujain@gmail.com>
Signed-off-by: Deepak Jain <deepujain@gmail.com>
Signed-off-by: Deepak Jain <deepujain@gmail.com>
Signed-off-by: Deepak Jain <deepujain@gmail.com>
Signed-off-by: Deepak Jain <deepujain@gmail.com>
Signed-off-by: Deepak Jain <deepujain@gmail.com>
Signed-off-by: Deepak Jain <deepujain@gmail.com>
Signed-off-by: Deepak Jain <deepujain@gmail.com>
@deepujain
deepujain force-pushed the fix/8326-openclaw-http-mcp-config branch from 8c488c6 to 0dd3d5a Compare August 10, 2026 05:23
@deepujain

Copy link
Copy Markdown
Contributor Author

The test no longer uses check-then-write file assertions; absence is verified from directory contents and presence by direct reads. The 89 lifecycle tests and all pre-push typechecks pass.

@deepujain

Copy link
Copy Markdown
Contributor Author

Cleanup now checks ownership across project, XDG, and legacy home layers, preserves drifted entries, and removes every matching managed entry. The branch is current with main; 89 lifecycle tests and all pre-push typechecks pass. Could you take another look at 3e450c6?

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.

[Ubuntu 26.04][Agent&Skills] agent npm-installs an HTTP MCP server added via mcp add instead of calling it over HTTP

3 participants