@jini-ai/mcp 0.3.0 → 0.3.1
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/bin/serve.d.ts.map +1 -1
- package/dist/bin/serve.js +17 -10
- package/dist/bin/serve.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/server/tools/delegated-tool.d.ts +33 -0
- package/dist/server/tools/delegated-tool.d.ts.map +1 -1
- package/dist/server/tools/delegated-tool.js +84 -11
- package/dist/server/tools/delegated-tool.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/serve.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../src/bin/serve.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,gBAAgB,IAAI,uBAAuB,EAAgC,MAAM,cAAc,CAAC;AACzG,OAAO,EAAE,mBAAmB,IAAI,0BAA0B,EAA6B,MAAM,0BAA0B,CAAC;AAQxH,0HAA0H;AAC1H,eAAO,MAAM,cAAc,gBAAgB,CAAC;AAC5C,+JAA+J;AAC/J,eAAO,MAAM,kBAAkB,oBAAoB,CAAC;AACpD;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,sBAAsB,CAAC;AACxD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,8BAA8B,mCAAmC,CAAC;AAS/E,MAAM,WAAW,SAAS;IACxB,2BAA2B;IAC3B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACjC,oCAAoC;IACpC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IA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S;IACxB,2BAA2B;IAC3B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACjC,oCAAoC;IACpC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,gEAAgE;IAChE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC;IACxC,sDAAsD;IACtD,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,uBAAuB,CAAC;IAC3D,4CAA4C;IAC5C,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,0BAA0B,CAAC;IACjE,wGAAwG;IACxG,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,MAAM,CAAC;IAC1C,wEAAwE;IACxE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IAClC,6BAA6B;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC;IAC1B,8BAA8B;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC;CAC5B;AAMD;;;;;;;GAOG;AACH,wBAAsB,KAAK,CAAC,IAAI,GAAE,SAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAqE/D"}
|
package/dist/bin/serve.js
CHANGED
|
@@ -5,7 +5,7 @@ import { createMcpToolServer as createMcpToolServerDefault } from '../server/too
|
|
|
5
5
|
import { RUN_TOOLS } from '../server/tools/run-tools.js';
|
|
6
6
|
import { TOOL_CATALOG_TOOLS } from '../server/tools/tool-catalog-tools.js';
|
|
7
7
|
import { COMPONENT_CATALOG_TOOLS } from '../server/tools/component-catalog-tools.js';
|
|
8
|
-
import { createExecuteDelegatedToolTool } from '../server/tools/delegated-tool.js';
|
|
8
|
+
import { createExecuteDelegatedToolTool, createExecuteReadonlyDelegatedToolTool } from '../server/tools/delegated-tool.js';
|
|
9
9
|
import { KERNEL_RESOURCES } from '../server/resources/active-resource.js';
|
|
10
10
|
/** The one run this process is scoped to for its entire lifetime. Set by the spawning daemon, never by the MCP client. */
|
|
11
11
|
export const RUN_ID_ENV_VAR = 'JINI_RUN_ID';
|
|
@@ -67,19 +67,26 @@ export async function serve(deps = {}) {
|
|
|
67
67
|
const options = { flagUrl: null, env, envVarName: DAEMON_URL_ENV_VAR, warn: writeErr };
|
|
68
68
|
return resolveDaemonUrlFn(options);
|
|
69
69
|
};
|
|
70
|
+
// Shared by both gateways so their run scope, correlation-id source, and deadline cannot diverge
|
|
71
|
+
// — the only difference between the two defs is the read-only constraint each declares.
|
|
72
|
+
const delegatedGatewayOptions = {
|
|
73
|
+
runId,
|
|
74
|
+
...(deps.generateToolUseId !== undefined ? { generateToolUseId: deps.generateToolUseId } : {}),
|
|
75
|
+
// Parsed, not validated: `createExecuteDelegatedToolTool` already rejects a non-finite or
|
|
76
|
+
// non-positive value back to the default, so `NaN` from a malformed env var lands there too.
|
|
77
|
+
...(env[DELEGATED_TOOL_TIMEOUT_ENV_VAR] !== undefined
|
|
78
|
+
? { delegatedToolTimeoutMs: Number(env[DELEGATED_TOOL_TIMEOUT_ENV_VAR]) }
|
|
79
|
+
: {}),
|
|
80
|
+
};
|
|
70
81
|
const tools = [
|
|
71
82
|
...RUN_TOOLS,
|
|
72
83
|
...TOOL_CATALOG_TOOLS,
|
|
73
84
|
...COMPONENT_CATALOG_TOOLS,
|
|
74
|
-
createExecuteDelegatedToolTool(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
...(env[DELEGATED_TOOL_TIMEOUT_ENV_VAR] !== undefined
|
|
80
|
-
? { delegatedToolTimeoutMs: Number(env[DELEGATED_TOOL_TIMEOUT_ENV_VAR]) }
|
|
81
|
-
: {}),
|
|
82
|
-
}),
|
|
85
|
+
createExecuteDelegatedToolTool(delegatedGatewayOptions),
|
|
86
|
+
// Hosted ALONGSIDE the unconstrained gateway, never instead of it. A client that gates on
|
|
87
|
+
// `readOnlyHint: true` can now reach the read half of the catalog at all; every other client
|
|
88
|
+
// sees both and picks by what its call actually does.
|
|
89
|
+
createExecuteReadonlyDelegatedToolTool(delegatedGatewayOptions),
|
|
83
90
|
];
|
|
84
91
|
// Absent credential => no `authHeaders` at all => byte-identical request headers to before this
|
|
85
92
|
// env var existed. See DAEMON_TOKEN_ENV_VAR's doc for why an unset value is not a startup failure.
|
package/dist/bin/serve.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/bin/serve.ts"],"names":[],"mappings":";AAuCA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,gBAAgB,IAAI,uBAAuB,EAAgC,MAAM,cAAc,CAAC;AACzG,OAAO,EAAE,mBAAmB,IAAI,0BAA0B,EAA6B,MAAM,0BAA0B,CAAC;AAExH,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AACrF,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/bin/serve.ts"],"names":[],"mappings":";AAuCA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,gBAAgB,IAAI,uBAAuB,EAAgC,MAAM,cAAc,CAAC;AACzG,OAAO,EAAE,mBAAmB,IAAI,0BAA0B,EAA6B,MAAM,0BAA0B,CAAC;AAExH,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AACrF,OAAO,EAAE,8BAA8B,EAAE,sCAAsC,EAAE,MAA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C,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACzG,IAAI,YAAY,EAAE,CAAC;IACjB,MAAM,KAAK,EAAE,CAAC;AAChB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export { activeContextResource, buildResourceIndex, handleResourceRead, KERNEL_R
|
|
|
23
23
|
export type { McpResourceDef, McpResourceReadResult } from './server/index.js';
|
|
24
24
|
export { searchToolsTool, describeToolTool, TOOL_CATALOG_TOOLS } from './server/index.js';
|
|
25
25
|
export { searchComponentsTool, describeComponentTool, COMPONENT_CATALOG_TOOLS } from './server/index.js';
|
|
26
|
-
export { createExecuteDelegatedToolTool, DEFAULT_DELEGATED_TOOL_TIMEOUT_MS } from './server/index.js';
|
|
26
|
+
export { createExecuteDelegatedToolTool, createExecuteReadonlyDelegatedToolTool, DEFAULT_DELEGATED_TOOL_TIMEOUT_MS, } from './server/index.js';
|
|
27
27
|
export type { CreateExecuteDelegatedToolToolOptions } from './server/index.js';
|
|
28
28
|
export { AGENT_SLUGS, isAgentSlug, planAgentInstall, applyJsonInstall, removeJsonInstall, } from './agent-install/index.js';
|
|
29
29
|
export type { AgentSlug, McpLaunchSpec, PlanContext, CliInstallPlan, JsonInstallPlan, ManualInstallPlan, InstallPlan, } from './agent-install/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,YAAY,EACZ,WAAW,EACX,eAAe,EACf,SAAS,EACT,YAAY,EACZ,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC;AAGzB,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-27,7 +27,7 @@ export { searchToolsTool, describeToolTool, TOOL_CATALOG_TOOLS } from './server/
|
|
|
27
27
|
// ── server: the component-catalog discovery defs (search_components / describe_component) ──
|
|
28
28
|
export { searchComponentsTool, describeComponentTool, COMPONENT_CATALOG_TOOLS } from './server/index.js';
|
|
29
29
|
// ── server: gap 3's MCP-callback delegated-tool-execution def ──────────────
|
|
30
|
-
export { createExecuteDelegatedToolTool, DEFAULT_DELEGATED_TOOL_TIMEOUT_MS } from './server/index.js';
|
|
30
|
+
export { createExecuteDelegatedToolTool, createExecuteReadonlyDelegatedToolTool, DEFAULT_DELEGATED_TOOL_TIMEOUT_MS, } from './server/index.js';
|
|
31
31
|
// ── agent-install: register an MCP server into external agents ──────────────
|
|
32
32
|
export { AGENT_SLUGS, isAgentSlug, planAgentInstall, applyJsonInstall, removeJsonInstall, } from './agent-install/index.js';
|
|
33
33
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,+EAA+E;AAC/E,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC;AAUzB,+EAA+E;AAC/E,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,EACb,yBAAyB,EACzB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,GACV,MAAM,iBAAiB,CAAC;AAczB,+EAA+E;AAC/E,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,aAAa,EACb,cAAc,GACf,MAAM,iBAAiB,CAAC;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MAAM,iBAAiB,CAAC;AAczB,+EAA+E;AAC/E,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,aAAa,EACb,cAAc,GACf,MAAM,iBAAiB,CAAC;AAGzB,+EAA+E;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,+EAA+E;AAC/E,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,+EAA+E;AAC/E,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,oBAAoB,EACpB,aAAa,EACb,UAAU,EACV,cAAc,EACd,QAAQ,EACR,cAAc,EACd,aAAa,EACb,SAAS,EACT,YAAY,EACZ,WAAW,EACX,cAAc,EACd,cAAc,EACd,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC;AAW3B,8EAA8E;AAC9E,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAG3B,+EAA+E;AAC/E,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE1F,8FAA8F;AAC9F,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAEzG,8EAA8E;AAC9E,OAAO,EACL,8BAA8B,EAC9B,sCAAsC,EACtC,iCAAiC,GAClC,MAAM,mBAAmB,CAAC;AAG3B,+EAA+E;AAC/E,OAAO,EACL,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC"}
|
|
@@ -49,6 +49,39 @@ export interface CreateExecuteDelegatedToolToolOptions {
|
|
|
49
49
|
* process (one per spawned `claude` run, see `../../bin/serve.js`) calls this once at startup;
|
|
50
50
|
* every `tools/call` for the returned def's `name` during that process's lifetime executes
|
|
51
51
|
* against the same run.
|
|
52
|
+
*
|
|
53
|
+
* Declares `readOnlyHint: false`, which is the truth about a gateway that reaches the entire
|
|
54
|
+
* registry — reads and writes alike. See {@link createExecuteReadonlyDelegatedToolTool} for what
|
|
55
|
+
* that costs under a host that gates on the annotation, and for the companion that answers it.
|
|
52
56
|
*/
|
|
53
57
|
export declare function createExecuteDelegatedToolTool(options: CreateExecuteDelegatedToolToolOptions): McpToolDef;
|
|
58
|
+
/**
|
|
59
|
+
* Builds the `execute_readonly_delegated_tool` companion for one specific `runId` — the same
|
|
60
|
+
* gateway, narrowed to tools whose registration declares them read-only, and annotated
|
|
61
|
+
* `readOnlyHint: true`.
|
|
62
|
+
*
|
|
63
|
+
* WHY IT EXISTS. `execute_delegated_tool` is the sole route from an externally-injected MCP client
|
|
64
|
+
* into this host's entire native tool catalog, and it correctly annotates itself
|
|
65
|
+
* `readOnlyHint: false`. A runtime that auto-denies any MCP tool lacking `readOnlyHint: true`
|
|
66
|
+
* (headless `codex exec`, observed) therefore kills 100% of delegated calls — reads included —
|
|
67
|
+
* before they leave the client process. Nothing reaches the daemon, so no execution row is written
|
|
68
|
+
* and no error surfaces; the model, given no grounding signal at all, narrates a tool call that
|
|
69
|
+
* never happened. Meanwhile `search_tools`/`describe_tool` work, so discovery succeeds and only
|
|
70
|
+
* execution silently dies, which is the worst possible shape for the failure.
|
|
71
|
+
*
|
|
72
|
+
* WHY IT ENFORCES RATHER THAN ASSERTS. MCP annotations are static per tool declaration — the
|
|
73
|
+
* protocol has no way to vary one per call — so a read-only surface can only be a SECOND
|
|
74
|
+
* declaration, never a mode of the first. And a tool that declared `readOnlyHint: true` while
|
|
75
|
+
* still reaching writes would be worse than the bug it fixes: it would launder a write past a
|
|
76
|
+
* caller's own safety gate, and that caller has no way to audit the claim. The check is therefore
|
|
77
|
+
* made where it can be a fact rather than a claim — the daemon, via
|
|
78
|
+
* `@jini-ai/http-kit`'s `requireReadOnly`, resolving the id against the live `ToolRegistry` and
|
|
79
|
+
* `@jini-ai/core`'s `isReadOnlyTool`. Refusal is deny-by-default: an id that is unregistered, or
|
|
80
|
+
* registered without a read-only classification, is refused with a message naming the tool and
|
|
81
|
+
* pointing at `execute_delegated_tool`.
|
|
82
|
+
*
|
|
83
|
+
* Flipping the existing tool's annotation instead was rejected for the same reason: it would lie to
|
|
84
|
+
* every caller, including the ones the annotation exists to protect.
|
|
85
|
+
*/
|
|
86
|
+
export declare function createExecuteReadonlyDelegatedToolTool(options: CreateExecuteDelegatedToolToolOptions): McpToolDef;
|
|
54
87
|
//# sourceMappingURL=delegated-tool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegated-tool.d.ts","sourceRoot":"","sources":["../../../src/server/tools/delegated-tool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"delegated-tool.d.ts","sourceRoot":"","sources":["../../../src/server/tools/delegated-tool.ts"],"names":[],"mappings":"AAqCA,OAAO,EAAoC,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAmCxF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,iCAAiC,QAAgB,CAAC;AAE/D,MAAM,WAAW,qCAAqC;IACpD,6FAA6F;IAC7F,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,yEAAyE;IACzE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,MAAM,CAAC;IAC1C;;;;;;;;;OASG;IACH,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAC;CAC1C;AA6FD;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,qCAAqC,GAAG,UAAU,CAYzG;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,sCAAsC,CAAC,OAAO,EAAE,qCAAqC,GAAG,UAAU,CAgBjH"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module @jini-ai/mcp/server/tools/delegated-tool
|
|
3
3
|
*
|
|
4
|
-
* `execute_delegated_tool`
|
|
4
|
+
* `execute_delegated_tool` and its read-only companion `execute_readonly_delegated_tool` — the
|
|
5
|
+
* MCP-callback half of gap 3's continuation transport (see
|
|
5
6
|
* `packages/daemon/source-map.md`'s "run/chat orchestration gap 3, part 1" addition and this
|
|
6
7
|
* package's own dated section in `source-map.md` for the rest of the spike). The swarm-consensus
|
|
7
8
|
* Final Recommendation asked for exactly this: "inject the already-shipped MCP host into one
|
|
@@ -23,6 +24,14 @@
|
|
|
23
24
|
* confused-deputy path (one run's MCP subprocess executing a tool call "as" a different run).
|
|
24
25
|
* `toolUseId` is likewise generated per call (`randomUUID` by default), not model-supplied — a
|
|
25
26
|
* model has no legitimate reason to choose its own correlation id either.
|
|
27
|
+
*
|
|
28
|
+
* TWO defs, ONE code path. `createDelegatedGateway` builds both; the factories differ only in the
|
|
29
|
+
* name/title/description they present and in whether the request carries `requireReadOnly: true`.
|
|
30
|
+
* The read-only companion exists because MCP annotations are static per tool declaration — a
|
|
31
|
+
* surface that promises "this only reads" can only be a second declaration, never a per-call mode —
|
|
32
|
+
* and it ENFORCES that promise daemon-side rather than asserting it, because a `readOnlyHint: true`
|
|
33
|
+
* tool that could still reach writes would launder a write past its caller's own safety gate. See
|
|
34
|
+
* {@link createExecuteReadonlyDelegatedToolTool} for the failure that motivated it.
|
|
26
35
|
*/
|
|
27
36
|
import { randomUUID } from 'node:crypto';
|
|
28
37
|
import { postDaemonJson } from '../daemon-client.js';
|
|
@@ -84,12 +93,15 @@ function unwrapMcpContentEnvelope(result) {
|
|
|
84
93
|
*/
|
|
85
94
|
export const DEFAULT_DELEGATED_TOOL_TIMEOUT_MS = 6 * 60 * 1000;
|
|
86
95
|
/**
|
|
87
|
-
* Builds
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
96
|
+
* Builds one gateway def. Both exported factories call this; there is no second copy of the
|
|
97
|
+
* request body, the timeout rule, or the unwrap.
|
|
98
|
+
*
|
|
99
|
+
* @param variant - The presentation/constraint half (see {@link DelegatedGatewayVariant}).
|
|
100
|
+
* @param options - The per-process run scope and its optional overrides.
|
|
101
|
+
* @returns The `McpToolDef` to host.
|
|
102
|
+
* @complexity O(1) at construction; each call is one HTTP round trip.
|
|
91
103
|
*/
|
|
92
|
-
|
|
104
|
+
function createDelegatedGateway(variant, options) {
|
|
93
105
|
const { runId } = options;
|
|
94
106
|
const generateToolUseId = options.generateToolUseId ?? randomUUID;
|
|
95
107
|
const requested = options.delegatedToolTimeoutMs;
|
|
@@ -97,8 +109,8 @@ export function createExecuteDelegatedToolTool(options) {
|
|
|
97
109
|
? requested
|
|
98
110
|
: DEFAULT_DELEGATED_TOOL_TIMEOUT_MS;
|
|
99
111
|
return {
|
|
100
|
-
name:
|
|
101
|
-
description:
|
|
112
|
+
name: variant.name,
|
|
113
|
+
description: variant.description,
|
|
102
114
|
inputSchema: {
|
|
103
115
|
type: 'object',
|
|
104
116
|
properties: {
|
|
@@ -126,11 +138,11 @@ export function createExecuteDelegatedToolTool(options) {
|
|
|
126
138
|
additionalProperties: false,
|
|
127
139
|
},
|
|
128
140
|
annotations: {
|
|
129
|
-
readOnlyHint:
|
|
130
|
-
idempotentHint:
|
|
141
|
+
readOnlyHint: variant.readOnlyHint,
|
|
142
|
+
idempotentHint: variant.idempotentHint,
|
|
131
143
|
destructiveHint: false,
|
|
132
144
|
openWorldHint: false,
|
|
133
|
-
title:
|
|
145
|
+
title: variant.title,
|
|
134
146
|
},
|
|
135
147
|
handler: async (args, ctx) => {
|
|
136
148
|
requireString(args.toolId, 'toolId');
|
|
@@ -139,6 +151,7 @@ export function createExecuteDelegatedToolTool(options) {
|
|
|
139
151
|
toolUseId: generateToolUseId(),
|
|
140
152
|
toolId: args.toolId,
|
|
141
153
|
input: args.input,
|
|
154
|
+
...(variant.requireReadOnly === undefined ? {} : { requireReadOnly: variant.requireReadOnly }),
|
|
142
155
|
};
|
|
143
156
|
const data = await postDaemonJson(ctx.baseUrl, '/api/delegated-tool-calls', body, {
|
|
144
157
|
...daemonCallOptions(ctx),
|
|
@@ -148,4 +161,64 @@ export function createExecuteDelegatedToolTool(options) {
|
|
|
148
161
|
},
|
|
149
162
|
};
|
|
150
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Builds the `execute_delegated_tool` tool def for one specific `runId`. A fresh MCP server
|
|
166
|
+
* process (one per spawned `claude` run, see `../../bin/serve.js`) calls this once at startup;
|
|
167
|
+
* every `tools/call` for the returned def's `name` during that process's lifetime executes
|
|
168
|
+
* against the same run.
|
|
169
|
+
*
|
|
170
|
+
* Declares `readOnlyHint: false`, which is the truth about a gateway that reaches the entire
|
|
171
|
+
* registry — reads and writes alike. See {@link createExecuteReadonlyDelegatedToolTool} for what
|
|
172
|
+
* that costs under a host that gates on the annotation, and for the companion that answers it.
|
|
173
|
+
*/
|
|
174
|
+
export function createExecuteDelegatedToolTool(options) {
|
|
175
|
+
return createDelegatedGateway({
|
|
176
|
+
name: 'execute_delegated_tool',
|
|
177
|
+
title: 'Execute a Jini-registered tool',
|
|
178
|
+
description: 'Execute a Jini-registered tool (never an agent-vendor-specific tool name) against the current run, routed through the daemon\'s ToolExecutor deny-by-default gate — the same authorization/confirmation/audit path every other tool-execution mechanism in this host uses. On a completed outcome, returns {result} normally. Any other outcome surfaces as an HTTP error the caller must catch, not a status field in a 200 body: denied/confirmation-denied raise a 403 TOOL_OPERATION_DENIED; timed-out/cancelled/failed raise a 500 INTERNAL_ERROR.',
|
|
179
|
+
readOnlyHint: false,
|
|
180
|
+
idempotentHint: false,
|
|
181
|
+
}, options);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Builds the `execute_readonly_delegated_tool` companion for one specific `runId` — the same
|
|
185
|
+
* gateway, narrowed to tools whose registration declares them read-only, and annotated
|
|
186
|
+
* `readOnlyHint: true`.
|
|
187
|
+
*
|
|
188
|
+
* WHY IT EXISTS. `execute_delegated_tool` is the sole route from an externally-injected MCP client
|
|
189
|
+
* into this host's entire native tool catalog, and it correctly annotates itself
|
|
190
|
+
* `readOnlyHint: false`. A runtime that auto-denies any MCP tool lacking `readOnlyHint: true`
|
|
191
|
+
* (headless `codex exec`, observed) therefore kills 100% of delegated calls — reads included —
|
|
192
|
+
* before they leave the client process. Nothing reaches the daemon, so no execution row is written
|
|
193
|
+
* and no error surfaces; the model, given no grounding signal at all, narrates a tool call that
|
|
194
|
+
* never happened. Meanwhile `search_tools`/`describe_tool` work, so discovery succeeds and only
|
|
195
|
+
* execution silently dies, which is the worst possible shape for the failure.
|
|
196
|
+
*
|
|
197
|
+
* WHY IT ENFORCES RATHER THAN ASSERTS. MCP annotations are static per tool declaration — the
|
|
198
|
+
* protocol has no way to vary one per call — so a read-only surface can only be a SECOND
|
|
199
|
+
* declaration, never a mode of the first. And a tool that declared `readOnlyHint: true` while
|
|
200
|
+
* still reaching writes would be worse than the bug it fixes: it would launder a write past a
|
|
201
|
+
* caller's own safety gate, and that caller has no way to audit the claim. The check is therefore
|
|
202
|
+
* made where it can be a fact rather than a claim — the daemon, via
|
|
203
|
+
* `@jini-ai/http-kit`'s `requireReadOnly`, resolving the id against the live `ToolRegistry` and
|
|
204
|
+
* `@jini-ai/core`'s `isReadOnlyTool`. Refusal is deny-by-default: an id that is unregistered, or
|
|
205
|
+
* registered without a read-only classification, is refused with a message naming the tool and
|
|
206
|
+
* pointing at `execute_delegated_tool`.
|
|
207
|
+
*
|
|
208
|
+
* Flipping the existing tool's annotation instead was rejected for the same reason: it would lie to
|
|
209
|
+
* every caller, including the ones the annotation exists to protect.
|
|
210
|
+
*/
|
|
211
|
+
export function createExecuteReadonlyDelegatedToolTool(options) {
|
|
212
|
+
return createDelegatedGateway({
|
|
213
|
+
name: 'execute_readonly_delegated_tool',
|
|
214
|
+
title: 'Execute a read-only Jini-registered tool',
|
|
215
|
+
description: 'Execute a READ-ONLY Jini-registered tool (never an agent-vendor-specific tool name) against the current run. Identical to execute_delegated_tool — same ToolExecutor deny-by-default authorization/confirmation/audit path, same {result} envelope, same errors — except that the daemon first checks the requested toolId against the live registry and refuses anything not registered as read-only, with a 403 TOOL_OPERATION_DENIED naming the tool. Use this for any tool that only reads. For a tool that creates, updates, deletes, publishes, or mints anything, call execute_delegated_tool instead; this one will refuse it.',
|
|
216
|
+
readOnlyHint: true,
|
|
217
|
+
// A read-only call has no state to advance, so repeating it is the same call. Matches
|
|
218
|
+
// `tool-catalog-tools.ts`'s and `run-tools.ts`'s own read annotations rather than inventing a
|
|
219
|
+
// third convention for the same claim.
|
|
220
|
+
idempotentHint: true,
|
|
221
|
+
requireReadOnly: true,
|
|
222
|
+
}, options);
|
|
223
|
+
}
|
|
151
224
|
//# sourceMappingURL=delegated-tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegated-tool.js","sourceRoot":"","sources":["../../../src/server/tools/delegated-tool.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"delegated-tool.js","sourceRoot":"","sources":["../../../src/server/tools/delegated-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAmB,MAAM,qBAAqB,CAAC;AAOxF,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAS,wBAAwB,CAAC,MAAe;IAC/C,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,K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