@smartbear/mcp 0.43.0 → 0.45.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 (35) hide show
  1. package/dist/bugsnag/client/api/Project.js +1 -1
  2. package/dist/bugsnag/client.js +14 -2
  3. package/dist/bugsnag/input-schemas.js +31 -13
  4. package/dist/bugsnag/tool/error/get-error.js +5 -4
  5. package/dist/bugsnag/tool/error/list-project-errors.js +7 -5
  6. package/dist/bugsnag/tool/error/update-error.js +7 -4
  7. package/dist/bugsnag/tool/event/get-event-details-from-dashboard-url.js +3 -2
  8. package/dist/bugsnag/tool/event/get-event.js +4 -0
  9. package/dist/bugsnag/tool/event/list-error-events.js +16 -4
  10. package/dist/bugsnag/tool/performance/get-span-group.js +1 -0
  11. package/dist/bugsnag/tool/performance/get-trace.js +13 -5
  12. package/dist/bugsnag/tool/performance/list-span-groups.js +7 -3
  13. package/dist/bugsnag/tool/performance/list-spans.js +5 -2
  14. package/dist/bugsnag/tool/performance/list-trace-fields.js +1 -1
  15. package/dist/bugsnag/tool/performance/set-network-endpoint-groupings.js +3 -2
  16. package/dist/bugsnag/tool/project/get-current-project.js +3 -3
  17. package/dist/bugsnag/tool/project/list-project-event-filters.js +3 -3
  18. package/dist/bugsnag/tool/project/list-projects.js +6 -3
  19. package/dist/bugsnag/tool/release/get-build.js +4 -1
  20. package/dist/bugsnag/tool/release/get-release.js +4 -1
  21. package/dist/bugsnag/tool/release/list-releases.js +5 -4
  22. package/dist/common/cache.js +21 -2
  23. package/dist/common/config-names.js +12 -0
  24. package/dist/common/info.js +2 -0
  25. package/dist/common/list-integrations.js +53 -0
  26. package/dist/common/server.js +65 -3
  27. package/dist/common/transport-http.js +206 -35
  28. package/dist/common/transport-stdio.js +1 -6
  29. package/dist/package.json.js +1 -1
  30. package/dist/zephyr/common/rest-api-schemas.js +12 -3
  31. package/dist/zephyr/tool/test-case/create-web-link.js +17 -2
  32. package/dist/zephyr/tool/test-case/get-test-cases.js +9 -0
  33. package/dist/zephyr/tool/test-cycle/create-web-link.js +18 -2
  34. package/package.json +3 -1
  35. package/src/pactflow/drift/README.md +91 -0
@@ -2,6 +2,7 @@ import packageJson from "../package.json.js";
2
2
  import { getCurrentClientIdentity } from "./client-identity.js";
3
3
  const MCP_SERVER_NAME = packageJson.config.mcpServerName;
4
4
  const MCP_SERVER_VERSION = packageJson.version;
5
+ const MCP_SERVER_INSTRUCTIONS = "SmartBear MCP Server: debugging and monitoring (BugSnag), API design and contract testing (Swagger, PactFlow), test management and execution (QMetry, QTM4J, Zephyr, Reflect, BearQ), and code review (Collaborator). Only tools for products with valid, configured credentials are registered. Call smartbear_list_integrations to see what's active and what each unconfigured product needs.";
5
6
  const MCP_TRANSPORT = process.env.MCP_TRANSPORT?.toLowerCase().trim() || "stdio";
6
7
  const USER_AGENT = `${MCP_SERVER_NAME}/${MCP_SERVER_VERSION} ${MCP_TRANSPORT}`;
