@qase/mcp-server 2.7.5 → 3.0.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 (121) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +17 -11
  3. package/build/auth/mcp-guard.d.ts.map +1 -1
  4. package/build/auth/mcp-guard.js +1 -1
  5. package/build/auth/mcp-guard.js.map +1 -1
  6. package/build/cache/metrics.js +2 -0
  7. package/build/cache/metrics.js.map +1 -1
  8. package/build/index.js +27 -5
  9. package/build/index.js.map +1 -1
  10. package/build/operations-v2/composites/ci-report.js +3 -5
  11. package/build/operations-v2/composites/ci-report.js.map +1 -1
  12. package/build/operations-v2/composites/regression-run.js +2 -1
  13. package/build/operations-v2/composites/regression-run.js.map +1 -1
  14. package/build/operations-v2/composites/triage-defect.js +5 -7
  15. package/build/operations-v2/composites/triage-defect.js.map +1 -1
  16. package/build/operations-v2/escape/api.js +11 -4
  17. package/build/operations-v2/escape/api.js.map +1 -1
  18. package/build/operations-v2/index.d.ts +1 -0
  19. package/build/operations-v2/index.d.ts.map +1 -1
  20. package/build/operations-v2/index.js +1 -0
  21. package/build/operations-v2/index.js.map +1 -1
  22. package/build/operations-v2/meta/discover.d.ts +5 -4
  23. package/build/operations-v2/meta/discover.d.ts.map +1 -1
  24. package/build/operations-v2/meta/discover.js +13 -32
  25. package/build/operations-v2/meta/discover.js.map +1 -1
  26. package/build/operations-v2/meta/tool-help.d.ts +10 -0
  27. package/build/operations-v2/meta/tool-help.d.ts.map +1 -0
  28. package/build/operations-v2/meta/tool-help.js +42 -0
  29. package/build/operations-v2/meta/tool-help.js.map +1 -0
  30. package/build/operations-v2/qql/index.js +15 -9
  31. package/build/operations-v2/qql/index.js.map +1 -1
  32. package/build/operations-v2/read/get.js +2 -1
  33. package/build/operations-v2/read/get.js.map +1 -1
  34. package/build/operations-v2/read/project-context.js +5 -6
  35. package/build/operations-v2/read/project-context.js.map +1 -1
  36. package/build/operations-v2/write/attachments.js +16 -21
  37. package/build/operations-v2/write/attachments.js.map +1 -1
  38. package/build/operations-v2/write/case-fields.d.ts +26 -215
  39. package/build/operations-v2/write/case-fields.d.ts.map +1 -1
  40. package/build/operations-v2/write/case-fields.js +28 -24
  41. package/build/operations-v2/write/case-fields.js.map +1 -1
  42. package/build/operations-v2/write/cases-bulk.js +2 -1
  43. package/build/operations-v2/write/cases-bulk.js.map +1 -1
  44. package/build/operations-v2/write/cases.js +4 -3
  45. package/build/operations-v2/write/cases.js.map +1 -1
  46. package/build/operations-v2/write/custom-fields.js +13 -10
  47. package/build/operations-v2/write/custom-fields.js.map +1 -1
  48. package/build/operations-v2/write/defects.js +7 -9
  49. package/build/operations-v2/write/defects.js.map +1 -1
  50. package/build/operations-v2/write/environments.js +5 -5
  51. package/build/operations-v2/write/environments.js.map +1 -1
  52. package/build/operations-v2/write/external-issues.js +2 -2
  53. package/build/operations-v2/write/external-issues.js.map +1 -1
  54. package/build/operations-v2/write/milestones.js +6 -6
  55. package/build/operations-v2/write/milestones.js.map +1 -1
  56. package/build/operations-v2/write/plans.js +5 -5
  57. package/build/operations-v2/write/plans.js.map +1 -1
  58. package/build/operations-v2/write/projects.js +9 -8
  59. package/build/operations-v2/write/projects.js.map +1 -1
  60. package/build/operations-v2/write/results.js +7 -12
  61. package/build/operations-v2/write/results.js.map +1 -1
  62. package/build/operations-v2/write/reviews.js +18 -18
  63. package/build/operations-v2/write/reviews.js.map +1 -1
  64. package/build/operations-v2/write/runs.js +8 -6
  65. package/build/operations-v2/write/runs.js.map +1 -1
  66. package/build/operations-v2/write/shared-steps.js +5 -8
  67. package/build/operations-v2/write/shared-steps.js.map +1 -1
  68. package/build/operations-v2/write/suites.js +4 -3
  69. package/build/operations-v2/write/suites.js.map +1 -1
  70. package/build/server-instructions.d.ts +1 -1
  71. package/build/server-instructions.d.ts.map +1 -1
  72. package/build/server-instructions.js +4 -4
  73. package/build/server.d.ts.map +1 -1
  74. package/build/server.js +154 -104
  75. package/build/server.js.map +1 -1
  76. package/build/transports/body-limit.d.ts +9 -17
  77. package/build/transports/body-limit.d.ts.map +1 -1
  78. package/build/transports/body-limit.js +18 -2
  79. package/build/transports/body-limit.js.map +1 -1
  80. package/build/transports/rate-limit.d.ts +1 -1
  81. package/build/transports/rate-limit.js +1 -1
  82. package/build/transports/sse.js +1 -1
  83. package/build/transports/sse.js.map +1 -1
  84. package/build/transports/streamableHttp.d.ts.map +1 -1
  85. package/build/transports/streamableHttp.js +83 -171
  86. package/build/transports/streamableHttp.js.map +1 -1
  87. package/build/utils/auth-context.d.ts +30 -0
  88. package/build/utils/auth-context.d.ts.map +1 -1
  89. package/build/utils/auth-context.js +33 -0
  90. package/build/utils/auth-context.js.map +1 -1
  91. package/build/utils/errors.js +3 -3
  92. package/build/utils/errors.js.map +1 -1
  93. package/build/utils/protocol-telemetry.d.ts +62 -0
  94. package/build/utils/protocol-telemetry.d.ts.map +1 -0
  95. package/build/utils/protocol-telemetry.js +123 -0
  96. package/build/utils/protocol-telemetry.js.map +1 -0
  97. package/build/utils/registry.d.ts +28 -34
  98. package/build/utils/registry.d.ts.map +1 -1
  99. package/build/utils/registry.js +107 -102
  100. package/build/utils/registry.js.map +1 -1
  101. package/build/utils/request-state.d.ts +71 -0
  102. package/build/utils/request-state.d.ts.map +1 -0
  103. package/build/utils/request-state.js +108 -0
  104. package/build/utils/request-state.js.map +1 -0
  105. package/build/utils/server-context.d.ts +53 -16
  106. package/build/utils/server-context.d.ts.map +1 -1
  107. package/build/utils/server-context.js +147 -39
  108. package/build/utils/server-context.js.map +1 -1
  109. package/build/utils/validation.d.ts +12 -25
  110. package/build/utils/validation.d.ts.map +1 -1
  111. package/build/utils/validation.js +2 -2
  112. package/build/utils/validation.js.map +1 -1
  113. package/build/version.d.ts +1 -1
  114. package/build/version.js +1 -1
  115. package/docs/connect.md +23 -7
  116. package/docs/migration.md +182 -10
  117. package/docs/self-run.md +50 -7
  118. package/docs/tools.md +54 -60
  119. package/docs/troubleshooting.md +43 -16
  120. package/package.json +11 -12
  121. package/server.json +2 -2
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Multi-round-trip request state.
3
+ *
4
+ * A destructive confirmation now spans two requests: the first returns an
5
+ * input-required result, the second carries the answer. Nothing on the server
6
+ * remembers the first one — the only thing that connects them is the opaque
7
+ * `requestState` string the client echoes back.
8
+ */
9
+ import type { RequestStateCodec } from '@modelcontextprotocol/server';
10
+ /** What a pending destructive confirmation carries across the round trip. */
11
+ export interface ConfirmationState {
12
+ /** The tool the confirmation was issued for; an answer only counts for it. */
13
+ tool: string;
14
+ /**
15
+ * Digest of the arguments the human was shown.
16
+ *
17
+ * The tool name alone does not say WHAT was confirmed. Without this, an
18
+ * accepted `qase_case_delete {code:'TEST', id:1}` could be echoed back
19
+ * unchanged against `{code:'PROD', id:999}` for the whole lifetime of the
20
+ * state — same caller, same tool, valid signature — and the second case
21
+ * would be deleted with nobody asked. The client here is the agent, and
22
+ * stopping exactly that is what this gate is for.
23
+ */
24
+ arguments: string;
25
+ }
26
+ /**
27
+ * How long a confirmation stays answerable.
28
+ *
29
+ * This is a human's thinking time, not a protocol timeout: the prompt is in
30
+ * front of a person deciding whether to delete something. Ten minutes is long
31
+ * enough to read the arguments, check them elsewhere and come back, and short
32
+ * enough that an answer given before lunch is not still spendable after it.
33
+ * It is the SDK's own default, stated here because it is a policy decision
34
+ * rather than an implementation detail.
35
+ */
36
+ export declare const CONFIRMATION_TTL_SECONDS = 600;
37
+ /**
38
+ * Digest of a call's arguments, for pinning a confirmation to the exact call
39
+ * the human saw.
40
+ *
41
+ * Canonical: keys are sorted at every depth, so `{a:1,b:2}` and `{b:2,a:1}`
42
+ * agree — the same call written two ways is the same call, and a client that
43
+ * re-serialises its arguments between rounds must not be told its answer no
44
+ * longer counts. Array order is preserved, because it is part of the value.
45
+ */
46
+ export declare function digestArguments(args: Record<string, unknown>): string;
47
+ /**
48
+ * requestState round-trips through the client, so it comes back as
49
+ * attacker-controlled input and has to be integrity-checked. The SDK does not
50
+ * do that for us — this is the HMAC layer it expects.
51
+ *
52
+ * The key must be the same on every replica that might receive the echoed
53
+ * value. Without one we generate a random key and say so: a single replica
54
+ * keeps working, a multi-replica deployment would reject its own second round.
55
+ *
56
+ * `bind` ties a minted confirmation to the caller and the method, so a
57
+ * confirmation issued to one authenticated user cannot be replayed by another
58
+ * — the spec's user-binding requirement for state that gates authorization.
59
+ * The binding value never reaches the wire; the codec stores a keyed tag.
60
+ * The caller identity comes from `subjectFromContext` (auth-context.ts) — the
61
+ * same derivation tool activation uses — so a caller with no OAuth `sub` is
62
+ * bound by their per-request token digest rather than collapsing onto one
63
+ * shared, empty binding for everyone.
64
+ */
65
+ export declare function createRequestStateCodecFromEnv(env?: typeof process.env): RequestStateCodec<ConfirmationState>;
66
+ /**
67
+ * Lazy for the same reason as the event bus and the activation store:
68
+ * importing the module must not build anything and must not write to stderr.
69
+ */
70
+ export declare function getRequestStateCodec(): RequestStateCodec<ConfirmationState>;
71
+ //# sourceMappingURL=request-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-state.d.ts","sourceRoot":"","sources":["../../src/utils/request-state.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,8BAA8B,CAAC;AAGrF,6EAA6E;AAC7E,MAAM,WAAW,iBAAiB;IAChC,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;;;;OASG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAID;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,MAAM,CAAC;AA4B5C;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAIrE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,8BAA8B,CAC5C,GAAG,GAAE,OAAO,OAAO,CAAC,GAAiB,GACpC,iBAAiB,CAAC,iBAAiB,CAAC,CAmBtC;AAKD;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,iBAAiB,CAAC,iBAAiB,CAAC,CAG3E"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Multi-round-trip request state.
3
+ *
4
+ * A destructive confirmation now spans two requests: the first returns an
5
+ * input-required result, the second carries the answer. Nothing on the server
6
+ * remembers the first one — the only thing that connects them is the opaque
7
+ * `requestState` string the client echoes back.
8
+ */
9
+ import { createHash, randomBytes } from 'node:crypto';
10
+ import { createRequestStateCodec } from '@modelcontextprotocol/server';
11
+ import { subjectFromContext } from './auth-context.js';
12
+ const MIN_KEY_BYTES = 32;
13
+ /**
14
+ * How long a confirmation stays answerable.
15
+ *
16
+ * This is a human's thinking time, not a protocol timeout: the prompt is in
17
+ * front of a person deciding whether to delete something. Ten minutes is long
18
+ * enough to read the arguments, check them elsewhere and come back, and short
19
+ * enough that an answer given before lunch is not still spendable after it.
20
+ * It is the SDK's own default, stated here because it is a policy decision
21
+ * rather than an implementation detail.
22
+ */
23
+ export const CONFIRMATION_TTL_SECONDS = 600;
24
+ /**
25
+ * Order two keys by code unit, NOT by `localeCompare`.
26
+ *
27
+ * This ordering feeds a digest that two replicas must agree on, and
28
+ * `localeCompare` depends on the runtime's locale data — it could order the
29
+ * same two keys differently on two machines and refuse a confirmation the
30
+ * user actually gave.
31
+ */
32
+ function byCodeUnit(a, b) {
33
+ if (a < b)
34
+ return -1;
35
+ if (a > b)
36
+ return 1;
37
+ return 0;
38
+ }
39
+ /** Recursively sort object keys so two spellings of one value serialise alike. */
40
+ function canonicalize(value) {
41
+ if (Array.isArray(value))
42
+ return value.map(canonicalize);
43
+ if (value === null || typeof value !== 'object')
44
+ return value;
45
+ const source = value;
46
+ return Object.fromEntries(Object.keys(source)
47
+ .sort(byCodeUnit)
48
+ .map((key) => [key, canonicalize(source[key])]));
49
+ }
50
+ /**
51
+ * Digest of a call's arguments, for pinning a confirmation to the exact call
52
+ * the human saw.
53
+ *
54
+ * Canonical: keys are sorted at every depth, so `{a:1,b:2}` and `{b:2,a:1}`
55
+ * agree — the same call written two ways is the same call, and a client that
56
+ * re-serialises its arguments between rounds must not be told its answer no
57
+ * longer counts. Array order is preserved, because it is part of the value.
58
+ */
59
+ export function digestArguments(args) {
60
+ return createHash('sha256')
61
+ .update(JSON.stringify(canonicalize(args)))
62
+ .digest('hex');
63
+ }
64
+ /**
65
+ * requestState round-trips through the client, so it comes back as
66
+ * attacker-controlled input and has to be integrity-checked. The SDK does not
67
+ * do that for us — this is the HMAC layer it expects.
68
+ *
69
+ * The key must be the same on every replica that might receive the echoed
70
+ * value. Without one we generate a random key and say so: a single replica
71
+ * keeps working, a multi-replica deployment would reject its own second round.
72
+ *
73
+ * `bind` ties a minted confirmation to the caller and the method, so a
74
+ * confirmation issued to one authenticated user cannot be replayed by another
75
+ * — the spec's user-binding requirement for state that gates authorization.
76
+ * The binding value never reaches the wire; the codec stores a keyed tag.
77
+ * The caller identity comes from `subjectFromContext` (auth-context.ts) — the
78
+ * same derivation tool activation uses — so a caller with no OAuth `sub` is
79
+ * bound by their per-request token digest rather than collapsing onto one
80
+ * shared, empty binding for everyone.
81
+ */
82
+ export function createRequestStateCodecFromEnv(env = process.env) {
83
+ const configured = env.QASE_MCP_REQUEST_STATE_KEY;
84
+ if (configured !== undefined && Buffer.byteLength(configured) < MIN_KEY_BYTES) {
85
+ throw new Error(`QASE_MCP_REQUEST_STATE_KEY must be at least ${MIN_KEY_BYTES} bytes; got ${Buffer.byteLength(configured)}.`);
86
+ }
87
+ if (!configured) {
88
+ console.error('[RequestState] QASE_MCP_REQUEST_STATE_KEY is not set — generating a per-process key. ' +
89
+ 'Multi-round-trip confirmations will fail across replicas; set the variable to a shared ' +
90
+ 'value of at least 32 bytes before running more than one.');
91
+ }
92
+ return createRequestStateCodec({
93
+ key: configured ?? randomBytes(MIN_KEY_BYTES),
94
+ ttlSeconds: CONFIRMATION_TTL_SECONDS,
95
+ bind: (ctx) => `${ctx.mcpReq.method}\0${subjectFromContext(ctx)}`,
96
+ });
97
+ }
98
+ /** The one codec this process mints and verifies with, built on first use. */
99
+ let processCodec;
100
+ /**
101
+ * Lazy for the same reason as the event bus and the activation store:
102
+ * importing the module must not build anything and must not write to stderr.
103
+ */
104
+ export function getRequestStateCodec() {
105
+ processCodec ??= createRequestStateCodecFromEnv();
106
+ return processCodec;
107
+ }
108
+ //# sourceMappingURL=request-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-state.js","sourceRoot":"","sources":["../../src/utils/request-state.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAmBvD,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C;;;;;;;GAOG;AACH,SAAS,UAAU,CAAC,CAAS,EAAE,CAAS;IACtC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC;IACrB,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IACpB,OAAO,CAAC,CAAC;AACX,CAAC;AAED,kFAAkF;AAClF,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACzD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,MAAM,GAAG,KAAgC,CAAC;IAChD,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;SAChB,IAAI,CAAC,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CAAC;IAClD,OAAO,YAAY,CAAC;AACtB,CAAC"}
@@ -1,14 +1,17 @@
1
1
  /**
2
2
  * Server Context
3
3
  *
4
- * Provides access to the MCP Server instance within tool handlers
5
- * via AsyncLocalStorage, following the same pattern as auth-context.ts.
4
+ * Per-request context for code that sits too far below a request handler to be
5
+ * passed it, carried through AsyncLocalStorage the same way auth-context.ts
6
+ * carries the caller's subject.
6
7
  *
7
- * This enables features that require server-level access (elicitation,
8
- * tool list notifications) without passing the server through handler signatures.
8
+ * Two stores live here: the MCP `Server` instance (for server-level features)
9
+ * and the handler's own `ServerContext`, which is what the destructive-action
10
+ * gate needs — it reads the retry's answers, the verified request state, and
11
+ * the protocol era off it.
9
12
  */
