@jini-ai/mcp 0.7.1 → 0.7.3-next.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.
Files changed (142) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/agent-install/antigravity/install.d.ts +15 -0
  3. package/dist/agent-install/antigravity/install.js +15 -0
  4. package/dist/agent-install/claude/install.d.ts +4 -0
  5. package/dist/agent-install/claude/install.js +11 -0
  6. package/dist/agent-install/cline/install.d.ts +4 -0
  7. package/dist/agent-install/cline/install.js +7 -0
  8. package/dist/agent-install/codex/install.d.ts +4 -0
  9. package/dist/agent-install/codex/install.js +10 -0
  10. package/dist/agent-install/cursor/install.d.ts +4 -0
  11. package/dist/agent-install/cursor/install.js +4 -0
  12. package/dist/agent-install/hermes/install.d.ts +4 -0
  13. package/dist/agent-install/hermes/install.js +26 -0
  14. package/dist/agent-install/index.d.ts +1 -1
  15. package/dist/agent-install/install.d.ts +1 -11
  16. package/dist/agent-install/install.js +29 -167
  17. package/dist/agent-install/kimi/install.d.ts +4 -0
  18. package/dist/agent-install/kimi/install.js +10 -0
  19. package/dist/agent-install/openclaw/install.d.ts +4 -0
  20. package/dist/agent-install/openclaw/install.js +4 -0
  21. package/dist/agent-install/opencode/install.d.ts +4 -0
  22. package/dist/agent-install/opencode/install.js +7 -0
  23. package/dist/agent-install/owned-json-install.d.ts +7 -0
  24. package/dist/agent-install/owned-json-install.js +4 -4
  25. package/dist/agent-install/pi/install.d.ts +4 -0
  26. package/dist/agent-install/pi/install.js +13 -0
  27. package/dist/agent-install/planner-shared.d.ts +40 -0
  28. package/dist/agent-install/planner-shared.js +52 -0
  29. package/dist/agent-install/trae/install.d.ts +4 -0
  30. package/dist/agent-install/trae/install.js +7 -0
  31. package/dist/agent-install/vibe/install.d.ts +4 -0
  32. package/dist/agent-install/vibe/install.js +30 -0
  33. package/dist/bin/serve.js +5 -3
  34. package/dist/client/client.js +11 -7
  35. package/dist/core/claude/config.d.ts +21 -0
  36. package/dist/core/claude/config.js +29 -0
  37. package/dist/core/config-shared.d.ts +27 -0
  38. package/dist/core/config-shared.js +64 -0
  39. package/dist/core/config.d.ts +60 -81
  40. package/dist/core/config.js +33 -192
  41. package/dist/core/opencode/config.d.ts +39 -0
  42. package/dist/core/opencode/config.js +74 -0
  43. package/dist/core/tokens.d.ts +38 -25
  44. package/dist/core/tokens.js +23 -54
  45. package/dist/federation/adapter.http.d.ts +8 -5
  46. package/dist/federation/adapter.http.js +12 -8
  47. package/dist/federation/admissions.d.ts +36 -0
  48. package/dist/federation/admissions.js +34 -0
  49. package/dist/federation/approvals/call-confirmation.js +2 -2
  50. package/dist/federation/approvals/remembered-approval.d.ts +11 -2
  51. package/dist/federation/approvals/remembered-approval.js +11 -8
  52. package/dist/federation/approvals/revocation-reason.d.ts +3 -1
  53. package/dist/federation/approvals/revocation-reason.js +1 -1
  54. package/dist/federation/approvals/revocation.js +3 -3
  55. package/dist/federation/approvals/scope-option.d.ts +3 -1
  56. package/dist/federation/approvals/scope-option.js +1 -1
  57. package/dist/federation/bootstrap.d.ts +1 -1
  58. package/dist/federation/bootstrap.js +4 -5
  59. package/dist/federation/config.d.ts +1 -1
  60. package/dist/federation/hosted/access.d.ts +53 -1
  61. package/dist/federation/hosted/access.js +94 -0
  62. package/dist/federation/hosted/connection-gate.js +1 -1
  63. package/dist/federation/hosted/index.d.ts +11 -3
  64. package/dist/federation/hosted/index.js +9 -3
  65. package/dist/federation/hosted/pinned-capability.d.ts +91 -0
  66. package/dist/federation/hosted/pinned-capability.js +73 -0
  67. package/dist/federation/hosted/probe.d.ts +67 -0
  68. package/dist/federation/hosted/probe.js +99 -0
  69. package/dist/federation/hosted/revocation.d.ts +5 -2
  70. package/dist/federation/hosted/revocation.js +1 -1
  71. package/dist/federation/hosted/store-config.d.ts +43 -0
  72. package/dist/federation/hosted/store-config.js +209 -0
  73. package/dist/federation/hosted/store-credentials.d.ts +74 -0
  74. package/dist/federation/hosted/store-credentials.js +228 -0
  75. package/dist/federation/hosted/store-input.d.ts +55 -0
  76. package/dist/federation/hosted/store-input.js +232 -0
  77. package/dist/federation/hosted/store-oauth-fields.d.ts +26 -0
  78. package/dist/federation/hosted/store-oauth-fields.js +246 -0
  79. package/dist/federation/hosted/store-view.d.ts +49 -0
  80. package/dist/federation/hosted/store-view.js +112 -0
  81. package/dist/federation/hosted/store.d.ts +13 -180
  82. package/dist/federation/hosted/store.js +33 -1252
  83. package/dist/federation/hosted/store.memory.d.ts +26 -1
  84. package/dist/federation/hosted/store.memory.js +71 -22
  85. package/dist/federation/hosted/store.save.d.ts +39 -0
  86. package/dist/federation/hosted/store.save.js +63 -0
  87. package/dist/federation/hosted/vault.d.ts +79 -1
  88. package/dist/federation/hosted/vault.js +107 -0
  89. package/dist/federation/hosted/vocabulary.d.ts +1 -1
  90. package/dist/federation/hosted/vocabulary.js +1 -1
  91. package/dist/federation/index.d.ts +1 -0
  92. package/dist/federation/index.js +1 -0
  93. package/dist/federation/mcp-protocol.d.ts +1 -1
  94. package/dist/federation/mcp-protocol.js +1 -1
  95. package/dist/federation/ports.d.ts +2 -2
  96. package/dist/federation/refusal-notice.d.ts +1 -1
  97. package/dist/federation/refusal-notice.js +1 -1
  98. package/dist/federation/registrations.d.ts +6 -6
  99. package/dist/federation/registrations.js +1 -1
  100. package/dist/federation/reload.js +37 -36
  101. package/dist/federation/stdio/adapter.stdio.js +27 -20
  102. package/dist/federation/stdio/default-connect.d.ts +2 -5
  103. package/dist/federation/stdio/default-connect.js +2 -1
  104. package/dist/federation/stdio/index.d.ts +1 -0
  105. package/dist/federation/stdio/index.js +1 -0
  106. package/dist/federation/stdio/smoke.d.ts +62 -0
  107. package/dist/federation/stdio/smoke.js +156 -0
  108. package/dist/federation/trust.d.ts +2 -2
  109. package/dist/federation/trust.js +4 -4
  110. package/dist/index.d.ts +3 -4
  111. package/dist/index.js +1 -1
  112. package/dist/server/adapters/sdk-server.d.ts +88 -0
  113. package/dist/server/adapters/sdk-server.js +27 -0
  114. package/dist/server/{sdk-transport.d.ts → adapters/sdk-transport.d.ts} +3 -3
  115. package/dist/server/{sdk-transport.js → adapters/sdk-transport.js} +2 -2
  116. package/dist/server/adapters/sdk-wire.d.ts +16 -0
  117. package/dist/server/adapters/sdk-wire.js +16 -0
  118. package/dist/server/call-progress.d.ts +48 -0
  119. package/dist/server/call-progress.js +60 -0
  120. package/dist/server/http-tool-server.adapter.js +209 -196
  121. package/dist/server/index.d.ts +1 -0
  122. package/dist/server/loopback-fetch.d.ts +5 -0
  123. package/dist/server/loopback-fetch.js +48 -0
  124. package/dist/server/resource-protocol.d.ts +1 -1
  125. package/dist/server/run-tool-host.js +3 -1
  126. package/dist/server/stdio-hosting.d.ts +8 -12
  127. package/dist/server/stdio-hosting.js +135 -126
  128. package/dist/server/tool-arguments.d.ts +9 -1
  129. package/dist/server/tool-arguments.js +18 -4
  130. package/dist/server/tool-protocol.d.ts +15 -3
  131. package/dist/server/tool-protocol.js +18 -21
  132. package/dist/server/tool-result-pages.js +37 -28
  133. package/dist/server/tool-server.d.ts +8 -46
  134. package/dist/server/tool-server.js +138 -128
  135. package/dist/server/tools/component-catalog-tools.d.ts +2 -2
  136. package/dist/server/tools/component-catalog-tools.js +2 -2
  137. package/dist/server/tools/delegated-tool.js +74 -57
  138. package/dist/server/tools/run-tools.d.ts +5 -5
  139. package/dist/server/tools/run-tools.js +5 -5
  140. package/dist/server/tools/tool-catalog-tools.d.ts +2 -2
  141. package/dist/server/tools/tool-catalog-tools.js +35 -12
  142. package/package.json +8 -9