7
8
  function sanitizeUserAgentToken(value) {
@@ -22,6 +23,7 @@ function getUserAgent() {
22
23
  return appendClientIdentity(USER_AGENT);
23
24
  }
24
25
  export {
26
+ MCP_SERVER_INSTRUCTIONS,
25
27
  MCP_SERVER_NAME,
26
28
  MCP_SERVER_VERSION,
27
29
  MCP_TRANSPORT,
@@ -0,0 +1,53 @@
1
+ import { clientRegistry } from "./client-registry.js";
2
+ import { getHeaderName, getEnvVarName } from "./config-names.js";
3
+ import { getTypeDescription, isOptionalType } from "./zod-utils.js";
4
+ const LIST_INTEGRATIONS_TOOL_NAME = "smartbear_list_integrations";
5
+ const INTEGRATION_DESCRIPTIONS = {
6
+ BugSnag: "Error monitoring and stability data for your applications.",
7
+ Swagger: "API design, hosting and governance with SwaggerHub.",
8
+ "Contract Testing": "Consumer-driven contract testing and can-i-deploy checks with PactFlow.",
9
+ QMetry: "Test case management and execution with QMetry.",
10
+ QTM4J: "Test case management and execution in Jira with QMetry QTM4J.",
11
+ Zephyr: "Test case management and execution tracking.",
12
+ Reflect: "No-code web test automation and test runs.",
13
+ BearQ: "AI-driven test creation and execution.",
14
+ Collaborator: "Peer code and document review."
15
+ };
16
+ function buildIntegrationsReport(server) {
17
+ const added = server.getClients();
18
+ const integrations = clientRegistry.getAll().map((catalogClient) => {
19
+ const product = catalogClient.name;
20
+ const description = INTEGRATION_DESCRIPTIONS[product] ?? "No description available.";
21
+ const active = added.find((c) => c.name === product);
22
+ if (active?.isConfigured()) {
23
+ const toolsets = server.getToolsetStats(product);
24
+ return {
25
+ product,
26
+ description,
27
+ configured: true,
28
+ toolCount: toolsets.reduce(
29
+ (sum, ts) => sum + (ts.enabled ? ts.toolCount : 0),
30
+ 0
31
+ ),
32
+ toolsets
33
+ };
34
+ }
35
+ return {
36
+ product,
37
+ description,
38
+ configured: false,
39
+ setup: Object.entries(catalogClient.config.shape).map(([key, type]) => ({
40
+ envVar: getEnvVarName(catalogClient.configPrefix, key),
41
+ header: getHeaderName(catalogClient.configPrefix, key),
42
+ required: !isOptionalType(type),
43
+ description: getTypeDescription(type) ?? ""
44
+ }))
45
+ };
46
+ });
47
+ return { integrations };
48
+ }
49
+ export {
50
+ INTEGRATION_DESCRIPTIONS,
51
+ LIST_INTEGRATIONS_TOOL_NAME,
52
+ buildIntegrationsReport
53
+ };
@@ -4,7 +4,8 @@ import Bugsnag from "./bugsnag.js";
4
4
  import { errorTypeOf, trackToolCalled } from "./analytics.js";
5
5
  import { isCachingEnabled, CacheService, getConfiguredCacheTtlSeconds } from "./cache.js";
6
6
  import { toClientIdentity, getCurrentClientIdentity } from "./client-identity.js";
7
- import { MCP_SERVER_VERSION, MCP_SERVER_NAME } from "./info.js";
7
+ import { MCP_SERVER_VERSION, MCP_SERVER_NAME, MCP_SERVER_INSTRUCTIONS } from "./info.js";
8
+ import { LIST_INTEGRATIONS_TOOL_NAME, buildIntegrationsReport } from "./list-integrations.js";
8
9
  import { runWithElicitationScope, InputRequiredSignal, executeElicitationOrPolyfill, isElicitationPolyfillResult } from "./pollyfills.js";
9
10
  import { getRequestEra, getRequestClientMeta } from "./request-context.js";
10
11
  import { ToolError } from "./tools.js";
@@ -30,6 +31,8 @@ class SmartBearMcpServer extends McpServer {
30
31
  enabledToolsets;
31
32
  mcpClientIdentity;
32
33
  analyticsSession;
34
+ /** Per client name: every tool the client offered, bucketed by toolset. */
35
+ toolsetStats = /* @__PURE__ */ new Map();
33
36
  constructor(enabledToolsets, era = "legacy") {
34
37
  super(
35
38
  {
@@ -37,6 +40,8 @@ class SmartBearMcpServer extends McpServer {
37
40
  version: MCP_SERVER_VERSION
38
41
  },
39
42
  {
43
+ // Static text, identical for every session, era and transport.
44
+ instructions: MCP_SERVER_INSTRUCTIONS,
40
45
  capabilities: era === "modern" ? {
41
46
  // resources and prompts are supported by some but not all clients.
42
47
  // No `logging`: deprecated by SEP-2577 as of 2026-07-28 (our
@@ -65,10 +70,52 @@ class SmartBearMcpServer extends McpServer {
65
70
  ...isCachingEnabled() ? { cacheHints: buildCacheHints() } : {}
66
71
  }
67
72
  );
68
- this.cache = new CacheService();
73
+ this.cache = new CacheService({ sweepExpired: false });
69
74
  if (enabledToolsets) {
70
75
  this.enabledToolsets = enabledToolsets.split(",").map((s) => s.trim().toLowerCase());
71
76
  }
77
+ this.registerListIntegrationsTool();
78
+ }
79
+ /**
80
+ * Registered unconditionally (not via addClient) so it exists even when no
81
+ * product is configured. Reads only in-memory metadata, so it never needs
82
+ * credentials and never throws a ToolError for missing configuration.
83
+ */
84
+ registerListIntegrationsTool() {
85
+ this.registerTool(
86
+ LIST_INTEGRATIONS_TOOL_NAME,
87
+ {
88
+ title: "SmartBear: List Integrations",
89
+ description: "Lists every SmartBear product this server supports, whether it is configured for this connection, and for unconfigured products the environment variable or HTTP header each setting needs. Only products allowed by the server's MCP_CLIENTS setting are listed. Products that accept per-request OAuth tokens (BearQ, Reflect, QMetry) always show as configured. Takes no parameters.",
90
+ inputSchema: z.object({}),
91
+ annotations: {
92
+ title: "SmartBear: List Integrations",
93
+ readOnlyHint: true,
94
+ destructiveHint: false,
95
+ idempotentHint: true,
96
+ openWorldHint: false
97
+ }
98
+ },
99
+ async () => ({
100
+ content: [
101
+ {
102
+ type: "text",
103
+ text: JSON.stringify(buildIntegrationsReport(this), null, 2)
104
+ }
105
+ ]
106
+ })
107
+ );
108
+ }
109
+ /**
110
+ * Toolset breakdown for a client: the full potential tool count per toolset
111
+ * and whether the toolset is enabled (so hidden tools are visible).
112
+ */
113
+ getToolsetStats(clientName) {
114
+ return [...this.toolsetStats.get(clientName) ?? []].map(([name, { total, enabled }]) => ({
115
+ name,
116
+ toolCount: total,
117
+ enabled: enabled > 0
118
+ })).sort((a, b) => a.name.localeCompare(b.name));
72
119
  }
73
120
  getCache() {
74
121
  return this.cache;
@@ -170,7 +217,9 @@ class SmartBearMcpServer extends McpServer {
170
217
  this.clients.push(client);
171
218
  await client.registerTools(
172
219
  (params, cb) => {
173
- if (!this.isToolEnabled(client, params.toolset)) {
220
+ const enabled = this.isToolEnabled(client, params.toolset);
221
+ this.recordToolset(client.name, params.toolset, enabled);
222
+ if (!enabled) {
174
223
  return null;
175
224
  }
176
225
  const toolName = this.getCapabilityName(client, params.title);
@@ -329,6 +378,19 @@ ${result.instructions}`
329
378
  }
330
379
  this.sortToolsDeterministically();
331
380
  }
381
+ recordToolset(clientName, toolset, enabled) {
382
+ let byToolset = this.toolsetStats.get(clientName);
383
+ if (!byToolset) {
384
+ byToolset = /* @__PURE__ */ new Map();
385
+ this.toolsetStats.set(clientName, byToolset);
386
+ }
387
+ const stats = byToolset.get(toolset) ?? { total: 0, enabled: 0 };
388
+ stats.total++;
389
+ if (enabled) {
390
+ stats.enabled++;
391
+ }
392
+ byToolset.set(toolset, stats);
393
+ }
332
394
  /**
333
395
  * Re-key the SDK's tool registry alphabetically so `tools/list` output is
334
396
  * deterministic regardless of client registration order.
@@ -1,5 +1,5 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
- import { randomUUID } from "node:crypto";
2
+ import { randomBytes, randomUUID, createHmac } from "node:crypto";
3
3
  import { createServer } from "node:http";
4
4
  import querystring from "node:querystring";
5
5
  import { toNodeHandler, toWebRequest, NodeStreamableHTTPServerTransport } from "@modelcontextprotocol/node";
@@ -7,13 +7,103 @@ import { createMcpHandler, isLegacyRequest, isInitializeRequest } from "@modelco
7
7
  import { SSEServerTransport } from "@modelcontextprotocol/server-legacy/sse";
8
8
  import { initAnalytics, isToolsListRequest, trackToolsListed, createAnalyticsSession, flushAnalytics } from "./analytics.js";
9
9
  import { clientRegistry } from "./client-registry.js";
10
+ import { getHeaderName, getEnvVarName } from "./config-names.js";
10
11
  import { MCP_SERVER_VERSION } from "./info.js";
11
12
  import { extractModernClientMeta, handleInitializeMessage } from "./initialize.js";
12
13
  import { withRequestHeaders, withRequestContext, setRequestMcpClient, setModernRequestClient } from "./request-context.js";
13
14
  import { SmartBearMcpServer } from "./server.js";
14
15
  import { registerShutdownHandler, isDraining } from "./shutdown.js";
15
- import { getEnvVarName } from "./transport-stdio.js";
16
+ import "node:module";
17
+ import "@modelcontextprotocol/server/stdio";
16
18
  import { isOptionalType, getTypeDescription } from "./zod-utils.js";
19
+ function trackExchange(entry, res) {
20
+ entry.inFlight = (entry.inFlight ?? 0) + 1;
21
+ entry.lastActivity = Date.now();
22
+ res.once("close", () => {
23
+ entry.inFlight = Math.max(0, (entry.inFlight ?? 1) - 1);
24
+ entry.lastActivity = Date.now();
25
+ });
26
+ }
27
+ const DEFAULT_SESSION_IDLE_TIMEOUT_MS = 4 * 60 * 60 * 1e3;
28
+ function getSessionIdleTimeoutMs() {
29
+ const raw = process.env.SESSION_IDLE_TIMEOUT_MS?.trim();
30
+ if (!raw) return DEFAULT_SESSION_IDLE_TIMEOUT_MS;
31
+ const parsed = Number(raw);
32
+ return Number.isInteger(parsed) && parsed >= 0 ? parsed : DEFAULT_SESSION_IDLE_TIMEOUT_MS;
33
+ }
34
+ async function reapIdleSessions(transports, idleMs, now = Date.now()) {
35
+ const idle = [...transports.entries()].filter(
36
+ ([, entry]) => (entry.inFlight ?? 0) === 0 && now - (entry.lastActivity ?? now) > idleMs
37
+ );
38
+ await Promise.all(
39
+ idle.map(async ([sessionId, entry]) => {
40
+ if ((entry.inFlight ?? 0) > 0) return;
41
+ if (!transports.delete(sessionId)) return;
42
+ console.log(`[MCP] Reaping idle session: ${redactSessionId(sessionId)}`);
43
+ try {
44
+ await entry.transport.close();
45
+ } catch (err) {
46
+ console.error("[MCP] Error closing idle session:", err);
47
+ }
48
+ endSessionAnalytics(entry.server);
49
+ try {
50
+ await entry.server.cleanupSession(sessionId);
51
+ } catch (err) {
52
+ console.error("[MCP] Error cleaning up idle session:", err);
53
+ }
54
+ })
55
+ );
56
+ return idle.length;
57
+ }
58
+ const IDENTITY_KEY = randomBytes(32);
59
+ function resolveCredentialIdentity(server) {
60
+ const parts = [];
61
+ for (const client of server.getClients()) {
62
+ const token = client.getAuthToken?.();
63
+ if (token) {
64
+ parts.push(
65
+ `${client.capabilityPrefix}:${token.replace(/^Bearer\s+/i, "")}`
66
+ );
67
+ }
68
+ }
69
+ if (parts.length === 0) {
70
+ return null;
71
+ }
72
+ return createHmac("sha256", IDENTITY_KEY).update(parts.join("\0")).digest("hex");
73
+ }
74
+ function requestIdentity(req, server) {
75
+ return withRequestContext(req, () => resolveCredentialIdentity(server));
76
+ }
77
+ function writeSessionNotFound(res) {
78
+ res.writeHead(404, { "Content-Type": "application/json" });
79
+ res.end(
80
+ JSON.stringify({
81
+ jsonrpc: "2.0",
82
+ error: {
83
+ code: -32001,
84
+ message: "Session not found"
85
+ },
86
+ id: null
87
+ })
88
+ );
89
+ }
90
+ function authorizeSessionRequest(req, res, entry, notFound = writeSessionNotFound) {
91
+ if (!entry.identity) {
92
+ return true;
93
+ }
94
+ const current = requestIdentity(req, entry.server);
95
+ if (current === entry.identity) {
96
+ return true;
97
+ }
98
+ req.resume();
99
+ if (current === null) {
100
+ res.writeHead(401, unauthorizedHeaders(req.headers, req.headers.host));
101
+ res.end("Unauthorized: credentials are required on every request");
102
+ } else {
103
+ notFound(res);
104
+ }
105
+ return false;
106
+ }
17
107
  const PROBE_HEADERS = {
18
108
  "Content-Type": "application/json",
19
109
  "Cache-Control": "no-store"
@@ -64,6 +154,37 @@ function getBaseUrlFromHeaders(headers) {
64
154
  function getBaseUrl(req) {
65
155
  return getBaseUrlFromHeaders(req.headers);
66
156
  }
157
+ function hasExpiredBearerJwt(req, now = Date.now()) {
158
+ const header = req.headers.authorization;
159
+ const value = Array.isArray(header) ? header[0] : header;
160
+ const token = value?.match(/^Bearer\s+(\S+)/i)?.[1];
161
+ if (!token) return false;
162
+ const parts = token.split(".");
163
+ if (parts.length !== 3) return false;
164
+ try {
165
+ const { exp } = JSON.parse(
166
+ Buffer.from(parts[1], "base64url").toString("utf8")
167
+ );
168
+ return typeof exp === "number" && exp * 1e3 <= now;
169
+ } catch {
170
+ return false;
171
+ }
172
+ }
173
+ function rejectExpiredBearerToken(req, res) {
174
+ if (!hasExpiredBearerJwt(req)) return false;
175
+ req.resume();
176
+ res.writeHead(401, {
177
+ "Content-Type": "application/json",
178
+ "WWW-Authenticate": `Bearer error="invalid_token", error_description="The access token expired", resource_metadata="${getBaseUrl(req)}/.well-known/oauth-protected-resource"`
179
+ });
180
+ res.end(
181
+ JSON.stringify({
182
+ error: "invalid_token",
183
+ error_description: "The access token expired"
184
+ })
185
+ );
186
+ return true;
187
+ }
67
188
  async function runHttpMode() {
68
189
  const PORT = process.env.PORT ? Number.parseInt(process.env.PORT, 10) : 3e3;
69
190
  const allowedOrigins = process.env.ALLOWED_ORIGINS?.split(",") || [
@@ -172,7 +293,18 @@ ${headerHelp.join("\n")}`
172
293
  );
173
294
  }
174
295
  });
296
+ const idleMs = getSessionIdleTimeoutMs();
297
+ const reaper = idleMs > 0 ? setInterval(
298
+ () => {
299
+ reapIdleSessions(transports, idleMs).catch(
300
+ (err) => console.error("[MCP] Idle session reaper failed:", err)
301
+ );
302
+ },
303
+ Math.min(6e4, Math.max(1e3, Math.floor(idleMs / 2)))
304
+ ) : void 0;
305
+ reaper?.unref();
175
306
  registerShutdownHandler("http-transport", async () => {
307
+ if (reaper) clearInterval(reaper);
176
308
  try {
177
309
  await modernHandler.close();
178
310
  } catch (err) {
@@ -243,26 +375,42 @@ async function createNewTransport(req, res, transports) {
243
375
  if (!server) {
244
376
  return null;
245
377
  }
378
+ const identity = requestIdentity(req, server) ?? void 0;
246
379
  const transport = new NodeStreamableHTTPServerTransport({
247
380
  sessionIdGenerator: () => randomUUID(),
248
381
  onsessioninitialized: (newSessionId) => {
249
- console.log(`[MCP] New session initialized: ${newSessionId}`);
250
- transports.set(newSessionId, { server, transport });
382
+ console.log(
383
+ `[MCP] New session initialized: ${redactSessionId(newSessionId)}`
384
+ );
385
+ const entry = {
386
+ server,
387
+ transport,
388
+ lastActivity: Date.now(),
389
+ identity
390
+ };
391
+ transports.set(newSessionId, entry);
392
+ trackExchange(entry, res);
251
393
  attachSessionAnalytics(server, newSessionId, "streamable-http");
252
394
  }
253
395
  });
254
396
  transport.onmessage = (message) => handleSessionMessage(server, message);
255
397
  transport.onclose = () => {
256
398
  if (transport.sessionId) {
257
- console.log(`[MCP] Session closed: ${transport.sessionId}`);
258
- transports.delete(transport.sessionId);
259
- endSessionAnalytics(server);
260
- server.cleanupSession(transport.sessionId);
399
+ console.log(
400
+ `[MCP] Session closed: ${redactSessionId(transport.sessionId)}`
401
+ );
402
+ if (transports.delete(transport.sessionId)) {
403
+ endSessionAnalytics(server);
404
+ server.cleanupSession(transport.sessionId);
405
+ }
261
406
  }
262
407
  };
263
408
  await server.connect(transport);
264
409
  return transport;
265
410
  }
411
+ function redactSessionId(sessionId) {
412
+ return `${sessionId.slice(0, 8)}...`;
413
+ }
266
414
  function handleSessionMessage(server, message) {
267
415
  handleInitializeMessage(server, message);
268
416
  if (isToolsListRequest(message)) {
@@ -303,6 +451,7 @@ function createModernHandler() {
303
451
  );
304
452
  }
305
453
  async function handleMcpEndpoint(req, res, transports, modern) {
454
+ if (rejectExpiredBearerToken(req, res)) return;
306
455
  if (req.headers["mcp-session-id"]) {
307
456
  await handleStreamableHttpRequest(req, res, transports);
308
457
  return;
@@ -348,22 +497,19 @@ function extractModernClientMetaFromBody(parsedBody) {
348
497
  }
349
498
  async function handleStreamableHttpRequest(req, res, transports, preParsed) {
350
499
  try {
500
+ if (rejectExpiredBearerToken(req, res)) return;
351
501
  const sessionId = req.headers["mcp-session-id"];
352
- if (sessionId && !transports.has(sessionId)) {
502
+ const sessionEntry = sessionId ? transports.get(sessionId) : void 0;
503
+ if (sessionId && !sessionEntry) {
353
504
  req.resume();
354
- res.writeHead(404, { "Content-Type": "application/json" });
355
- res.end(
356
- JSON.stringify({
357
- jsonrpc: "2.0",
358
- error: {
359
- code: -32001,
360
- message: "Session not found"
361
- },
362
- id: null
363
- })
364
- );
505
+ writeSessionNotFound(res);
365
506
  return;
366
507
  }
508
+ if (sessionEntry && !authorizeSessionRequest(req, res, sessionEntry)) {
509
+ return;
510
+ }
511
+ const existingEntry = sessionId ? transports.get(sessionId) : void 0;
512
+ if (existingEntry) trackExchange(existingEntry, res);
367
513
  const parsedBody = preParsed ? preParsed.body : await parseRequestBody(req);
368
514
  let transport;
369
515
  if (sessionId) {
@@ -406,13 +552,23 @@ async function handleStreamableHttpRequest(req, res, transports, preParsed) {
406
552
  }
407
553
  }
408
554
  async function handleLegacySseRequest(req, res, transports) {
555
+ if (rejectExpiredBearerToken(req, res)) return;
409
556
  const server = await newServer(req, res);
410
557
  if (!server) {
411
558
  return;
412
559
  }
560
+ const identity = requestIdentity(req, server) ?? void 0;
413
561
  const transport = new SSEServerTransport("/message", res);
414
562
  transport.onmessage = (message) => handleSessionMessage(server, message);
415
- transports.set(transport.sessionId, { server, transport });
563
+ transports.set(transport.sessionId, {
564
+ server,
565
+ transport,
566
+ lastActivity: Date.now(),
567
+ // The SSE stream itself is an open exchange; the res "close" handler
568
+ // below removes the session when it ends.
569
+ inFlight: 1,
570
+ identity
571
+ });
416
572
  attachSessionAnalytics(server, transport.sessionId, "sse");
417
573
  res.on("close", () => {
418
574
  transports.delete(transport.sessionId);
@@ -421,7 +577,12 @@ async function handleLegacySseRequest(req, res, transports) {
421
577
  });
422
578
  await server.connect(transport);
423
579
  }
580
+ function writeLegacySessionNotFound(res) {
581
+ res.writeHead(404, { "Content-Type": "text/plain" });
582
+ res.end("Session not found");
583
+ }
424
584
  async function handleLegacyMessageRequest(req, res, url, transports) {
585
+ if (rejectExpiredBearerToken(req, res)) return;
425
586
  const sessionId = url.searchParams.get("sessionId");
426
587
  if (!sessionId) {
427
588
  res.writeHead(400, { "Content-Type": "text/plain" });
@@ -430,15 +591,18 @@ async function handleLegacyMessageRequest(req, res, url, transports) {
430
591
  }
431
592
  const session = transports.get(sessionId);
432
593
  if (!session) {
433
- res.writeHead(404, { "Content-Type": "text/plain" });
434
- res.end("Session not found");
594
+ writeLegacySessionNotFound(res);
435
595
  return;
436
596
  }
597
+ trackExchange(session, res);
437
598
  if (!(session.transport instanceof SSEServerTransport)) {
438
599
  res.writeHead(400, { "Content-Type": "text/plain" });
439
600
  res.end("Invalid transport for this endpoint");
440
601
  return;
441
602
  }
603
+ if (!authorizeSessionRequest(req, res, session, writeLegacySessionNotFound)) {
604
+ return;
605
+ }
442
606
  let body = "";
443
607
  req.on("data", (chunk) => {
444
608
  body += chunk.toString();
@@ -528,18 +692,21 @@ async function buildConfiguredServer(getConfig, headers, host, res, era) {
528
692
  const headerHelp = getHttpHeadersHelp();
529
693
  const errorMessage = headerHelp.length > 0 ? `Configuration error: ${error instanceof Error ? error.message : String(error)}. Please provide valid headers:
530
694
  ${headerHelp.join("\n")}` : "No clients support HTTP header configuration.";
531
- const responseHeaders = {
532
- "Content-Type": "text/plain"
533
- };
534
- if (process.env.BASE_URL || host) {
535
- responseHeaders["WWW-Authenticate"] = `OAuth resource_metadata="${getBaseUrlFromHeaders(headers)}/.well-known/oauth-protected-resource"`;
536
- }
537
- res.writeHead(401, responseHeaders);
695
+ res.writeHead(401, unauthorizedHeaders(headers, host));
538
696
  res.end(errorMessage);
539
697
  return null;
540
698
  }
541
699
  return server;
542
700
  }
701
+ function unauthorizedHeaders(headers, host) {
702
+ const responseHeaders = {
703
+ "Content-Type": "text/plain"
704
+ };
705
+ if (process.env.BASE_URL || host) {
706
+ responseHeaders["WWW-Authenticate"] = `OAuth resource_metadata="${getBaseUrlFromHeaders(headers)}/.well-known/oauth-protected-resource"`;
707
+ }
708
+ return responseHeaders;
709
+ }
543
710
  async function newServer(req, res) {
544
711
  return buildConfiguredServer(
545
712
  (clientPrefix, key) => getConfigValue(clientPrefix, key, req),
@@ -558,11 +725,6 @@ async function newServerFromWebRequest(request, res) {
558
725
  "modern"
559
726
  );
560
727
  }
561
- function getHeaderName(clientPrefix, key) {
562
- return `${clientPrefix}-${key.split("_").map(
563
- (part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase()
564
- ).join("-")}`;
565
- }
566
728
  function getQueryStringName(clientPrefix, key) {
567
729
  return `${clientPrefix.toLowerCase()}${key.split("_").map(
568
730
  (part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase()
@@ -593,17 +755,26 @@ function getHttpHeadersHelp() {
593
755
  }
594
756
  export {
595
757
  attachSessionAnalytics,
758
+ authorizeSessionRequest,
596
759
  drainHttpTransport,
597
760
  endSessionAnalytics,
598
761
  getBaseUrl,
599
762
  getBaseUrlFromHeaders,
600
763
  getHeaderName,
601
764
  getQueryStringName,
765
+ getSessionIdleTimeoutMs,
602
766
  handleHealthRequest,
767
+ handleLegacyMessageRequest,
768
+ handleLegacySseRequest,
769
+ handleMcpEndpoint,
603
770
  handleReadyRequest,
604
771
  handleSessionMessage,
605
772
  handleStreamableHttpRequest,
773
+ hasExpiredBearerJwt,
606
774
  newServer,
607
775
  newServerFromWebRequest,
776
+ reapIdleSessions,
777
+ rejectExpiredBearerToken,
778
+ resolveCredentialIdentity,
608
779
  runHttpMode
609
780
  };
@@ -2,6 +2,7 @@ import { enableCompileCache } from "node:module";
2
2
  import { StdioServerTransport, serveStdio } from "@modelcontextprotocol/server/stdio";
3
3
  import { setProcessClientIdentity, toClientIdentity } from "./client-identity.js";
4
4
  import { clientRegistry } from "./client-registry.js";
5
+ import { getEnvVarName } from "./config-names.js";
5
6
  import { USER_AGENT } from "./info.js";
6
7
  import { handleInitializeMessage, extractModernClientMeta } from "./initialize.js";
7
8
  import { SmartBearMcpServer } from "./server.js";
@@ -36,9 +37,6 @@ async function buildStdioServer(era = "legacy") {
36
37
  message.length > 0 ? `No clients configured. Please provide valid environment variables for at least one client:
37
38
  ${message.join("\n")}` : "No clients support environment variable configuration."
38
39
  );
39
- for (const entry of clientRegistry.getAll()) {
40
- await server.addClient(entry);
41
- }
42
40
  }
43
41
  return server;
44
42
  }
@@ -119,9 +117,6 @@ async function runStdioMode() {
119
117
  }
120
118
  });
121
119
  }
122
- function getEnvVarName(clientPrefix, key) {
123
- return `${clientPrefix.toUpperCase().replace(/-/g, "_")}_${key.toUpperCase()}`;
124
- }
125
120
  export {
126
121
  buildStdioServer,
127
122
  createInitializeCaptureTap,
@@ -1,4 +1,4 @@
1
- const version = "0.43.0";
1
+ const version = "0.45.0";
2
2
  const config = { "mcpServerName": "SmartBear MCP Server" };
3
3
  const packageJson = {
4
4
  version,
@@ -387,6 +387,9 @@ const ListTestCasesCursorPaginatedQueryParams = zod.object({
387
387
  startAtId: zod.int().min(listTestCasesCursorPaginatedQueryStartAtIdMin).default(listTestCasesCursorPaginatedQueryStartAtIdDefault).describe("Zero-indexed starting position for ID-based pagination."),
388
388
  updatedAfter: zod.iso.datetime({ offset: true }).optional().describe(
389
389
  "Filter only entities updated after the given time. Format: yyyy-MM-dd'T'HH:mm:ss'Z'"
390
+ ),
391
+ nameOrKey: zod.string().optional().describe(
392
+ "Filter only entities with the given Test Case name or key. If provided, the project key must also be provided."
390
393
  )
391
394
  });
392
395
  const listTestCasesCursorPaginated200ResponseOneNextStartAtIdMin = 0;
@@ -5126,6 +5129,9 @@ const CreateTestExecutionBody = zod.strictObject({
5126
5129
  comment: zod.string().nullish().describe("Comment added against overall test case execution."),
5127
5130
  customFields: zod.record(zod.string(), zod.unknown()).optional().describe(
5128
5131
  "Multi-line text fields support HTML and should denote new lines with the \\<br\\> tag.\nDates should be in the format 'yyyy-MM-dd'.\nUsers should have values of Jira User Account IDs.\n"
5132
+ ),
5133
+ automated: zod.boolean().optional().describe(
5134
+ "(optional) If true, the execution is marked as automated in the Zephyr UI; if false, it’s marked as manual. Defaults to true if not provided."
5129
5135
  )
5130
5136
  });
5131
5137
  const CreateTestExecution201Response = zod.strictObject({
@@ -5581,6 +5587,9 @@ const UpdateTestExecutionBody = zod.strictObject({
5581
5587
  "The actual end date of the test cycle. Format: yyyy-MM-dd'T'HH:mm:ss'Z'"
5582
5588
  ),
5583
5589
  executionTime: zod.int().min(updateTestExecutionBodyExecutionTimeMin).optional().describe("Actual test execution time in milliseconds."),
5590
+ automated: zod.boolean().optional().describe(
5591
+ "(optional) If true, the execution is marked as automated in the Zephyr UI; if false, it’s marked as manual. Defaults to true if not provided."
5592
+ ),
5584
5593
  executedById: zod.string().regex(updateTestExecutionBodyExecutedByIdRegExp).nullish().describe("Atlassian Account ID of the Jira user."),
5585
5594
  assignedToId: zod.string().regex(updateTestExecutionBodyAssignedToIdRegExp).nullish().describe("Atlassian Account ID of the Jira user."),
5586
5595
  comment: zod.string().nullish().describe("Comment added against overall test case execution.")
@@ -7469,7 +7478,7 @@ zod.object({
7469
7478
  const createCustomExecutionsBodyTestCycleNameMax = 255;
7470
7479
  const createCustomExecutionsBodyTestCycleNameRegExp = /^(?!\\s*$).+/;
7471
7480
  zod.strictObject({
7472
- file: zod.instanceof(File),
7481
+ file: zod.instanceof(Blob),
7473
7482
  testCycle: zod.strictObject({
7474
7483
  name: zod.string().min(1).max(createCustomExecutionsBodyTestCycleNameMax).regex(createCustomExecutionsBodyTestCycleNameRegExp).optional(),
7475
7484
  description: zod.string().nullish().describe("Description outlining the scope."),
@@ -7518,7 +7527,7 @@ zod.object({
7518
7527
  const createCucumberExecutionsBodyTestCycleNameMax = 255;
7519
7528
  const createCucumberExecutionsBodyTestCycleNameRegExp = /^(?!\\s*$).+/;
7520
7529
  zod.strictObject({
7521
- file: zod.instanceof(File),
7530
+ file: zod.instanceof(Blob),
7522
7531
  testCycle: zod.strictObject({
7523
7532
  name: zod.string().min(1).max(createCucumberExecutionsBodyTestCycleNameMax).regex(createCucumberExecutionsBodyTestCycleNameRegExp).optional(),
7524
7533
  description: zod.string().nullish().describe("Description outlining the scope."),
@@ -7567,7 +7576,7 @@ zod.object({
7567
7576
  const createJUnitExecutionsBodyTestCycleNameMax = 255;
7568
7577
  const createJUnitExecutionsBodyTestCycleNameRegExp = /^(?!\\s*$).+/;
7569
7578
  zod.strictObject({
7570
- file: zod.instanceof(File),
7579
+ file: zod.instanceof(Blob),
7571
7580
  testCycle: zod.strictObject({
7572
7581
  name: zod.string().min(1).max(createJUnitExecutionsBodyTestCycleNameMax).regex(createJUnitExecutionsBodyTestCycleNameRegExp).optional(),
7573
7582
  description: zod.string().nullish().describe("Description outlining the scope."),