10
13
  import { AsyncLocalStorage } from 'async_hooks';
11
- import type { Server, RequestId } from '@modelcontextprotocol/server';
14
+ import type { InputRequiredResult, Server, ServerContext } from '@modelcontextprotocol/server';
12
15
  /**
13
16
  * Per-request server storage.
14
17
  * Holds the Server instance for the current request context.
@@ -19,14 +22,45 @@ export declare const serverStorage: AsyncLocalStorage<Server>;
19
22
  * Returns undefined if called outside of a serverStorage.run() scope.
20
23
  */
21
24
  export declare function getServer(): Server | undefined;
25
+ /** Per-request handler context, for code too far below the handler to be passed it. */
26
+ export declare const requestContextStorage: AsyncLocalStorage<ServerContext>;
27
+ /**
28
+ * Get the current request's handler context.
29
+ * Returns undefined if called outside of a requestContextStorage.run() scope.
30
+ */
31
+ export declare function getRequestContext(): ServerContext | undefined;
32
+ /**
33
+ * Thrown by the destructive-action gate to hand an input-required result up to
34
+ * the `tools/call` handler.
35
+ *
36
+ * Multi-round-trip works by RETURNING the request, but the gate is called from
37
+ * inside plain tool handlers (`(args) => Promise<R>`) several frames below the
38
+ * handler that does the returning — see src/operations-v2/escape/api.ts. An
39
+ * exception is the only way up that does not change every handler's signature.
40
+ */
41
+ export declare class InputRequiredSignal extends Error {
42
+ readonly result: InputRequiredResult;
43
+ constructor(result: InputRequiredResult);
44
+ }
22
45
  /** Why a destructive action was refused. */