@@ -3,13 +3,13 @@
3
3
  *
4
4
  * `execute_delegated_tool` and its read-only companion `execute_readonly_delegated_tool` — the
5
5
  * MCP-callback half of gap 3's continuation transport (see
6
- * `packages/daemon/archived provenance ledger`'s "run/chat orchestration gap 3, part 1" addition and this
6
+ * `070311a07^:packages/daemon/source-map.md`'s "run/chat orchestration gap 3, part 1" addition and this
7
7
  * package's own dated section in `archived provenance ledger` for the rest of the spike). The swarm-consensus
8
8
  * Final Recommendation asked for exactly this: "inject the already-shipped MCP host into one
9
9
  * MCP-capable CLI's launch config, prove a tool round-trip through the existing
10
10
  * `delegated-tool-bridge.ts`." Where `../tools/run-tools.js`'s tools proxy generic
11
11
  * run-lifecycle HTTP endpoints, this tool proxies the new `POST /api/delegated-tool-calls`
12
- * daemon route (`packages/http/src/delegated-tools.ts`), which is the one and only thing that
12
+ * daemon route (`packages/daemon/src/http/delegated-tools.ts`), which is the one and only thing that
13
13
  * calls into `createDelegatedToolBridge` (`packages/daemon/src/delegated-tool-bridge.ts`) — the
