Skip to content

Commit 49b5b86

Browse files
authored
feat: node-hosted plugins β€” dynamic tools, MCP servers, and skills (#90431)
* feat: node-hosted plugins β€” dynamic tools, MCP servers, and skills Nodes become declarative plugin hosts: - node.pluginTools.update: node hosts publish plugin-registered agent tool descriptors; gateway materializes them as agent tools executing via node.invoke under the node command allowlist, with tools.effective invalidation and node online/offline removal. - Trusted paired-node descriptors: no gateway-side plugin registration required; gateway.nodes.pluginTools.enabled off-switch (default on); description/count caps; deterministic node-prefixed collision names. - Declarative node-hosted MCP: nodeHost.mcp.servers (McpServerConfig shape) starts MCP clients on the node host, publishes tools as pluginId node-mcp, executes via built-in mcp.tools.call.v1 with per-layer timeouts, failure isolation, and orphan-safe shutdown. No re-pairing when servers change. - Node-hosted skills: node.skills.update publishes ~/.openclaw/skills content (64 skills/64KB/512KB caps both sides); gateway merges them into the skills snapshot while connected and exec host=node is available, with node:// locators, node-prefixed collisions, disabled command dispatch, and gateway.nodes.skills.enabled + nodeHost.skills.enabled switches. - Security: node-supplied pluginIds cannot satisfy pluginId-scoped tool allowlists unless gateway-registered; reserved node-mcp id requires the core MCP descriptor shape; protocol registry kept out of public plugin-sdk dts. - E2E: pond harness proves publication, MCP round-trip, skills locator, and disconnect/reconnect for all three surfaces. * style: format node-plugin-tools test * fix(skills): keep status loader unfiltered when eligibility is passed skills.status started passing eligibility for the node-skill merge, which flipped loadWorkspaceSkillEntries into filtered mode and dropped disabled skills from status reports (QA plugin-lifecycle-hot-reload timeout). Status now merges node skills explicitly around an unfiltered load. Also: regen docs_map for new node docs sections; add the intentional node-host MCP onclose suppression to the lint-suppression allowlist.
1 parent fdf5812 commit 49b5b86

123 files changed

Lines changed: 6800 additions & 431 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

β€Žapps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swiftβ€Ž

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,6 +1895,90 @@ public struct NodeRenameParams: Codable, Sendable {
18951895

18961896
public struct NodeListParams: Codable, Sendable {}
18971897

1898+
public struct NodePluginToolDescriptor: Codable, Sendable {
1899+
public let pluginid: String
1900+
public let name: String
1901+
public let description: String
1902+
public let parameters: [String: AnyCodable]?
1903+
public let command: String?
1904+
public let mcp: [String: AnyCodable]?
1905+
1906+
public init(
1907+
pluginid: String,
1908+
name: String,
1909+
description: String,
1910+
parameters: [String: AnyCodable]? = nil,
1911+
command: String? = nil,
1912+
mcp: [String: AnyCodable]? = nil)
1913+
{
1914+
self.pluginid = pluginid
1915+
self.name = name
1916+
self.description = description
1917+
self.parameters = parameters
1918+
self.command = command
1919+
self.mcp = mcp
1920+
}
1921+
1922+
private enum CodingKeys: String, CodingKey {
1923+
case pluginid = "pluginId"
1924+
case name
1925+
case description
1926+
case parameters
1927+
case command
1928+
case mcp
1929+
}
1930+
}
1931+
1932+
public struct NodePluginToolsUpdateParams: Codable, Sendable {
1933+
public let tools: [NodePluginToolDescriptor]
1934+
1935+
public init(
1936+
tools: [NodePluginToolDescriptor])
1937+
{
1938+
self.tools = tools
1939+
}
1940+
1941+
private enum CodingKeys: String, CodingKey {
1942+
case tools
1943+
}
1944+
}
1945+
1946+
public struct NodeSkillDescriptor: Codable, Sendable {
1947+
public let name: String
1948+
public let description: String
1949+
public let content: String
1950+
1951+
public init(
1952+
name: String,
1953+
description: String,
1954+
content: String)
1955+
{
1956+
self.name = name
1957+
self.description = description
1958+
self.content = content
1959+
}
1960+
1961+
private enum CodingKeys: String, CodingKey {
1962+
case name
1963+
case description
1964+
case content
1965+
}
1966+
}
1967+
1968+
public struct NodeSkillsUpdateParams: Codable, Sendable {
1969+
public let skills: [NodeSkillDescriptor]
1970+
1971+
public init(
1972+
skills: [NodeSkillDescriptor])
1973+
{
1974+
self.skills = skills
1975+
}
1976+
1977+
private enum CodingKeys: String, CodingKey {
1978+
case skills
1979+
}
1980+
}
1981+
18981982
public struct NodePendingAckParams: Codable, Sendable {
18991983
public let ids: [String]
19001984

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
2788a2f397b519b111105ce543db300c1cdc4c3d67993ce31c8e4aa918dc5279 config-baseline.json
2-
1b4ea34ca4c7edcbb29173dd7ebed0a35077dda23e95093c4e199606d505d179 config-baseline.core.json
1+
a660c73743b50c4a6a546932504724647daa06bd273e19be506d40b1a2aecb53 config-baseline.json
2+
0084dc1fce9c0e9cd2e838456a726d641c1733827cf826e6de5e8cf7206e3dd7 config-baseline.core.json
33
82596aeb4c8d4cd18fefae554ff4d0c9e2cd82895b53d460db8f8ceb819f0ef6 config-baseline.channel.json
44
168e3c52da484c235fbc451dead71af16c3bee0c0186c460e5b4b4af70a496df config-baseline.plugin.json

β€Ždocs/cli/node.mdβ€Ž

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@ Common use cases:
2525
Execution is still guarded by **exec approvals** and per-agent allowlists on the
2626
node host, so you can keep command access scoped and explicit.
2727

28+
`openclaw node run` can publish plugin or MCP-backed tools after it connects.
29+
The Gateway trusts descriptors from the paired node by default, while requiring
30+
each descriptor's command to remain in the node's approved command surface. The
31+
agent sees each accepted descriptor as a normal plugin tool, but execution still
32+
goes through `node.invoke`, so disconnecting the node removes the tool from new
33+
agent runs. Gateway operators can disable publication with
34+
`gateway.nodes.pluginTools.enabled: false`.
35+
36+
For declarative MCP tools, add the normal MCP server shape under
37+
`nodeHost.mcp.servers` in `openclaw.json` on the node machine, then restart the
38+
node host. The node declares the approval-gated `mcp.tools.call.v1` command
39+
family and publishes listed tools after connecting; changing the server list
40+
later does not require re-pairing. See
41+
[Node-hosted MCP servers](/nodes#node-hosted-mcp-servers).
42+
2843
## Browser proxy (zero-config)
2944

3045
Node hosts automatically advertise a browser proxy if `browser.enabled` is not

β€Ždocs/docs_map.mdβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3625,6 +3625,7 @@ Do not edit it by hand; run `pnpm docs:map:gen`.
36253625
- H3: Client capabilities
36263626
- H3: Node connect example
36273627
- H2: Roles and scopes
3628+
- H3: Caps/commands/permissions (node)
36283629
- H2: Presence
36293630
- H3: Node background alive event
36303631
- H2: Broadcast event scoping
@@ -4745,6 +4746,8 @@ Do not edit it by hand; run `pnpm docs:map:gen`.
47454746
- H3: Remote gateway via SSH tunnel (loopback bind)
47464747
- H3: Start a node host (service)
47474748
- H3: Pair + name
4749+
- H3: Node-hosted MCP servers
4750+
- H3: Node-hosted skills
47484751
- H3: Headless identity state
47494752
- H3: Allowlist the commands
47504753
- H3: Point exec at the node
@@ -9730,6 +9733,7 @@ Do not edit it by hand; run `pnpm docs:map:gen`.
97309733
- Route: /tools/skills
97319734
- Headings:
97329735
- H2: Loading order
9736+
- H2: Node-hosted skills
97339737
- H2: Per-agent vs shared skills
97349738
- H2: Agent allowlists
97359739
- H2: Plugins and skills

β€Ždocs/gateway/protocol.mdβ€Ž

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,35 @@ method scope (`operator.pairing`), based on the pending request's declared
264264
| non-exec commands | `operator.pairing` + `operator.write` |
265265
| includes `system.run`, `system.run.prepare`, or `system.which` | `operator.pairing` + `operator.admin` |
266266

267+
### Caps/commands/permissions (node)
268+
269+
Nodes declare capability claims at connect time:
270+
271+
- `caps`: high-level capability categories such as `camera`, `canvas`, `screen`,
272+
`location`, `voice`, and `talk`.
273+
- `commands`: command allowlist for invoke.
274+
- `permissions`: granular toggles (e.g. `screen.record`, `camera.capture`).
275+
276+
The Gateway treats these as **claims** and enforces server-side allowlists.
277+
Connected nodes can publish optional agent-visible plugin or MCP tool
278+
descriptors with `node.pluginTools.update` after a successful connect or
279+
reconnect. Headless node hosts restart to apply declarative MCP inventory
280+
changes. This update method is the only publication path; plugin tool descriptors are not accepted in
281+
`connect` params. Each descriptor must use a provider-safe tool `name` and name
282+
a `command` in the node's current command allowlist. The Gateway trusts descriptor
283+
metadata from the paired node, filters descriptors outside the approved command
284+
surface, removes them when the node disconnects, and rejects operator attempts
285+
to mutate another node's catalog. Set `gateway.nodes.pluginTools.enabled: false`
286+
to ignore node-published descriptors.
287+
288+
Connected node hosts publish their complete skill replacement catalog with
289+
`node.skills.update`. This node-role method is the only node skill publication
290+
path; skills are not accepted in `connect` params. Each descriptor contains a
291+
safe name, description, and bounded `SKILL.md` content. The Gateway parses that
292+
content with the normal skills loader, includes it in agent skill snapshots
293+
while the node is connected, and removes it on disconnect. Set
294+
`gateway.nodes.skills.enabled: false` to ignore node-published skills.
295+
267296
## Presence
268297

269298
- `system-presence` returns entries keyed by device identity, including
@@ -499,7 +528,9 @@ methods. Treat this as feature discovery, not a full enumeration of
499528
- `node.rename` updates a paired node label.
500529
- `node.invoke` forwards a command to a connected node.
501530
- `node.invoke.result` returns the result for an invoke request.
531+
- `mcp.tools.call.v1` is the headless node-host command for calling a configured node-local MCP tool. It is carried through `node.invoke`, requires the node to declare the command, and remains subject to pairing approval and `gateway.nodes.denyCommands`.
502532
- `node.event` carries node-originated events back into the gateway.
533+
- `node.pluginTools.update` is the only publication path for replacing the connected node's agent-visible plugin/MCP tool descriptors; `connect` params do not carry them.
503534
- `node.pending.pull` and `node.pending.ack` are the connected-node queue APIs.
504535
- `node.pending.enqueue` and `node.pending.drain` manage durable pending work for offline/disconnected nodes.
505536

β€Ždocs/nodes/index.mdβ€Ž

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,81 @@ Naming options:
136136
- `--display-name` on `openclaw node run` / `openclaw node install` (persists in `~/.openclaw/node.json` on the node, alongside the client instance ID and Gateway connection metadata).
137137
- `openclaw nodes rename --node <id|name|ip> --name "Build Node"` (gateway override).
138138

139+
### Node-hosted MCP servers
140+
141+
Configure MCP servers in `openclaw.json` on the node machine, not on the
142+
Gateway:
143+
144+
```json5
145+
{
146+
nodeHost: {
147+
mcp: {
148+
servers: {
149+
localDocs: {
150+
command: "npx",
151+
args: ["-y", "@modelcontextprotocol/server-filesystem", "/srv/docs"],
152+
toolFilter: {
153+
include: ["read_*", "search"],
154+
},
155+
},
156+
internalApi: {
157+
url: "https://mcp.internal.example/mcp",
158+
transport: "streamable-http",
159+
headers: {
160+
Authorization: "Bearer ${INTERNAL_MCP_TOKEN}",
161+
},
162+
},
163+
},
164+
},
165+
},
166+
}
167+
```
168+
169+
The headless node host starts these servers, lists their tools, and publishes
170+
the descriptors after connecting. Tool calls return to that node through
171+
`mcp.tools.call.v1`; the Gateway does not need matching MCP config or a JS
172+
plugin. OAuth MCP servers are not supported by this node-hosted v1 path.
173+
174+
The first time the node declares the `mcp.tools.call.v1` command family, approve
175+
the pending node command-surface upgrade. Adding, removing, or filtering servers
176+
after that does not require re-pairing because the approved command family is
177+
unchanged. Restart `openclaw node run` or `openclaw node restart` to apply node
178+
MCP config changes; the node host does not watch this config.
179+
180+
Gateway operators can ignore all agent-visible tools published by paired nodes,
181+
including node-hosted MCP tools, with
182+
`gateway.nodes.pluginTools.enabled: false`. Exact command denies such as
183+
`gateway.nodes.denyCommands: ["mcp.tools.call.v1"]` also block execution.
184+
185+
### Node-hosted skills
186+
187+
Install skills under the node machine's active OpenClaw skills directory,
188+
`~/.openclaw/skills` by default. `OPENCLAW_HOME`, `OPENCLAW_STATE_DIR`, and
189+
`OPENCLAW_CONFIG_PATH` move that active profile. `OPENCLAW_STATE_DIR` takes
190+
precedence for skills; otherwise, `skills/` is beside the path printed by
191+
`openclaw config file`. The headless node host publishes valid `SKILL.md` files
192+
after it connects, and the Gateway adds them to agent skill snapshots only while
193+
that node remains connected. Each skill directory name must match the `name`
194+
frontmatter field so the abstract node locator maps to one entry without adding
195+
another protocol field.
196+
197+
The initial node-role pairing approves skill publication. Adding, removing, or
198+
changing skills does not require another pairing or Gateway configuration
199+
change. Restart `openclaw node run` or `openclaw node restart` after changing
200+
node skill files; the node host does not watch the skills directory.
201+
202+
Node-hosted skill entries identify their node and carry their execution
203+
location. Skill files, referenced relative paths, and binaries remain on that
204+
node. Load instructions and run commands with
205+
`exec host=node node=<node-id>` so relative paths resolve on the node rather
206+
than the Gateway machine. The publishing node must have approved `system.run`,
207+
and the agent's exec policy must allow `host=node`; otherwise the skill stays
208+
out of that agent's snapshot.
209+
210+
Set `nodeHost.skills.enabled: false` on the node to stop publication. Gateway
211+
operators can ignore skills from every paired node with
212+
`gateway.nodes.skills.enabled: false`.
213+
139214
### Headless identity state
140215

141216
The headless node keeps three separate state files:
@@ -278,7 +353,7 @@ These rows describe the Gateway policy ceiling, not the commands implemented by
278353

279354
`talk.ptt.start`, `talk.ptt.stop`, `talk.ptt.cancel`, and `talk.ptt.once` are allowed by default for any node that advertises the `talk` capability or declares `talk.*` commands, independent of platform label.
280355

281-
Desktop host commands (`system.run`, `system.run.prepare`, `system.which`, `browser.proxy`, `screen.snapshot` on macOS/Windows) are not part of the static platform-default table above. They become available once the operator approves a pairing request that declares them, after which the node's approved command set carries them forward on reconnect.
356+
Desktop host commands (`system.run`, `system.run.prepare`, `system.which`, `browser.proxy`, `mcp.tools.call.v1`, and `screen.snapshot` on macOS/Windows) are not part of the static platform-default table above. They become available once the operator approves a pairing request that declares them, after which the node's approved command set carries them forward on reconnect.
282357

283358
Dangerous or privacy-heavy commands still require explicit opt-in with `gateway.nodes.allowCommands`, even if a node declares them: `camera.snap`, `camera.clip`, `screen.record`, `computer.act`, `contacts.add`, `calendar.add`, `reminders.add`, `sms.send`, `sms.search`. `gateway.nodes.denyCommands` always wins over defaults and extra allowlist entries. See [Computer use](/nodes/computer-use) for the additional macOS, tool-policy, and arming gates around desktop input.
284359

@@ -303,6 +378,10 @@ Node-related settings live under `gateway.nodes` and `tools.exec`:
303378
// node pairing on an exact device-key match read back over SSH.
304379
sshVerify: true,
305380
},
381+
// Trust agent-visible plugin tools published by paired nodes (default: true).
382+
pluginTools: {
383+
enabled: true,
384+
},
306385
// Opt into dangerous/privacy-heavy node commands (camera.snap, etc.).
307386
allowCommands: ["camera.snap", "screen.record"],
308387
// Block exact command names even if defaults or allowCommands include them.
@@ -322,7 +401,7 @@ Node-related settings live under `gateway.nodes` and `tools.exec`:
322401
}
323402
```
324403

325-
Use exact node command names. `denyCommands` removes a command even when a platform default or `allowCommands` entry would otherwise allow it. See [Gateway configuration reference](/gateway/configuration-reference#gateway) for gateway node pairing and command-policy field details.
404+
Use exact node command names. `denyCommands` removes a command even when a platform default or `allowCommands` entry would otherwise allow it. Paired nodes may publish agent-visible plugin tool descriptors by default, but each descriptor's command must still be in the node's approved command surface. Set `gateway.nodes.pluginTools.enabled: false` to ignore all such descriptors. See [Gateway configuration reference](/gateway/configuration-reference#gateway) for gateway node pairing and command-policy field details.
326405

327406
Per-agent exec node override:
328407

β€Ždocs/plugins/sdk-overview.mdβ€Ž

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,11 @@ Use [`defineToolPlugin`](/plugins/tool-plugins) for simple tool-only plugins
139139
with fixed tool names. Use `api.registerTool(...)` directly for mixed plugins
140140
or fully dynamic tool registration.
141141

142-
| Method | What it registers |
143-
| ------------------------------- | --------------------------------------------- |
144-
| `api.registerTool(tool, opts?)` | Agent tool (required or `{ optional: true }`) |
145-
| `api.registerCommand(def)` | Custom command (bypasses the LLM) |
142+
| Method | What it registers |
143+
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
144+
| `api.registerTool(tool, opts?)` | Agent tool (required or `{ optional: true }`) |
145+
| `api.registerCommand(def)` | Custom command (bypasses the LLM) |
146+
| `api.registerNodeHostCommand(command)` | Command handled by `openclaw node run`; optional `agentTool` metadata can expose it as an agent-visible tool while the node is connected |
146147

147148
Plugin commands can set `agentPromptGuidance` when the agent needs a short,
148149
command-owned routing hint. Keep that text about the command itself; do not add
@@ -169,6 +170,19 @@ surfaces: only guidance explicitly scoped to `codex_app_server` is promoted into
169170
that higher-priority lane. Legacy string guidance and unscoped structured
170171
guidance remain available to non-Codex prompt surfaces for compatibility.
171172

173+
Node-host commands run on the connected node host, not inside the Gateway
174+
process. If `agentTool` is present, the node publishes a descriptor after a
175+
successful Gateway connect; the Gateway exposes it to agent runs only while that
176+
node is connected and only if the descriptor's `command` is in the node's
177+
approved command surface. Set `agentTool.defaultPlatforms` to opt a
178+
non-dangerous command into the default node command allowlist; otherwise require
179+
explicit `gateway.nodes.allowCommands` or a node-invoke policy. `agentTool.name`
180+
must be provider-safe: start with a letter, use only letters, digits,
181+
underscores, or hyphens, and stay within 64 characters. MCP-backed node tools
182+
can set `agentTool.mcp` metadata so catalog and tool-search surfaces can show
183+
the remote MCP server/tool identity, but execution still goes through the
184+
advertised node command.
185+
172186
### Infrastructure
173187

174188
| Method | What it registers |

β€Ždocs/plugins/sdk-runtime.mdβ€Ž

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,15 @@ two-party event loops that do not go through the shared inbound reply runner.
334334
});
335335
```
336336

337+
`nodes.list(...)` includes each connected node's advertised
338+
`nodePluginTools` descriptors when that node exposes plugin or MCP-backed
339+
tools to the agent. Those descriptors are live connection state: the Gateway
340+
drops them when the node disconnects, and a node can replace them with
341+
`node.pluginTools.update` after local plugin/MCP inventory changes.
342+
337343
Inside the Gateway this runtime is in-process. In plugin CLI commands it calls the configured Gateway over RPC, so commands such as `openclaw googlemeet recover-tab` can inspect paired nodes from the terminal. Node commands still go through normal Gateway node pairing, command allowlists, plugin node-invoke policies, and node-local command handling.
338344

339-
Plugins that expose dangerous node-host commands should register a node-invoke policy with `api.registerNodeInvokePolicy(...)`. The policy runs in the Gateway after command allowlist checks and before the command is forwarded to the node, so direct `node.invoke` calls and higher-level plugin tools share the same enforcement path.
345+
Plugins that expose node-hosted agent tools can set `agentTool.defaultPlatforms` for non-dangerous commands that should be allowlisted by default. Omit it when operators must opt in with `gateway.nodes.allowCommands`. Dangerous node-host commands should register a node-invoke policy with `api.registerNodeInvokePolicy(...)`; the policy runs in the Gateway after command allowlist checks and before the command is forwarded to the node, so direct `node.invoke` calls, node-hosted plugin tools, and higher-level plugin tools share the same enforcement path.
340346

341347
<Warning>
342348
The optional `scopes` field requests Gateway operator scopes for the invocation. OpenClaw honors it only for bundled plugins and trusted official plugin installations; requests from other plugins do not elevate the call. Use it only when a trusted plugin must invoke a node command with a stricter Gateway scope, such as `operator.admin`.

0 commit comments

Comments
Β (0)