@cyanheads/mcp-ts-core 0.13.9 → 0.13.11

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 (192) hide show
  1. package/AGENTS.md +41 -15
  2. package/CLAUDE.md +41 -15
  3. package/README.md +37 -11
  4. package/biome.json +1 -1
  5. package/changelog/0.13.x/0.13.10.md +118 -0
  6. package/changelog/0.13.x/0.13.11.md +113 -0
  7. package/dist/cli/app-render.d.ts +11 -0
  8. package/dist/cli/app-render.d.ts.map +1 -0
  9. package/dist/cli/app-render.js +150 -0
  10. package/dist/cli/app-render.js.map +1 -0
  11. package/dist/cli/init.d.ts +2 -1
  12. package/dist/cli/init.d.ts.map +1 -1
  13. package/dist/cli/init.js +10 -2
  14. package/dist/cli/init.js.map +1 -1
  15. package/dist/config/index.d.ts +3 -0
  16. package/dist/config/index.d.ts.map +1 -1
  17. package/dist/config/index.js +11 -0
  18. package/dist/config/index.js.map +1 -1
  19. package/dist/core/app.d.ts.map +1 -1
  20. package/dist/core/app.js +15 -1
  21. package/dist/core/app.js.map +1 -1
  22. package/dist/core/context.d.ts +92 -22
  23. package/dist/core/context.d.ts.map +1 -1
  24. package/dist/core/context.js +65 -16
  25. package/dist/core/context.js.map +1 -1
  26. package/dist/core/index.d.ts +1 -1
  27. package/dist/core/index.d.ts.map +1 -1
  28. package/dist/core/index.js.map +1 -1
  29. package/dist/core/worker.d.ts +6 -0
  30. package/dist/core/worker.d.ts.map +1 -1
  31. package/dist/core/worker.js +1 -0
  32. package/dist/core/worker.js.map +1 -1
  33. package/dist/linter/rules/error-contract-rules.d.ts +3 -44
  34. package/dist/linter/rules/error-contract-rules.d.ts.map +1 -1
  35. package/dist/linter/rules/error-contract-rules.js +8 -144
  36. package/dist/linter/rules/error-contract-rules.js.map +1 -1
  37. package/dist/linter/rules/index.d.ts +1 -1
  38. package/dist/linter/rules/index.d.ts.map +1 -1
  39. package/dist/linter/rules/index.js +1 -1
  40. package/dist/linter/rules/index.js.map +1 -1
  41. package/dist/linter/rules/resource-rules.d.ts.map +1 -1
  42. package/dist/linter/rules/resource-rules.js +1 -2
  43. package/dist/linter/rules/resource-rules.js.map +1 -1
  44. package/dist/linter/rules/tool-rules.d.ts.map +1 -1
  45. package/dist/linter/rules/tool-rules.js +1 -2
  46. package/dist/linter/rules/tool-rules.js.map +1 -1
  47. package/dist/mcp-server/handlerContext.d.ts +26 -13
  48. package/dist/mcp-server/handlerContext.d.ts.map +1 -1
  49. package/dist/mcp-server/handlerContext.js +32 -17
  50. package/dist/mcp-server/handlerContext.js.map +1 -1
  51. package/dist/mcp-server/inputRequired.d.ts +120 -8
  52. package/dist/mcp-server/inputRequired.d.ts.map +1 -1
  53. package/dist/mcp-server/inputRequired.js +177 -12
  54. package/dist/mcp-server/inputRequired.js.map +1 -1
  55. package/dist/mcp-server/prompts/prompt-registration.d.ts +10 -2
  56. package/dist/mcp-server/prompts/prompt-registration.d.ts.map +1 -1
  57. package/dist/mcp-server/prompts/prompt-registration.js +49 -11
  58. package/dist/mcp-server/prompts/prompt-registration.js.map +1 -1
  59. package/dist/mcp-server/resources/resource-registration.d.ts +4 -2
  60. package/dist/mcp-server/resources/resource-registration.d.ts.map +1 -1
  61. package/dist/mcp-server/resources/resource-registration.js +6 -4
  62. package/dist/mcp-server/resources/resource-registration.js.map +1 -1
  63. package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts +4 -3
  64. package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts.map +1 -1
  65. package/dist/mcp-server/resources/utils/resourceHandlerFactory.js +60 -21
  66. package/dist/mcp-server/resources/utils/resourceHandlerFactory.js.map +1 -1
  67. package/dist/mcp-server/server.d.ts +9 -0
  68. package/dist/mcp-server/server.d.ts.map +1 -1
  69. package/dist/mcp-server/server.js +14 -13
  70. package/dist/mcp-server/server.js.map +1 -1
  71. package/dist/mcp-server/tools/tool-registration.d.ts +7 -3
  72. package/dist/mcp-server/tools/tool-registration.d.ts.map +1 -1
  73. package/dist/mcp-server/tools/tool-registration.js +9 -5
  74. package/dist/mcp-server/tools/tool-registration.js.map +1 -1
  75. package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts +17 -9
  76. package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts.map +1 -1
  77. package/dist/mcp-server/tools/utils/toolHandlerFactory.js +91 -50
  78. package/dist/mcp-server/tools/utils/toolHandlerFactory.js.map +1 -1
  79. package/dist/mcp-server/transports/http/httpErrorHandler.d.ts.map +1 -1
  80. package/dist/mcp-server/transports/http/httpErrorHandler.js +7 -1
  81. package/dist/mcp-server/transports/http/httpErrorHandler.js.map +1 -1
  82. package/dist/services/mirror/sqlite/handle.d.ts +11 -5
  83. package/dist/services/mirror/sqlite/handle.d.ts.map +1 -1
  84. package/dist/services/mirror/sqlite/handle.js +46 -8
  85. package/dist/services/mirror/sqlite/handle.js.map +1 -1
  86. package/dist/services/mirror/sqlite/sqliteMirrorStore.d.ts +6 -1
  87. package/dist/services/mirror/sqlite/sqliteMirrorStore.d.ts.map +1 -1
  88. package/dist/services/mirror/sqlite/sqliteMirrorStore.js.map +1 -1
  89. package/dist/testing/apps/browser.d.ts +27 -0
  90. package/dist/testing/apps/browser.d.ts.map +1 -0
  91. package/dist/testing/apps/browser.js +162 -0
  92. package/dist/testing/apps/browser.js.map +1 -0
  93. package/dist/testing/apps/cdp-pipe.d.ts +79 -0
  94. package/dist/testing/apps/cdp-pipe.d.ts.map +1 -0
  95. package/dist/testing/apps/cdp-pipe.js +200 -0
  96. package/dist/testing/apps/cdp-pipe.js.map +1 -0
  97. package/dist/testing/apps/csp.d.ts +17 -0
  98. package/dist/testing/apps/csp.d.ts.map +1 -0
  99. package/dist/testing/apps/csp.js +50 -0
  100. package/dist/testing/apps/csp.js.map +1 -0
  101. package/dist/testing/apps/host-pages.d.ts +47 -0
  102. package/dist/testing/apps/host-pages.d.ts.map +1 -0
  103. package/dist/testing/apps/host-pages.js +138 -0
  104. package/dist/testing/apps/host-pages.js.map +1 -0
  105. package/dist/testing/apps/index.d.ts +167 -0
  106. package/dist/testing/apps/index.d.ts.map +1 -0
  107. package/dist/testing/apps/index.js +36 -0
  108. package/dist/testing/apps/index.js.map +1 -0
  109. package/dist/testing/apps/partial-json.d.ts +14 -0
  110. package/dist/testing/apps/partial-json.d.ts.map +1 -0
  111. package/dist/testing/apps/partial-json.js +71 -0
  112. package/dist/testing/apps/partial-json.js.map +1 -0
  113. package/dist/testing/apps/run.d.ts +13 -0
  114. package/dist/testing/apps/run.d.ts.map +1 -0
  115. package/dist/testing/apps/run.js +659 -0
  116. package/dist/testing/apps/run.js.map +1 -0
  117. package/dist/testing/index.d.ts +17 -2
  118. package/dist/testing/index.d.ts.map +1 -1
  119. package/dist/testing/index.js +21 -7
  120. package/dist/testing/index.js.map +1 -1
  121. package/dist/types-global/errors.d.ts +18 -15
  122. package/dist/types-global/errors.d.ts.map +1 -1
  123. package/dist/utils/index.d.ts +1 -1
  124. package/dist/utils/index.d.ts.map +1 -1
  125. package/dist/utils/index.js +1 -1
  126. package/dist/utils/index.js.map +1 -1
  127. package/dist/utils/internal/error-handler/errorHandler.d.ts +5 -4
  128. package/dist/utils/internal/error-handler/errorHandler.d.ts.map +1 -1
  129. package/dist/utils/internal/error-handler/errorHandler.js +9 -7
  130. package/dist/utils/internal/error-handler/errorHandler.js.map +1 -1
  131. package/dist/utils/internal/error-handler/types.d.ts +3 -1
  132. package/dist/utils/internal/error-handler/types.d.ts.map +1 -1
  133. package/dist/utils/internal/logger.d.ts +21 -1
  134. package/dist/utils/internal/logger.d.ts.map +1 -1
  135. package/dist/utils/internal/logger.js +31 -14
  136. package/dist/utils/internal/logger.js.map +1 -1
  137. package/dist/utils/internal/performance.d.ts +7 -3
  138. package/dist/utils/internal/performance.d.ts.map +1 -1
  139. package/dist/utils/internal/performance.js +16 -9
  140. package/dist/utils/internal/performance.js.map +1 -1
  141. package/dist/utils/internal/telemetryMessages.d.ts +0 -1
  142. package/dist/utils/internal/telemetryMessages.d.ts.map +1 -1
  143. package/dist/utils/internal/telemetryMessages.js +0 -1
  144. package/dist/utils/internal/telemetryMessages.js.map +1 -1
  145. package/dist/utils/security/sanitization.d.ts +16 -13
  146. package/dist/utils/security/sanitization.d.ts.map +1 -1
  147. package/dist/utils/security/sanitization.js +74 -33
  148. package/dist/utils/security/sanitization.js.map +1 -1
  149. package/dist/utils/telemetry/attributes.d.ts +12 -5
  150. package/dist/utils/telemetry/attributes.d.ts.map +1 -1
  151. package/dist/utils/telemetry/attributes.js +12 -5
  152. package/dist/utils/telemetry/attributes.js.map +1 -1
  153. package/framework-skills/add-app-tool/SKILL.md +2 -1
  154. package/framework-skills/add-service/SKILL.md +3 -12
  155. package/framework-skills/add-test/SKILL.md +20 -17
  156. package/framework-skills/add-tool/SKILL.md +30 -34
  157. package/framework-skills/api-config/SKILL.md +12 -2
  158. package/framework-skills/api-context/SKILL.md +156 -41
  159. package/framework-skills/api-errors/SKILL.md +43 -47
  160. package/framework-skills/api-linter/SKILL.md +5 -29
  161. package/framework-skills/api-mirror/SKILL.md +4 -3
  162. package/framework-skills/api-telemetry/SKILL.md +16 -10
  163. package/framework-skills/api-testing/SKILL.md +47 -11
  164. package/framework-skills/api-utils/SKILL.md +3 -3
  165. package/framework-skills/api-workers/SKILL.md +3 -1
  166. package/framework-skills/code-simplifier/SKILL.md +2 -2
  167. package/framework-skills/design-mcp-server/SKILL.md +5 -5
  168. package/framework-skills/field-test/SKILL.md +53 -8
  169. package/framework-skills/git-wrapup/SKILL.md +2 -2
  170. package/framework-skills/orchestrations/SKILL.md +1 -1
  171. package/framework-skills/orchestrations/workflows/greenfield-build.md +2 -2
  172. package/framework-skills/polish-docs-meta/SKILL.md +4 -3
  173. package/framework-skills/polish-docs-meta/references/server-json.md +24 -26
  174. package/framework-skills/release-and-publish/SKILL.md +3 -3
  175. package/framework-skills/release-pr-review/SKILL.md +6 -6
  176. package/framework-skills/security-pass/SKILL.md +8 -7
  177. package/framework-skills/setup/SKILL.md +2 -2
  178. package/package.json +38 -22
  179. package/scripts/devcheck.ts +43 -21
  180. package/scripts/install-otel.ts +84 -0
  181. package/scripts/lint-packaging.ts +279 -28
  182. package/scripts/prune-musl-packages.ts +146 -0
  183. package/templates/.env.example +2 -0
  184. package/templates/.github/workflows/codeql.yml +10 -1
  185. package/templates/AGENTS.md +5 -4
  186. package/templates/CLAUDE.md +5 -4
  187. package/templates/Dockerfile +76 -50
  188. package/templates/_.dockerignore +3 -5
  189. package/templates/_.gitignore +4 -4
  190. package/templates/package.json +4 -4
  191. package/templates/server.json +7 -21
  192. package/templates/src/mcp-server/tools/definitions/echo.tool.ts +3 -8
