@alfe.ai/openclaw-mcp-bundler 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.cts +26 -28
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +26 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/plugin.d.cts +11 -21
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.ts +11 -21
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin2.cjs +410 -92
- package/dist/plugin2.d.cts +2 -2
- package/dist/plugin2.d.ts +2 -2
- package/dist/plugin2.js +410 -92
- package/dist/plugin2.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -3,43 +3,41 @@ import { t as plugin } from "./plugin.cjs";
|
|
|
3
3
|
//#region src/cli-backend-detect.d.ts
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Decide whether to defer to OpenClaw's native `bundleMcp:true` path for
|
|
7
|
+
* this run. Pre-May-2026 this gated on backend type (claude-cli /
|
|
8
|
+
* codex-cli), but the actual hazard was double-registration: when
|
|
9
|
+
* `openclaw.json#mcp.servers` had entries AND the plugin registered the
|
|
10
|
+
* same tools via `api.registerTool`, claude-cli's bundleMcp would spawn
|
|
11
|
+
* its own copy and OpenClaw would suffix-disambiguate the duplicates.
|
|
8
12
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* flag and we call that instead — see project_openclaw_mcp_bundler.md TODO).
|
|
13
|
+
* The single-source-of-truth refactor stops mirror-writing the alfe
|
|
14
|
+
* store into openclaw.json, so `mcp.servers` is empty in practice. The
|
|
15
|
+
* native path on claude-cli has nothing to spawn, our plugin's IPC path
|
|
16
|
+
* is the only one in play, and we register on every backend.
|
|
14
17
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* MiniMax is the bug we exist to fix.
|
|
18
|
+
* The escape hatch survives: a user who hand-edits `mcp.servers` in
|
|
19
|
+
* openclaw.json (private dev MCP, etc.) gets the native path back —
|
|
20
|
+
* this function returns true, the plugin no-ops, and claude-cli/codex-cli
|
|
21
|
+
* spawn that entry themselves.
|
|
20
22
|
*/
|
|
21
23
|
interface ConfigLike {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
model?: string;
|
|
25
|
-
cliBackends?: Record<string, unknown>;
|
|
26
|
-
};
|
|
24
|
+
mcp?: {
|
|
25
|
+
servers?: Record<string, unknown>;
|
|
27
26
|
};
|
|
28
27
|
}
|
|
29
28
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* Returns true when openclaw.json#mcp.servers has at least one entry —
|
|
30
|
+
* signalling that the native bundleMcp path is in play for THIS run
|
|
31
|
+
* (regardless of backend) and the plugin should defer to it.
|
|
32
32
|
*
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* If `agents.defaults.cliBackends` explicitly configures one of the native
|
|
40
|
-
* backends, we trust that override.
|
|
33
|
+
* Empty object / missing key → false → plugin registers IPC-proxied tools.
|
|
34
|
+
*/
|
|
35
|
+
declare function hasNativeOpenclawMcpServers(cfg: ConfigLike | undefined): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Back-compat alias for callers still on the old name. Internal — drop
|
|
38
|
+
* once we cut the next major.
|
|
41
39
|
*/
|
|
42
|
-
declare
|
|
40
|
+
declare const detectNativeBundleMcp: typeof hasNativeOpenclawMcpServers;
|
|
43
41
|
//#endregion
|
|
44
42
|
export { plugin as default, detectNativeBundleMcp };
|
|
45
43
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/cli-backend-detect.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/cli-backend-detect.ts"],"mappings":";;;;;;;;AAgCA;AAWA;;;;;;;;;;;;;UAxBU,UAAA;;cAEI;;;;;;;;;;iBAWE,2BAAA,MAAiC;;;;;cAWpC,8BAAqB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,43 +3,41 @@ import { t as plugin } from "./plugin.js";
|
|
|
3
3
|
//#region src/cli-backend-detect.d.ts
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Decide whether to defer to OpenClaw's native `bundleMcp:true` path for
|
|
7
|
+
* this run. Pre-May-2026 this gated on backend type (claude-cli /
|
|
8
|
+
* codex-cli), but the actual hazard was double-registration: when
|
|
9
|
+
* `openclaw.json#mcp.servers` had entries AND the plugin registered the
|
|
10
|
+
* same tools via `api.registerTool`, claude-cli's bundleMcp would spawn
|
|
11
|
+
* its own copy and OpenClaw would suffix-disambiguate the duplicates.
|
|
8
12
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* flag and we call that instead — see project_openclaw_mcp_bundler.md TODO).
|
|
13
|
+
* The single-source-of-truth refactor stops mirror-writing the alfe
|
|
14
|
+
* store into openclaw.json, so `mcp.servers` is empty in practice. The
|
|
15
|
+
* native path on claude-cli has nothing to spawn, our plugin's IPC path
|
|
16
|
+
* is the only one in play, and we register on every backend.
|
|
14
17
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* MiniMax is the bug we exist to fix.
|
|
18
|
+
* The escape hatch survives: a user who hand-edits `mcp.servers` in
|
|
19
|
+
* openclaw.json (private dev MCP, etc.) gets the native path back —
|
|
20
|
+
* this function returns true, the plugin no-ops, and claude-cli/codex-cli
|
|
21
|
+
* spawn that entry themselves.
|
|
20
22
|
*/
|
|
21
23
|
interface ConfigLike {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
model?: string;
|
|
25
|
-
cliBackends?: Record<string, unknown>;
|
|
26
|
-
};
|
|
24
|
+
mcp?: {
|
|
25
|
+
servers?: Record<string, unknown>;
|
|
27
26
|
};
|
|
28
27
|
}
|
|
29
28
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* Returns true when openclaw.json#mcp.servers has at least one entry —
|
|
30
|
+
* signalling that the native bundleMcp path is in play for THIS run
|
|
31
|
+
* (regardless of backend) and the plugin should defer to it.
|
|
32
32
|
*
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* If `agents.defaults.cliBackends` explicitly configures one of the native
|
|
40
|
-
* backends, we trust that override.
|
|
33
|
+
* Empty object / missing key → false → plugin registers IPC-proxied tools.
|
|
34
|
+
*/
|
|
35
|
+
declare function hasNativeOpenclawMcpServers(cfg: ConfigLike | undefined): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Back-compat alias for callers still on the old name. Internal — drop
|
|
38
|
+
* once we cut the next major.
|
|
41
39
|
*/
|
|
42
|
-
declare
|
|
40
|
+
declare const detectNativeBundleMcp: typeof hasNativeOpenclawMcpServers;
|
|
43
41
|
//#endregion
|
|
44
42
|
export { plugin as default, detectNativeBundleMcp };
|
|
45
43
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/cli-backend-detect.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/cli-backend-detect.ts"],"mappings":";;;;;;;;AAgCA;AAWA;;;;;;;;;;;;;UAxBU,UAAA;;cAEI;;;;;;;;;;iBAWE,2BAAA,MAAiC;;;;;cAWpC,8BAAqB"}
|
package/dist/plugin.d.cts
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
//#region
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
args?: string[];
|
|
11
|
-
env?: Record<string, string>;
|
|
12
|
-
cwd?: string;
|
|
13
|
-
}
|
|
14
|
-
interface RemoteServerConfig {
|
|
15
|
-
url: string;
|
|
16
|
-
transport?: 'sse' | 'streamable-http';
|
|
17
|
-
headers?: Record<string, string>;
|
|
18
|
-
connectionTimeoutMs?: number;
|
|
1
|
+
//#region src/ipc-client.d.ts
|
|
2
|
+
interface IpcResponse<T = unknown> {
|
|
3
|
+
id: string;
|
|
4
|
+
ok: boolean;
|
|
5
|
+
payload?: T;
|
|
6
|
+
error?: {
|
|
7
|
+
code: string;
|
|
8
|
+
message: string;
|
|
9
|
+
};
|
|
19
10
|
}
|
|
20
11
|
//#endregion
|
|
21
12
|
//#region src/plugin.d.ts
|
|
@@ -34,8 +25,7 @@ interface ConfigSnapshot {
|
|
|
34
25
|
};
|
|
35
26
|
};
|
|
36
27
|
mcp?: {
|
|
37
|
-
servers?: Record<string,
|
|
38
|
-
sessionIdleTtlMs?: number;
|
|
28
|
+
servers?: Record<string, unknown>;
|
|
39
29
|
};
|
|
40
30
|
}
|
|
41
31
|
interface AgentToolResult {
|
|
@@ -90,5 +80,5 @@ declare const plugin: {
|
|
|
90
80
|
deactivate(api: OpenClawPluginApi): void;
|
|
91
81
|
};
|
|
92
82
|
//#endregion
|
|
93
|
-
export { plugin as t };
|
|
83
|
+
export { IpcResponse as n, plugin as t };
|
|
94
84
|
//# sourceMappingURL=plugin.d.cts.map
|
package/dist/plugin.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":["McpServerConfig","StdioServerConfig","RemoteServerConfig","Record","McpTransportKind","McpToolDescriptor","ReconcileDiff","Logger","McpToolCallResult","BundlerOptions","STDIO_ENV_DENYLIST","Set","sanitizeStdioEnv","ConnectionDeps","McpClientHandle","Promise","AbortSignal","Connection","defaultConnect","McpBundler","sanitizeNameSegment","buildNamespacedToolName","disambiguateAgainst","ReadonlySet"],"sources":["../../mcp-bundler/dist/index.d.ts","../src/plugin.ts"],"sourcesContent":["//#region src/types.d.ts\n/**\n * Shape of a single MCP server entry — matches OpenClaw `mcp.servers.{name}`.\n * Either a stdio child process spec or a remote URL spec.\n */\ntype McpServerConfig = StdioServerConfig | RemoteServerConfig;\ninterface StdioServerConfig {\n command: string;\n args?: string[];\n env?: Record<string, string>;\n cwd?: string;\n}\ninterface RemoteServerConfig {\n url: string;\n transport?: 'sse' | 'streamable-http';\n headers?: Record<string, string>;\n connectionTimeoutMs?: number;\n}\ntype McpTransportKind = 'stdio' | 'sse' | 'streamable-http';\n/**\n * One tool surfaced from one MCP server, after namespacing.\n */\ninterface McpToolDescriptor {\n /** Namespaced name as the LLM sees it: `{serverName}__{originalName}`, sanitized + max 64 chars. */\n prefixed: string;\n /** Server name (key in `mcp.servers.*`). */\n server: string;\n /** Original tool name as advertised by the MCP server. */\n original: string;\n /** Human label for the tool (truncated description, suitable for UI). */\n label: string;\n /** Full description from the MCP server. */\n description: string;\n /** JSON Schema (object) for tool parameters. */\n parameters: Record<string, unknown>;\n}\ninterface ReconcileDiff {\n added: string[];\n removed: string[];\n changed: string[];\n unchanged: string[];\n}\ninterface Logger {\n debug: (msg: string, meta?: Record<string, unknown>) => void;\n info: (msg: string, meta?: Record<string, unknown>) => void;\n warn: (msg: string, meta?: Record<string, unknown>) => void;\n error: (msg: string, meta?: Record<string, unknown>) => void;\n}\ninterface McpToolCallResult {\n content: Record<string, unknown>[];\n isError?: boolean;\n}\ninterface BundlerOptions {\n logger?: Logger;\n /** Idle TTL for spawned children (ms). 0 disables. Default: 600_000 (10 min). */\n idleTtlMs?: number;\n /** Sweep interval for idle reaping (ms). Default: 60_000 (1 min). */\n idleSweepIntervalMs?: number;\n}\n//# sourceMappingURL=types.d.ts.map\n//#endregion\n//#region src/connection.d.ts\n/** Env keys OpenClaw rejects from stdio MCP env blocks. Filter them out before spawning. */\ndeclare const STDIO_ENV_DENYLIST: Set<string>;\ndeclare function sanitizeStdioEnv(env: Record<string, string> | undefined): Record<string, string>;\ninterface ConnectionDeps {\n /**\n * Factory for an MCP Client connected to the given config. Injected so tests\n * can mock without spawning real processes. In production this wraps\n * `@modelcontextprotocol/sdk/client`.\n */\n connect: (server: McpServerConfig) => Promise<McpClientHandle>;\n}\n/**\n * Minimal interface our connection layer needs from an MCP client. Mirrors\n * the @modelcontextprotocol/sdk Client surface but kept narrow so we can\n * mock cleanly in tests.\n */\ninterface McpClientHandle {\n listTools(): Promise<{\n name: string;\n description?: string;\n inputSchema: Record<string, unknown>;\n }[]>;\n callTool(name: string, args: unknown, opts?: {\n signal?: AbortSignal;\n }): Promise<McpToolCallResult>;\n close(): Promise<void>;\n}\n/**\n * One Connection per MCP server. Owns lifecycle (lazy-spawn, close, refresh-lock).\n * Refresh-lock pattern adapted from AIWerk `index.ts:219-250` — prevents\n * reconnect + `notifications/tools/list_changed` race.\n */\ndeclare class Connection {\n readonly name: string;\n readonly config: McpServerConfig;\n private readonly deps;\n private readonly logger;\n private client;\n private tools;\n private connectInFlight;\n private refreshInFlight;\n private refreshQueued;\n private lastUsedAt;\n constructor(params: {\n name: string;\n config: McpServerConfig;\n deps: ConnectionDeps;\n logger?: Logger;\n });\n /** Returns the most recent known tool list. May be empty if the server hasn't connected yet. */\n snapshotTools(): McpToolDescriptor[];\n /** Whether an MCP child process / remote connection has been established. */\n isConnected(): boolean;\n /** Idle timestamp for reaping. */\n idleSinceMs(): number;\n /**\n * Lazy connect + tool discovery. Safe to call concurrently; in-flight\n * connects coalesce.\n */\n ensureConnected(): Promise<void>;\n private connectAndDiscover;\n /**\n * Re-discover tools. Used on reconnect or `tools/list_changed` notification.\n * Refresh-lock collapses concurrent refreshes; if one is in flight, the next\n * is queued (max 1 queued, since N>1 queued provides no extra freshness).\n */\n refresh(): Promise<void>;\n callTool(originalName: string, args: unknown, signal?: AbortSignal): Promise<McpToolCallResult>;\n /**\n * Close the underlying transport. Idempotent. If a connect is in flight\n * (warmup racing with reconcile-removal), wait for it to settle and then\n * close the client it produced — otherwise the child process is orphaned.\n */\n close(): Promise<void>;\n /**\n * Stable hash of the config for diff detection in `reconcile`.\n * Two configs with the same hash are equivalent (no restart needed).\n */\n configFingerprint(): string;\n}\n/**\n * Build the production `connect` factory using the official MCP SDK.\n * Kept in a separate function so tests can substitute a mock without\n * pulling the SDK into the test bundle.\n */\ndeclare function defaultConnect(server: McpServerConfig): Promise<McpClientHandle>;\n//# sourceMappingURL=connection.d.ts.map\n//#endregion\n//#region src/bundler.d.ts\n/**\n * Provider-agnostic MCP server bundler. Holds N MCP server connections,\n * exposes a unified namespaced tool catalog, and routes calls to the right\n * server.\n *\n * Designed to be embedded in any host (OpenClaw plugin, AI proxy, Lambda).\n * Public surface is intentionally synchronous where the host needs sync\n * (snapshot, listTools), async only where I/O is unavoidable.\n */\ndeclare class McpBundler {\n private readonly logger;\n private readonly connections;\n private readonly idleTtlMs;\n private readonly idleSweepIntervalMs;\n private idleSweepTimer;\n private readonly deps;\n private disposed;\n private reconcileLatch;\n constructor(opts?: BundlerOptions, deps?: ConnectionDeps);\n /**\n * Diff `desired` against current connections, spawn newcomers, dispose\n * removals, hot-restart on config change. Pull-based — call whenever the\n * host's config snapshot may have changed. Cheap if no diff.\n *\n * Lazy: newly-added servers are NOT eagerly connected; they connect on the\n * first `callTool()` (or first `listTools()` after `forceDiscover()`).\n * This avoids paying spawn cost for servers the agent never uses.\n */\n reconcile(desired: Record<string, McpServerConfig>): Promise<ReconcileDiff>;\n private doReconcile;\n /**\n * Synchronous snapshot of all currently-known tools across connected servers.\n * Servers that have not connected yet contribute nothing. Intended for use\n * inside OpenClaw's plugin tool factory which must be sync.\n *\n * Tool names are namespaced and disambiguated (suffix `-2`, `-3` on collision)\n * so cross-server name clashes never produce duplicate registrations.\n */\n listTools(): McpToolDescriptor[];\n /**\n * Eagerly connect to every configured server and discover tools. Used by\n * hosts that want a hot list rather than the lazy default. Errors are\n * swallowed per-server (logged), so one bad server doesn't fail the batch.\n */\n warmup(): Promise<void>;\n /**\n * Invoke a tool by its namespaced name. Routes to the originating server.\n * Errors are returned as `{ isError: true, content: [...] }` so a failing\n * tool doesn't crash the host.\n */\n callTool(prefixed: string, args: unknown, signal?: AbortSignal): Promise<McpToolCallResult>;\n /**\n * Resolve a namespaced tool name back to its server connection and original\n * tool name. Returns undefined if the tool is not currently advertised.\n */\n private routeToolName;\n /**\n * Tear down all connections and stop background tasks. Idempotent.\n * Call from `registerRuntimeLifecycle({ cleanup })` in the host plugin.\n */\n dispose(): Promise<void>;\n private startIdleSweep;\n private sweepIdle;\n}\n//# sourceMappingURL=bundler.d.ts.map\n//#endregion\n//#region src/tool-naming.d.ts\n/**\n * Tool name sanitization and collision handling.\n *\n * OpenClaw constraint: tool names must match `[A-Za-z0-9_-]` and be ≤64 chars.\n * Pattern mirrored from `openclaw/src/agents/pi-bundle-mcp-names.ts`.\n *\n * Strategy: prefix every tool with its server name (`{server}__{tool}`),\n * sanitize disallowed chars to `_`, truncate, then suffix-disambiguate\n * (`-2`, `-3`, ...) on collision.\n */\ndeclare function sanitizeNameSegment(value: string): string;\ndeclare function buildNamespacedToolName(server: string, tool: string): string;\n/**\n * Disambiguate a candidate name against an existing set by appending `-2`, `-3`, etc.\n * Mutates nothing; returns the chosen name. Caller is responsible for inserting it\n * into the set.\n */\ndeclare function disambiguateAgainst(candidate: string, taken: ReadonlySet<string>): string;\n//# sourceMappingURL=tool-naming.d.ts.map\n\n//#endregion\nexport { type BundlerOptions, Connection, type ConnectionDeps, type Logger, McpBundler, type McpClientHandle, type McpServerConfig, type McpToolCallResult, type McpToolDescriptor, type McpTransportKind, type ReconcileDiff, type RemoteServerConfig, STDIO_ENV_DENYLIST, type StdioServerConfig, buildNamespacedToolName, defaultConnect, disambiguateAgainst,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HANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
//#region
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
args?: string[];
|
|
11
|
-
env?: Record<string, string>;
|
|
12
|
-
cwd?: string;
|
|
13
|
-
}
|
|
14
|
-
interface RemoteServerConfig {
|
|
15
|
-
url: string;
|
|
16
|
-
transport?: 'sse' | 'streamable-http';
|
|
17
|
-
headers?: Record<string, string>;
|
|
18
|
-
connectionTimeoutMs?: number;
|
|
1
|
+
//#region src/ipc-client.d.ts
|
|
2
|
+
interface IpcResponse<T = unknown> {
|
|
3
|
+
id: string;
|
|
4
|
+
ok: boolean;
|
|
5
|
+
payload?: T;
|
|
6
|
+
error?: {
|
|
7
|
+
code: string;
|
|
8
|
+
message: string;
|
|
9
|
+
};
|
|
19
10
|
}
|
|
20
11
|
//#endregion
|
|
21
12
|
//#region src/plugin.d.ts
|
|
@@ -34,8 +25,7 @@ interface ConfigSnapshot {
|
|
|
34
25
|
};
|
|
35
26
|
};
|
|
36
27
|
mcp?: {
|
|
37
|
-
servers?: Record<string,
|
|
38
|
-
sessionIdleTtlMs?: number;
|
|
28
|
+
servers?: Record<string, unknown>;
|
|
39
29
|
};
|
|
40
30
|
}
|
|
41
31
|
interface AgentToolResult {
|
|
@@ -90,5 +80,5 @@ declare const plugin: {
|
|
|
90
80
|
deactivate(api: OpenClawPluginApi): void;
|
|
91
81
|
};
|
|
92
82
|
//#endregion
|
|
93
|
-
export { plugin as t };
|
|
83
|
+
export { IpcResponse as n, plugin as t };
|
|
94
84
|
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","names":["McpServerConfig","StdioServerConfig","RemoteServerConfig","Record","McpTransportKind","McpToolDescriptor","ReconcileDiff","Logger","McpToolCallResult","BundlerOptions","STDIO_ENV_DENYLIST","Set","sanitizeStdioEnv","ConnectionDeps","McpClientHandle","Promise","AbortSignal","Connection","defaultConnect","McpBundler","sanitizeNameSegment","buildNamespacedToolName","disambiguateAgainst","ReadonlySet"],"sources":["../../mcp-bundler/dist/index.d.ts","../src/plugin.ts"],"sourcesContent":["//#region src/types.d.ts\n/**\n * Shape of a single MCP server entry — matches OpenClaw `mcp.servers.{name}`.\n * Either a stdio child process spec or a remote URL spec.\n */\ntype McpServerConfig = StdioServerConfig | RemoteServerConfig;\ninterface StdioServerConfig {\n command: string;\n args?: string[];\n env?: Record<string, string>;\n cwd?: string;\n}\ninterface RemoteServerConfig {\n url: string;\n transport?: 'sse' | 'streamable-http';\n headers?: Record<string, string>;\n connectionTimeoutMs?: number;\n}\ntype McpTransportKind = 'stdio' | 'sse' | 'streamable-http';\n/**\n * One tool surfaced from one MCP server, after namespacing.\n */\ninterface McpToolDescriptor {\n /** Namespaced name as the LLM sees it: `{serverName}__{originalName}`, sanitized + max 64 chars. */\n prefixed: string;\n /** Server name (key in `mcp.servers.*`). */\n server: string;\n /** Original tool name as advertised by the MCP server. */\n original: string;\n /** Human label for the tool (truncated description, suitable for UI). */\n label: string;\n /** Full description from the MCP server. */\n description: string;\n /** JSON Schema (object) for tool parameters. */\n parameters: Record<string, unknown>;\n}\ninterface ReconcileDiff {\n added: string[];\n removed: string[];\n changed: string[];\n unchanged: string[];\n}\ninterface Logger {\n debug: (msg: string, meta?: Record<string, unknown>) => void;\n info: (msg: string, meta?: Record<string, unknown>) => void;\n warn: (msg: string, meta?: Record<string, unknown>) => void;\n error: (msg: string, meta?: Record<string, unknown>) => void;\n}\ninterface McpToolCallResult {\n content: Record<string, unknown>[];\n isError?: boolean;\n}\ninterface BundlerOptions {\n logger?: Logger;\n /** Idle TTL for spawned children (ms). 0 disables. Default: 600_000 (10 min). */\n idleTtlMs?: number;\n /** Sweep interval for idle reaping (ms). Default: 60_000 (1 min). */\n idleSweepIntervalMs?: number;\n}\n//# sourceMappingURL=types.d.ts.map\n//#endregion\n//#region src/connection.d.ts\n/** Env keys OpenClaw rejects from stdio MCP env blocks. Filter them out before spawning. */\ndeclare const STDIO_ENV_DENYLIST: Set<string>;\ndeclare function sanitizeStdioEnv(env: Record<string, string> | undefined): Record<string, string>;\ninterface ConnectionDeps {\n /**\n * Factory for an MCP Client connected to the given config. Injected so tests\n * can mock without spawning real processes. In production this wraps\n * `@modelcontextprotocol/sdk/client`.\n */\n connect: (server: McpServerConfig) => Promise<McpClientHandle>;\n}\n/**\n * Minimal interface our connection layer needs from an MCP client. Mirrors\n * the @modelcontextprotocol/sdk Client surface but kept narrow so we can\n * mock cleanly in tests.\n */\ninterface McpClientHandle {\n listTools(): Promise<{\n name: string;\n description?: string;\n inputSchema: Record<string, unknown>;\n }[]>;\n callTool(name: string, args: unknown, opts?: {\n signal?: AbortSignal;\n }): Promise<McpToolCallResult>;\n close(): Promise<void>;\n}\n/**\n * One Connection per MCP server. Owns lifecycle (lazy-spawn, close, refresh-lock).\n * Refresh-lock pattern adapted from AIWerk `index.ts:219-250` — prevents\n * reconnect + `notifications/tools/list_changed` race.\n */\ndeclare class Connection {\n readonly name: string;\n readonly config: McpServerConfig;\n private readonly deps;\n private readonly logger;\n private client;\n private tools;\n private connectInFlight;\n private refreshInFlight;\n private refreshQueued;\n private lastUsedAt;\n constructor(params: {\n name: string;\n config: McpServerConfig;\n deps: ConnectionDeps;\n logger?: Logger;\n });\n /** Returns the most recent known tool list. May be empty if the server hasn't connected yet. */\n snapshotTools(): McpToolDescriptor[];\n /** Whether an MCP child process / remote connection has been established. */\n isConnected(): boolean;\n /** Idle timestamp for reaping. */\n idleSinceMs(): number;\n /**\n * Lazy connect + tool discovery. Safe to call concurrently; in-flight\n * connects coalesce.\n */\n ensureConnected(): Promise<void>;\n private connectAndDiscover;\n /**\n * Re-discover tools. Used on reconnect or `tools/list_changed` notification.\n * Refresh-lock collapses concurrent refreshes; if one is in flight, the next\n * is queued (max 1 queued, since N>1 queued provides no extra freshness).\n */\n refresh(): Promise<void>;\n callTool(originalName: string, args: unknown, signal?: AbortSignal): Promise<McpToolCallResult>;\n /**\n * Close the underlying transport. Idempotent. If a connect is in flight\n * (warmup racing with reconcile-removal), wait for it to settle and then\n * close the client it produced — otherwise the child process is orphaned.\n */\n close(): Promise<void>;\n /**\n * Stable hash of the config for diff detection in `reconcile`.\n * Two configs with the same hash are equivalent (no restart needed).\n */\n configFingerprint(): string;\n}\n/**\n * Build the production `connect` factory using the official MCP SDK.\n * Kept in a separate function so tests can substitute a mock without\n * pulling the SDK into the test bundle.\n */\ndeclare function defaultConnect(server: McpServerConfig): Promise<McpClientHandle>;\n//# sourceMappingURL=connection.d.ts.map\n//#endregion\n//#region src/bundler.d.ts\n/**\n * Provider-agnostic MCP server bundler. Holds N MCP server connections,\n * exposes a unified namespaced tool catalog, and routes calls to the right\n * server.\n *\n * Designed to be embedded in any host (OpenClaw plugin, AI proxy, Lambda).\n * Public surface is intentionally synchronous where the host needs sync\n * (snapshot, listTools), async only where I/O is unavoidable.\n */\ndeclare class McpBundler {\n private readonly logger;\n private readonly connections;\n private readonly idleTtlMs;\n private readonly idleSweepIntervalMs;\n private idleSweepTimer;\n private readonly deps;\n private disposed;\n private reconcileLatch;\n constructor(opts?: BundlerOptions, deps?: ConnectionDeps);\n /**\n * Diff `desired` against current connections, spawn newcomers, dispose\n * removals, hot-restart on config change. Pull-based — call whenever the\n * host's config snapshot may have changed. Cheap if no diff.\n *\n * Lazy: newly-added servers are NOT eagerly connected; they connect on the\n * first `callTool()` (or first `listTools()` after `forceDiscover()`).\n * This avoids paying spawn cost for servers the agent never uses.\n */\n reconcile(desired: Record<string, McpServerConfig>): Promise<ReconcileDiff>;\n private doReconcile;\n /**\n * Synchronous snapshot of all currently-known tools across connected servers.\n * Servers that have not connected yet contribute nothing. Intended for use\n * inside OpenClaw's plugin tool factory which must be sync.\n *\n * Tool names are namespaced and disambiguated (suffix `-2`, `-3` on collision)\n * so cross-server name clashes never produce duplicate registrations.\n */\n listTools(): McpToolDescriptor[];\n /**\n * Eagerly connect to every configured server and discover tools. Used by\n * hosts that want a hot list rather than the lazy default. Errors are\n * swallowed per-server (logged), so one bad server doesn't fail the batch.\n */\n warmup(): Promise<void>;\n /**\n * Invoke a tool by its namespaced name. Routes to the originating server.\n * Errors are returned as `{ isError: true, content: [...] }` so a failing\n * tool doesn't crash the host.\n */\n callTool(prefixed: string, args: unknown, signal?: AbortSignal): Promise<McpToolCallResult>;\n /**\n * Resolve a namespaced tool name back to its server connection and original\n * tool name. Returns undefined if the tool is not currently advertised.\n */\n private routeToolName;\n /**\n * Tear down all connections and stop background tasks. Idempotent.\n * Call from `registerRuntimeLifecycle({ cleanup })` in the host plugin.\n */\n dispose(): Promise<void>;\n private startIdleSweep;\n private sweepIdle;\n}\n//# sourceMappingURL=bundler.d.ts.map\n//#endregion\n//#region src/tool-naming.d.ts\n/**\n * Tool name sanitization and collision handling.\n *\n * OpenClaw constraint: tool names must match `[A-Za-z0-9_-]` and be ≤64 chars.\n * Pattern mirrored from `openclaw/src/agents/pi-bundle-mcp-names.ts`.\n *\n * Strategy: prefix every tool with its server name (`{server}__{tool}`),\n * sanitize disallowed chars to `_`, truncate, then suffix-disambiguate\n * (`-2`, `-3`, ...) on collision.\n */\ndeclare function sanitizeNameSegment(value: string): string;\ndeclare function buildNamespacedToolName(server: string, tool: string): string;\n/**\n * Disambiguate a candidate name against an existing set by appending `-2`, `-3`, etc.\n * Mutates nothing; returns the chosen name. Caller is responsible for inserting it\n * into the set.\n */\ndeclare function disambiguateAgainst(candidate: string, taken: ReadonlySet<string>): string;\n//# sourceMappingURL=tool-naming.d.ts.map\n\n//#endregion\nexport { type BundlerOptions, Connection, type ConnectionDeps, type Logger, McpBundler, type McpClientHandle, type McpServerConfig, type McpToolCallResult, type McpToolDescriptor, type McpTransportKind, type ReconcileDiff, type RemoteServerConfig, STDIO_ENV_DENYLIST, type StdioServerConfig, buildNamespacedToolName, defaultConnect, disambi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