@qase/mcp-server 2.7.5 → 3.0.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.
- package/CHANGELOG.md +46 -0
- package/README.md +4 -4
- package/build/auth/mcp-guard.d.ts.map +1 -1
- package/build/auth/mcp-guard.js +1 -1
- package/build/auth/mcp-guard.js.map +1 -1
- package/build/cache/metrics.js +2 -0
- package/build/cache/metrics.js.map +1 -1
- package/build/index.js +27 -5
- package/build/index.js.map +1 -1
- package/build/operations-v2/composites/ci-report.js +3 -5
- package/build/operations-v2/composites/ci-report.js.map +1 -1
- package/build/operations-v2/composites/regression-run.js +2 -1
- package/build/operations-v2/composites/regression-run.js.map +1 -1
- package/build/operations-v2/composites/triage-defect.js +5 -7
- package/build/operations-v2/composites/triage-defect.js.map +1 -1
- package/build/operations-v2/escape/api.js +11 -4
- package/build/operations-v2/escape/api.js.map +1 -1
- package/build/operations-v2/index.d.ts +1 -0
- package/build/operations-v2/index.d.ts.map +1 -1
- package/build/operations-v2/index.js +1 -0
- package/build/operations-v2/index.js.map +1 -1
- package/build/operations-v2/meta/discover.d.ts +5 -4
- package/build/operations-v2/meta/discover.d.ts.map +1 -1
- package/build/operations-v2/meta/discover.js +13 -32
- package/build/operations-v2/meta/discover.js.map +1 -1
- package/build/operations-v2/meta/tool-help.d.ts +10 -0
- package/build/operations-v2/meta/tool-help.d.ts.map +1 -0
- package/build/operations-v2/meta/tool-help.js +42 -0
- package/build/operations-v2/meta/tool-help.js.map +1 -0
- package/build/operations-v2/qql/index.js +15 -9
- package/build/operations-v2/qql/index.js.map +1 -1
- package/build/operations-v2/read/get.js +2 -1
- package/build/operations-v2/read/get.js.map +1 -1
- package/build/operations-v2/read/project-context.js +5 -6
- package/build/operations-v2/read/project-context.js.map +1 -1
- package/build/operations-v2/write/attachments.js +16 -21
- package/build/operations-v2/write/attachments.js.map +1 -1
- package/build/operations-v2/write/case-fields.d.ts +26 -215
- package/build/operations-v2/write/case-fields.d.ts.map +1 -1
- package/build/operations-v2/write/case-fields.js +28 -24
- package/build/operations-v2/write/case-fields.js.map +1 -1
- package/build/operations-v2/write/cases-bulk.js +2 -1
- package/build/operations-v2/write/cases-bulk.js.map +1 -1
- package/build/operations-v2/write/cases.js +4 -3
- package/build/operations-v2/write/cases.js.map +1 -1
- package/build/operations-v2/write/custom-fields.js +13 -10
- package/build/operations-v2/write/custom-fields.js.map +1 -1
- package/build/operations-v2/write/defects.js +7 -9
- package/build/operations-v2/write/defects.js.map +1 -1
- package/build/operations-v2/write/environments.js +5 -5
- package/build/operations-v2/write/environments.js.map +1 -1
- package/build/operations-v2/write/external-issues.js +2 -2
- package/build/operations-v2/write/external-issues.js.map +1 -1
- package/build/operations-v2/write/milestones.js +6 -6
- package/build/operations-v2/write/milestones.js.map +1 -1
- package/build/operations-v2/write/plans.js +5 -5
- package/build/operations-v2/write/plans.js.map +1 -1
- package/build/operations-v2/write/projects.js +6 -6
- package/build/operations-v2/write/projects.js.map +1 -1
- package/build/operations-v2/write/results.js +7 -12
- package/build/operations-v2/write/results.js.map +1 -1
- package/build/operations-v2/write/reviews.js +18 -18
- package/build/operations-v2/write/reviews.js.map +1 -1
- package/build/operations-v2/write/runs.js +8 -6
- package/build/operations-v2/write/runs.js.map +1 -1
- package/build/operations-v2/write/shared-steps.js +5 -8
- package/build/operations-v2/write/shared-steps.js.map +1 -1
- package/build/operations-v2/write/suites.js +4 -3
- package/build/operations-v2/write/suites.js.map +1 -1
- package/build/server-instructions.d.ts +1 -1
- package/build/server-instructions.d.ts.map +1 -1
- package/build/server-instructions.js +4 -4
- package/build/server.d.ts.map +1 -1
- package/build/server.js +154 -104
- package/build/server.js.map +1 -1
- package/build/transports/body-limit.d.ts +9 -17
- package/build/transports/body-limit.d.ts.map +1 -1
- package/build/transports/body-limit.js +18 -2
- package/build/transports/body-limit.js.map +1 -1
- package/build/transports/rate-limit.d.ts +1 -1
- package/build/transports/rate-limit.js +1 -1
- package/build/transports/sse.js +1 -1
- package/build/transports/sse.js.map +1 -1
- package/build/transports/streamableHttp.d.ts.map +1 -1
- package/build/transports/streamableHttp.js +83 -171
- package/build/transports/streamableHttp.js.map +1 -1
- package/build/utils/auth-context.d.ts +30 -0
- package/build/utils/auth-context.d.ts.map +1 -1
- package/build/utils/auth-context.js +33 -0
- package/build/utils/auth-context.js.map +1 -1
- package/build/utils/protocol-telemetry.d.ts +62 -0
- package/build/utils/protocol-telemetry.d.ts.map +1 -0
- package/build/utils/protocol-telemetry.js +123 -0
- package/build/utils/protocol-telemetry.js.map +1 -0
- package/build/utils/registry.d.ts +28 -34
- package/build/utils/registry.d.ts.map +1 -1
- package/build/utils/registry.js +107 -102
- package/build/utils/registry.js.map +1 -1
- package/build/utils/request-state.d.ts +71 -0
- package/build/utils/request-state.d.ts.map +1 -0
- package/build/utils/request-state.js +108 -0
- package/build/utils/request-state.js.map +1 -0
- package/build/utils/server-context.d.ts +53 -16
- package/build/utils/server-context.d.ts.map +1 -1
- package/build/utils/server-context.js +147 -39
- package/build/utils/server-context.js.map +1 -1
- package/build/utils/validation.d.ts +12 -25
- package/build/utils/validation.d.ts.map +1 -1
- package/build/utils/validation.js +2 -2
- package/build/utils/validation.js.map +1 -1
- package/build/version.d.ts +1 -1
- package/build/version.js +1 -1
- package/docs/self-run.md +40 -3
- package/docs/tools.md +54 -60
- package/docs/troubleshooting.md +29 -8
- package/package.json +8 -9
- package/server.json +2 -2
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { mcpAuthRouter } from '@modelcontextprotocol/server-legacy/auth';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { toNodeHandler } from '@modelcontextprotocol/node';
|
|
4
|
+
import { createMcpHandler } from '@modelcontextprotocol/server';
|
|
5
5
|
import { requestTokenStorage } from '../utils/auth-context.js';
|
|
6
6
|
import { integrationStorage } from '../utils/integration-context.js';
|
|
7
|
-
import { normalizeIntegrationMarker } from '../utils/integration-marker.js';
|
|
8
7
|
import { getMetrics } from '../cache/index.js';
|
|
9
8
|
import { getOAuthConfig } from '../auth/oauth-config.js';
|
|
10
9
|
import { createJwksVerifier } from '../auth/jwks-verifier.js';
|
|
@@ -13,24 +12,9 @@ import { createMcpGuard } from '../auth/mcp-guard.js';
|
|
|
13
12
|
import { createBearerRequiredGuard } from '../auth/bearer-guard.js';
|
|
14
13
|
import { authorizeRedirectUriStorage } from '../auth/client-context.js';
|
|
15
14
|
import { createJsonParseErrorHandler } from './json-parse-error.js';
|
|
16
|
-
import { readBodyLimit } from './body-limit.js';
|
|
15
|
+
import { readBodyLimit, bodyLimitBytes } from './body-limit.js';
|
|
17
16
|
import { createMcpRateLimiter } from './rate-limit.js';
|
|
18
|
-
|
|
19
|
-
function isInitializeRequest(body) {
|
|
20
|
-
return (typeof body === 'object' && body !== null && 'method' in body && body.method === 'initialize');
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Read the integration marker off a request, normalised (see integration-marker.ts).
|
|
24
|
-
*
|
|
25
|
-
* Two channels, both required. The header is the primary one; the query parameter
|
|
26
|
-
* exists because it is not yet proven that custom request headers survive the
|
|
27
|
-
* OAuth flow on the hosted endpoint in every MCP client, and a URL is the one
|
|
28
|
-
* thing every client definitely passes through. The query parameter is only read
|
|
29
|
-
* at session creation — after that the value is remembered per session.
|
|
30
|
-
*/
|
|
31
|
-
function readIntegrationMarker(value) {
|
|
32
|
-
return typeof value === 'string' ? normalizeIntegrationMarker(value) : undefined;
|
|
33
|
-
}
|
|
17
|
+
import { normalizeIntegrationMarker } from '../utils/integration-marker.js';
|
|
34
18
|
/**
|
|
35
19
|
* Interpret TRUST_PROXY for express's `trust proxy` setting: a hop count, the
|
|
36
20
|
* booleans, or anything else passed through verbatim (express also accepts a
|
|
@@ -59,16 +43,31 @@ export function setupStreamableHttpTransport(createServer, config, oauthDeps) {
|
|
|
59
43
|
// CORS middleware for inspector
|
|
60
44
|
app.use((req, res, next) => {
|
|
61
45
|
res.header('Access-Control-Allow-Origin', process.env.CORS_ORIGIN || '*');
|
|
62
|
-
|
|
46
|
+
// This middleware is mounted with no path, so it answers the preflight for
|
|
47
|
+
// every route on this app, not just `/mcp`: `/health`, `/metrics`, and the
|
|
48
|
+
// OAuth well-known/metadata routes (plus mcpAuthRouter, when OAuth is on)
|
|
49
|
+
// are all GET, so GET stays advertised. DELETE is the one method that
|
|
50
|
+
// drops out: it was the session-end operation on `/mcp`, no other route
|
|
51
|
+
// here ever served it, and there is no session left to end — verified
|
|
52
|
+
// with curl against a running server that GET and DELETE on `/mcp` both
|
|
53
|
+
// answer 405, on the legacy-stateless leg and on a modern-negotiated
|
|
54
|
+
// request alike.
|
|
55
|
+
res.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
|
|
63
56
|
// Mcp-Method / Mcp-Name are required request headers as of MCP spec 2026-07-28
|
|
64
57
|
// (gateway routing without body parsing) — allow them ahead of client adoption.
|
|
65
58
|
// X-Qase-Integration is ours: without it a browser-based client's preflight
|
|
66
59
|
// strips the marker and only the ?integration= fallback would work.
|
|
60
|
+
// mcp-session-id is kept even though we no longer issue one: allowing a
|
|
61
|
+
// header nobody sends is harmless, and dropping it breaks preflight for a
|
|
62
|
+
// client that still sends it.
|
|
67
63
|
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, mcp-session-id, Mcp-Method, Mcp-Name, X-Qase-Integration');
|
|
68
|
-
// Expose auth challenge
|
|
69
|
-
// Claude.ai web) can read
|
|
70
|
-
// 401 WWW-Authenticate challenge is invisible to client JS and OAuth never
|
|
71
|
-
|
|
64
|
+
// Expose the auth challenge so browser-based MCP clients (Inspector,
|
|
65
|
+
// Claude.ai web) can read it from cross-origin responses. Without this the
|
|
66
|
+
// 401 WWW-Authenticate challenge is invisible to client JS and OAuth never
|
|
67
|
+
// starts. mcp-session-id is not exposed: we no longer issue one, and
|
|
68
|
+
// exposing a header we never send only invites a client to reconstruct
|
|
69
|
+
// session behaviour that does not exist.
|
|
70
|
+
res.header('Access-Control-Expose-Headers', 'WWW-Authenticate');
|
|
72
71
|
if (req.method === 'OPTIONS') {
|
|
73
72
|
res.sendStatus(200);
|
|
74
73
|
return;
|
|
@@ -152,38 +151,33 @@ export function setupStreamableHttpTransport(createServer, config, oauthDeps) {
|
|
|
152
151
|
createMcpRateLimiter(),
|
|
153
152
|
mcpGuard ?? createBearerRequiredGuard(),
|
|
154
153
|
];
|
|
155
|
-
//
|
|
156
|
-
//
|
|
157
|
-
//
|
|
158
|
-
//
|
|
159
|
-
//
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
console.error(`[StreamableHTTP] Evicted stale session: ${id}`);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}, 5 * 60 * 1000); // check every 5 minutes
|
|
186
|
-
cleanupInterval.unref(); // don't keep the process alive just for cleanup
|
|
154
|
+
// One handler serves both protocol eras.
|
|
155
|
+
//
|
|
156
|
+
// `createMcpHandler` is per-request by construction: it calls the factory for
|
|
157
|
+
// every request it serves and throws the instance away with the response. The
|
|
158
|
+
// session map that used to live here — with its TTL sweep, its 404 for an
|
|
159
|
+
// unknown id and its `mcp-session-id` header — has no counterpart in the
|
|
160
|
+
// 2026-07-28 era, and the handler answers the two operations that only made
|
|
161
|
+
// sense with a session (`GET` and `DELETE` on this endpoint) with 405.
|
|
162
|
+
//
|
|
163
|
+
// `legacy: 'stateless'` keeps 2025-era clients working: their requests are
|
|
164
|
+
// routed to the handler's stateless legacy leg, which builds the same kind of
|
|
165
|
+
// streamable-HTTP transport the hand-wired code did, minus the session.
|
|
166
|
+
const mcpHandler = createMcpHandler(() => createServer(), {
|
|
167
|
+
legacy: 'stateless',
|
|
168
|
+
// Without this the SDK caps bodies at its own 4 MiB default and silently
|
|
169
|
+
// undoes the 10 MB limit configured for attachment uploads.
|
|
170
|
+
maxRequestBodySize: bodyLimitBytes(),
|
|
171
|
+
onerror: (err) => console.error('[StreamableHTTP] handler error:', err),
|
|
172
|
+
});
|
|
173
|
+
// The adapter applies its own bound to bodies it reads off the Node stream.
|
|
174
|
+
// Every request here arrives behind `express.json()` and is handed over as a
|
|
175
|
+
// parsed body, so that path is not taken — but the two caps are set from the
|
|
176
|
+
// same place so they cannot drift if it ever is.
|
|
177
|
+
const nodeHandler = toNodeHandler(mcpHandler, {
|
|
178
|
+
maxRequestBodySize: bodyLimitBytes(),
|
|
179
|
+
onerror: (err) => console.error('[StreamableHTTP] adapter error:', err),
|
|
180
|
+
});
|
|
187
181
|
// Health check endpoint
|
|
188
182
|
app.get('/health', (_req, res) => {
|
|
189
183
|
res.json({ status: 'ok', transport: 'streamable-http' });
|
|
@@ -193,128 +187,46 @@ export function setupStreamableHttpTransport(createServer, config, oauthDeps) {
|
|
|
193
187
|
res.set('Content-Type', 'text/plain; version=0.0.4');
|
|
194
188
|
res.send(getMetrics().renderPrometheus());
|
|
195
189
|
});
|
|
196
|
-
// MCP endpoint
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
sessions.delete(sessionId);
|
|
212
|
-
sessionLastSeen.delete(sessionId);
|
|
213
|
-
sessionIntegrations.delete(sessionId);
|
|
214
|
-
console.error(`[StreamableHTTP] Session closed: ${sessionId}`);
|
|
215
|
-
res.status(200).json({ status: 'session closed' });
|
|
216
|
-
}
|
|
217
|
-
catch (error) {
|
|
218
|
-
console.error('[StreamableHTTP] Error closing session:', error);
|
|
219
|
-
if (!res.headersSent) {
|
|
220
|
-
res.status(500).json({
|
|
221
|
-
error: 'Internal server error',
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
// MCP endpoint - GET for SSE streams (if needed)
|
|
227
|
-
app.get(endpoint, ...guards, async (req, res) => {
|
|
228
|
-
const sessionId = req.headers['mcp-session-id'];
|
|
229
|
-
if (!sessionId) {
|
|
230
|
-
res.status(400).json({ error: 'Missing mcp-session-id header' });
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
if (!sessions.has(sessionId)) {
|
|
234
|
-
// Unknown session → 404 so the client re-initializes (see POST handler).
|
|
235
|
-
res.status(404).json({ error: 'Session not found. Reinitialize the session.' });
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
const transport = sessions.get(sessionId);
|
|
239
|
-
try {
|
|
240
|
-
await transport.handleRequest(req, res);
|
|
241
|
-
}
|
|
242
|
-
catch (error) {
|
|
243
|
-
console.error('[StreamableHTTP] Error handling GET request:', error);
|
|
244
|
-
if (!res.headersSent) {
|
|
245
|
-
res.status(500).json({
|
|
246
|
-
error: 'Internal server error',
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
// MCP endpoint - POST for messages
|
|
252
|
-
app.post(endpoint, ...guards, async (req, res) => {
|
|
253
|
-
console.error(`[StreamableHTTP] POST ${endpoint} received`, {
|
|
254
|
-
sessionId: req.headers['mcp-session-id'],
|
|
255
|
-
body: req.body,
|
|
256
|
-
});
|
|
257
|
-
const sessionId = req.headers['mcp-session-id'];
|
|
258
|
-
let transport;
|
|
259
|
-
// Integration marker on this request, if it carried one.
|
|
260
|
-
const headerIntegration = readIntegrationMarker(req.headers['x-qase-integration']);
|
|
261
|
-
// The one remembered for the session, filled in below.
|
|
262
|
-
let sessionIntegration;
|
|
263
|
-
if (sessionId && sessions.has(sessionId)) {
|
|
264
|
-
// Reuse existing transport for this session — bump last-seen
|
|
265
|
-
transport = sessions.get(sessionId);
|
|
266
|
-
sessionLastSeen.set(sessionId, Date.now());
|
|
267
|
-
sessionIntegration = sessionIntegrations.get(sessionId);
|
|
268
|
-
}
|
|
269
|
-
else if (isInitializeRequest(req.body)) {
|
|
270
|
-
// This is an initialize request - create new session
|
|
271
|
-
const newSessionId = randomUUID();
|
|
272
|
-
transport = new NodeStreamableHTTPServerTransport({
|
|
273
|
-
sessionIdGenerator: () => newSessionId,
|
|
274
|
-
// Responses stream as SSE (the spec default). In JSON mode the pending
|
|
275
|
-
// HTTP response cannot carry a server→client request, so a destructive
|
|
276
|
-
// confirmation prompt can never reach the caller mid-call.
|
|
277
|
-
});
|
|
278
|
-
// Store session and record creation time
|
|
279
|
-
sessions.set(newSessionId, transport);
|
|
280
|
-
sessionLastSeen.set(newSessionId, Date.now());
|
|
281
|
-
// Remember the integration for the life of the session. The query parameter
|
|
282
|
-
// is only available here, on the initialize request that carries the URL.
|
|
283
|
-
sessionIntegration = headerIntegration ?? readIntegrationMarker(req.query.integration);
|
|
284
|
-
if (sessionIntegration) {
|
|
285
|
-
sessionIntegrations.set(newSessionId, sessionIntegration);
|
|
286
|
-
}
|
|
287
|
-
// Create a fresh Server instance per session — the SDK requires one Server per transport
|
|
288
|
-
await createServer().connect(transport);
|
|
289
|
-
console.error(`[StreamableHTTP] New session created: ${newSessionId}`);
|
|
290
|
-
}
|
|
291
|
-
else if (sessionId) {
|
|
292
|
-
// Session ID provided but unknown (expired, evicted, server restarted, or the
|
|
293
|
-
// request landed on a different instance). Per the MCP streamable-http spec,
|
|
294
|
-
// respond 404 so the client transparently starts a new session (re-initialize)
|
|
295
|
-
// instead of getting stuck on a 400. Auth (JWT) is client-side, so no re-login.
|
|
296
|
-
res.status(404).json({ error: 'Session not found. Reinitialize the session.' });
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
else {
|
|
300
|
-
// No session ID and not an initialize request.
|
|
301
|
-
res.status(400).json({
|
|
302
|
-
error: 'Bad Request: no session ID provided and not an initialize request',
|
|
303
|
-
});
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
190
|
+
// MCP endpoint — one route for every method.
|
|
191
|
+
//
|
|
192
|
+
// `GET` and `DELETE` used to have hand-written routes of their own: resume
|
|
193
|
+
// the standalone stream, end the session. Both are 2025-era session
|
|
194
|
+
// operations and there is no session to do either to, so the handler answers
|
|
195
|
+
// them `405`. They stay mounted here — rather than left to express's own
|
|
196
|
+
// 404 — precisely so that the handler's 405 is what a client receives, and
|
|
197
|
+
// so that an unauthenticated probe of either still meets the guard chain
|
|
198
|
+
// first.
|
|
199
|
+
//
|
|
200
|
+
// The guard chain is unchanged and stays in this order: rate limiter (reject a
|
|
201
|
+
// flood before spending a signature verify on it) → auth guard → the two
|
|
202
|
+
// AsyncLocalStorage scopes → the handler.
|
|
203
|
+
app.all(endpoint, ...guards, async (req, res) => {
|
|
204
|
+
console.error(`[StreamableHTTP] ${req.method} ${endpoint} received`);
|
|
306
205
|
// Extract per-request token from Authorization header (Bearer <token>)
|
|
307
206
|
const authHeader = req.headers['authorization'] || '';
|
|
308
207
|
const requestToken = authHeader.startsWith('Bearer ') ? authHeader.slice(7).trim() : '';
|
|
309
208
|
if (requestToken) {
|
|
310
209
|
console.error('[StreamableHTTP] Using per-request Bearer token');
|
|
311
210
|
}
|
|
312
|
-
//
|
|
313
|
-
//
|
|
314
|
-
|
|
211
|
+
// Read per request, not per session — there is no session to remember it
|
|
212
|
+
// for. Header first, since a browser-based client's preflight strips a
|
|
213
|
+
// query-string marker but not a declared request header; the query
|
|
214
|
+
// parameter is the fallback for clients that cannot set headers.
|
|
215
|
+
// normalizeIntegrationMarker() re-validates against ALLOWED_INTEGRATIONS,
|
|
216
|
+
// so an unknown or malformed marker resolves to '', same as no marker at
|
|
217
|
+
// all — and getIntegration() falls through to QASE_MCP_INTEGRATION,
|
|
218
|
+
// exactly as it does on stdio.
|
|
219
|
+
const rawIntegration = req.headers['x-qase-integration'] || req.query.integration;
|
|
220
|
+
const integration = normalizeIntegrationMarker(typeof rawIntegration === 'string' ? rawIntegration : undefined) ??
|
|
221
|
+
'';
|
|
315
222
|
// Run the handler inside AsyncLocalStorage context so getApiClient() can read the token
|
|
316
223
|
try {
|
|
317
|
-
await requestTokenStorage.run(requestToken, () => integrationStorage.run(integration, () =>
|
|
224
|
+
await requestTokenStorage.run(requestToken, () => integrationStorage.run(integration, () =>
|
|
225
|
+
// `req.auth` is the pass-through authInfo: the adapter forwards
|
|
226
|
+
// whatever upstream middleware attached, and the handler never reads
|
|
227
|
+
// a header or verifies a token itself. `req.body` is what
|
|
228
|
+
// express.json() already parsed, so nothing re-reads the stream.
|
|
229
|
+
nodeHandler(req, res, req.body)));
|
|
318
230
|
}
|
|
319
231
|
catch (error) {
|
|
320
232
|
console.error('[StreamableHTTP] Error handling request:', error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamableHttp.js","sourceRoot":"","sources":["../../src/transports/streamableHttp.ts"],"names":[],"mappings":"AAAA,OAAO,OAAoB,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,iCAAiC,EAAE,MAAM,4BAA4B,CAAC;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAoB,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAqB,MAAM,0BAA0B,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,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,IAAI,IAAI,MAAM,CAAC,IAAI,GAAG,QAAQ,EAAE,CAAC,CAAC;QAC/F,OAAO,CAAC,KAAK,CAAC,yCAAyC,IAAI,IAAI,MAAM,CAAC,IAAI,SAAS,CAAC,CAAC;IACvF,CAAC,CAAC,CAAC;IAEH,uBAAuB;IACvB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE;QACtC,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,4BAA4B;IAC5B,UAAU,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE;QACrC,OAAO,CAAC,KAAK,CACX,+CAA+C,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,UAAU,EAAE,CAC3F,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,2DAA2D;IAC1D,GAAW,CAAC,WAAW,GAAG,UAAU,CAAC;IAEtC,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -13,4 +13,34 @@ export declare const requestTokenStorage: AsyncLocalStorage<string>;
|
|
|
13
13
|
* global cache shard.
|
|
14
14
|
*/
|
|
15
15
|
export declare function getEffectiveToken(): string;
|
|
16
|
+
/** The literal key used when there is no authenticated subject (OAuth off). */
|
|
17
|
+
export declare const LOCAL_SUBJECT = "local";
|
|
18
|
+
/**
|
|
19
|
+
* Derive the caller's identity for per-caller isolation — tool activation
|
|
20
|
+
* (src/server.ts) and the destructive-confirmation caller binding
|
|
21
|
+
* (src/utils/request-state.ts) both call this ONE function, so the two can
|
|
22
|
+
* never drift apart.
|
|
23
|
+
*
|
|
24
|
+
* Precedence:
|
|
25
|
+
* 1. `extra.sub` — set by our JWKS verifier (src/auth/jwks-verifier.ts)
|
|
26
|
+
* when OAuth validated a JWT that actually carries a `sub` claim.
|
|
27
|
+
* 2. A digest of the per-request API token — covers every other
|
|
28
|
+
* reachable state that leaves `sub` unset: OAuth on with an opaque
|
|
29
|
+
* Qase token (src/auth/mcp-guard.ts passes it through without setting
|
|
30
|
+
* `req.auth`), a JWT with no `sub` claim, and the SSE transport, which
|
|
31
|
+
* has no OAuth wiring at all. Both HTTP transports
|
|
32
|
+
* (streamableHttp.ts, sse.ts) open `requestTokenStorage` for every
|
|
33
|
+
* request, so the token is available here without new plumbing.
|
|
34
|
+
* SHA-256 hex digest, never the token itself — the raw token would
|
|
35
|
+
* otherwise end up in a Redis key (tool activation) or a log line.
|
|
36
|
+
* 3. `LOCAL_SUBJECT` — stdio, where there is no per-request token and one
|
|
37
|
+
* process serves one user, so a single shared identity is correct.
|
|
38
|
+
*/
|
|
39
|
+
export declare function subjectFromContext(ctx: {
|
|
40
|
+
http?: {
|
|
41
|
+
authInfo?: {
|
|
42
|
+
extra?: Record<string, unknown>;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
}): string;
|
|
16
46
|
//# sourceMappingURL=auth-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-context.d.ts","sourceRoot":"","sources":["../../src/utils/auth-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"auth-context.d.ts","sourceRoot":"","sources":["../../src/utils/auth-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,2BAAkC,CAAC;AAEnE;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAW1C;AAED,+EAA+E;AAC/E,eAAO,MAAM,aAAa,UAAU,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE;IACtC,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE;YAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;SAAE,CAAA;KAAE,CAAC;CAC3D,GAAG,MAAM,CAQT"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
2
3
|
/**
|
|
3
4
|
* Per-request token storage.
|
|
4
5
|
* Holds the Bearer token extracted from the Authorization header for the current request.
|
|
@@ -23,4 +24,36 @@ export function getEffectiveToken() {
|
|
|
23
24
|
}
|
|
24
25
|
return envToken;
|
|
25
26
|
}
|
|
27
|
+
/** The literal key used when there is no authenticated subject (OAuth off). */
|
|
28
|
+
export const LOCAL_SUBJECT = 'local';
|
|
29
|
+
/**
|
|
30
|
+
* Derive the caller's identity for per-caller isolation — tool activation
|
|
31
|
+
* (src/server.ts) and the destructive-confirmation caller binding
|
|
32
|
+
* (src/utils/request-state.ts) both call this ONE function, so the two can
|
|
33
|
+
* never drift apart.
|
|
34
|
+
*
|
|
35
|
+
* Precedence:
|
|
36
|
+
* 1. `extra.sub` — set by our JWKS verifier (src/auth/jwks-verifier.ts)
|
|
37
|
+
* when OAuth validated a JWT that actually carries a `sub` claim.
|
|
38
|
+
* 2. A digest of the per-request API token — covers every other
|
|
39
|
+
* reachable state that leaves `sub` unset: OAuth on with an opaque
|
|
40
|
+
* Qase token (src/auth/mcp-guard.ts passes it through without setting
|
|
41
|
+
* `req.auth`), a JWT with no `sub` claim, and the SSE transport, which
|
|
42
|
+
* has no OAuth wiring at all. Both HTTP transports
|
|
43
|
+
* (streamableHttp.ts, sse.ts) open `requestTokenStorage` for every
|
|
44
|
+
* request, so the token is available here without new plumbing.
|
|
45
|
+
* SHA-256 hex digest, never the token itself — the raw token would
|
|
46
|
+
* otherwise end up in a Redis key (tool activation) or a log line.
|
|
47
|
+
* 3. `LOCAL_SUBJECT` — stdio, where there is no per-request token and one
|
|
48
|
+
* process serves one user, so a single shared identity is correct.
|
|
49
|
+
*/
|
|
50
|
+
export function subjectFromContext(ctx) {
|
|
51
|
+
const sub = ctx.http?.authInfo?.extra?.sub;
|
|
52
|
+
if (typeof sub === 'string' && sub.length > 0)
|
|
53
|
+
return sub;
|
|
54
|
+
const token = requestTokenStorage.getStore();
|
|
55
|
+
if (token)
|
|
56
|
+
return createHash('sha256').update(token).digest('hex');
|
|
57
|
+
return LOCAL_SUBJECT;
|
|
58
|
+
}
|
|
26
59
|
//# sourceMappingURL=auth-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-context.js","sourceRoot":"","sources":["../../src/utils/auth-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"auth-context.js","sourceRoot":"","sources":["../../src/utils/auth-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,iBAAiB,EAAU,CAAC;AAEnE;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,YAAY,GAAG,mBAAmB,CAAC,QAAQ,EAAE,CAAC;IACpD,IAAI,YAAY;QAAE,OAAO,YAAY,CAAC;IACtC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IAC5C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,kGAAkG;YAChG,6DAA6D,CAChE,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,+EAA+E;AAC/E,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAElC;IACC,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,CAAC;IAC3C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IAE1D,MAAM,KAAK,GAAG,mBAAmB,CAAC,QAAQ,EAAE,CAAC;IAC7C,IAAI,KAAK;QAAE,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEnE,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who is talking to us, and on which revision of the protocol.
|
|
3
|
+
*
|
|
4
|
+
* This server serves two protocol eras at once, and the decision to stop
|
|
5
|
+
* serving the older one cannot be made from the code — only from traffic. The
|
|
6
|
+
* counter this module feeds is what turns "should we drop 2025-11-25?" into a
|
|
7
|
+
* question with an answer.
|
|
8
|
+
*
|
|
9
|
+
* On the 2026-07-28 revision every request carries a `_meta` envelope naming
|
|
10
|
+
* the revision and identifying the client, so both labels come from the
|
|
11
|
+
* request itself. A 2025-era request carries no envelope at all; the client's
|
|
12
|
+
* name is then only known where an `initialize` happened (stdio, SSE), and is
|
|
13
|
+
* reported as `unknown` on a stateless HTTP leg — which is itself worth
|
|
14
|
+
* knowing, since that is exactly the traffic a strict modern-only endpoint
|
|
15
|
+
* would refuse.
|
|
16
|
+
*/
|
|
17
|
+
/** Distinct client names this process will ever emit as a label. */
|
|
18
|
+
export declare const CLIENT_LABEL_LIMIT = 20;
|
|
19
|
+
/**
|
|
20
|
+
* Turns a client-supplied name into a bounded metric label.
|
|
21
|
+
*
|
|
22
|
+
* The name arrives from the wire, and every distinct value becomes its own
|
|
23
|
+
* series in an in-process map that nothing evicts. So the value is both
|
|
24
|
+
* normalised (a label is not free-form text) and CAPPED: past the limit every
|
|
25
|
+
* new name collapses into one bucket. Names already seen keep their series, so
|
|
26
|
+
* the clients that actually matter stay legible however much noise arrives
|
|
27
|
+
* after them.
|
|
28
|
+
*/
|
|
29
|
+
export declare class ClientLabeller {
|
|
30
|
+
private readonly limit;
|
|
31
|
+
private readonly seen;
|
|
32
|
+
constructor(limit?: number);
|
|
33
|
+
label(raw: unknown): string;
|
|
34
|
+
}
|
|
35
|
+
/** The handler context this module reads — narrower than the SDK's, on purpose. */
|
|
36
|
+
interface TelemetryContext {
|
|
37
|
+
mcpReq?: {
|
|
38
|
+
envelope?: Record<string, unknown>;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The two labels for one request. The revision string is passed through as the
|
|
43
|
+
* envelope names it rather than folded into an era, so a revision that does not
|
|
44
|
+
* exist yet shows up as itself on the day a client first sends it.
|
|
45
|
+
*/
|
|
46
|
+
export declare function protocolLabels(ctx: TelemetryContext, labeller: ClientLabeller): {
|
|
47
|
+
protocol: string;
|
|
48
|
+
client: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Who made this request, for a log line.
|
|
52
|
+
*
|
|
53
|
+
* Unlike the metric labels this is uncapped and keeps the client's version:
|
|
54
|
+
* a log has no cardinality problem, and when a refusal has to be explained
|
|
55
|
+
* the exact client build is the thing worth knowing. Reading a refusal
|
|
56
|
+
* without it leaves "some client declined" and no way to tell whose.
|
|
57
|
+
*/
|
|
58
|
+
export declare function describeCaller(ctx: TelemetryContext): string;
|
|
59
|
+
/** Count one served request under the revision and client it came from. */
|
|
60
|
+
export declare function recordProtocolRequest(ctx: TelemetryContext): void;
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=protocol-telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-telemetry.d.ts","sourceRoot":"","sources":["../../src/utils/protocol-telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,oEAAoE;AACpE,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAUrC;;;;;;;;;GASG;AACH,qBAAa,cAAc;IAGb,OAAO,CAAC,QAAQ,CAAC,KAAK;IAFlC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqB;gBAEb,KAAK,GAAE,MAA2B;IAE/D,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;CAe5B;AAED,mFAAmF;AACnF,UAAU,gBAAgB;IACxB,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;CACjD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,gBAAgB,EACrB,QAAQ,EAAE,cAAc,GACvB;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAkBtC;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,gBAAgB,GAAG,MAAM,CAkB5D;AAoBD,2EAA2E;AAC3E,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI,CAEjE"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who is talking to us, and on which revision of the protocol.
|
|
3
|
+
*
|
|
4
|
+
* This server serves two protocol eras at once, and the decision to stop
|
|
5
|
+
* serving the older one cannot be made from the code — only from traffic. The
|
|
6
|
+
* counter this module feeds is what turns "should we drop 2025-11-25?" into a
|
|
7
|
+
* question with an answer.
|
|
8
|
+
*
|
|
9
|
+
* On the 2026-07-28 revision every request carries a `_meta` envelope naming
|
|
10
|
+
* the revision and identifying the client, so both labels come from the
|
|
11
|
+
* request itself. A 2025-era request carries no envelope at all; the client's
|
|
12
|
+
* name is then only known where an `initialize` happened (stdio, SSE), and is
|
|
13
|
+
* reported as `unknown` on a stateless HTTP leg — which is itself worth
|
|
14
|
+
* knowing, since that is exactly the traffic a strict modern-only endpoint
|
|
15
|
+
* would refuse.
|
|
16
|
+
*/
|
|
17
|
+
import { PROTOCOL_VERSION_META_KEY, CLIENT_INFO_META_KEY } from '@modelcontextprotocol/server';
|
|
18
|
+
import { getMetrics } from '../cache/index.js';
|
|
19
|
+
import { getServer } from './server-context.js';
|
|
20
|
+
/** Distinct client names this process will ever emit as a label. */
|
|
21
|
+
export const CLIENT_LABEL_LIMIT = 20;
|
|
22
|
+
/** The label for a request whose era carries no version envelope. */
|
|
23
|
+
const LEGACY_PROTOCOL = 'legacy';
|
|
24
|
+
const UNKNOWN_CLIENT = 'unknown';
|
|
25
|
+
/** An envelope that names no revision — shape drift, not an era. */
|
|
26
|
+
const UNKNOWN_PROTOCOL = 'unknown';
|
|
27
|
+
const OVERFLOW_CLIENT = 'other';
|
|
28
|
+
const MAX_CLIENT_LENGTH = 32;
|
|
29
|
+
/**
|
|
30
|
+
* Turns a client-supplied name into a bounded metric label.
|
|
31
|
+
*
|
|
32
|
+
* The name arrives from the wire, and every distinct value becomes its own
|
|
33
|
+
* series in an in-process map that nothing evicts. So the value is both
|
|
34
|
+
* normalised (a label is not free-form text) and CAPPED: past the limit every
|
|
35
|
+
* new name collapses into one bucket. Names already seen keep their series, so
|
|
36
|
+
* the clients that actually matter stay legible however much noise arrives
|
|
37
|
+
* after them.
|
|
38
|
+
*/
|
|
39
|
+
export class ClientLabeller {
|
|
40
|
+
limit;
|
|
41
|
+
seen = new Set();
|
|
42
|
+
constructor(limit = CLIENT_LABEL_LIMIT) {
|
|
43
|
+
this.limit = limit;
|
|
44
|
+
}
|
|
45
|
+
label(raw) {
|
|
46
|
+
if (typeof raw !== 'string')
|
|
47
|
+
return UNKNOWN_CLIENT;
|
|
48
|
+
const cleaned = raw
|
|
49
|
+
.toLowerCase()
|
|
50
|
+
.replace(/[^a-z0-9._-]+/g, '-')
|
|
51
|
+
.replace(/^-+|-+$/g, '')
|
|
52
|
+
.slice(0, MAX_CLIENT_LENGTH);
|
|
53
|
+
if (!cleaned)
|
|
54
|
+
return UNKNOWN_CLIENT;
|
|
55
|
+
if (this.seen.has(cleaned))
|
|
56
|
+
return cleaned;
|
|
57
|
+
if (this.seen.size >= this.limit)
|
|
58
|
+
return OVERFLOW_CLIENT;
|
|
59
|
+
this.seen.add(cleaned);
|
|
60
|
+
return cleaned;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The two labels for one request. The revision string is passed through as the
|
|
65
|
+
* envelope names it rather than folded into an era, so a revision that does not
|
|
66
|
+
* exist yet shows up as itself on the day a client first sends it.
|
|
67
|
+
*/
|
|
68
|
+
export function protocolLabels(ctx, labeller) {
|
|
69
|
+
const envelope = ctx.mcpReq?.envelope;
|
|
70
|
+
if (!envelope) {
|
|
71
|
+
// 2025-era: the name is known only if an initialize established it.
|
|
72
|
+
return {
|
|
73
|
+
protocol: LEGACY_PROTOCOL,
|
|
74
|
+
client: labeller.label(getServer()?.getClientVersion()?.name),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const version = envelope[PROTOCOL_VERSION_META_KEY];
|
|
78
|
+
const clientInfo = envelope[CLIENT_INFO_META_KEY];
|
|
79
|
+
return {
|
|
80
|
+
protocol: typeof version === 'string' && version.length > 0 ? version : UNKNOWN_PROTOCOL,
|
|
81
|
+
client: labeller.label(clientInfo?.name),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Who made this request, for a log line.
|
|
86
|
+
*
|
|
87
|
+
* Unlike the metric labels this is uncapped and keeps the client's version:
|
|
88
|
+
* a log has no cardinality problem, and when a refusal has to be explained
|
|
89
|
+
* the exact client build is the thing worth knowing. Reading a refusal
|
|
90
|
+
* without it leaves "some client declined" and no way to tell whose.
|
|
91
|
+
*/
|
|
92
|
+
export function describeCaller(ctx) {
|
|
93
|
+
const envelope = ctx.mcpReq?.envelope;
|
|
94
|
+
if (!envelope) {
|
|
95
|
+
// 2025-era: the name is whatever `initialize` established on this
|
|
96
|
+
// connection, and a stateless leg never saw one.
|
|
97
|
+
const legacy = getServer()?.getClientVersion();
|
|
98
|
+
return formatCaller(legacy?.name, legacy?.version, LEGACY_PROTOCOL);
|
|
99
|
+
}
|
|
100
|
+
const version = envelope[PROTOCOL_VERSION_META_KEY];
|
|
101
|
+
const info = envelope[CLIENT_INFO_META_KEY];
|
|
102
|
+
return formatCaller(info?.name, info?.version, typeof version === 'string' && version ? version : UNKNOWN_PROTOCOL);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* `name version @ revision`, leaving out whichever parts the client withheld.
|
|
106
|
+
*
|
|
107
|
+
* Both eras read their three values from different places but write the same
|
|
108
|
+
* line, so the shape lives here once — the two call sites differ in where
|
|
109
|
+
* they look, not in what they produce. Everything arriving here is `unknown`
|
|
110
|
+
* because it came off the wire.
|
|
111
|
+
*/
|
|
112
|
+
function formatCaller(name, version, revision) {
|
|
113
|
+
const who = typeof name === 'string' && name ? name : 'unknown';
|
|
114
|
+
const build = typeof version === 'string' && version ? ' ' + version : '';
|
|
115
|
+
return `${who}${build} @ ${revision}`;
|
|
116
|
+
}
|
|
117
|
+
/** One labeller per process, so the cap bounds the process and not one request. */
|
|
118
|
+
const processLabeller = new ClientLabeller();
|
|
119
|
+
/** Count one served request under the revision and client it came from. */
|
|
120
|
+
export function recordProtocolRequest(ctx) {
|
|
121
|
+
getMetrics().incCounter('qase_mcp_requests_total', protocolLabels(ctx, processLabeller));
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=protocol-telemetry.js.map
|