skip to content

An OpenClaw assistant that also answers strangers gains a database MCP server; do its tools bypass tool policy, and how do you scope them?

level: seniorimportance: must knowfreq 10%

answer

  1. borrowed tools, same rules
  2. one plugin id for all of them
  3. server__tool names
  4. filter first, then policy
  5. sandboxed turns need a second allow

basics

~20 s

No. MCP tools become OpenClaw tools under the bundle-mcp plugin id, named server__tool, and pass the same tool profile, allow and deny lists, per-sender limits and sandbox gate as built-in tools; filter the server's tools and deny them to strangers.

solid answer

~40 s

Connecting a server does not bypass policy: its tools are exposed as plugin-owned tools under `bundle-mcp`, named like `ledger-db__run_readonly_query`. The `coding` and `messaging` profiles allow `bundle-mcp`, `minimal` hides it, and `tools.deny` wins over any allow, so `tools.deny: ["ledger-db__*"]` or `["bundle-mcp"]` removes them and a whole-server deny stops OpenClaw connecting at all. Scope in layers: `toolFilter.include` on the server so write tools never become OpenClaw tools, per-agent `tools` under `agents.entries`, and `tools.toolsBySender` with a `"*"` entry denying `ledger-db__*` so only the owner's turns can reach the database. In sandboxed sessions `tools.sandbox.tools` is a second allow gate. An AGENTS.md rule is guidance, not enforcement.

code

json · 12 lines
json
{
  "tools": {
    "profile": "messaging",
    "toolsBySender": {
      "id:owner-sender-id": {},
      "*": { "deny": ["ledger-db__*"] }
    },
    "sandbox": {
      "tools": { "alsoAllow": ["ledger-db__*"] }
    }
  }
}

go deeper

for a junior

Recall that MCP tools pass through OpenClaw's tool policy like any other tool, and that the coding and messaging profiles include them while minimal hides them.

for a middle

Explain bundle-mcp, the server__tool naming, deny winning over allow, and how toolFilter differs from tools.deny.

for a senior

Lay out the scoping for an assistant strangers can reach: a narrow filter, a per-sender deny, a split agent, and the sandbox allow gate that silently hides tools if you forget it.

for a principal

Decide where the boundary sits: per-sender rules on one agent, a separate private agent, or a separate Gateway, given that one Gateway is one trust boundary.

