@qase/mcp-server 3.2.1 → 3.3.0

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 (83) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/build/cache/metrics.js +6 -1
  3. package/build/cache/metrics.js.map +1 -1
  4. package/build/client/index.d.ts.map +1 -1
  5. package/build/client/index.js +6 -1
  6. package/build/client/index.js.map +1 -1
  7. package/build/operations-v2/composites/ci-report.js +2 -2
  8. package/build/operations-v2/composites/ci-report.js.map +1 -1
  9. package/build/operations-v2/composites/regression-run.js +2 -2
  10. package/build/operations-v2/composites/regression-run.js.map +1 -1
  11. package/build/operations-v2/composites/triage-defect.js +2 -2
  12. package/build/operations-v2/composites/triage-defect.js.map +1 -1
  13. package/build/operations-v2/escape/api.js +21 -12
  14. package/build/operations-v2/escape/api.js.map +1 -1
  15. package/build/operations-v2/meta/discover.js +8 -7
  16. package/build/operations-v2/meta/discover.js.map +1 -1
  17. package/build/operations-v2/meta/tool-help.js +5 -2
  18. package/build/operations-v2/meta/tool-help.js.map +1 -1
  19. package/build/operations-v2/qql/index.js +3 -3
  20. package/build/operations-v2/qql/index.js.map +1 -1
  21. package/build/operations-v2/read/get.js +5 -2
  22. package/build/operations-v2/read/get.js.map +1 -1
  23. package/build/operations-v2/read/project-context.js +30 -4
  24. package/build/operations-v2/read/project-context.js.map +1 -1
  25. package/build/operations-v2/write/attachments.js +4 -3
  26. package/build/operations-v2/write/attachments.js.map +1 -1
  27. package/build/operations-v2/write/cases-bulk.js +2 -2
  28. package/build/operations-v2/write/cases-bulk.js.map +1 -1
  29. package/build/operations-v2/write/cases.js +4 -3
  30. package/build/operations-v2/write/cases.js.map +1 -1
  31. package/build/operations-v2/write/custom-fields.js +4 -3
  32. package/build/operations-v2/write/custom-fields.js.map +1 -1
  33. package/build/operations-v2/write/defects.js +4 -3
  34. package/build/operations-v2/write/defects.js.map +1 -1
  35. package/build/operations-v2/write/environments.js +4 -3
  36. package/build/operations-v2/write/environments.js.map +1 -1
  37. package/build/operations-v2/write/external-issues.js +2 -2
  38. package/build/operations-v2/write/external-issues.js.map +1 -1
  39. package/build/operations-v2/write/milestones.js +4 -3
  40. package/build/operations-v2/write/milestones.js.map +1 -1
  41. package/build/operations-v2/write/plans.js +4 -3
  42. package/build/operations-v2/write/plans.js.map +1 -1
  43. package/build/operations-v2/write/projects.js +4 -3
  44. package/build/operations-v2/write/projects.js.map +1 -1
  45. package/build/operations-v2/write/results.js +4 -3
  46. package/build/operations-v2/write/results.js.map +1 -1
  47. package/build/operations-v2/write/reviews.js +7 -6
  48. package/build/operations-v2/write/reviews.js.map +1 -1
  49. package/build/operations-v2/write/runs.js +5 -4
  50. package/build/operations-v2/write/runs.js.map +1 -1
  51. package/build/operations-v2/write/shared-steps.js +4 -3
  52. package/build/operations-v2/write/shared-steps.js.map +1 -1
  53. package/build/operations-v2/write/suites.js +4 -3
  54. package/build/operations-v2/write/suites.js.map +1 -1
  55. package/build/server.d.ts.map +1 -1
  56. package/build/server.js +84 -48
  57. package/build/server.js.map +1 -1
  58. package/build/transports/streamableHttp.d.ts.map +1 -1
  59. package/build/transports/streamableHttp.js +3 -2
  60. package/build/transports/streamableHttp.js.map +1 -1
  61. package/build/utils/output-schemas.d.ts.map +1 -1
  62. package/build/utils/output-schemas.js +2 -1
  63. package/build/utils/output-schemas.js.map +1 -1
  64. package/build/utils/protocol-telemetry.d.ts +18 -1
  65. package/build/utils/protocol-telemetry.d.ts.map +1 -1
  66. package/build/utils/protocol-telemetry.js +35 -3
  67. package/build/utils/protocol-telemetry.js.map +1 -1
  68. package/build/utils/registry.d.ts +38 -10
  69. package/build/utils/registry.d.ts.map +1 -1
  70. package/build/utils/registry.js +68 -31
  71. package/build/utils/registry.js.map +1 -1
  72. package/build/utils/server-context.d.ts +28 -2
  73. package/build/utils/server-context.d.ts.map +1 -1
  74. package/build/utils/server-context.js +118 -38
  75. package/build/utils/server-context.js.map +1 -1
  76. package/build/utils/tool-telemetry.d.ts +48 -0
  77. package/build/utils/tool-telemetry.d.ts.map +1 -0
  78. package/build/utils/tool-telemetry.js +142 -0
  79. package/build/utils/tool-telemetry.js.map +1 -0
  80. package/build/version.d.ts +1 -1
  81. package/build/version.js +1 -1
  82. package/package.json +1 -1
  83. package/server.json +2 -2
