openclaw - ✅(Solved) Fix Feature: let openclaw mcp serve request configurable operator scopes [1 pull requests, 2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#73864Fetched 2026-04-29 06:14:01
View on GitHub
Comments
2
Participants
3
Timeline
3
Reactions
0
Author
Timeline (top)
commented ×2cross-referenced ×1

Please add a supported way for openclaw mcp serve to request a narrower operator scope set, such as --scope <scope...>, a config/env equivalent, or explicit MCP modes like read, write, and approvals.

Root Cause

For an external agent stack, I wanted to split one broad MCP bridge device into separate paired identities:

  • read-only inspection: operator.read
  • message send: operator.read + operator.write
  • approvals: operator.read + operator.approvals

That would let an MCP client expose only the bridge subprocess it needs for a workflow and reduce blast radius if a single subprocess/client is compromised. With the current fixed scope request, the split creates separate devices but not separate privileges.

PR fix notes

PR #74030: [AI-assisted] feat(mcp): allow serve operator scope selection

Description (problem / solution / changelog)

Summary

  • Problem: openclaw mcp serve always requested the default operator scopes and could not be started with a narrower/explicit scope set.
  • Why it matters: operators may need to run the MCP bridge with only the scopes required for their integration.
  • What changed: added repeatable --scope validation/plumbing and passed configured operator scopes through to the gateway client.
  • What did NOT change (scope boundary): default mcp serve scope behavior is unchanged when --scope is omitted.

AI-assisted: yes, built with Codex. I understand the code changes and verified the focused regressions locally.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #73864
  • This PR fixes a bug or regression

Root Cause (if applicable)

  • Root cause: MCP serve options did not expose operator scope selection, and the channel bridge always supplied the fixed default scope list.
  • Missing detection / guardrail: no CLI/server tests covered explicit scope plumbing.
  • Contributing context (if known): N/A

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
  • Target test or file: src/cli/mcp-cli.test.ts, src/mcp/channel-server.test.ts
  • Scenario the test should lock in: CLI accepts repeatable valid scopes, rejects unknown scopes, and the channel bridge passes configured scopes or defaults when omitted.
  • Why this is the smallest reliable guardrail: it covers the CLI option and gateway-client construction boundaries without requiring a live gateway.
  • Existing test that already covers this (if any): N/A
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

openclaw mcp serve now supports repeatable --scope <operator.scope> flags.

Diagram (if applicable)

N/A

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? Yes
  • If any Yes, explain risk + mitigation: Users can explicitly choose the operator scopes requested by the MCP bridge. Values are validated against known operator scopes, and omission preserves the previous default scope set.

Repro + Verification

Environment

  • OS: Windows
  • Runtime/container: local Node.js / pnpm workspace
  • Model/provider: N/A
  • Integration/channel (if any): MCP CLI/channel bridge
  • Relevant config (redacted): N/A

Steps

  1. Start openclaw mcp serve --scope operator.read --scope operator.approvals.
  2. Confirm requested scopes are passed to the gateway client.
  3. Start without --scope and confirm existing defaults are preserved.
  4. Try an unknown scope and confirm the CLI rejects it.

Expected

  • Explicit valid scopes are honored; invalid scopes fail fast; omitted scopes keep current defaults.

Actual

  • Before this change, scope selection was not configurable.

Evidence

  • Failing test/log before + passing after

Focused local validation:

node scripts/test-projects.mjs src/cli/mcp-cli.test.ts src/mcp/channel-server.test.ts
Test Files  2 passed (2)
Tests       14 passed (14)

Human Verification (required)

  • Verified scenarios: focused CLI and channel bridge tests; git diff --check before commit.
  • Edge cases checked: duplicate/repeatable scope collection, invalid scope rejection, default scope fallback.
  • What you did not verify: live MCP bridge against a real gateway; full repo pnpm test / pnpm check.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: users might request an insufficient scope set for a workflow.
    • Mitigation: default behavior is unchanged unless users opt into explicit scopes, and invalid scope names are rejected.

Changed files

  • src/cli/mcp-cli.test.ts (modified, +37/-0)
  • src/cli/mcp-cli.ts (modified, +27/-0)
  • src/mcp/channel-bridge.ts (modified, +3/-1)
  • src/mcp/channel-server.test.ts (modified, +77/-0)
  • src/mcp/channel-server.ts (modified, +3/-0)
RAW_BUFFERClick to expand / collapse

Summary

Please add a supported way for openclaw mcp serve to request a narrower operator scope set, such as --scope <scope...>, a config/env equivalent, or explicit MCP modes like read, write, and approvals.

Problem

openclaw mcp serve is the stdio bridge process used by external MCP clients. Today it appears to construct its gateway client with a fixed scope request:

  • operator.read
  • operator.write
  • operator.approvals

The CLI help for openclaw mcp serve exposes --url, --token, --token-file, --password, --password-file, --claude-channel-mode, and --verbose, but no scope or mode selector.

That makes it impossible to run multiple profile-isolated MCP bridge identities with different least-privilege scope tiers. Separate --profile state directories can produce distinct device identities, but every stock mcp serve subprocess still requests the same effective privileges.

Why this matters

For an external agent stack, I wanted to split one broad MCP bridge device into separate paired identities:

  • read-only inspection: operator.read
  • message send: operator.read + operator.write
  • approvals: operator.read + operator.approvals

That would let an MCP client expose only the bridge subprocess it needs for a workflow and reduce blast radius if a single subprocess/client is compromised. With the current fixed scope request, the split creates separate devices but not separate privileges.

Reproduction / source notes

Environment:

  • OpenClaw 2026.4.26 (be8c246)
  • WSL2 Ubuntu
  • local gateway on ws://127.0.0.1:18789

Observed locally:

  1. openclaw mcp serve --help has no --scope or mode flag.
  2. Installed bundled source dist/mcp-cli-BRkpM26h.js constructs GatewayClient for MCP with scopes: [READ_SCOPE, WRITE_SCOPE, APPROVALS_SCOPE].
  3. dist/client-Dh94CUDv.js defaults to operator.admin only if no scopes are supplied; MCP does supply scopes, so the issue is the fixed three-scope MCP request, not the admin fallback.
  4. tools/list advertises the static 9-tool MCP surface, so authorization has to be verified by actual tools/call behavior, not registration.

Local investigation record:

Suggested solutions

Any of these would unblock least-privilege MCP bridges:

  1. Add openclaw mcp serve --scope <scope...> with repeatable scopes.
  2. Add equivalent config/env support for MCP bridge scope request.
  3. Add explicit modes, for example openclaw mcp serve --mode read|write|approvals, each mapping to documented scope sets.
  4. Optionally filter tools/list by the active token's authorized scopes, or at least document that tools/list is static and invocation-time auth is canonical.

Related

This is adjacent to #49183, but narrower. #49183 is about mapping authenticated operator scopes into agent tool policy. This issue is about the MCP bridge's own gateway-client scope request during pairing/connection.

extent analysis

TL;DR

Add a --scope flag to openclaw mcp serve to allow for customizable operator scope sets.

Guidance

  • Implement a --scope flag in openclaw mcp serve that accepts repeatable scopes, such as --scope operator.read --scope operator.write.
  • Consider adding equivalent config/env support for MCP bridge scope request to provide an alternative to the command-line flag.
  • Introduce explicit modes (e.g., --mode read|write|approvals) that map to documented scope sets for easier usage.
  • Review the tools/list behavior to ensure it accurately reflects the authorized scopes of the active token.

Example

openclaw mcp serve --scope operator.read --scope operator.write

This example demonstrates how the proposed --scope flag could be used to request a specific set of scopes.

Notes

The solution should be implemented in a way that maintains backward compatibility and does not introduce security vulnerabilities. The --scope flag should be designed to accept multiple scopes to accommodate different use cases.

Recommendation

Apply a workaround by modifying the openclaw mcp serve command to accept a customizable scope set, such as adding a --scope flag. This will allow for more flexible and secure MCP bridge configurations.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix Feature: let openclaw mcp serve request configurable operator scopes [1 pull requests, 2 comments, 3 participants]