You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6b9e814
Browse filesBrowse the repository at this point in the historyBrowse files
**OpenClaw.Shared** owns the low-level gateway clients (`OpenClawGatewayClient`, `WindowsNodeClient`, `WebSocketClientBase`), device identity/signing (`DeviceIdentity`), protocol models, and the `IOperatorGatewayClient` interface.
18
18
19
+
`WindowsNodeClient` also owns gateway invocation lifetime at the transport
20
+
boundary. Active invokes are registered by invoke ID in a focused cancellation
21
+
registry, linked to the node connection lifetime, and cancelled individually by
22
+
the gateway `node.invoke.cancel` event. Active invocations atomically transition
23
+
to cancelled or completed when capability execution returns; whichever
24
+
transition wins determines the protocol outcome. Capability implementations
25
+
remain responsible for cooperative cancellation of their own underlying work.
26
+
19
27
**OpenClaw.Connection** owns all connection management: `GatewayConnectionManager`, `GatewayRegistry`, `CredentialResolver`, `ConnectionStateMachine`, `NodeConnector`, `SshTunnelService/Manager`, `SetupCodeDecoder`, and all connection interfaces/DTOs/enums. This project has zero WinUI dependencies and is independently testable.
20
28
21
29
**OpenClaw.Tray.WinUI** consumes the connection layer through interfaces. It never creates gateway clients directly — `GatewayConnectionManager` owns that entirely.
Copy file name to clipboardExpand all lines: docs/MCP_MODE.md
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,9 +66,37 @@ The capability list lives on `NodeService`, *not* on `WindowsNodeClient`. That s
66
66
-`tools/list` — flattens `_capabilities` into MCP tools. Tool name = command name (`"screen.snapshot"`); known commands get curated descriptions from `McpToolBridge.CommandDescriptions`; unknown commands fall back to `"{category} capability: {command}"`. `inputSchema` is permissive.
67
67
-`tools/call` — finds the capability via `INodeCapability.CanHandle(name)`, builds a `NodeInvokeRequest` (the same struct the gateway path uses), calls `ExecuteAsync`, wraps the result as MCP `content[].text`. Tool failures come back as `result.isError = true`, not JSON-RPC errors (per MCP spec — JSON-RPC errors are reserved for protocol issues).
-`notifications/cancelled` — cancels the active request whose JSON-RPC ID is
70
+
supplied as `params.requestId`. A cancelled `tools/call` completes with an MCP
71
+
tool error containing `cancelled`. If concurrent HTTP scheduling processes
72
+
cancellation just before an already-sent call registers, the notification
73
+
records a pending cancellation for five seconds. The first matching
74
+
registration atomically consumes that tombstone and returns `cancelled` before
75
+
capability execution begins, so correctness does not depend on scheduler
76
+
timing. Repeated notifications for the same pending ID do not extend its
77
+
original five-second lifetime. Pending cancellations and recent-completion
78
+
guards are each capped at 1,024 entries;
79
+
expired entries are pruned first and the oldest remaining entry is evicted at
80
+
capacity. Because JSON-RPC IDs are client-scoped but this stateless HTTP
81
+
transport has no client identity, duplicate active IDs are allowed and
82
+
cancellation is ignored when more than one active call matches; this prevents
83
+
one local client from cancelling another client when the collision is already
84
+
observable. Request matching uses the decoded JSON string value or normalized
85
+
arbitrary-precision JSON number value, while preserving the distinction
86
+
between string and numeric IDs. A tombstone cannot predict a later
87
+
cross-client ID collision, so it cancels the first matching registration;
88
+
complete isolation would require client identity in the transport. A recent
89
+
completion guard also prevents a late notification from poisoning immediate
90
+
ID reuse.
69
91
70
92
The bridge takes a `Func<IReadOnlyList<INodeCapability>>` rather than a snapshot. Every `tools/list` re-reads the live list. This is what guarantees zero-cost capability addition — register a new capability after server start and it appears on the next `tools/list`.
71
93
94
+
Cancellation is cooperative and uses the same `CancellationToken` capability
95
+
contract as the gateway transport. Screen and camera operations propagate the
96
+
token through recording consent/countdown, camera admission, capture waits, and
97
+
recording shutdown. The HTTP request deadline remains a separate safety bound;
98
+
no command-specific transport deadlines are applied.
99
+
72
100
### HTTP transport
73
101
74
102
`OpenClaw.Shared/Mcp/McpHttpServer.cs` is `System.Net.HttpListener` bound to `http://127.0.0.1:8765/`. Loopback-only by construction; not reachable from any other machine even with firewall holes. A defensive `IPAddress.IsLoopback` check on each request acts as belt-and-suspenders.
0 commit comments