@@ -12,7 +12,8 @@
12
12
  */
13
13
  import { AsyncLocalStorage } from 'async_hooks';
14
14
  import { CLIENT_CAPABILITIES_META_KEY, inputRequired, inputResponse, } from '@modelcontextprotocol/server';
15
- import { digestArguments, getRequestStateCodec } from './request-state.js';
15
+ import { CONFIRMATION_TTL_SECONDS, digestArguments, getRequestStateCodec, } from './request-state.js';
16
+ import { noteOutcome } from './tool-telemetry.js';
16
17
  /**
17
18
  * Per-request server storage.
18
19
  * Holds the Server instance for the current request context.
@@ -55,6 +56,30 @@ export class InputRequiredSignal extends Error {
55
56
  }
56
57
  const REFUSED_UNSUPPORTED = { allowed: false, reason: 'unsupported' };
57
58
  const REFUSED_INCAPABLE = { allowed: false, reason: 'incapable' };
59
+ /** The argument a held call is repeated with; stripped before any handler sees it. */
60
+ export const CONFIRM_TOKEN_ARG = 'confirm_token';
61
+ /** The confirm token the current call was made with, if any. */
62
+ export const confirmTokenStorage = new AsyncLocalStorage();
63
+ /**
64
+ * Check a confirm token the agent came back with.
65
+ *
66
+ * The token is the same signed, caller-bound, ten-minute state a prompt uses,
67
+ * so it carries the same pinning: it opens exactly the call it was issued for —
68
+ * this tool, these arguments — and nothing else.
69
+ */
70
+ async function acceptToken(ctx, token, toolName, args) {
71
+ let state;
72
+ try {
73
+ state = await getRequestStateCodec().verify(token, ctx);
74
+ }
75
+ catch {
76
+ return { allowed: false, reason: 'token_invalid' };
77
+ }
78
+ if (state?.tool !== toolName || state.arguments !== digestArguments(args)) {
79
+ return { allowed: false, reason: 'token_invalid' };
80
+ }
81
+ return { allowed: true };
82
+ }
58
83
  /**
59
84
  * Whether a 2026 request's own envelope says the client can be shown a form.
60
85
  *
@@ -81,41 +106,68 @@ function clientCanBeAsked(envelope) {
81
106
  * a cancel, an answer belonging to some other confirmation — all refuse, and
82
107
  * name the reason so the caller can say what happened.
83
108
  */