23
46
  export type RefusalReason =
24
- /** The client cannot show a confirmation prompt at all. */
47
+ /** The client speaks an era on which this server cannot ask at all. */
25
48
  'unsupported'
26
- /** The prompt was sent but no answer came back (dropped, timed out). */
49
+ /** The client speaks the right era but never said it can show a prompt. */
50
+ | 'incapable'
51
+ /** The prompt was sent but no usable answer came back for this action. */
27
52
  | 'undeliverable'
28
53
  /** The human saw the prompt and said no. */
29
- | 'declined';
54
+ | 'declined'
55
+ /**
56
+ * The client dropped the prompt instead of answering it.
57
+ *
58
+ * Kept apart from `declined` deliberately. Reporting a cancel as a refusal
59
+ * tells somebody they said no to a question they were never shown — which
60
+ * is exactly how this reached us: a tester was told they had declined a run
61
+ * deletion they had never been asked about.
62
+ */
63
+ | 'cancelled';
30
64
  /** Outcome of the destructive-action gate. */
31
65
  export type DestructiveConfirmation = {
32
66
  allowed: true;
@@ -35,17 +69,20 @@ export type DestructiveConfirmation = {
35
69
  reason: RefusalReason;
36
70
  };
37
71
  /**
38
- * Ask the user to confirm a destructive action via MCP elicitation.
72
+ * Ask the user to confirm a destructive action, across a round trip.
39
73
  *
40
- * Fail-closed: the action proceeds only on an explicit yes. Anything else —
41
- * no server, no elicitation capability, an undelivered prompt, a decline —
42
- * refuses and names the reason, so the caller can say what happened.
74
+ * On the first round there is no answer, so the gate signals an input-required
75
+ * result and the `tools/call` handler returns it; the client collects the
76
+ * answer and retries the same call carrying it. On the retry the answer is
77
+ * read straight off the request.
43
78
  *
44
- * `relatedRequestId` is what makes the prompt arrive: without it the SDK sends
45
- * the request on the standalone SSE stream (opened by `GET /mcp`), which MCP
46
- * clients do not open, and the prompt is silently dropped.
79
+ * Fail-closed: the action proceeds only on an explicit accept whose signed
80
+ * state names this very call — this tool, with these arguments. No request
81
+ * context, a client on a protocol revision this server cannot ask, a decline,
82
+ * a cancel, an answer belonging to some other confirmation — all refuse, and
83
+ * name the reason so the caller can say what happened.
47
84
  */
48
- export declare function confirmDestructiveAction(toolName: string, args: Record<string, unknown>, relatedRequestId?: RequestId): Promise<DestructiveConfirmation>;
85
+ export declare function confirmDestructiveAction(toolName: string, args: Record<string, unknown>): Promise<DestructiveConfirmation>;
49
86
  /** Human-readable explanation for a refused destructive action. */
50
87
  export declare function describeRefusal(toolName: string, reason: RefusalReason): string;
51
88
  //# sourceMappingURL=server-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server-context.d.ts","sourceRoot":"","sources":["../../src/utils/server-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEtE;;;GAGG;AACH,eAAO,MAAM,aAAa,2BAAkC,CAAC;AAE7D;;;GAGG;AACH,wBAAgB,SAAS,IAAI,MAAM,GAAG,SAAS,CAE9C;AAED,4CAA4C;AAC5C,MAAM,MAAM,aAAa;AACvB,2DAA2D;AACzD,aAAa;AACf,wEAAwE;GACtE,eAAe;AACjB,4CAA4C;GAC1C,UAAU,CAAC;AAEf,8CAA8C;AAC9C,MAAM,MAAM,uBAAuB,GAAG;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAE,CAAC;AAIpG;;;;;;;;;;GAUG;AACH,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,gBAAgB,CAAC,EAAE,SAAS,GAC3B,OAAO,CAAC,uBAAuB,CAAC,CAiClC;AAED,mEAAmE;AACnE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM,CAgB/E"}
1
+ {"version":3,"file":"server-context.d.ts","sourceRoot":"","sources":["../../src/utils/server-context.ts"],"names":[],"mappings":"A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
- * via AsyncLocalStorage, following the same pattern as auth-context.ts.
4
+ * Per-request context for code that sits too far below a request handler to be
5
+ * passed it, carried through AsyncLocalStorage the same way auth-context.ts
6
+ * carries the caller's subject.
6
7
  *
7
- * This enables features that require server-level access (elicitation,
8
- * tool list notifications) without passing the server through handler signatures.
8
+ * Two stores live here: the MCP `Server` instance (for server-level features)
9
+ * and the handler's own `ServerContext`, which is what the destructive-action
10
+ * gate needs — it reads the retry's answers, the verified request state, and
11
+ * the protocol era off it.
9
12
  */
10
13
  import { AsyncLocalStorage } from 'async_hooks';
14
+ import { CLIENT_CAPABILITIES_META_KEY, inputRequired, inputResponse, } from '@modelcontextprotocol/server';
15
+ import { digestArguments, getRequestStateCodec } from './request-state.js';
11
16
  /**
12
17
  * Per-request server storage.
13
18
  * Holds the Server instance for the current request context.
@@ -20,59 +25,162 @@ export const serverStorage = new AsyncLocalStorage();
20
25
  export function getServer() {
21
26
  return serverStorage.getStore();
22
27
  }
28
+ /** Per-request handler context, for code too far below the handler to be passed it. */
29
+ export const requestContextStorage = new AsyncLocalStorage();
30
+ /**
31
+ * Get the current request's handler context.
32
+ * Returns undefined if called outside of a requestContextStorage.run() scope.
33
+ */
34
+ export function getRequestContext() {
35
+ return requestContextStorage.getStore();
36
+ }
37
+ /** The key the confirmation request and its answer are correlated by. */
38
+ const CONFIRM_KEY = 'confirm';
39
+ /**
40
+ * Thrown by the destructive-action gate to hand an input-required result up to
41
+ * the `tools/call` handler.
42
+ *
43
+ * Multi-round-trip works by RETURNING the request, but the gate is called from
44
+ * inside plain tool handlers (`(args) => Promise<R>`) several frames below the
45
+ * handler that does the returning — see src/operations-v2/escape/api.ts. An
46
+ * exception is the only way up that does not change every handler's signature.
47
+ */
48
+ export class InputRequiredSignal extends Error {
49
+ result;
50
+ constructor(result) {
51
+ super('input required');
52
+ this.result = result;
53
+ this.name = 'InputRequiredSignal';
54
+ }
55
+ }
23
56
  const REFUSED_UNSUPPORTED = { allowed: false, reason: 'unsupported' };
57
+ const REFUSED_INCAPABLE = { allowed: false, reason: 'incapable' };
24
58
  /**
25
- * Ask the user to confirm a destructive action via MCP elicitation.
59
+ * Whether a 2026 request's own envelope says the client can be shown a form.
26
60
  *
27
- * Fail-closed: the action proceeds only on an explicit yes. Anything else —
28
- * no server, no elicitation capability, an undelivered prompt, a decline —
29
- * refuses and names the reason, so the caller can say what happened.
61
+ * The capability is per request, not per connection: the SDK refuses to send
62
+ * an input request a client never declared it can handle, and does so by
63
+ * throwing. Reading the same declaration ourselves turns that into an answer
64
+ * the caller can act on instead of an exception from inside the transport.
65
+ */
66
+ function clientCanBeAsked(envelope) {
67
+ const declared = envelope[CLIENT_CAPABILITIES_META_KEY];
68
+ return declared?.elicitation !== undefined;
69
+ }
70
+ /**
71
+ * Ask the user to confirm a destructive action, across a round trip.
30
72
  *
31
- * `relatedRequestId` is what makes the prompt arrive: without it the SDK sends
32
- * the request on the standalone SSE stream (opened by `GET /mcp`), which MCP
33
- * clients do not open, and the prompt is silently dropped.
73
+ * On the first round there is no answer, so the gate signals an input-required
74
+ * result and the `tools/call` handler returns it; the client collects the
75
+ * answer and retries the same call carrying it. On the retry the answer is
76
+ * read straight off the request.
77
+ *
78
+ * Fail-closed: the action proceeds only on an explicit accept whose signed
79
+ * state names this very call — this tool, with these arguments. No request
80
+ * context, a client on a protocol revision this server cannot ask, a decline,
81
+ * a cancel, an answer belonging to some other confirmation — all refuse, and
82
+ * name the reason so the caller can say what happened.
34
83
  */
35
- export async function confirmDestructiveAction(toolName, args, relatedRequestId) {
36
- const server = getServer();
37
- if (!server)
38
- return REFUSED_UNSUPPORTED;
39
- // Check if the client supports elicitation
40
- const caps = server.getClientCapabilities();
41
- if (!caps?.elicitation)
84
+ export async function confirmDestructiveAction(toolName, args) {
85
+ const ctx = getRequestContext();
86
+ if (!ctx)
42
87
  return REFUSED_UNSUPPORTED;
43
- try {
44
- const argsPreview = Object.entries(args)
45
- .map(([k, v]) => ` ${k}: ${JSON.stringify(v)}`)
46
- .join('\n');
47
- const result = await server.elicitInput({
48
- message: `Confirm destructive action: ${toolName}\n\n${argsPreview}\n\n` +
49
- 'This permanently deletes the resource and cannot be undone.',
50
- // No fields to fill in: accepting the prompt is the confirmation, and
51
- // the client's own decline button is the refusal. A checkbox on top of
52
- // that only produced false refusals — people accepted the dialog and
53
- // left the box at its default.
54
- requestedSchema: { type: 'object', properties: {} },
55
- }, relatedRequestId === undefined ? undefined : { relatedRequestId });
56
- return result.action === 'accept' ? { allowed: true } : { allowed: false, reason: 'declined' };
88
+ // Round two: the client came back with an answer. `inputResponse` is what
89
+ // separates a refusal from a missing answer — `acceptedContent` reads both
90
+ // as "nothing", which would send a decline round the loop again until it hit
91
+ // the client's maxRounds.
92
+ const answer = inputResponse(ctx.mcpReq.inputResponses, CONFIRM_KEY);
93
+ if (answer.kind === 'elicit') {
94
+ // The state was already verified by the seam before this handler ran — it
95
+ // is this process's own, for this caller, unexpired. What is left is that
96
+ // the answer belongs to THIS call: the same tool, and the same arguments
97
+ // the human was shown. Neither alone is enough. Without the tool, one
98
+ // confirmation would open every destructive tool; without the arguments,
99
+ // one confirmed deletion would authorise every other deletion by the same
100
+ // tool until the state expired.
101
+ //
102
+ // A plain string comparison, not `timingSafeEqual`: both operands are
103
+ // public values derived from arguments the caller itself sent, and the one
104
+ // from the wire is already integrity-proven, so there is no secret for a
105
+ // timing difference to leak. `timingSafeEqual` would also throw on a
106
+ // length mismatch, which is a shape this has to answer rather than crash.
107
+ const state = ctx.mcpReq.requestState();
108
+ if (state?.tool !== toolName || state.arguments !== digestArguments(args)) {
109
+ // Not a decline: the human never saw these arguments, so nobody said no
110
+ // — and nobody said yes either. Unconfirmed, nothing deleted.
111
+ return { allowed: false, reason: 'undeliverable' };
112
+ }
113
+ if (answer.action === 'accept')
114
+ return { allowed: true };
115
+ // `cancel` is the client dropping the question, `decline` is a person
116
+ // answering it. Only one of them is somebody saying no.
117
+ return { allowed: false, reason: answer.action === 'cancel' ? 'cancelled' : 'declined' };
118
+ }
119
+ // Round one. A 2025-era request carries no per-request envelope. On a
120
+ // stateless leg that is the end of it: the per-request instance never saw an
121
+ // `initialize`, so nothing says the client could answer and there is no
122
+ // connection to ask on — refuse, do not ask.
123
+ //
124
+ // A legacy connection that is still stateful (the SSE transport, and a stdio
125
+ // connection that negotiated 2025) is the exception: that instance DID see
126
+ // `initialize`, and the SDK's own legacy shim fulfils the same
127
+ // input-required return by sending a real `elicitation/create` on it and
128
+ // re-entering this handler with the answer. Declared capabilities are what
129
+ // the shim's gate consults, so they are what decides here too.
130
+ const envelope = ctx.mcpReq.envelope;
131
+ if (envelope === undefined) {
132
+ if (!getServer()?.getClientCapabilities()?.elicitation)
133
+ return REFUSED_UNSUPPORTED;
57
134
  }
58
- catch (error) {
59
- // The prompt never came back — refuse rather than delete unconfirmed.
60
- console.error('[Server] Elicitation failed, refusing destructive action:', error);
61
- return { allowed: false, reason: 'undeliverable' };
135
+ else if (!clientCanBeAsked(envelope)) {
136
+ return REFUSED_INCAPABLE;
62
137
  }
138
+ const argsPreview = Object.entries(args)
139
+ .map(([k, v]) => ` ${k}: ${JSON.stringify(v)}`)
140
+ .join('\n');
141
+ throw new InputRequiredSignal(inputRequired({
142
+ inputRequests: {
143
+ [CONFIRM_KEY]: inputRequired.elicit({
144
+ message: `Confirm destructive action: ${toolName}\n\n${argsPreview}\n\n` +
145
+ 'This permanently deletes the resource and cannot be undone.',
146
+ // No fields to fill in: accepting the prompt is the confirmation, and
147
+ // the client's own decline button is the refusal. A checkbox on top of
148
+ // that only produced false refusals — people accepted the dialog and
149
+ // left the box at its default.
150
+ requestedSchema: { type: 'object', properties: {} },
151
+ }),
152
+ },
153
+ requestState: await getRequestStateCodec().mint({ tool: toolName, arguments: digestArguments(args) }, ctx),
154
+ }));
63
155
  }
64
156
  /** Human-readable explanation for a refused destructive action. */
65
157
  export function describeRefusal(toolName, reason) {
66
158
  switch (reason) {
67
159
  case 'unsupported':
68
- return (`Refused "${toolName}": destructive actions need confirmation, and this client ` +
69
- `does not support MCP elicitation, so it cannot be asked for. Use a client that ` +
70
- `declares the elicitation capability, or perform the deletion in the Qase UI.`);
160
+ // Two ways out, not one. A 2025-era client CAN be asked — over a
161
+ // long-lived connection, through elicitation — but only if it says it
162
+ // supports it; naming just the protocol upgrade sends people looking
163
+ // for a new client when a capability would do. Claude Desktop, measured
164
+ // on the wire, offers neither: it negotiates 2025-11-25 and declares no
165
+ // elicitation, so for it the UI really is the answer.
166
+ return (`Refused "${toolName}": destructive actions need confirmation, and this client cannot be ` +
167
+ `asked for one — it speaks MCP 2025-11-25 and does not support elicitation. Use a client ` +
168
+ `that negotiates 2026-07-28, or one that supports elicitation over stdio, or delete it ` +
169
+ `in the Qase UI.`);
71
170
  case 'undeliverable':
72
171
  return (`Refused "${toolName}": the confirmation prompt was not answered, so the action ` +
73
172
  `was not confirmed. Nothing was deleted. Retry and answer the prompt.`);
173
+ case 'incapable':
174
+ return (`Refused "${toolName}": destructive actions need confirmation, and this client did not ` +
175
+ `declare that it can show one, so there is nowhere to ask. Use a client that supports ` +
176
+ `confirmation prompts, or delete it in the Qase UI.`);
74
177
  case 'declined':
75
178
  return `Action "${toolName}" declined by the user. Nothing was deleted.`;
179
+ case 'cancelled':
180
+ return (`Action "${toolName}" was not confirmed: the client cancelled the confirmation request ` +
181
+ `instead of answering it. Nothing was deleted. If you were never shown a prompt, the ` +
182
+ `client received the request and dropped it — check that it supports confirmation ` +
183
+ `prompts, or delete it in the Qase UI.`);
76
184
  }
77
185
  }
78
186
  //# sourceMappingURL=server-context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server-context.js","sourceRoot":"","sources":["../../src/utils/server-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,iBAAiB,EAAU,CAAC;AAE7D;;;GAGG;AACH,MAAM,UAAU,SAAS;IAC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13 +14,7 @@ import { z } from 'zod';
14
14
  export declare const PaginationSchema: z.ZodObject<{
15
15
  limit: z.ZodOptional<z.ZodNumber>;
16
16
  offset: z.ZodOptional<z.ZodNumber>;
17
- }, "strip", z.ZodTypeAny, {
18
- limit?: number | undefined;
19
- offset?: number | undefined;
20
- }, {
21
- limit?: number | undefined;
22
- offset?: number | undefined;
23
- }>;
17
+ }, z.core.$strip>;
24
18
  /**
25
19
  * Schema for Qase project codes
26
20
  * Format: 2-10 uppercase letters, numbers, or underscores
@@ -42,7 +36,11 @@ export declare const HashSchema: z.ZodString;
42
36
  /**
43
37
  * Schema for filtering by entity status
44
38
  */
45
- export declare const StatusFilterSchema: z.ZodOptional<z.ZodEnum<["active", "archived", "deleted"]>>;
39
+ export declare const StatusFilterSchema: z.ZodOptional<z.ZodEnum<{
40
+ active: "active";
41
+ archived: "archived";
42
+ deleted: "deleted";
43
+ }>>;
46
44
  /**
47
45
  * Helper function to merge a schema with pagination parameters
48
46
  *
@@ -56,16 +54,13 @@ export declare const StatusFilterSchema: z.ZodOptional<z.ZodEnum<["active", "arc
56
54
  * });
57
55
  * ```
58
56
  */
59
- export declare function withPagination<T extends z.ZodRawShape>(schema: T): z.ZodObject<z.objectUtil.extendShape<T, {
57
+ export declare function withPagination<T extends z.ZodRawShape>(schema: T): z.ZodObject<(keyof T & ("limit" | "offset") extends never ? { -readonly [P in keyof T]: T[P]; } & {
60
58
  limit: z.ZodOptional<z.ZodNumber>;
61
59
  offset: z.ZodOptional<z.ZodNumber>;
62
- }>, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<z.objectUtil.extendShape<T, {
60
+ } : { [K in keyof { -readonly [P in keyof T]: T[P]; } as K extends "limit" | "offset" ? never : K]: { -readonly [P in keyof T]: T[P]; }[K]; } & {
63
61
  limit: z.ZodOptional<z.ZodNumber>;
64
62
  offset: z.ZodOptional<z.ZodNumber>;
65
- }>>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<z.objectUtil.extendShape<T, {
66
- limit: z.ZodOptional<z.ZodNumber>;
67
- offset: z.ZodOptional<z.ZodNumber>;
68
- }>> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
63
+ }) extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.core.$strip>;
69
64
  /**
70
65
  * Helper function to add project code to a schema
71
66
  *
@@ -82,11 +77,7 @@ export declare function withPagination<T extends z.ZodRawShape>(schema: T): z.Zo
82
77
  */
83
78
  export declare function withProjectCode<T extends z.ZodRawShape>(schema: T): z.ZodObject<{
84
79
  code: z.ZodString;
85
- } & T, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
86
- code: z.ZodString;
87
- } & T>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<{
88
- code: z.ZodString;
89
- } & T> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
80
+ } & T extends infer T_1 ? { -readonly [P in keyof T_1]: T_1[P]; } : never, z.core.$strip>;
90
81
  /**
91
82
  * Helper function to make all fields in a schema optional
92
83
  *
@@ -94,12 +85,8 @@ export declare function withProjectCode<T extends z.ZodRawShape>(schema: T): z.Z
94
85
  * @returns Schema with all fields optional
95
86
  */
96
87
  export declare function makePartial<T extends z.ZodObject<z.ZodRawShape>>(schema: T): z.ZodObject<{
97
- [x: string]: z.ZodOptional<z.ZodTypeAny>;
98
- }, z.UnknownKeysParam, z.ZodTypeAny, {
99
- [x: string]: any;
100
- }, {
101
- [x: string]: any;
102
- }>;
88
+ [x: string]: z.ZodOptional<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
89
+ }, z.core.$strip>;
103
90
  export type Pagination = z.infer<typeof PaginationSchema>;
104
91
  export type ProjectCode = z.infer<typeof ProjectCodeSchema>;
105
92
  export type EntityId = z.infer<typeof IdSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;EAc3B,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,aAQ+C,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,YAAY,4BAAwE,CAAC;AAElG;;GAEG;AACH,eAAO,MAAM,QAAQ,aAAuE,CAAC;AAE7F;;GAEG;AACH,eAAO,MAAM,UAAU,aAAyD,CAAC;AAEjF;;GAEG;AACH,eAAO,MAAM,kBAAkB,6DAGO,CAAC;AAEvC;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;;;;;;;;;mEAEhE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;;;;;;sEAKjE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;;;;;;GAE1E;AAGD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAChD,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC"}
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"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