@@ -15,11 +15,16 @@
15
15
  * returns against 2025-era clients by issuing real `elicitation/create` /
16
16
  * `sampling/createMessage` / `roots/list` requests and re-entering the handler.
17
17
  *
18
+ * What a handler reads back is bounded by what its client declared: the
19
+ * per-request capability view (#580) decides which responses reach
20
+ * `ctx.inputs` (#496), and an opt-in key seals the `requestState` a handler
21
+ * returns so a retry can only echo what this server minted.
22
+ *
18
23
  * @see {@link https://modelcontextprotocol.io/specification/2026-07-28/basic/patterns/mrtr | MCP Multi-Round-Trip Requests}
19
24
  * @module src/mcp-server/inputRequired
20
25
  */
21
- import { acceptedContent, inputRequired, inputResponse, } from '@modelcontextprotocol/server';
22
- import { JsonRpcErrorCode, McpError } from '../types-global/errors.js';
26
+ import { acceptedContent, CLIENT_CAPABILITIES_META_KEY, createRequestStateCodec, inputRequired, inputResponse, } from '@modelcontextprotocol/server';
27
+ import { configurationError, internalError, JsonRpcErrorCode, McpError, } from '../types-global/errors.js';
23
28
  /**
24
29
  * Thrown by `ctx.requestInput(...)` and caught by the handler factories, which
25
30
  * return the carried `input_required` result to the SDK instead of a normal
@@ -45,6 +50,23 @@ export function isInputRequiredSignal(error) {
45
50
  error !== null &&
46
51
  error.isInputRequiredSignal === true));
47
52
  }
53
+ /**
54
+ * The view for one instance: on a 2025-era instance the `initialize`-declared
55
+ * value, read through the instance on every call so an `initialize` that lands
56
+ * after registration is seen; on a 2026-07-28 instance the request's own
57
+ * `io.modelcontextprotocol/clientCapabilities` envelope key, which the SDK has
58
+ * validated before dispatch. `getClientCapabilities()` is not used there — a
59
+ * 2026-07-28 stdio instance never has it backfilled.
60
+ */
61
+ export function clientCapabilityView(era, server) {
62
+ if (era === 'modern') {
63
+ return {
64
+ era,
65
+ capabilities: (mcpReq) => mcpReq?.envelope?.[CLIENT_CAPABILITIES_META_KEY],
66
+ };
67
+ }
68
+ return { era, capabilities: () => server.server.getClientCapabilities() };
69
+ }
48
70
  // ---------------------------------------------------------------------------
49
71
  // Client-capability gate (#379)
50
72
  // ---------------------------------------------------------------------------
@@ -54,7 +76,7 @@ export function isInputRequiredSignal(error) {
54
76
  * declare it in `errors[]`, because it names a property of the connection
55
77
  * rather than a domain outcome.
56
78
  */
57
- const CLIENT_CAPABILITY_MISSING_REASON = 'client_capability_missing';
79
+ export const CLIENT_CAPABILITY_MISSING_REASON = 'client_capability_missing';
58
80
  /**
59
81
  * What an embedded request kind requires, mode-aware where the capability is:
60
82
  * URL-mode elicitation needs `elicitation.url`, form-mode (or mode-omitted)
@@ -103,7 +125,9 @@ function capabilityPath({ capability, member }) {
103
125
  return member === undefined ? capability : `${capability}.${member}`;
104
126
  }
105
127
  /**
106
- * Builds the gate for one connection from its declared client capabilities.
128
+ * Builds the gate for one request from the capabilities its client declared —
129
+ * the value the instance's {@link ClientCapabilityView} resolved, which
130
+ * `ctx.clientCapabilities` carries too.
107
131
  *
108
132
  * Only the 2025-era arm needs it. There the refusal is produced by the SDK's
109
133
  * legacy shim, which runs *above* the handler callback on the result that
@@ -115,21 +139,20 @@ function capabilityPath({ capability, member }) {
115
139
  * the SDK itself, which raises `MissingRequiredClientCapabilityError`
116
140
  * (`-32021`) — that arm takes no gate.
117
141
  *
118
- * `clientCapabilities()` returning `undefined` is the per-request legacy case:
119
- * an instance that never saw an `initialize` holds no capability view, so every
120
- * embedded request is refused, and the message and hint say so.
142
+ * `declared` being `undefined` is the per-request legacy case: an instance that
143
+ * never saw an `initialize` holds no capability view, so every embedded
144
+ * request is refused, and the message and hint say so.
121
145
  *
122
146
  * The hint ends at reconnecting (#495). Whether the caller could instead
123
147
  * supply the answer as an argument is the handler's knowledge, not the gate's:
124
148
  * a consent gate deliberately has no such field, so the gate appends a
125
149
  * fallback only when the handler passed one.
126
150
  */
127
- export function createInputRequiredGate(clientCapabilities) {
151
+ export function createInputRequiredGate(declared) {
128
152
  return (result, fallbackHint) => {
129
153
  const requests = result.inputRequests;
130
154
  if (requests === undefined)
131
155
  return;
132
- const declared = clientCapabilities();
133
156
  for (const [key, entry] of Object.entries(requests)) {
134
157
  const requirement = capabilityRequirement(entry);
135
158
  if (requirement === undefined || isDeclared(requirement, declared))
@@ -175,14 +198,81 @@ export function createRequestInput(gate) {
175
198
  throw new InputRequiredSignal(result);
176
199
  };
177
200
  }
201
+ // ---------------------------------------------------------------------------
202
+ // ctx.inputs — responses filtered by declared capability (#496)
203
+ // ---------------------------------------------------------------------------
204
+ /** Content block types only a tool-enabled sampling result carries. */
205
+ const TOOL_BLOCK_TYPES = new Set(['tool_use', 'tool_result']);
206
+ /** Whether sampling content — one block or an array — holds a tool block. */
207
+ function carriesToolBlock(content) {
208
+ return (Array.isArray(content) ? content : [content]).some((block) => typeof block === 'object' &&
209
+ block !== null &&
210
+ TOOL_BLOCK_TYPES.has(block.type));
211
+ }
212
+ /**
213
+ * What one response requires — the response-side twin of
214
+ * {@link capabilityRequirement}, so an answer needs whatever the request it
215
+ * answers would have needed. An elicit result carrying `content` is a
216
+ * form-mode answer and needs `elicitation.form`; one without (a URL-mode
217
+ * accept, a decline, a cancel) needs `elicitation` in any mode. A sampling
218
+ * result holding a `tool_use` or `tool_result` block answers a tool-enabled
219
+ * request and needs `sampling.tools`; any other needs `sampling`. A roots
220
+ * result needs `roots`. `undefined` for an entry the SDK's classifier reads as
221
+ * no kind.
222
+ *
223
+ * `content` is read off the raw `entry`, not the view: the view keeps it only
224
+ * when it is an object, while `ctx.inputs.responses` exposes the entry as sent.
225
+ */
226
+ function responseRequirement(view, entry) {
227
+ switch (view.kind) {
228
+ case 'elicit':
229
+ return entry.content === undefined
230
+ ? { capability: 'elicitation' }
231
+ : { capability: 'elicitation', member: 'form' };
232
+ case 'sampling':
233
+ return carriesToolBlock(view.result.content)
234
+ ? { capability: 'sampling', member: 'tools' }
235
+ : { capability: 'sampling' };
236
+ case 'roots':
237
+ return { capability: 'roots' };
238
+ default:
239
+ return;
240
+ }
241
+ }
242
+ /**
243
+ * The entries of `responses` the client's declared capabilities cover, at the
244
+ * same mode level the gate applies to requests ({@link responseRequirement},
245
+ * {@link isDeclared}), or `undefined` when none survives.
246
+ *
247
+ * The SDK lifts `inputResponses` off every client request, a first call and a
248
+ * 2025-era request included, so a client can arrive pre-answered with no
249
+ * `input_required` result ever sent. An answer the client's modes do not cover
250
+ * cannot have come from a round this server asked for: on the 2025 arm the
251
+ * legacy shim only issues requests the connection declared, and on 2026-07-28
252
+ * the SDK refuses an embedded request the envelope does not cover. Dropping
253
+ * those closes the pre-answered consent-gate bypass — a URL-only client's form
254
+ * answer included — without touching a legitimate round. With no view
255
+ * (`declared` undefined) nothing survives, and an entry the SDK's classifier
256
+ * cannot read as any kind has no capability to justify it either.
257
+ */
258
+ export function declaredResponses(responses, declared) {
259
+ if (responses === undefined || declared === undefined)
260
+ return;
261
+ const kept = Object.entries(responses).filter(([key, entry]) => {
262
+ const requirement = responseRequirement(inputResponse(responses, key), entry);
263
+ return requirement !== undefined && isDeclared(requirement, declared);
264
+ });
265
+ return kept.length > 0 ? Object.fromEntries(kept) : undefined;
266
+ }
178
267
  /**
179
- * Builds the `ctx.inputs` reader over a retried request's `inputResponses`.
268
+ * Builds the `ctx.inputs` reader over a retried request's `inputResponses`,
269
+ * keeping only the answers `declared` covers ({@link declaredResponses}).
180
270
  *
181
271
  * Values arrive from the client and are never re-validated by the SDK — pass a
182
272
  * schema to `accepted()` wherever the content matters.
183
273
  */
184
- export function createContextInputs(mcpReq) {
185
- return contextInputsFrom(mcpReq?.inputResponses, mcpReq?.droppedInputResponseKeys ?? [], () => mcpReq?.requestState());
274
+ export function createContextInputs(mcpReq, declared) {
275
+ return contextInputsFrom(declaredResponses(mcpReq?.inputResponses, declared), mcpReq?.droppedInputResponseKeys ?? [], () => mcpReq?.requestState());
186
276
  }
187
277
  /**
188
278
  * The `ctx.inputs` reader over an explicit set of responses — what
@@ -201,4 +291,79 @@ export function contextInputsFrom(responses, dropped, state) {
201
291
  view: (key) => inputResponse(responses, key),
202
292
  };
203
293
  }
294
+ // ---------------------------------------------------------------------------
295
+ // requestState sealing (MCP_REQUEST_STATE_KEY)
296
+ // ---------------------------------------------------------------------------
297
+ /**
298
+ * How long a sealed `requestState` verifies, in seconds. Longer than the SDK
299
+ * legacy shim's 600 s per-round timeout, so a 2025-era round the shim holds
300
+ * open never outlives its own state; the codec's 600 s default leaves no
301
+ * margin.
302
+ */
303
+ const REQUEST_STATE_TTL_SECONDS = 900;
304
+ /** The shortest key the SDK codec accepts, in UTF-8 bytes. */
305
+ const REQUEST_STATE_KEY_MIN_BYTES = 32;
306
+ /**
307
+ * The principal a sealed state is bound to: the request's authenticated
308
+ * `clientId`, `subject`, and `tenantId`, each empty when absent — as they all
309
+ * are on stdio and under `MCP_AUTH_MODE=none`. The codec stores an HMAC tag of
310
+ * it, never the value.
311
+ */
312
+ function principalOf(ctx) {
313
+ const auth = ctx.http?.authInfo;
314
+ return JSON.stringify([auth?.clientId ?? '', auth?.subject ?? '', auth?.tenantId ?? '']);
315
+ }
316
+ /**
317
+ * The process's sealer, or `undefined` when no key is configured — in which
318
+ * case nothing reaches the SDK and handlers read the raw wire string, exactly
319
+ * as before the option existed. There is deliberately no per-process random
320
+ * key: a 2026-07-28 retry can land on another instance or outlive a restart,
321
+ * and every instance that may receive an echoed state needs the same key.
322
+ *
323
+ * @throws {McpError} `ConfigurationError` naming `MCP_REQUEST_STATE_KEY` when
324
+ * the key is shorter than 32 UTF-8 bytes. The key itself is never included.
325
+ */
326
+ export function createRequestStateSealer(key) {
327
+ if (key === undefined)
328
+ return;
329
+ if (new TextEncoder().encode(key).byteLength < REQUEST_STATE_KEY_MIN_BYTES) {
330
+ throw configurationError(`MCP_REQUEST_STATE_KEY must be at least ${REQUEST_STATE_KEY_MIN_BYTES} bytes. Set a longer random secret, shared by every instance that serves this server, or unset it.`, { variable: 'MCP_REQUEST_STATE_KEY', minimumBytes: REQUEST_STATE_KEY_MIN_BYTES });
331
+ }
332
+ const codec = createRequestStateCodec({
333
+ key,
334
+ ttlSeconds: REQUEST_STATE_TTL_SECONDS,
335
+ bind: principalOf,
336
+ });
337
+ return {
338
+ async seal(result, ctx) {
339
+ if (typeof result.requestState !== 'string')
340
+ return result;
341
+ return { ...result, requestState: await codec.mint(result.requestState, ctx) };
342
+ },
343
+ verify: (state, ctx) => codec.verify(state, ctx),
344
+ };
345
+ }
346
+ /**
347
+ * What a handler factory rethrows for a value its handler threw: an
348
+ * input-required signal carrying its `requestState` sealed when `sealer` is
349
+ * configured, anything else unchanged.
350
+ *
351
+ * The factories call it inside the measured region, where the signal is
352
+ * rethrown. Minting can reject — WebCrypto failing, or no request context for
353
+ * the principal binding — and a rejection there would escape the factory with
354
+ * no error envelope, no failure record, and no request id. It resolves to an
355
+ * `InternalError` instead, so the call fails through the family's ordinary
356
+ * error path; the codec's error rides as `cause` into the server log only, and
357
+ * no part of the key reaches it.
358
+ */
359
+ export async function sealThrown(thrown, sealer, ctx) {
360
+ if (sealer === undefined || !isInputRequiredSignal(thrown))
361
+ return thrown;
362
+ try {
363
+ return new InputRequiredSignal(await sealer.seal(thrown.result, ctx));
364
+ }
365
+ catch (error) {
366
+ return internalError('Could not seal the requestState of an input_required result.', undefined, { cause: error });
367
+ }
368
+ }
204
369
  //# sourceMappingURL=inputRequired.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"inputRequired.js","sourceRoot":"","sources":["../../src/mcp-server/inputRequired.ts"],"names":[],"mapp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AAE,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC;KACjD,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,MAAe,EACf,MAAsC,EACtC,GAAkB;IAElB,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC1E,IAAI,CAAC;QACH,OAAO,IAAI,mBAAmB,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IACxE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,aAAa,CAClB,8DAA8D,EAC9D,SAAS,EACT,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -6,16 +6,24 @@
6
6
  * @module src/mcp-server/prompts/prompt-registration
7
7
  */
8
8
  import type { McpServer } from '@modelcontextprotocol/server';
9
+ import { type RequestStateSealer } from '../inputRequired.js';
9
10
  import type { AnyPromptDefinition } from './utils/promptDefinition.js';
10
11
  import type { logger as defaultLogger } from '../../utils/internal/logger.js';
11
12
  export declare class PromptRegistry {
12
13
  private promptDefs;
13
14
  private logger;
15
+ private requestState?;
14
16
  /** Tracks registered prompt names to detect duplicates at startup. */
15
17
  private readonly registeredNames;
16
- constructor(promptDefs: AnyPromptDefinition[], logger: typeof defaultLogger);
17
18
  /**
18
- * Registers all prompts on the given MCP server.
19
+ * @param requestState - The process's `requestState` sealer, present when
20
+ * `MCP_REQUEST_STATE_KEY` is set; an `input_required` result leaves with
21
+ * its state sealed, as a tool's and a resource's do.
22
+ */
23
+ constructor(promptDefs: AnyPromptDefinition[], logger: typeof defaultLogger, requestState?: RequestStateSealer | undefined);
24
+ /**
25
+ * Registers all prompts on the given MCP server. Registration logs under one
26
+ * context; each `prompts/get` call logs under its own.
19
27
  */
20
28
  registerAll(server: McpServer): Promise<void>;
21
29
  /** Throws at startup if a prompt with the same name was already registered. */
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-registration.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/prompts/prompt-registration.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAwC,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGpG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AAG1F,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI1E,qBAAa,cAAc;IAKvB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,MAAM;IALhB,sEAAsE;IACtE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqB;IAErD,YACU,UAAU,EAAE,mBAAmB,EAAE,EACjC,MAAM,EAAE,OAAO,aAAa,EAClC;IAEJ;;OAEG;IACG,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBlD;IAED,+EAA+E;IAC/E,OAAO,CAAC,gBAAgB;YAUV,cAAc;CAwE7B"}
1
+ {"version":3,"file":"prompt-registration.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/prompts/prompt-registration.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAGV,SAAS,EAEV,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAEL,KAAK,kBAAkB,EAExB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AAG1F,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI1E,qBAAa,cAAc;IAUvB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,YAAY,CAAC;IAXvB,sEAAsE;IACtE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqB;IAErD;;;;OAIG;IACH,YACU,UAAU,EAAE,mBAAmB,EAAE,EACjC,MAAM,EAAE,OAAO,aAAa,EAC5B,YAAY,CAAC,EAAE,kBAAkB,YAAA,EACvC;IAEJ;;;OAGG;IACG,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBlD;IAED,+EAA+E;IAC/E,OAAO,CAAC,gBAAgB;YAUV,cAAc;CAsG7B"}
@@ -1,4 +1,5 @@
1
- import { isInputRequiredSignal } from '../inputRequired.js';
1
+ import { handlerParentContext } from '../handlerContext.js';
2
+ import { isInputRequiredSignal, sealThrown, } from '../inputRequired.js';
2
3
  import { JsonRpcErrorCode, McpError } from '../../types-global/errors.js';
3
4
  import { ErrorHandler } from '../../utils/internal/error-handler/errorHandler.js';
4
5
  import { measurePromptGeneration } from '../../utils/internal/performance.js';
@@ -6,14 +7,22 @@ import { requestContextService } from '../../utils/internal/requestContext.js';
6
7
  export class PromptRegistry {
7
8
  promptDefs;
8
9
  logger;
10
+ requestState;
9
11
  /** Tracks registered prompt names to detect duplicates at startup. */
10
12
  registeredNames = new Set();
11
- constructor(promptDefs, logger) {
13
+ /**
14
+ * @param requestState - The process's `requestState` sealer, present when
15
+ * `MCP_REQUEST_STATE_KEY` is set; an `input_required` result leaves with
16
+ * its state sealed, as a tool's and a resource's do.
17
+ */
18
+ constructor(promptDefs, logger, requestState) {
12
19
  this.promptDefs = promptDefs;
13
20
  this.logger = logger;
21
+ this.requestState = requestState;
14
22
  }
15
23
  /**
16
- * Registers all prompts on the given MCP server.
24
+ * Registers all prompts on the given MCP server. Registration logs under one
25
+ * context; each `prompts/get` call logs under its own.
17
26
  */
18
27
  async registerAll(server) {
19
28
  this.registeredNames.clear();
@@ -52,10 +61,34 @@ export class PromptRegistry {
52
61
  ...(promptDef.args && {
53
62
  argsSchema: promptDef.args,
54
63
  }),
55
- }, async (args) => {
64
+ }, async (...params) => {
65
+ // The SDK calls a prompt registered with `argsSchema` as
66
+ // `(args, ctx)` and one without as `(ctx)` alone (#581).
67
+ const [args, serverContext] = (promptDef.args ? params : [undefined, params[0]]);
68
+ // Per call, as for tools and resources, not the registration `context`:
69
+ // its `requestId` is the one the call's records carry and its error
70
+ // `data` returns (#576).
71
+ const requestContext = requestContextService.createRequestContext({
72
+ parentContext: handlerParentContext(serverContext),
73
+ operation: 'HandlePromptGet',
74
+ additionalContext: { promptName: promptDef.name },
75
+ });
56
76
  try {
57
- const validatedArgs = promptDef.args ? promptDef.args.parse(args) : args;
58
- const messages = await measurePromptGeneration(() => Promise.resolve(promptDef.generate(validatedArgs)), { ...context, promptName: promptDef.name }, validatedArgs);
77
+ // An argless prompt's `generate` is typed to receive `{}`; its
78
+ // input measures as nothing.
79
+ const validatedArgs = promptDef.args ? promptDef.args.parse(args) : {};
80
+ const messages = await measurePromptGeneration(async () => {
81
+ try {
82
+ return await promptDef.generate(validatedArgs);
83
+ }
84
+ catch (error) {
85
+ // Inside the measurement, as for tools and resources: an
86
+ // input-required signal leaves with its `requestState`
87
+ // sealed when a key is configured, so a sealing failure
88
+ // is a failed call like any other.
89
+ throw await sealThrown(error, this.requestState, serverContext);
90
+ }
91
+ }, { ...requestContext, promptName: promptDef.name }, promptDef.args ? validatedArgs : undefined);
59
92
  return { messages };
60
93
  }
61
94
  catch (error) {
@@ -65,15 +98,20 @@ export class PromptRegistry {
65
98
  if (isInputRequiredSignal(error))
66
99
  return error.result;
67
100
  /**
68
- * `handleError` logs the stack and cause chain; the client gets
69
- * the classified code and message, plus only the `data` a thrown
70
- * `McpError` declared — the same wire shape as tools and resources.
101
+ * `handleError` writes the call's one `error` record, with the
102
+ * stack and cause chain; the completion record stays at `info`
103
+ * (#582). The client gets the classified code and message, plus
104
+ * only the `data` a thrown `McpError` declared and the call's
105
+ * `requestId` (#576) — the same wire shape as tools and resources.
71
106
  */
72
107
  const handled = ErrorHandler.handleError(error, {
73
108
  operation: `prompt:${promptDef.name}`,
74
- context,
109
+ context: requestContext,
75
110
  });
76
- throw new McpError(handled instanceof McpError ? handled.code : JsonRpcErrorCode.InternalError, handled.message, error instanceof McpError ? error.data : undefined, { cause: error });
111
+ throw new McpError(handled instanceof McpError ? handled.code : JsonRpcErrorCode.InternalError, handled.message, {
112
+ ...(error instanceof McpError ? error.data : undefined),
113
+ requestId: requestContext.requestId,
114
+ }, { cause: error });
77
115
  }
78
116
  });
79
117
  this.logger.debug(`Registered prompt: ${promptDef.name}`, context);
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-registration.js","sourceRoot":"","sources":["../../../src/mcp-server/prompts/prompt-registration.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAE9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,MAAM,OAAO,cAAc;IAKf,UAAU;IACV,MAAM;IALhB,sEAAsE;IACrD,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;IAErD,YACU,UAAiC,EACjC,MAA4B;0BAD5B,UAAU;sBACV,MAAM;IACb,CAAC;IAEJ;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,MAAiB;QACjC,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QAE7B,MAAM,OAAO,GAAG,qBAAqB,CAAC,oBAAoB,CAAC;YACzD,SAAS,EAAE,4BAA4B;SACxC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,UAAU,CAAC,MAAM,eAAe,EAAE,OAAO,CAAC,CAAC;QAEjF,qEAAqE;QACrE,2EAA2E;QAC3E,2DAA2D;QAC3D,KAAK,MAAM,SAAS,IAAI,IAAI,C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oB;YAChD,QAAQ,EAAE,IAAI;SACf,CACF,CAAC;IACJ,CAAC;CACF"}
1
+ {"version":3,"file":"prompt-registration.js","sourceRoot":"","sources":["../../../src/mcp-server/prompts/prompt-registration.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EACL,qBAAqB,EAErB,UAAU,GACX,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAE9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,MAAM,OAAO,cAAc;IAUf,UAAU;IACV,MAAM;IACN,YAAY;IAXtB,sEAAsE;IACrD,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;IAErD;;;;OAIG;IACH,YACU,UAAiC,EACjC,MAA4B,EAC5B,YAAiC;0BAFjC,UAAU;sBACV,MAAM;4BACN,YAAY;IACnB,CAAC;IAEJ;;;OAGG;IACH,KAAK,CAAC,WAAW,CAAC,MAAiB;QACjC,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QAE7B,MAAM,OAAO,GAAG,qBAAqB,CAAC,oBAAoB,CAAC;YACzD,SAAS,EAAE,4BAA4B;SACxC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,UAAU,CAAC,MAAM,eAAe,EAAE,OAAO,CAAC,CAAC;QAEjF,qEAAqE;QACrE,2EAA2E;QAC3E,2DAA2D;QAC3D,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACxC,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACxD,CAAC;QAED,IA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;uBAMG;oBACH,MAAM,OAAO,GAAG,YAAY,CAAC,WAAW,CAAC,KAAK,EAAE;wBAC9C,SAAS,EAAE,UAAU,SAAS,CAAC,IAAI,EAAE;wBACrC,OAAO,EAAE,cAAc;qBACxB,CAAC,CAAC;oBACH,MAAM,IAAI,QAAQ,CAChB,OAAO,YAAY,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,aAAa,EAC3E,OAAO,CAAC,OAAO,EACf;wBACE,GAAG,CAAC,KAAK,YAAY,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;wBACvD,SAAS,EAAE,cAAc,CAAC,SAAS;qBACpC,EACD,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;gBACJ,CAAC;YACH,CAAC,CACF,CAAC;YAEF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,SAAS,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;QACrE,CAAC,EACD;YACE,SAAS,EAAE,qBAAqB,SAAS,CAAC,IAAI,EAAE;YAChD,OAAO;YACP,SAAS,EAAE,gBAAgB,CAAC,oBAAoB;YAChD,QAAQ,EAAE,IAAI;SACf,CACF,CAAC;IACJ,CAAC;CACF"}
@@ -3,7 +3,7 @@
3
3
  * @module src/mcp-server/resources/resource-registration
4
4
  */
5
5
  import { type McpServer, type ServerNotifier } from '@modelcontextprotocol/server';
6
- import type { InputRequiredGate } from '../inputRequired.js';
6
+ import type { ClientCapabilityView } from '../inputRequired.js';
7
7
  import type { ResourceSubscriptions } from '../notifications.js';
8
8
  import type { AnyResourceDefinition } from './utils/resourceDefinition.js';
9
9
  import { type HandlerServices } from './utils/resourceHandlerFactory.js';
@@ -15,8 +15,10 @@ export declare class ResourceRegistry {
15
15
  constructor(resourceDefs: AnyResourceDefinition[], services: HandlerServices);
16
16
  /**
17
17
  * Registers all resolved resource definitions with the provided McpServer instance.
18
+ * `capabilities` is the instance's view of what its client declared (#580),
19
+ * which every handler context resolves per request.
18
20
  */
19
- registerAll(server: McpServer, subscriptions?: ResourceSubscriptions, bus?: ServerNotifier, inputGate?: InputRequiredGate): Promise<void>;
21
+ registerAll(server: McpServer, subscriptions?: ResourceSubscriptions, bus?: ServerNotifier, capabilities?: ClientCapabilityView): Promise<void>;
20
22
  /** Throws at startup if a resource with the same name was already registered. */
21
23
  private assertUniqueName;
22
24
  private registerResource;
@@ -1 +1 @@
1
- {"version":3,"file":"resource-registration.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/resources/resource-registration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAChG,OAAO,EAEL,KAAK,eAAe,EAErB,MAAM,wDAAwD,CAAC;AAUhE,qBAAa,gBAAgB;IAKzB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,QAAQ;IALlB,wEAAwE;IACxE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqB;IAErD,YACU,YAAY,EAAE,qBAAqB,EAAE,EACrC,QAAQ,EAAE,eAAe,EAC/B;IAEJ;;OAEG;IACU,WAAW,CACtB,MAAM,EAAE,SAAS,EACjB,aAAa,CAAC,EAAE,qBAAqB,EACrC,GAAG,CAAC,EAAE,cAAc,EACpB,SAAS,CAAC,EAAE,iBAAiB,GAC5B,OAAO,CAAC,IAAI,CAAC,CA4Bf;IAED,iFAAiF;IACjF,OAAO,CAAC,gBAAgB;YAUV,gBAAgB;CAyD/B"}
1
+ {"version":3,"file":"resource-registration.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/resources/resource-registration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAChG,OAAO,EAEL,KAAK,eAAe,EAErB,MAAM,wDAAwD,CAAC;AAUhE,qBAAa,gBAAgB;IAKzB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,QAAQ;IALlB,wEAAwE;IACxE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqB;IAErD,YACU,YAAY,EAAE,qBAAqB,EAAE,EACrC,QAAQ,EAAE,eAAe,EAC/B;IAEJ;;;;OAIG;IACU,WAAW,CACtB,MAAM,EAAE,SAAS,EACjB,aAAa,CAAC,EAAE,qBAAqB,EACrC,GAAG,CAAC,EAAE,cAAc,EACpB,YAAY,CAAC,EAAE,oBAAoB,GAClC,OAAO,CAAC,IAAI,CAAC,CA4Bf;IAED,iFAAiF;IACjF,OAAO,CAAC,gBAAgB;YAUV,gBAAgB;CAyD/B"}
@@ -22,8 +22,10 @@ export class ResourceRegistry {
22
22
  }
23
23
  /**
24
24
  * Registers all resolved resource definitions with the provided McpServer instance.
25
+ * `capabilities` is the instance's view of what its client declared (#580),
26
+ * which every handler context resolves per request.
25
27
  */
26
- async registerAll(server, subscriptions, bus, inputGate) {
28
+ async registerAll(server, subscriptions, bus, capabilities) {
27
29
  this.registeredNames.clear();
28
30
  // Per-server notifier closures targeting `server.send*ListChanged()`. Bound
29
31
  // once per registerAll() call — never mutated on a shared services object
@@ -45,7 +47,7 @@ export class ResourceRegistry {
45
47
  // declared `resources` capability, so a server with no resources still
46
48
  // answers `resources/list` with an empty array rather than `-32601`.
47
49
  for (const resourceDef of this.resourceDefs) {
48
- await this.registerResource(server, resourceDef, notifiers, inputGate);
50
+ await this.registerResource(server, resourceDef, notifiers, capabilities);
49
51
  }
50
52
  }
51
53
  /** Throws at startup if a resource with the same name was already registered. */
@@ -56,7 +58,7 @@ export class ResourceRegistry {
56
58
  }
57
59
  this.registeredNames.add(name);
58
60
  }
59
- async registerResource(server, def, notifiers, inputGate) {
61
+ async registerResource(server, def, notifiers, capabilities) {
60
62
  const resourceName = def.name ?? def.uriTemplate;
61
63
  const registrationContext = requestContextService.createRequestContext({
62
64
  operation: 'ResourceRegistry.registerResource',
@@ -65,7 +67,7 @@ export class ResourceRegistry {
65
67
  logger.debug(`Registering resource: '${resourceName}'`, registrationContext);
66
68
  this.assertUniqueName(resourceName);
67
69
  await ErrorHandler.tryCatch(() => {
68
- const handler = createResourceHandler(def, this.services, notifiers, inputGate);
70
+ const handler = createResourceHandler(def, this.services, notifiers, capabilities);
69
71
  const title = def.title ?? resourceName;
70
72
  const mimeType = def.mimeType ?? 'application/json';
71
73
  const metadata = {
@@ -1 +1 @@
1
- {"version":3,"file":"resource-registration.js","sourceRoot":"","sources":["../../../src/mcp-server/resources/resource-registration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAEL,gBAAgB,GAEjB,MAAM,8BAA8B,CAAC;AAKtC,OAAO,EACL,qBAAqB,GAGtB,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,SAAS,uBAAuB,CAAC,WAAmB;IAClD,OAAO,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,OAAO,gBAAgB;IAKjB,YAAY;IACZ,QAAQ;IALl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,CAAC;YACJ,CAAC;YAED,MAAM,CAAC,KAAK,CAAC,aAAa,YAAY,4BAA4B,EAAE,mBAAmB,CAAC,CAAC;QAC3F,CAAC,EACD;YACE,SAAS,EAAE,uBAAuB,YAAY,EAAE;YAChD,OAAO,EAAE,mBAAmB;YAC5B,SAAS,EAAE,gBAAgB,CAAC,oBAAoB;YAChD,QAAQ,EAAE,IAAI;SACf,CACF,CAAC;IACJ,CAAC;CACF"}
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import type { InputRequiredResult, ReadResourceResult, ServerContext, Variables } from '@modelcontextprotocol/server';
7
7
  import { type HandlerServices } from '../../handlerContext.js';
8
- import { type InputRequiredGate } from '../../inputRequired.js';
8
+ import { type ClientCapabilityView } from '../../inputRequired.js';
9
9
  import type { NotifierSources } from '../../notifications.js';
10
10
  import type { AnyResourceDefinition } from './resourceDefinition.js';
11
11
  /** The factory's own contract, shared with the tool factory. */
@@ -30,7 +30,8 @@ export declare function defaultResponseFormatter(result: unknown, meta: {
30
30
  * - Checks inline `auth` scopes if defined
31
31
  * - Validates params via Zod schema
32
32
  * - Formats response via `format` or JSON default
33
- * - Catches errors and re-throws for the SDK
33
+ * - Catches errors and re-throws for the SDK, with the declared recovery filled
34
+ * (#579) and the read's request id added (#576)
34
35
  */
35
- export declare function createResourceHandler(def: AnyResourceDefinition, services: HandlerServices, notifiers: NotifierSources, inputGate?: InputRequiredGate): (uri: URL, variables: Variables, ctx: ServerContext) => Promise<ReadResourceResult | InputRequiredResult>;
36
+ export declare function createResourceHandler(def: AnyResourceDefinition, services: HandlerServices, notifiers: NotifierSources, capabilities?: ClientCapabilityView): (uri: URL, variables: Variables, ctx: ServerContext) => Promise<ReadResourceResult | InputRequiredResult>;
36
37
  //# sourceMappingURL=resourceHandlerFactory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resourceHandlerFactory.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/resources/utils/resourceHandlerFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,SAAS,EACV,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAEL,KAAK,eAAe,EAGrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,KAAK,iBAAiB,EAAyB,MAAM,+BAA+B,CAAC;AAC9F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAWhG,gEAAgE;AAChE,YAAY,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,YAAY,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAiBrE;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,OAAO,EACf,IAAI,EAAE;IAAE,GAAG,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACnC,kBAAkB,CAAC,UAAU,CAAC,CAShC;AAkBD;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,qBAAqB,EAC1B,QAAQ,EAAE,eAAe,EACzB,SAAS,EAAE,eAAe,EAC1B,SAAS,CAAC,EAAE,iBAAiB,GAC5B,CACD,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,aAAa,KACf,OAAO,CAAC,kBAAkB,GAAG,mBAAmB,CAAC,CA8FrD"}
1
+ {"version":3,"file":"resourceHandlerFactory.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/resources/utils/resourceHandlerFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,SAAS,EACV,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAEL,KAAK,eAAe,EAGrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,KAAK,oBAAoB,EAG1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAWhG,gEAAgE;AAChE,YAAY,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,YAAY,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAiBrE;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,OAAO,EACf,IAAI,EAAE;IAAE,GAAG,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACnC,kBAAkB,CAAC,UAAU,CAAC,CAShC;AA6BD;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,qBAAqB,EAC1B,QAAQ,EAAE,eAAe,EACzB,SAAS,EAAE,eAAe,EAC1B,YAAY,CAAC,EAAE,oBAAoB,GAClC,CACD,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,aAAa,KACf,OAAO,CAAC,kBAAkB,GAAG,mBAAmB,CAAC,CAiGrD"}