84
- export async function confirmDestructiveAction(toolName, args) {
109
+ export async function confirmDestructiveAction(toolName, args, options = {}) {
110
+ const verdict = await decide(toolName, args, options);
111
+ if (!verdict.allowed) {
112
+ noteOutcome(verdict.reason === 'token_required' ? 'confirm_token_issued' : `refused_${verdict.reason}`);
113
+ }
114
+ return verdict;
115
+ }
116
+ /** Why this client cannot be shown a prompt, or undefined when it can. */
117
+ function whyCannotAsk(ctx) {
118
+ const envelope = ctx.mcpReq.envelope;
119
+ if (envelope === undefined) {
120
+ return getServer()?.getClientCapabilities()?.elicitation ? undefined : REFUSED_UNSUPPORTED;
121
+ }
122
+ return clientCanBeAsked(envelope) ? undefined : REFUSED_INCAPABLE;
123
+ }
124
+ /** Round two: the client came back with an answer to the prompt. */
125
+ function judgeAnswer(ctx, action, toolName, args) {
126
+ // The state was already verified by the seam before this handler ran — it
127
+ // is this process's own, for this caller, unexpired. What is left is that
128
+ // the answer belongs to THIS call: the same tool, and the same arguments
129
+ // the human was shown. Neither alone is enough. Without the tool, one
130
+ // confirmation would open every destructive tool; without the arguments,
131
+ // one confirmed deletion would authorise every other deletion by the same
132
+ // tool until the state expired.
133
+ //
134
+ // A plain string comparison, not `timingSafeEqual`: both operands are
135
+ // public values derived from arguments the caller itself sent, and the one
136
+ // from the wire is already integrity-proven, so there is no secret for a
137
+ // timing difference to leak. `timingSafeEqual` would also throw on a
138
+ // length mismatch, which is a shape this has to answer rather than crash.
139
+ const state = ctx.mcpReq.requestState();
140
+ if (state?.tool !== toolName || state.arguments !== digestArguments(args)) {
141
+ // Not a decline: the human never saw these arguments, so nobody said no
142
+ // — and nobody said yes either. Unconfirmed, nothing deleted.
143
+ return { allowed: false, reason: 'undeliverable' };
144
+ }
145
+ if (action === 'accept')
146
+ return { allowed: true };
147
+ // `cancel` is the client dropping the question, `decline` is a person
148
+ // answering it. Only one of them is somebody saying no.
149
+ return { allowed: false, reason: action === 'cancel' ? 'cancelled' : 'declined' };
150
+ }
151
+ async function decide(toolName, args, options) {
152
+ const policy = options.policy ?? 'token-fallback';
85
153
  const ctx = getRequestContext();
86
154
  if (!ctx)
87
155
  return REFUSED_UNSUPPORTED;
156
+ const token = confirmTokenStorage.getStore();
157
+ if (token !== undefined) {
158
+ // A strict action never issues tokens, so a token offered for one is not
159
+ // something this server handed out for it.
160
+ if (policy === 'strict')
161
+ return { allowed: false, reason: 'token_invalid' };
162
+ return acceptToken(ctx, token, toolName, args);
163
+ }
88
164
  // Round two: the client came back with an answer. `inputResponse` is what
89
165
  // separates a refusal from a missing answer — `acceptedContent` reads both
90
166
  // as "nothing", which would send a decline round the loop again until it hit
91
167
  // the client's maxRounds.
92
168
  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
- }
169
+ if (answer.kind === 'elicit')
170
+ return judgeAnswer(ctx, answer.action, toolName, args);
119
171
  // Round one. A 2025-era request carries no per-request envelope. On a
120
172
  // stateless leg that is the end of it: the per-request instance never saw an
121
173
  // `initialize`, so nothing says the client could answer and there is no
@@ -127,17 +179,19 @@ export async function confirmDestructiveAction(toolName, args) {
127
179
  // input-required return by sending a real `elicitation/create` on it and
128
180
  // re-entering this handler with the answer. Declared capabilities are what
129
181
  // 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;
134
- }
135
- else if (!clientCanBeAsked(envelope)) {
136
- return REFUSED_INCAPABLE;
182
+ const cannotAsk = whyCannotAsk(ctx);
183
+ if (cannotAsk) {
184
+ if (policy === 'strict')
185
+ return cannotAsk;
186
+ // Refusing here left deletion broken outright in Claude.ai and every
187
+ // 2025-era HTTP client — about two thirds of delete attempts. The token
188
+ // keeps an explicit second step and the exact-call pinning; what it cannot
189
+ // prove is that a person, not the model, said yes, which is why `strict`
190
+ // exists for the removals too large to leave to that.
191
+ const minted = await getRequestStateCodec().mint({ tool: toolName, arguments: digestArguments(args) }, ctx);
192
+ return { allowed: false, reason: 'token_required', token: minted };
137
193
  }
138
- const argsPreview = Object.entries(args)
139
- .map(([k, v]) => ` ${k}: ${JSON.stringify(v)}`)
140
- .join('\n');
194
+ const argsPreview = previewArguments(args);
141
195
  throw new InputRequiredSignal(inputRequired({
142
196
  inputRequests: {
143
197
  [CONFIRM_KEY]: inputRequired.elicit({
@@ -153,9 +207,35 @@ export async function confirmDestructiveAction(toolName, args) {
153
207
  requestState: await getRequestStateCodec().mint({ tool: toolName, arguments: digestArguments(args) }, ctx),
154
208
  }));
155
209
  }
210
+ function previewArguments(args) {
211
+ return Object.entries(args)
212
+ .map(([k, v]) => ` ${k}: ${JSON.stringify(v)}`)
213
+ .join('\n');
214
+ }
215
+ /** What a held call answers with: the token and how to spend it. */
216
+ export function describeTokenRequest(toolName, args, token) {
217
+ const message = `Not done yet: "${toolName}" permanently deletes the resource and cannot be undone, ` +
218
+ `and this client cannot show a confirmation prompt.\n\n` +
219
+ `What would be deleted:\n${previewArguments(args)}\n\n` +
220
+ `Ask the user in the conversation whether to go ahead. Only if they say yes, call ` +
221
+ `${toolName} again with exactly the same arguments plus ${CONFIRM_TOKEN_ARG}: "${token}". ` +
222
+ `The token works once these arguments are unchanged and expires in ${CONFIRMATION_TTL_SECONDS / 60} minutes.`;
223
+ return {
224
+ message,
225
+ structured: {
226
+ confirmation_required: true,
227
+ [CONFIRM_TOKEN_ARG]: token,
228
+ expires_in_seconds: CONFIRMATION_TTL_SECONDS,
229
+ },
230
+ };
231
+ }
156
232
  /** Human-readable explanation for a refused destructive action. */
157
233
  export function describeRefusal(toolName, reason) {
158
234
  switch (reason) {
235
+ case 'token_invalid':
236
+ return (`Refused "${toolName}": the ${CONFIRM_TOKEN_ARG} does not match this call — it was issued ` +
237
+ `for different arguments, has expired, or was never issued for this action. Nothing was ` +
238
+ `deleted. Call again without ${CONFIRM_TOKEN_ARG} to get a fresh one.`);
159
239
  case 'unsupported':
160
240
  // Two ways out, not one. A 2025-era client CAN be asked — over a
161
241
  // long-lived connection, through elicitation — but only if it says it
@@ -1 +1 @@
1
- {"version":3,"file":"server-context.js","sourceRoot":"","sources":["../../src/utils/server-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,4BAA4B,EAC5B,aAAa,EACb,aAAa,GACd,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAA0B,MAAM,oBAAoB,CAAC;AAEnG;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,iBAAiB,EAAU,CAAC;AAE7D;;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AW,QAAQ,8CAA8C,CAAC;QAC3E,KAAK,WAAW;YACd,OAAO,CACL,WAAW,QAAQ,qEAAqE;gBACxF,sFAAsF;gBACtF,mFAAmF;gBACnF,uCAAuC,CACxC,CAAC;IACN,CAAC;AACH,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Per-call telemetry: one record per tools/call, filled in by whoever learns
3
+ * something about the call, flushed once at its end as a metric set and one
4
+ * JSON log line.
5
+ *
6
+ * Every label here is bounded. A value that comes from the wire — a client
7
+ * name, an API path, an entity — is either mapped onto a fixed vocabulary or
8
+ * collapsed into `other`, because each distinct value is a series in an
9
+ * in-process map that nothing evicts. Nothing identifies a user or workspace:
10
+ * no decision this feeds depends on who called.
11
+ */
12
+ import { AsyncLocalStorage } from 'async_hooks';
13
+ export type CallOutcome = 'ok' | 'tool_error' | 'exception' | 'unknown_tool'
14
+ /** First leg of a confirmation prompt; the retry is counted on its own. */
15
+ | 'input_required' | 'confirm_token_issued' | `refused_${string}`;
16
+ export interface CallRecord {
17
+ tool: string;
18
+ outcome?: CallOutcome;
19
+ /** A bounded per-tool detail: the entity read, the tool asked about. */
20
+ detail?: string;
21
+ api?: {
22
+ method: string;
23
+ route: string;
24
+ };
25
+ }
26
+ export declare const callRecordStorage: AsyncLocalStorage<CallRecord>;
27
+ /** The tool the current call is running, for tagging outbound API requests. */
28
+ export declare function currentTool(): string | undefined;
29
+ export declare function noteOutcome(outcome: CallOutcome): void;
30
+ /** Record a detail; callers pass only values they have already checked against a fixed set. */
31
+ export declare function noteDetail(detail: string): void;
32
+ export declare function noteApiCall(method: string, path: string): void;
33
+ /**
34
+ * `GET /v1/run/DEMO/12/public` → `/v1/run/{code}/{id}/public`.
35
+ *
36
+ * The output vocabulary is closed: a resource outside the API's known set, a
37
+ * path that is not versioned, or a segment that is neither a known word nor a
38
+ * recognisable value collapses into a placeholder, so whatever a model puts in
39
+ * `path` cannot mint a new series.
40
+ */
41
+ export declare function routeTemplate(path: string): string;
42
+ /**
43
+ * Close out a call: one counter per call with its outcome, running sums for
44
+ * duration and response size (their averages come from dividing by the
45
+ * count), and one log line carrying the same fields.
46
+ */
47
+ export declare function flushCall(record: CallRecord, client: string, durationMs: number, responseBytes: number): void;
48
+ //# sourceMappingURL=tool-telemetry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-telemetry.d.ts","sourceRoot":"","sources":["../../src/utils/tool-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,MAAM,MAAM,WAAW,GACnB,IAAI,GACJ,YAAY,GACZ,WAAW,GACX,cAAc;AAChB,2EAA2E;GACzE,gBAAgB,GAChB,sBAAsB,GACtB,WAAW,MAAM,EAAE,CAAC;AAExB,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,wEAAwE;IACxE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CACzC;AAED,eAAO,MAAM,iBAAiB,+BAAsC,CAAC;AAErE,+EAA+E;AAC/E,wBAAgB,WAAW,IAAI,MAAM,GAAG,SAAS,CAEhD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAGtD;AAID,+FAA+F;AAC/F,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAG/C;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAG9D;AAuCD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAmBlD;AAUD;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,GACpB,IAAI,CAiCN"}
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Per-call telemetry: one record per tools/call, filled in by whoever learns
3
+ * something about the call, flushed once at its end as a metric set and one
4
+ * JSON log line.
5
+ *
6
+ * Every label here is bounded. A value that comes from the wire — a client
7
+ * name, an API path, an entity — is either mapped onto a fixed vocabulary or
8
+ * collapsed into `other`, because each distinct value is a series in an
9
+ * in-process map that nothing evicts. Nothing identifies a user or workspace:
10
+ * no decision this feeds depends on who called.
11
+ */
12
+ import { AsyncLocalStorage } from 'async_hooks';
13
+ import { getMetrics } from '../cache/index.js';
14
+ export const callRecordStorage = new AsyncLocalStorage();
15
+ /** The tool the current call is running, for tagging outbound API requests. */
16
+ export function currentTool() {
17
+ return callRecordStorage.getStore()?.tool;
18
+ }
19
+ export function noteOutcome(outcome) {
20
+ const record = callRecordStorage.getStore();
21
+ if (record)
22
+ record.outcome = outcome;
23
+ }
24
+ const DETAIL_PATTERN = /^[a-z][a-z0-9_]{0,39}$/;
25
+ /** Record a detail; callers pass only values they have already checked against a fixed set. */
26
+ export function noteDetail(detail) {
27
+ const record = callRecordStorage.getStore();
28
+ if (record && DETAIL_PATTERN.test(detail))
29
+ record.detail = detail;
30
+ }
31
+ export function noteApiCall(method, path) {
32
+ const record = callRecordStorage.getStore();
33
+ if (record)
34
+ record.api = { method, route: routeTemplate(path) };
35
+ }
36
+ /** Resources whose second segment is a project code. */
37
+ const PROJECT_SCOPED = new Set([
38
+ 'case',
39
+ 'suite',
40
+ 'run',
41
+ 'result',
42
+ 'plan',
43
+ 'defect',
44
+ 'milestone',
45
+ 'environment',
46
+ 'shared_step',
47
+ 'configuration',
48
+ 'review',
49
+ 'search',
50
+ 'attachment',
51
+ 'project',
52
+ ]);
53
+ /** Resources the API serves outside a project. */
54
+ const GLOBAL = new Set(['author', 'user', 'custom_field', 'shared_parameter', 'system_field']);
55
+ /** Literal path words kept as they are; anything else is a value. */
56
+ const LITERALS = new Set([
57
+ 'access',
58
+ 'attach',
59
+ 'bulk',
60
+ 'complete',
61
+ 'detach',
62
+ 'external-issue',
63
+ 'group',
64
+ 'public',
65
+ 'resolve',
66
+ 'result',
67
+ 'results',
68
+ 'status',
69
+ ]);
70
+ /**
71
+ * `GET /v1/run/DEMO/12/public` → `/v1/run/{code}/{id}/public`.
72
+ *
73
+ * The output vocabulary is closed: a resource outside the API's known set, a
74
+ * path that is not versioned, or a segment that is neither a known word nor a
75
+ * recognisable value collapses into a placeholder, so whatever a model puts in
76
+ * `path` cannot mint a new series.
77
+ */
78
+ export function routeTemplate(path) {
79
+ const [pathOnly] = path.split('?');
80
+ const segments = pathOnly.split('/').filter(Boolean);
81
+ const [version, resource, ...rest] = segments;
82
+ if (!version || !/^v\d+$/.test(version))
83
+ return 'other';
84
+ if (!resource)
85
+ return `/${version}`;
86
+ // API v2 puts the project code first: /v2/{code}/run/{id}/result.
87
+ if (!PROJECT_SCOPED.has(resource) && !GLOBAL.has(resource)) {
88
+ if (rest.length === 0 || !PROJECT_SCOPED.has(rest[0]))
89
+ return `/${version}/other`;
90
+ return `/${[version, '{code}', rest[0], ...rest.slice(1).map(valueOrLiteral)].join('/')}`;
91
+ }
92
+ const out = [version, resource];
93
+ rest.forEach((segment, i) => {
94
+ const value = valueOrLiteral(segment);
95
+ out.push(value === '{x}' && i === 0 && PROJECT_SCOPED.has(resource) ? '{code}' : value);
96
+ });
97
+ return `/${out.join('/')}`;
98
+ }
99
+ function valueOrLiteral(segment) {
100
+ if (LITERALS.has(segment))
101
+ return segment;
102
+ if (/^\d+$/.test(segment))
103
+ return '{id}';
104
+ if (/^[0-9a-f]{40}$/i.test(segment))
105
+ return '{hash}';
106
+ if (/^[0-9a-f]{8}-[0-9a-f-]{27}$/i.test(segment))
107
+ return '{uuid}';
108
+ return '{x}';
109
+ }
110
+ /**
111
+ * Close out a call: one counter per call with its outcome, running sums for
112
+ * duration and response size (their averages come from dividing by the
113
+ * count), and one log line carrying the same fields.
114
+ */
115
+ export function flushCall(record, client, durationMs, responseBytes) {
116
+ const outcome = record.outcome ?? 'ok';
117
+ const metrics = getMetrics();
118
+ metrics.incCounter('qase_mcp_tool_calls_total', { tool: record.tool, client, outcome });
119
+ metrics.incCounter('qase_mcp_tool_duration_seconds_sum', { tool: record.tool }, durationMs / 1000);
120
+ metrics.incCounter('qase_mcp_tool_duration_seconds_count', { tool: record.tool });
121
+ metrics.incCounter('qase_mcp_tool_response_bytes_sum', { tool: record.tool }, responseBytes);
122
+ if (record.detail) {
123
+ metrics.incCounter('qase_mcp_tool_detail_total', { tool: record.tool, detail: record.detail });
124
+ }
125
+ if (record.api) {
126
+ metrics.incCounter('qase_mcp_api_escape_total', {
127
+ method: record.api.method,
128
+ route: record.api.route,
129
+ });
130
+ }
131
+ console.error(JSON.stringify({
132
+ evt: 'tool_call',
133
+ tool: record.tool,
134
+ client,
135
+ outcome,
136
+ ms: Math.round(durationMs),
137
+ bytes: responseBytes,
138
+ ...(record.detail && { detail: record.detail }),
139
+ ...(record.api && { api: record.api }),
140
+ }));
141
+ }
142
+ //# sourceMappingURL=tool-telemetry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-telemetry.js","sourceRoot":"","sources":["../../src/utils/tool-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAoB/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAc,CAAC;AAErE,+EAA+E;AAC/E,MAAM,UAAU,WAAW;IACzB,OAAO,iBAAiB,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,OAAoB;IAC9C,MAAM,MAAM,GAAG,iBAAiB,CAAC,QAAQ,EAAE,CAAC;IAC5C,I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AAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IACjG,CAAC;IACD,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;QACf,OAAO,CAAC,UAAU,CAAC,2BAA2B,EAAE;YAC9C,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM;YACzB,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK;SACxB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,KAAK,CACX,IAAI,CAAC,SAAS,CAAC;QACb,GAAG,EAAE,WAAW;QAChB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM;QACN,OAAO;QACP,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;QAC1B,KAAK,EAAE,aAAa;QACpB,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;QAC/C,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;KACvC,CAAC,CACH,CAAC;AACJ,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.2.1";
1
+ export declare const VERSION = "3.3.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/build/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // Auto-generated by prebuild script — do not edit manually
2
- export const VERSION = '3.2.1';
2
+ export const VERSION = '3.3.0';
3
3
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qase/mcp-server",
3
- "version": "3.2.1",
3
+ "version": "3.3.0",
4
4
  "mcpName": "io.qase/mcp-server",
5
5
  "description": "Official MCP server for Qase Test Management Platform",
6
6
  "type": "module",
package/server.json CHANGED
@@ -15,12 +15,12 @@
15
15
  "url": "https://github.com/qase-tms/qase-mcp-server",
16
16
  "source": "github"
17
17
  },
18
- "version": "3.2.1",
18
+ "version": "3.3.0",
19
19
  "packages": [
20
20
  {
21
21
  "registryType": "npm",
22
22
  "identifier": "@qase/mcp-server",
23
- "version": "3.2.1",
23
+ "version": "3.3.0",
24
24
  "transport": {
25
25
  "type": "stdio"
26
26
  },