## MCP tools are OpenClaw tools When OpenClaw connects an MCP server from **`mcp.servers`**, it discovers the server's tools and re-exposes them as **plugin-owned tools under the `bundle-mcp` plugin id**. Each gets a model-facing name of the form **`<server>__<tool>`**, so a server saved as `ledger-db` contributes tools such as `ledger-db__run_readonly_query`. The server prefix is made provider-safe: characters outside `A-Z`, `a-z`, `0-9`, `_` and `-` become `-`, a name that does not start with a letter gets an `mcp-` prefix, and long or duplicate prefixes are truncated or suffixed. Check the real names in the tool list before writing a glob. Because they are ordinary tools from then on, **every tool-policy layer applies**. The docs say it directly: connecting a server does not bypass your policy. ## The layers, from narrowest to broadest | Layer | Where it lives | What it does to MCP tools | |---|---|---| | `toolFilter.include` / `exclude` | the server's `mcp.servers` entry | Drops discovered tools before they become OpenClaw tools | | `tools.profile` | global or per agent | `coding` and `messaging` allow `bundle-mcp`; `minimal` hides it | | `tools.allow` / `tools.deny` | global, `agents.entries.*.tools`, `tools.byProvider` | Deny wins; accepts `bundle-mcp`, exact names and `*` globs | | `tools.toolsBySender` | global or per agent | Narrows tools for the turn's originating sender | | `tools.sandbox.tools` | sandboxed sessions | A second allow gate on top of everything above | Two details matter in practice: - A **whole-server denial** such as `tools.deny: ["bundle-mcp"]` or `["ledger-db__*"]` excludes the server **before connecting**; a denial of one tool applies to the discovered catalog. - `group:plugins` covers all loaded plugin-owned tools including MCP ones, while `group:openclaw` excludes plugin tools, so denying `group:openclaw` does not touch them. ## Scoping a database server on an assistant strangers can reach Who can message the assistant at all is decided by its channel access policy, a separate subject. Assume some strangers get through, and the database tools should serve only the owner. 1. **Expose the minimum.** Put `toolFilter.include: ["list_tables", "run_readonly_query"]` on the server so write tools never exist as OpenClaw tools, and give the server a database account that can only read. 2. **Deny by sender.** In `tools.toolsBySender`, a `"*"` entry with `deny: ["ledger-db__*"]` removes the tools from other senders' turns; sender keys are matched most specific first (`channel:<channelId>:<senderId>`, `id:`, `e164:`, `username:`, `name:`, then `"*"`), so the owner's own entry wins. Sender values come from the channel adapter, not from message text. 3. **Or split agents.** Keep the database server's tools allowed only on a private agent through `agents.entries.<id>.tools`, and route strangers to an agent that denies them. 4. **Mind the sandbox.** With sandbox mode `all` or `non-main`, add `bundle-mcp`, `group:plugins` or `ledger-db__*` to `tools.sandbox.tools.alsoAllow`, or the tools are filtered out of sandboxed turns even though the server loaded. `openclaw doctor` catches that shape for `mcp.servers` entries. ## What does not enforce anything - A line in AGENTS.md telling the agent not to query the database for strangers shapes behaviour; it does not stop a call. Enforcement is tool policy, filters and the sandbox gate. - Per-sender limits are defence in depth. OpenClaw supports one trust boundary per Gateway, a single operator or a mutually trusting team; these controls reduce exposure inside that boundary and do not make one Gateway safe for mutually untrusted users. - Prompt injection through tool output and tool descriptions is covered with the MCP security material; here, the point is which layer decides whether a call can happen. ## Checking what the agent actually gets 1. `openclaw mcp doctor ledger-db --probe` proves the server connects and lists the tools it reports; if an expected tool is missing there, check the server and its `toolFilter` before tool policy. 2. In a Control UI chat, **+ → Connectors → Tool access** lists the session's MCP tools and lets you deny individual ones for that session; the denial is enforced before the next turn starts. 3. `openclaw doctor` reports an `mcp.servers` setup whose tools a sandboxed session would filter out. 4. Per-run `toolsAllow` caps accept globs such as `ledger*`, but those can trigger discovery across all enabled servers; they do not limit which servers connect, and final allow, deny and sandbox policy still apply. Read the effective tool list after every policy change rather than trusting the config by eye: deny-wins and first-match sender rules are easy to misread.

  • The server probes fine, but in sandboxed turns the agent only sees built-in tools. Why?
    In sandbox mode `all` or `non-main`, `tools.sandbox.tools` is a second allow gate. The server loads, but its tools are filtered before the provider request unless `bundle-mcp`, `group:plugins` or a server glob such as `ledger-db__*` is in `tools.sandbox.tools.alsoAllow`. Add it, reload or restart the Gateway, and recheck the tool list; `openclaw doctor` flags this for `mcp.servers` entries.
  • When should you use toolFilter rather than tools.deny for an MCP server?
    `toolFilter` removes tools at the server, for every agent and sender, before they become OpenClaw tools; use it for tools nobody should have, such as write or admin tools. `tools.deny` and `toolsBySender` decide who gets the remaining tools, per agent, provider or sender. Using both is normal: the filter shrinks the catalogue, policy decides who may call what is left.

  • MCP tools come from outside, so OpenClaw's tool policy does not apply to them.
  • An AGENTS.md rule against querying the database for strangers enforces it.
  • The minimal profile still exposes configured MCP tools.
  • Denying group:openclaw removes the MCP server's tools.
  • Per-sender tool limits make one Gateway safe for mutually untrusted users.