14
14
  * same `ToolExecutor` deny-by-default gate every other tool-execution path in this codebase
15
15
  * already uses. No parallel authorization mechanism is introduced anywhere on this path.
@@ -126,32 +126,7 @@ function createDelegatedGateway(variant, { runId }, options) {
126
126
  name: variant.name,
127
127
  description: `${variant.description} MCP-local tool names advertised here are also accepted through their existing handlers. ${APPROVAL_GUIDANCE} Put the tool's own arguments inside input; non-conflicting top-level tool arguments are moved there automatically.`,
128
128
  argumentNormalization: { foldIntoInput: true },
129
- inputSchema: {
130
- type: 'object',
131
- properties: {
132
- toolId: {
133
- type: 'string',
134
- description: 'Jini registry tool id to invoke. Required.',
135
- },
136
- input: {
137
- // `type` is load-bearing, not decoration. Declared without one, an MCP client has no
138
- // signal that this property carries structured data, and at least one real client
139
- // (Claude Code, observed 2026-07-26) then delivers the model's object as a raw JSON
140
- // *string* — which every Jini tool rejects, because a tool's input is a record or
141
- // absent (`@jini-ai/daemon`'s `toCapabilityInput` refuses a string by name rather than
142
- // coercing it). The effect was that only no-input tools were callable at all.
143
- //
144
- // Object-only is narrower than "arbitrary JSON" and deliberately so: it is exactly
145
- // what every registered tool accepts today, it matches MCP's own convention that tool
146
- // arguments are objects, and widening it later (a union type, say) is additive.
147
- type: 'object',
148
- additionalProperties: true,
149
- description: 'JSON object of input fields for the tool. Optional; omit for a tool that takes no input. Must be an object, not a JSON-encoded string.',
150
- },
151
- },
152
- required: ['toolId'],
153
- additionalProperties: false,
154
- },
129
+ inputSchema: delegatedGatewayInputSchema(),
155
130
  annotations: {
156
131
  readOnlyHint: variant.readOnlyHint,
157
132
  idempotentHint: variant.idempotentHint,
@@ -159,35 +134,67 @@ function createDelegatedGateway(variant, { runId }, options) {
159
134
  openWorldHint: false,
160
135
  title: variant.title,
161
136
  },
162
- handler: async ({ args, ctx }) => {
163
- const toolId = requireString({ value: args.toolId, name: 'toolId' });
164
- // Local tools are advertised by this MCP host, not registered in the daemon catalog.
165
- // Use their existing handler/validator instead of inventing a second implementation there.
166
- const local = await ctx.callLocalTool?.({ name: toolId, input: (args.input ?? {}),
167
- requireReadOnly: variant.requireReadOnly === true }, {});
168
- if (local !== undefined)
169
- return local;
170
- const toolUseId = generateToolUseId({});
171
- const body = {
172
- runId,
173
- toolUseId,
174
- toolId: resolveMcpToolName({ name: toolId }, { isRegistered: candidate => ctx.diagnosticToolIds?.includes(candidate) ?? false }),
175
- // The schema tells the model to omit `input` for a tool that takes none, but most tool
176
- // handlers refuse an absent input ("input must be an object"). Sending `{}` makes the
177
- // schema's promise true instead of costing a red failed call and a retry.
178
- input: args.input ?? {},
179
- ...(variant.requireReadOnly === undefined ? {} : { requireReadOnly: variant.requireReadOnly }),
180
- };
181
- const data = await postDaemonJson({ baseUrl: ctx.baseUrl, route: '/api/delegated-tool-calls', body: body }, {
182
- ...daemonCallOptions({ ctx }),
183
- timeoutMs,
184
- });
185
- const output = unwrapMcpContentEnvelope(data.result);
186
- // Only an unwrapped MCP envelope can correlate against the bridge's saved content digest.
187
- if (!options.delegatedResultMarkers || !isRecord(output) || !Array.isArray(output.content))
188
- return output;
189
- return { ...output, content: [delegatedResultMarker({ toolUseId }), ...output.content] };
137
+ handler: delegatedGatewayHandler(variant, { runId, generateToolUseId, timeoutMs }, options),
138
+ };
139
+ }
140
+ function delegatedGatewayInputSchema() {
141
+ return {
142
+ type: 'object',
143
+ properties: {
144
+ toolId: {
145
+ type: 'string',
146
+ description: 'Jini registry tool id to invoke. Required.',
147
+ },
148
+ input: {
149
+ // `type` is load-bearing, not decoration. Declared without one, an MCP client has no
150
+ // signal that this property carries structured data, and at least one real client
151
+ // (Claude Code, observed 2026-07-26) then delivers the model's object as a raw JSON
152
+ // *string* — which every Jini tool rejects, because a tool's input is a record or
153
+ // absent (`@jini-ai/daemon`'s `toCapabilityInput` refuses a string by name rather than
154
+ // coercing it). The effect was that only no-input tools were callable at all.
155
+ //
156
+ // Object-only is narrower than "arbitrary JSON" and deliberately so: it is exactly
157
+ // what every registered tool accepts today, it matches MCP's own convention that tool
158
+ // arguments are objects, and widening it later (a union type, say) is additive.
159
+ type: 'object',
160
+ additionalProperties: true,
161
+ description: 'JSON object of input fields for the tool. Optional; omit for a tool that takes no input. Must be an object, not a JSON-encoded string.',
162
+ },
190
163
  },
164
+ required: ['toolId'],
165
+ additionalProperties: false,
166
+ };
167
+ }
168
+ function delegatedGatewayHandler(variant, scope, options) {
169
+ const { runId, generateToolUseId, timeoutMs } = scope;
170
+ return async ({ args, ctx }) => {
171
+ const toolId = requireString({ value: args.toolId, name: 'toolId' });
172
+ // Local tools are advertised by this MCP host, not registered in the daemon catalog.
173
+ // Use their existing handler/validator instead of inventing a second implementation there.
174
+ const local = await ctx.callLocalTool?.({ name: toolId, input: (args.input ?? {}),
175
+ requireReadOnly: variant.requireReadOnly === true }, {});
176
+ if (local !== undefined)
177
+ return local;
178
+ const toolUseId = generateToolUseId({});
179
+ const body = {
180
+ runId,
181
+ toolUseId,
182
+ toolId: resolveMcpToolName({ name: toolId }, { isRegistered: candidate => ctx.diagnosticToolIds?.includes(candidate) ?? false }),
183
+ // The schema tells the model to omit `input` for a tool that takes none, but most tool
184
+ // handlers refuse an absent input ("input must be an object"). Sending `{}` makes the
185
+ // schema's promise true instead of costing a red failed call and a retry.
186
+ input: args.input ?? {},
187
+ ...(variant.requireReadOnly === undefined ? {} : { requireReadOnly: variant.requireReadOnly }),
188
+ };
189
+ const data = await postDaemonJson({ baseUrl: ctx.baseUrl, route: '/api/delegated-tool-calls', body: body }, {
190
+ ...daemonCallOptions({ ctx }),
191
+ timeoutMs,
192
+ });
193
+ const output = unwrapMcpContentEnvelope(data.result);
194
+ // Only an unwrapped MCP envelope can correlate against the bridge's saved content digest.
195
+ if (!options.delegatedResultMarkers || !isRecord(output) || !Array.isArray(output.content))
196
+ return output;
197
+ return { ...output, content: [delegatedResultMarker({ toolUseId }), ...output.content] };
191
198
  };
192
199
  }
193
200
  /**
@@ -272,7 +279,17 @@ export function createTypedDelegatedToolTool({ runId, tool }, options = {}) {
272
279
  inputSchema: descriptor.inputSchema,
273
280
  argumentNormalization: { schemaInput: true },
274
281
  annotations: { ...gateway.annotations, title: descriptor.id },
275
- handler: ({ args, ctx }) => gateway.handler({ args: { toolId: descriptor.id, input: args }, ctx }),
282
+ // A published tool IS a daemon registry tool (it was described by the daemon's catalog). When the transport had to
283
+ // rename it (wireName differs from its id: a collision with a local tool, or an id that is not a safe name) the
284
+ // gateway must not resolve its registry id to an MCP-local tool that happens to share it: the call reaches the
285
+ // daemon with the registry id. When the names agree, the local entry the gateway finds is this tool itself.
286
+ handler: ({ args, ctx }) => gateway.handler({ args: { toolId: descriptor.id, input: args }, ctx: wireName === descriptor.id ? ctx : withoutLocalTools(ctx) }),
276
287
  };
277
288
  }
289
+ /** The context a daemon-bound call runs under: same everything, but no MCP-local tool resolution. */
290
+ function withoutLocalTools(ctx) {
291
+ const daemonContext = { ...ctx };
292
+ delete daemonContext.callLocalTool;
293
+ return daemonContext;
294
+ }
278
295
  //# sourceMappingURL=delegated-tool.js.map
@@ -1,13 +1,13 @@
1
1
  import { type McpToolDef } from '../tool-protocol.js';
2
- /** `start_run` -> `POST /api/runs` (`packages/http/src/runs.ts`'s `runStartRoute`). */
2
+ /** `start_run` -> `POST /api/runs` (`packages/daemon/src/http/runs.ts`'s `runStartRoute`). */
3
3
  export declare const startRunTool: McpToolDef;
4
- /** `get_run` -> `GET /api/runs/:runId` (`packages/http/src/runs.ts`'s `runStatusRoute`). */
4
+ /** `get_run` -> `GET /api/runs/:runId` (`packages/daemon/src/http/runs.ts`'s `runStatusRoute`). */
5
5
  export declare const getRunTool: McpToolDef;
6
- /** `cancel_run` -> `POST /api/runs/:runId/cancel` (`packages/http/src/runs.ts`'s `runCancelRoute`). */
6
+ /** `cancel_run` -> `POST /api/runs/:runId/cancel` (`packages/daemon/src/http/runs.ts`'s `runCancelRoute`). */
7
7
  export declare const cancelRunTool: McpToolDef;
8
- /** `get_active_context` -> `GET /api/active` (`packages/http/src/active-context.ts`'s `getActiveRoute`). */
8
+ /** `get_active_context` -> `GET /api/active` (`packages/daemon/src/http/active-context.ts`'s `getActiveRoute`). */
9
9
  export declare const getActiveContextTool: McpToolDef;
10
- /** `list_agents` -> `GET /api/agents` (`packages/http/src/agents.ts`'s `agentListRoute`). */
10
+ /** `list_agents` -> `GET /api/agents` (`packages/daemon/src/http/agents.ts`'s `agentListRoute`). */
11
11
  export declare const listAgentsTool: McpToolDef;
12
12
  /** The full set of kernel-run tool defs this package ships, ready to pass as `createMcpToolServer`'s `tools` option. */
13
13
  export declare const RUN_TOOLS: readonly McpToolDef[];
@@ -20,7 +20,7 @@ const WRITE_ANNOTATIONS = {
20
20
  function optionalNonEmptyString(value) {
21
21
  return typeof value === 'string' && value.length > 0 ? value : undefined;
22
22
  }
23
- /** `start_run` -> `POST /api/runs` (`packages/http/src/runs.ts`'s `runStartRoute`). */
23
+ /** `start_run` -> `POST /api/runs` (`packages/daemon/src/http/runs.ts`'s `runStartRoute`). */
24
24
  export const startRunTool = {
25
25
  name: 'start_run',
26
26
  description: 'Start a new run against a caller-supplied contextRef (an opaque identity the run belongs to — this kernel has no project/conversation noun, just that one caller-chosen string). Returns {run, started} immediately; poll get_run(run.id) for completion.',
@@ -56,7 +56,7 @@ export const startRunTool = {
56
56
  return postDaemonJson({ baseUrl: ctx.baseUrl, route: '/api/runs', body: body }, daemonCallOptions({ ctx }));
57
57
  },
58
58
  };
59
- /** `get_run` -> `GET /api/runs/:runId` (`packages/http/src/runs.ts`'s `runStatusRoute`). */
59
+ /** `get_run` -> `GET /api/runs/:runId` (`packages/daemon/src/http/runs.ts`'s `runStatusRoute`). */
60
60
  export const getRunTool = {
61
61
  name: 'get_run',
62
62
  description: 'Poll a run started by start_run. Returns {run} with the run\'s current state (queued|starting|running|succeeded|failed|cancelled, per @jini-ai/protocol\'s RunState).',
@@ -74,7 +74,7 @@ export const getRunTool = {
74
74
  return getDaemonJson({ baseUrl: ctx.baseUrl, route: `/api/runs/${encodeURIComponent(runId)}` }, daemonCallOptions({ ctx }));
75
75
  },
76
76
  };
77
- /** `cancel_run` -> `POST /api/runs/:runId/cancel` (`packages/http/src/runs.ts`'s `runCancelRoute`). */
77
+ /** `cancel_run` -> `POST /api/runs/:runId/cancel` (`packages/daemon/src/http/runs.ts`'s `runCancelRoute`). */
78
78
  export const cancelRunTool = {
79
79
  name: 'cancel_run',
80
80
  description: 'Request cancellation of an in-flight run started by start_run. A no-op on an already-terminal run.',
@@ -114,7 +114,7 @@ async function fetchActiveContext(ctx) {
114
114
  throw err;
115
115
  }
116
116
  }
117
- /** `get_active_context` -> `GET /api/active` (`packages/http/src/active-context.ts`'s `getActiveRoute`). */
117
+ /** `get_active_context` -> `GET /api/active` (`packages/daemon/src/http/active-context.ts`'s `getActiveRoute`). */
118
118
  export const getActiveContextTool = {
119
119
  name: 'get_active_context',
120
120
  description: 'The resource (resourceRef) plus optional detail the caller last recorded as its current focus via POST /api/active — a generic, product-neutral pointer (this kernel has no "project" or "file" noun; a host maps resourceRef to whatever domain object it manages). Returns {active:false} once the pointer has aged past its TTL (5 minutes, see ACTIVE_CONTEXT_TTL_MS in packages/http/src/active-context.ts) or was never set. On a host that does not support active context at all, the call fails with an explicit "not supported by this host" error instead — that means nothing is tracked here, not that the pointer expired.',
@@ -131,7 +131,7 @@ export const getActiveContextTool = {
131
131
  return data;
132
132
  },
133
133
  };
134
- /** `list_agents` -> `GET /api/agents` (`packages/http/src/agents.ts`'s `agentListRoute`). */
134
+ /** `list_agents` -> `GET /api/agents` (`packages/daemon/src/http/agents.ts`'s `agentListRoute`). */
135
135
  export const listAgentsTool = {
136
136
  name: 'list_agents',
137
137
  description: 'List every agent def registered with this host\'s @jini-ai/agent-runtime — {id, name} pairs suitable for start_run\'s optional agentId argument. Static registration data only: this does not probe which agent binaries are actually installed on the host machine.',
@@ -1,7 +1,7 @@
1
1
  import { type McpToolDef } from '../tool-protocol.js';
2
- /** `search_tools` -> `GET /api/tools/search` (`packages/http/src/tool-catalog.ts`'s `toolCatalogSearchRoute`). */
2
+ /** `search_tools` -> `GET /api/tools/search` (`packages/daemon/src/http/tool-catalog.ts`'s `toolCatalogSearchRoute`). */
3
3
  export declare const searchToolsTool: McpToolDef;
4
- /** `describe_tool` -> `GET /api/tools/:id` (`packages/http/src/tool-catalog.ts`'s `toolCatalogDescribeRoute`). */
4
+ /** `describe_tool` -> `GET /api/tools/:id` (`packages/daemon/src/http/tool-catalog.ts`'s `toolCatalogDescribeRoute`). */
5
5
  export declare const describeToolTool: McpToolDef;
6
6
  /** Both tool-catalog discovery tools, ready to pass as `createMcpToolServer`'s `tools` option. */
7
7
  export declare const TOOL_CATALOG_TOOLS: readonly McpToolDef[];
@@ -14,6 +14,7 @@
14
14
  */
15
15
  import { getDaemonJson } from '../daemon-client.js';
16
16
  import { isRecord } from '../tool-arguments.js';
17
+ import { toolCallText } from '@jini-ai/core/tool-call-text';
17
18
  import { daemonCallOptions, requireString } from '../tool-protocol.js';
18
19
  const READ_ANNOTATIONS = {
19
20
  readOnlyHint: true,
@@ -34,7 +35,7 @@ function describedDescriptor({ id, data }) {
34
35
  ...(data.inputSchema === undefined ? {} : { inputSchema: data.inputSchema }),
35
36
  };
36
37
  }
37
- /** `search_tools` -> `GET /api/tools/search` (`packages/http/src/tool-catalog.ts`'s `toolCatalogSearchRoute`). */
38
+ /** `search_tools` -> `GET /api/tools/search` (`packages/daemon/src/http/tool-catalog.ts`'s `toolCatalogSearchRoute`). */
38
39
  export const searchToolsTool = {
39
40
  name: 'search_tools',
40
41
  description: 'Search the durable tool catalog. Returns ranked {id, description, source, score, readOnly, sideEffects, signature} candidates — no full input schemas, so this stays cheap to call broadly. signature lists the arguments (required first, then name?: optional): supply EVERY required one on the first call; never send {} when signature names a required argument. Call describe_tool when signature is missing, says describe_tool, or a nested shape is unclear, before calling execute_delegated_tool. If nothing in the results fits, re-search with a higher limit or different phrasing rather than assuming the tool does not exist.',
@@ -60,7 +61,7 @@ export const searchToolsTool = {
60
61
  type: 'string',
61
62
  description: 'Describe what the tool you need DOES, the way its own documentation would describe it — a full phrase, not a keyword bag. Name the thing being acted on and the action, and include likely synonyms for both. Example: for a request like "how many people visited last week", write "retrieve site traffic and visitor analytics counts for a date range" rather than "visitors last week". Descriptive phrasing retrieves substantially better than terse keywords, because the catalog is matched on tool descriptions. Required.',
62
63
  },
63
- // Bounds mirror `packages/http-kit/src/tool-catalog.ts`'s `parseSearchInput`
64
+ // Bounds mirror `packages/daemon/src/http/tool-catalog.ts`'s `parseSearchInput`
64
65
  // exactly (`MAX_SEARCH_LIMIT = 25`, `DEFAULT_SEARCH_LIMIT = 10`, integers only,
65
66
  // `>= 1`). Declared rather than left as a bare `number` so MCP validation and the
66
67
  // route agree: otherwise `0`/`1.5` pass here and are refused downstream, and `26`
@@ -78,12 +79,14 @@ export const searchToolsTool = {
78
79
  type: 'integer',
79
80
  minimum: 1,
80
81
  maximum: 25,
82
+ clamp: true,
81
83
  description: 'Max hits to return (1-25). Optional, defaults to 10. If none of the returned candidates fit what you need, search again with a HIGHER limit (try 25) or different phrasing before concluding no tool exists — a matching tool may rank below the default cutoff.',
82
84
  },
83
85
  max_results: {
84
86
  type: 'integer',
85
87
  minimum: 1,
86
88
  maximum: 25,
89
+ clamp: true,
87
90
  description: 'Alias of limit (1-25). Supply only one value when using both names.',
88
91
  },
89
92
  },
@@ -91,7 +94,7 @@ export const searchToolsTool = {
91
94
  additionalProperties: false,
92
95
  },
93
96
  // Models also use this conventional search argument; normalize only the declared alias.
94
- argumentNormalization: { aliases: { max_results: 'limit' } },
97
+ argumentNormalization: { aliases: { max_results: 'limit' }, clamp: true },
95
98
  annotations: { ...READ_ANNOTATIONS, title: 'Search the tool catalog' },
96
99
  handler: async ({ args, ctx }) => {
97
100
  const query = requireString({ value: args.query, name: 'query' });
@@ -102,10 +105,31 @@ export const searchToolsTool = {
102
105
  return data.hits;
103
106
  },
104
107
  };
105
- /** `describe_tool` -> `GET /api/tools/:id` (`packages/http/src/tool-catalog.ts`'s `toolCatalogDescribeRoute`). */
108
+ /**
109
+ * How the model calls a described tool, by the name this server actually offers: a published tool by its wire
110
+ * name (`direct`), any other tool through the gateway with its registry id (`gateway`, also when the publication
111
+ * was skipped because the tool list or schema budget is full), and a schema-less group not at all (`none`).
112
+ * Publishing happens here, so the answer is what `tools/list` shows, never a guess.
113
+ *
114
+ * @returns `{ callAs, call }`, or `{ callAs: 'none' }` for a descriptor without an input schema.
115
+ * @throws Whatever `publishTool` throws (a malformed schema), before any call text is built.
116
+ * @complexity O(1) plus one `publishTool` call; no daemon I/O.
117
+ */
118
+ async function callInstructions({ descriptor, ctx }) {
119
+ // A family can describe its members without owning an executable input contract.
120
+ if (descriptor.inputSchema == null)
121
+ return { callAs: 'none' };
122
+ const readOnly = descriptor.readOnly === true;
123
+ const publication = ctx.publishTool === undefined ? undefined : await ctx.publishTool({ descriptor });
124
+ if (publication !== undefined && 'wireName' in publication) {
125
+ return { callAs: 'direct', call: toolCallText({ toolId: descriptor.id }, { wireName: publication.wireName }) };
126
+ }
127
+ return { callAs: 'gateway', call: toolCallText({ toolId: descriptor.id }, { readOnly }) };
128
+ }
129
+ /** `describe_tool` -> `GET /api/tools/:id` (`packages/daemon/src/http/tool-catalog.ts`'s `toolCatalogDescribeRoute`). */
106
130
  export const describeToolTool = {
107
131
  name: 'describe_tool',
108
- description: 'Get the full descriptor for one tool id found via search_tools — description, input schema, readOnly and sideEffects. Schema-less descriptors are information only. When dynamic publication is enabled, descriptors with an input schema also expose that operation as a concrete tool in tools/list; call it with its own arguments. Legacy fallback: use execute_readonly_delegated_tool only when readOnly is true. Supply id (aliases: toolId or name). Paid for only on the candidates that survive search, per the tool catalog\'s staged-discovery design.',
132
+ description: 'Get the full descriptor for one tool id found via search_tools — description, input schema, readOnly and sideEffects. Schema-less descriptors are information only. The result\'s callAs and call fields say exactly how to call it. Legacy fallback: use execute_readonly_delegated_tool only when readOnly is true. Supply id (aliases: toolId or name). Paid for only on the candidates that survive search, per the tool catalog\'s staged-discovery design.',
109
133
  inputSchema: {
110
134
  type: 'object',
111
135
  properties: {
@@ -121,13 +145,12 @@ export const describeToolTool = {
121
145
  handler: async ({ args, ctx }) => {
122
146
  const id = requireString({ value: args.id, name: 'id' });
123
147
  const data = await getDaemonJson({ baseUrl: ctx.baseUrl, route: `/api/tools/${encodeURIComponent(id)}` }, daemonCallOptions({ ctx }));
124
- if (ctx.publishTool) {
125
- const descriptor = describedDescriptor({ id, data });
126
- // A family can describe its members without owning an executable input contract.
127
- if (descriptor.inputSchema != null)
128
- await ctx.publishTool({ descriptor });
129
- }
130
- return data;
148
+ // A host that publishes validates the daemon's answer (a mismatch is an error, as before); one that does not
149
+ // passes an answer that is not this tool's descriptor through unchanged, with nothing to say about calling it.
150
+ if (ctx.publishTool === undefined && !(isRecord(data) && data.id === id))
151
+ return data;
152
+ const descriptor = describedDescriptor({ id, data });
153
+ return { ...data, ...(await callInstructions({ descriptor, ctx })) };
131
154
  },
132
155
  };
133
156
  /** Both tool-catalog discovery tools, ready to pass as `createMcpToolServer`'s `tools` option. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/mcp",
3
- "version": "0.7.1",
3
+ "version": "0.7.3-next.1",
4
4
  "description": "Model Context Protocol adapters: server config schema and IO, an MCP client, and agent-side MCP server installation.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -90,17 +90,16 @@
90
90
  },
91
91
  "dependencies": {
92
92
  "@cfworker/json-schema": "^4.1.1",
93
- "@modelcontextprotocol/sdk": "^1.29.0",
94
- "@jini-ai/protocol": "^0.7.1",
95
- "@jini-ai/platform": "^0.7.1",
96
- "@jini-ai/core": "^0.7.1"
93
+ "@modelcontextprotocol/sdk": "^1.32.2",
94
+ "@jini-ai/core": "^0.7.3-next.1",
95
+ "@jini-ai/protocol": "^0.7.3-next.1"
97
96
  },
98
97
  "devDependencies": {
99
98
  "@cfworker/json-schema": "^4.1.1",
100
- "@modelcontextprotocol/sdk": "^1.29.0",
101
- "@jini-ai/platform": "^0.7.1",
102
- "@jini-ai/daemon": "^0.7.1",
103
- "@jini-ai/core": "^0.7.1"
99
+ "@modelcontextprotocol/sdk": "^1.32.2",
100
+ "@jini-ai/core": "^0.7.3-next.1",
101
+ "@jini-ai/daemon": "^0.7.3-next.1",
102
+ "@jini-ai/platform": "^0.7.3-next.1"
104
103
  },
105
104
  "scripts": {
106
105
  "build": "tsc -p tsconfig.json && chmod +x dist/bin/serve.js",