@smartbear/mcp 0.37.0 → 0.38.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.
@@ -1,4 +1,6 @@
1
+ import { createHmac } from "node:crypto";
1
2
  import { z } from "zod";
3
+ import { CacheService } from "../common/cache.js";
2
4
  import { getUserAgent } from "../common/info.js";
3
5
  import { getRequestHeader } from "../common/request-context.js";
4
6
  import { ToolError } from "../common/tools.js";
@@ -28,13 +30,20 @@ import { ListReleases } from "./tool/release/list-releases.js";
28
30
  const HUB_PREFIX = "00000";
29
31
  const DEFAULT_DOMAIN = "bugsnag.com";
30
32
  const HUB_DOMAIN = "bugsnag.smartbear.com";
33
+ const BUGSNAG_CACHE_TTL_SECONDS = 60;
31
34
  const cacheKeys = {
32
35
  ORG: "bugsnag_org",
33
36
  PROJECTS: "bugsnag_projects",
34
37
  PROJECT_EVENT_FIELDS: "bugsnag_project_event_fields",
35
- PROJECT_TRACE_FIELDS: "bugsnag_project_trace_fields",
36
- CURRENT_PROJECT: "bugsnag_current_project"
38
+ PROJECT_TRACE_FIELDS: "bugsnag_project_trace_fields"
37
39
  };
40
+ let sharedCacheInstance;
41
+ function getSharedCache() {
42
+ if (!sharedCacheInstance) {
43
+ sharedCacheInstance = new CacheService();
44
+ }
45
+ return sharedCacheInstance;
46
+ }
38
47
  const EXCLUDED_EVENT_FIELDS = /* @__PURE__ */ new Set([
39
48
  "search"
40
49
  // This is searches multiple fields and is more a convenience for humans, we're removing to avoid over-matching
@@ -45,14 +54,16 @@ const ConfigurationSchema = z.object({
45
54
  endpoint: z.string().url().describe("BugSnag endpoint URL").optional()
46
55
  });
47
56
  class BugsnagClient {
48
- cache;
49
57
  _projectApiKey;
50
58
  _isConfigured = false;
51
59
  _currentUserApi;
52
60
  _errorsApi;
53
61
  _projectApi;
54
62
  _appEndpoint;
63
+ _cacheAuthority;
64
+ _endpoint;
55
65
  _authToken;
66
+ _selectedProjects = /* @__PURE__ */ new Map();
56
67
  get currentUserApi() {
57
68
  if (!this._currentUserApi) throw new Error("Client not configured");
58
69
  return this._currentUserApi;
@@ -69,22 +80,84 @@ class BugsnagClient {
69
80
  if (!this._appEndpoint) throw new Error("Client not configured");
70
81
  return this._appEndpoint;
71
82
  }
83
+ // Namespaces the shared cache by API authority and caller credential, hashed
84
+ // so neither value is exposed in a cache key. Tokens are meaningful only
85
+ // within their issuing authority, so both values are required for isolation.
86
+ // Returns undefined when there is no credential at all — callers then bypass the
87
+ // cache rather than sharing a single anonymous bucket.
88
+ cacheNamespace() {
89
+ const authToken = this.getAuthToken();
90
+ if (!authToken) {
91
+ return void 0;
92
+ }
93
+ const cacheAuthority = this.getRequestApiAuthority();
94
+ const namespace = createHmac("sha256", "bugsnag-cache-ns").update(cacheAuthority).update("\0").update(authToken).digest("hex").slice(0, 32);
95
+ return `tok:${namespace}`;
96
+ }
97
+ cacheKey(key) {
98
+ const namespace = this.cacheNamespace();
99
+ if (!namespace) {
100
+ return void 0;
101
+ }
102
+ return `${namespace}:${key}`;
103
+ }
104
+ // Namespaced cache read. Returns undefined when there is no credential to
105
+ // namespace by, so the caller falls through to the API.
106
+ cacheGet(key) {
107
+ const namespacedKey = this.cacheKey(key);
108
+ if (!namespacedKey) {
109
+ return void 0;
110
+ }
111
+ return getSharedCache().get(namespacedKey);
112
+ }
113
+ // Namespaced cache write. No-ops when there is no credential to namespace
114
+ // by, so an unauthenticated caller can never populate a shared entry.
115
+ cacheSet(key, value) {
116
+ const namespacedKey = this.cacheKey(key);
117
+ if (!namespacedKey) {
118
+ return;
119
+ }
120
+ getSharedCache().set(namespacedKey, value, BUGSNAG_CACHE_TTL_SECONDS);
121
+ }
72
122
  name = "BugSnag";
73
123
  capabilityPrefix = "bugsnag";
74
124
  configPrefix = "Bugsnag";
75
125
  config = ConfigurationSchema;
76
126
  defaultToolsets = ["Projects"];
77
- async configure(server, config) {
78
- this.cache = server.getCache();
127
+ async configure(_server, config) {
128
+ this._endpoint = config.endpoint;
79
129
  this._appEndpoint = this.getEndpoint(
80
130
  "app",
81
131
  config.project_api_key,
82
132
  config.endpoint
83
133
  );
134
+ this._cacheAuthority = this.getEndpoint(
135
+ "api",
136
+ config.project_api_key,
137
+ config.endpoint
138
+ );
84
139
  this._projectApiKey = config.project_api_key;
85
140
  this._authToken = config.auth_token;
86
141
  await this.initializeApis(config);
87
142
  }
143
+ getProjectApiKey() {
144
+ const contextHeader = getRequestHeader("Bugsnag-Project-Api-Key");
145
+ const requestProjectApiKey = Array.isArray(contextHeader) ? contextHeader[0] : contextHeader;
146
+ return requestProjectApiKey || this._projectApiKey;
147
+ }
148
+ getRequestApiAuthority() {
149
+ const authority = this.getEndpoint(
150
+ "api",
151
+ this.getProjectApiKey(),
152
+ this._endpoint
153
+ );
154
+ if (this._cacheAuthority && authority !== this._cacheAuthority) {
155
+ throw new ToolError(
156
+ `Bugsnag-Project-Api-Key cannot switch the API authority from ${this._cacheAuthority} to ${authority} within an active MCP session. Reconnect with the project key during session initialization.`
157
+ );
158
+ }
159
+ return authority;
160
+ }
88
161
  getAuthToken() {
89
162
  const contextHeader = getRequestHeader("Bugsnag-Auth-Token");
90
163
  if (contextHeader) {
@@ -98,7 +171,10 @@ class BugsnagClient {
98
171
  if (bearerToken) {
99
172
  return bearerToken;
100
173
  }
101
- return this._authToken ? `token ${this._authToken}` : null;
174
+ if (this._authToken) {
175
+ return `token ${this._authToken}`;
176
+ }
177
+ return null;
102
178
  }
103
179
  getBearerToken() {
104
180
  const contextHeader = getRequestHeader("Authorization");
@@ -175,7 +251,7 @@ class BugsnagClient {
175
251
  return `${dashboardUrl}/errors/${errorId}${queryString ? `?${queryString}` : ""}`;
176
252
  }
177
253
  async getOrganization() {
178
- let org = this.cache?.get(cacheKeys.ORG);
254
+ let org = this.cacheGet(cacheKeys.ORG);
179
255
  if (!org) {
180
256
  const response = await this.currentUserApi.listUserOrganizations();
181
257
  const orgs = response.body;
@@ -183,7 +259,7 @@ class BugsnagClient {
183
259
  throw new Error("No organizations found for the current user.");
184
260
  }
185
261
  org = orgs[0];
186
- this.cache?.set(cacheKeys.ORG, org);
262
+ this.cacheSet(cacheKeys.ORG, org);
187
263
  }
188
264
  return org;
189
265
  }
@@ -192,14 +268,14 @@ class BugsnagClient {
192
268
  // stores them in the cache for future use.
193
269
  // It throws an error if no organizations are found in the cache.
194
270
  async getProjects() {
195
- let projects = this.cache?.get(cacheKeys.PROJECTS);
271
+ let projects = this.cacheGet(cacheKeys.PROJECTS);
196
272
  if (!projects) {
197
273
  const org = await this.getOrganization();
198
274
  const response = await this.currentUserApi.getOrganizationProjects(
199
275
  org.id
200
276
  );
201
277
  projects = response.body;
202
- this.cache?.set(cacheKeys.PROJECTS, projects);
278
+ this.cacheSet(cacheKeys.PROJECTS, projects);
203
279
  }
204
280
  return projects;
205
281
  }
@@ -208,16 +284,16 @@ class BugsnagClient {
208
284
  return projects.find((p) => p.id === projectId) || null;
209
285
  }
210
286
  async getCurrentProject() {
211
- let project = this.cache?.get(cacheKeys.CURRENT_PROJECT) ?? null;
212
- if (!project && this._projectApiKey) {
213
- const projects = await this.getProjects();
214
- project = projects.find((p) => p.api_key === this._projectApiKey) ?? null;
215
- this.cache?.set(cacheKeys.CURRENT_PROJECT, project);
287
+ const projectApiKey = this.getProjectApiKey();
288
+ if (!projectApiKey) {
289
+ const namespace = this.cacheNamespace();
290
+ return namespace ? this._selectedProjects.get(namespace) ?? null : null;
216
291
  }
217
- return project;
292
+ const projects = await this.getProjects();
293
+ return projects.find((project) => project.api_key === projectApiKey) ?? null;
218
294
  }
219
295
  async getProjectEventFields(project) {
220
- const projectFiltersCache = this.cache?.get(
296
+ const projectFiltersCache = this.cacheGet(
221
297
  cacheKeys.PROJECT_EVENT_FIELDS
222
298
  ) || {};
223
299
  if (!projectFiltersCache[project.id]) {
@@ -226,18 +302,18 @@ class BugsnagClient {
226
302
  (field) => field.display_id && !EXCLUDED_EVENT_FIELDS.has(field.display_id)
227
303
  );
228
304
  projectFiltersCache[project.id] = filtersResponse;
229
- this.cache?.set(cacheKeys.PROJECT_EVENT_FIELDS, projectFiltersCache);
305
+ this.cacheSet(cacheKeys.PROJECT_EVENT_FIELDS, projectFiltersCache);
230
306
  }
231
307
  return projectFiltersCache[project.id];
232
308
  }
233
309
  async getProjectTraceFields(project) {
234
- const projectFiltersCache = this.cache?.get(
310
+ const projectFiltersCache = this.cacheGet(
235
311
  cacheKeys.PROJECT_TRACE_FIELDS
236
312
  ) || {};
237
313
  if (!projectFiltersCache[project.id]) {
238
314
  const filtersResponse = (await this.projectApi.listProjectTraceFields(project.id)).body;
239
315
  projectFiltersCache[project.id] = filtersResponse;
240
- this.cache?.set(cacheKeys.PROJECT_TRACE_FIELDS, projectFiltersCache);
316
+ this.cacheSet(cacheKeys.PROJECT_TRACE_FIELDS, projectFiltersCache);
241
317
  }
242
318
  return projectFiltersCache[project.id];
243
319
  }
@@ -267,8 +343,11 @@ class BugsnagClient {
267
343
  if (!maybeProject) {
268
344
  throw new ToolError(`Project with ID ${projectId} not found.`);
269
345
  }
270
- if (!this._projectApiKey) {
271
- this.cache?.set(cacheKeys.CURRENT_PROJECT, maybeProject);
346
+ if (!this.getProjectApiKey()) {
347
+ const namespace = this.cacheNamespace();
348
+ if (namespace) {
349
+ this._selectedProjects.set(namespace, maybeProject);
350
+ }
272
351
  }
273
352
  return maybeProject;
274
353
  } else {
@@ -16,9 +16,6 @@ function handleInitializeMessage(server, message) {
16
16
  }
17
17
  if (params?.protocolVersion === "2025-11-25") {
18
18
  const clientCapabilities = params.capabilities ?? {};
19
- if (Object.hasOwn(clientCapabilities, "sampling")) {
20
- server.setSamplingSupported(true);
21
- }
22
19
  if (Object.hasOwn(clientCapabilities, "elicitation")) {
23
20
  server.setElicitationSupported(true);
24
21
  }
@@ -1,43 +1,3 @@
1
- import { ToolError } from "./tools.js";
2
- async function executeSamplingOrPolyfill(server, prompt, maxTokens = 1e3) {
3
- if (!server.isSamplingSupported()) {
4
- return createPolyfillResult(prompt);
5
- }
6
- try {
7
- const response = await server.server.createMessage({
8
- messages: [
9
- {
10
- role: "user",
11
- content: {
12
- type: "text",
13
- text: prompt
14
- }
15
- }
16
- ],
17
- maxTokens
18
- });
19
- const content = response.content;
20
- if (content.type !== "text") {
21
- throw new ToolError(
22
- `Received unexpected response type from sampling: ${content.type}`
23
- );
24
- }
25
- return content.text;
26
- } catch (error) {
27
- console.error(error);
28
- return createPolyfillResult(prompt);
29
- }
30
- }
31
- function createPolyfillResult(prompt) {
32
- return {
33
- requiresPromptExecution: true,
34
- prompt,
35
- instructions: "Please execute the above prompt using your AI capabilities and re-request this tool with the result. Include the prompt result in your next request to continue the operation."
36
- };
37
- }
38
- function isSamplingPolyfillResult(value) {
39
- return typeof value === "object" && value !== null && "requiresPromptExecution" in value && value.requiresPromptExecution === true;
40
- }
41
1
  async function executeElicitationOrPolyfill(server, params, options) {
42
2
  if (!server.isElicitationSupported()) {
43
3
  return createElicitationPolyfillResult(params);
@@ -61,7 +21,5 @@ function isElicitationPolyfillResult(value) {
61
21
  }
62
22
  export {
63
23
  executeElicitationOrPolyfill,
64
- executeSamplingOrPolyfill,
65
- isElicitationPolyfillResult,
66
- isSamplingPolyfillResult
24
+ isElicitationPolyfillResult
67
25
  };
@@ -9,7 +9,6 @@ import { ToolError } from "./tools.js";
9
9
  import { getTypeDescription, getDefaultValue, getReadableTypeName, isOptionalType } from "./zod-utils.js";
10
10
  class SmartBearMcpServer extends McpServer {
11
11
  cache;
12
- samplingSupported = false;
13
12
  elicitationSupported = false;
14
13
  clientInfo;
15
14
  clients = [];
@@ -39,12 +38,6 @@ class SmartBearMcpServer extends McpServer {
39
38
  getCache() {
40
39
  return this.cache;
41
40
  }
42
- setSamplingSupported(supported) {
43
- this.samplingSupported = supported;
44
- }
45
- isSamplingSupported() {
46
- return this.samplingSupported;
47
- }
48
41
  setElicitationSupported(supported) {
49
42
  this.elicitationSupported = supported;
50
43
  }
@@ -1,4 +1,4 @@
1
- const version = "0.37.0";
1
+ const version = "0.38.0";
2
2
  const config = { "mcpServerName": "SmartBear MCP Server" };
3
3
  const packageJson = {
4
4
  version,
@@ -110,7 +110,6 @@ const GenerationInputSchema = z.object({
110
110
  "Optional test template to use as a basis for generation. Helps ensure generated tests follow your specific patterns, frameworks, and coding standards"
111
111
  )
112
112
  });
113
- const MatcherRecommendationInputSchema = z.array(EndpointMatcherSchema);
114
113
  const AiCreditsSchema = z.object({
115
114
  total: z.number().describe("The total number of AI credits available."),
116
115
  used: z.number().describe("The number of AI credits used.")
@@ -140,7 +139,6 @@ export {
140
139
  GenerationInputSchema,
141
140
  GenerationLanguages,
142
141
  HttpMethods,
143
- MatcherRecommendationInputSchema,
144
142
  OpenAPISchema,
145
143
  OpenAPIWithMatcherSchema,
146
144
  OrganizationEntitlementsSchema,
@@ -1,90 +1,11 @@
1
- import { executeSamplingOrPolyfill, isSamplingPolyfillResult } from "../../common/pollyfills.js";
2
- import { ToolError } from "../../common/tools.js";
3
- import { MatcherRecommendationInputSchema, EndpointMatcherSchema } from "./ai.js";
4
1
  import { OADMatcherPrompt } from "./prompts.js";
5
- async function getOADMatcherRecommendations(openAPI, server) {
6
- const prompt = OADMatcherPrompt.replace("{0}", JSON.stringify(openAPI));
7
- const response = await executeSamplingOrPolyfill(server, prompt, 1e3);
8
- if (isSamplingPolyfillResult(response)) {
9
- return response;
10
- }
11
- const regex = /```json[c5]?([\s\S]*?)```/i;
12
- const match = regex.exec(response);
13
- if (match) {
14
- const jsonText = match[1].trim();
15
- const parsed = JSON.parse(jsonText);
16
- const matcherRecommendations = MatcherRecommendationInputSchema.parse(parsed);
17
- return matcherRecommendations;
18
- } else {
19
- throw new ToolError(
20
- "Unable to parse recommendations please provide OpenAPI matchers manually."
21
- );
22
- }
23
- }
24
- async function getUserMatcherSelection(recommendations, getInput) {
25
- if (isSamplingPolyfillResult(recommendations)) {
26
- return recommendations;
27
- }
28
- const recommendationsMap = /* @__PURE__ */ new Map();
29
- recommendations.forEach((rec, index) => {
30
- recommendationsMap.set(`Recommendation ${index + 1}`, JSON.stringify(rec));
31
- });
32
- const result = await getInput({
33
- message: `Select one of the generated matchers you would want to use
34
-
35
- ${recommendations.map(
36
- (rec, index) => `
37
-
38
- Recommendation ${index + 1}:
39
-
40
-
41
- ${JSON.stringify(rec)}`
42
- ).join("\n\n")}`,
43
- requestedSchema: {
44
- type: "object",
45
- properties: {
46
- generatedMatchers: {
47
- type: "string",
48
- title: "Generated Matchers",
49
- description: "Use the matchers generated for the OpenAPI document",
50
- enum: recommendations.map(
51
- (_, index) => `Recommendation ${index + 1}`
52
- )
53
- }
54
- },
55
- required: ["generatedMatchers"]
56
- }
57
- });
58
- if (result.action === "accept") {
59
- return EndpointMatcherSchema.parse(
60
- JSON.parse(
61
- recommendationsMap.get(result.content?.generatedMatchers) || ""
62
- )
63
- );
64
- } else {
65
- const result2 = await getInput({
66
- message: "Enter the matchers you would want to use for the OpenAPI document",
67
- requestedSchema: {
68
- type: "object",
69
- properties: {
70
- enteredMatchers: {
71
- type: "string",
72
- title: "Enter the matchers you would want to use for the OpenAPI document",
73
- description: "Enter the matchers you would want to use for the OpenAPI document"
74
- }
75
- },
76
- required: ["enteredMatchers"]
77
- }
78
- });
79
- if (result2.action === "accept") {
80
- return EndpointMatcherSchema.parse(
81
- JSON.parse(result2.content?.enteredMatchers)
82
- );
83
- }
84
- return {};
85
- }
2
+ function getOADMatcherRecommendations(openAPI) {
3
+ return {
4
+ requiresPromptExecution: true,
5
+ prompt: OADMatcherPrompt.replace("{0}", JSON.stringify(openAPI)),
6
+ instructions: "Please execute the above prompt using your AI capabilities and re-request this tool with the result. Include the prompt result in your next request to continue the operation."
7
+ };
86
8
  }
87
9
  export {
88
- getOADMatcherRecommendations,
89
- getUserMatcherSelection
10
+ getOADMatcherRecommendations
90
11
  };
@@ -46,36 +46,16 @@ const OADMatcherPromptOpenAPIDocExample = {
46
46
  }
47
47
  }
48
48
  };
49
- const OADMatcherPromptRecommendationExample = [
50
- {
51
- path: "/users",
52
- methods: ["GET"],
53
- statusCodes: [200, "2XX"],
54
- operationId: "get*"
55
- },
56
- {
57
- path: "/users/*",
58
- methods: ["GET"],
59
- statusCodes: ["2XX"],
60
- operationId: "*User*"
61
- },
62
- {
63
- path: "/users",
64
- methods: ["GET"],
65
- statusCodes: [200],
66
- operationId: "getAllUsers"
67
- },
68
- {
69
- path: "/users/**",
70
- methods: ["GET"],
71
- statusCodes: ["2XX", 404],
72
- operationId: "get*"
73
- }
74
- ];
49
+ const OADMatcherPromptRecommendationExample = {
50
+ path: "/users",
51
+ methods: ["GET"],
52
+ statusCodes: [200],
53
+ operationId: "getAllUsers"
54
+ };
75
55
  const OADMatcherPrompt = `
76
56
 
77
- Generate a list of recommendations(maximum of 5) in JSON to use with an OpenAPI matcher.
78
- Zod Schema for the matcher to be generated is provided below in the markdown block of javascript use this to generate the recommendations for the matcher. Recommendations should contain all the fields from the schema and only output the JSON in a markdown formatted block.
57
+ Generate a single recommendation in JSON to use with an OpenAPI matcher.
58
+ Zod Schema for the matcher to be generated is provided below in the markdown block of javascript use this to generate the recommendation for the matcher. The recommendation should contain all the fields from the schema and only output the JSON in a markdown formatted block.
79
59
 
80
60
  \`\`\`javascript
81
61
  const EndpointMatcherSchema = ${JSON.stringify(EndpointMatcherSchema.toJSONSchema())};
@@ -89,7 +69,7 @@ if OpenAPI document provided is:-
89
69
  ${JSON.stringify(OADMatcherPromptOpenAPIDocExample, null, 2)}
90
70
  \`\`\`
91
71
 
92
- Generated recommendations are:-
72
+ Generated recommendation is:-
93
73
 
94
74
  \`\`\`json
95
75
  ${JSON.stringify(OADMatcherPromptRecommendationExample, null, 2)}
@@ -103,7 +83,7 @@ Now provided the below OpenAPI document:-
103
83
  {0}
104
84
  \`\`\`
105
85
 
106
- Give JSON recommendations only provide the JSON block in markdown don't include any additional text.
86
+ Give the JSON recommendation only provide the JSON block in markdown don't include any additional text.
107
87
  `;
108
88
  const argsSchema = z.object({
109
89
  openAPI: z.string().describe("The OpenAPI document to generate matcher recommendations for")
@@ -111,7 +91,7 @@ const argsSchema = z.object({
111
91
  const PROMPTS = [
112
92
  {
113
93
  title: "OpenAPI Matcher recommendations",
114
- description: "Get OpenAPI matcher recommendations using sampling",
94
+ description: "Get an OpenAPI matcher recommendation",
115
95
  argsSchema,
116
96
  callback: (args) => {
117
97
  const params = argsSchema.parse(args);
@@ -15,7 +15,6 @@ const TOOLS = [
15
15
  openWorld: false,
16
16
  clients: ["pactflow"],
17
17
  // ONLY pactflow
18
- enableElicitation: true,
19
18
  tags: ["pactflow-ai"]
20
19
  },
21
20
  {
@@ -30,7 +29,6 @@ const TOOLS = [
30
29
  idempotent: true,
31
30
  openWorld: false,
32
31
  clients: ["pactflow"],
33
- enableElicitation: true,
34
32
  tags: ["pactflow-ai"]
35
33
  },
36
34
  {
@@ -1,10 +1,9 @@
1
1
  import zod__default from "zod";
2
2
  import { getUserAgent } from "../common/info.js";
3
- import { isSamplingPolyfillResult } from "../common/pollyfills.js";
4
3
  import { getRequestHeader } from "../common/request-context.js";
5
4
  import { ToolError } from "../common/tools.js";
6
5
  import { withPagination } from "./client/pagination.js";
7
- import { getOADMatcherRecommendations, getUserMatcherSelection } from "./client/prompt-utils.js";
6
+ import { getOADMatcherRecommendations } from "./client/prompt-utils.js";
8
7
  import { PROMPTS } from "./client/prompts.js";
9
8
  import { TOOLS } from "./client/tools.js";
10
9
  const ConfigurationSchema = zod__default.object({
@@ -66,27 +65,12 @@ class PactflowClient {
66
65
  * Generate new Pact tests based on the provided input.
67
66
  *
68
67
  * @param toolInput The input data for the generation process.
69
- * @param getInput Function to get additional input from the user if needed.
70
- * @returns The result of the generation process or a polyfill result requiring prompt execution.
68
+ * @returns The result of the generation process or a result requiring prompt execution.
71
69
  * @throws Error if the HTTP request fails or the operation times out.
72
70
  */
73
- async generate(toolInput, getInput) {
71
+ async generate(toolInput, _getInput) {
74
72
  if (toolInput.openapi?.document && (!toolInput.openapi?.matcher || Object.keys(toolInput.openapi.matcher).length === 0)) {
75
- const matcherResponse = await getOADMatcherRecommendations(
76
- toolInput.openapi.document,
77
- this.server
78
- );
79
- if (isSamplingPolyfillResult(matcherResponse)) {
80
- return matcherResponse;
81
- }
82
- const userSelection = await getUserMatcherSelection(
83
- matcherResponse,
84
- getInput
85
- );
86
- if (isSamplingPolyfillResult(userSelection)) {
87
- return userSelection;
88
- }
89
- toolInput.openapi.matcher = userSelection;
73
+ return getOADMatcherRecommendations(toolInput.openapi.document);
90
74
  }
91
75
  const status_response = await this.submitHttpCallback(
92
76
  "/generate",
@@ -101,27 +85,12 @@ class PactflowClient {
101
85
  * Review the provided Pact tests and suggest improvements.
102
86
  *
103
87
  * @param toolInput The input data for the review process.
104
- * @param getInput Function to get additional input from the user if needed.
105
- * @returns The result of the review process or a polyfill result requiring prompt execution.
88
+ * @returns The result of the review process or a result requiring prompt execution.
106
89
  * @throws Error if the HTTP request fails or the operation times out.
107
90
  */
108
- async review(toolInput, getInput) {
91
+ async review(toolInput, _getInput) {
109
92
  if (toolInput.openapi?.document && (!toolInput.openapi?.matcher || Object.keys(toolInput.openapi.matcher).length === 0)) {
110
- const matcherResponse = await getOADMatcherRecommendations(
111
- toolInput.openapi.document,
112
- this.server
113
- );
114
- if (isSamplingPolyfillResult(matcherResponse)) {
115
- return matcherResponse;
116
- }
117
- const userSelection = await getUserMatcherSelection(
118
- matcherResponse,
119
- getInput
120
- );
121
- if (isSamplingPolyfillResult(userSelection)) {
122
- return userSelection;
123
- }
124
- toolInput.openapi.matcher = userSelection;
93
+ return getOADMatcherRecommendations(toolInput.openapi.document);
125
94
  }
126
95
  const status_response = await this.submitHttpCallback("/review", toolInput);
127
96
  return await this.pollForCompletion(
@@ -2,7 +2,7 @@ import { appendClientIdentity } from "../../common/info.js";
2
2
  import { ToolError } from "../../common/tools.js";
3
3
  import { applyEdits } from "./patch-spec-utils.js";
4
4
  import { buildSubdomainCandidate, buildPortalName, isConflictError, isOrganizationPortalConflict } from "./portal-utils.js";
5
- import { findTableOfContentsItem, buildPortalLiveUrl, normalizeSlug, isOpenAPI, isAsyncAPI } from "./utils.js";
5
+ import { buildPortalLiveUrl, findTableOfContentsItem, normalizeSlug, isOpenAPI, isAsyncAPI } from "./utils.js";
6
6
  const SWAGGER_URL_REGEX = /\/(apis|domains|templates)\/([^/]+)\/([^/]+)\/([^/]+)/;
7
7
  function hasId(value) {
8
8
  return typeof value === "object" && value !== null && "id" in value;
@@ -391,9 +391,30 @@ class SwaggerAPI {
391
391
  body: JSON.stringify(body)
392
392
  }
393
393
  );
394
- return this.handleResponse(response, {
395
- success: true
396
- });
394
+ const result = await this.handleResponse(
395
+ response,
396
+ {
397
+ success: true
398
+ }
399
+ );
400
+ if (hasId(result) && "slug" in result && "portalId" in result) {
401
+ try {
402
+ const product = result;
403
+ const portalDetails = await this.getPortal(String(product.portalId));
404
+ const url = buildPortalLiveUrl(
405
+ this.config,
406
+ portalDetails,
407
+ product.slug,
408
+ null,
409
+ null,
410
+ false
411
+ );
412
+ return { ...product, url };
413
+ } catch (error) {
414
+ console.warn("Failed to build URL for updated product:", error);
415
+ }
416
+ }
417
+ return result;
397
418
  }
398
419
  /**
399
420
  * Prepare publication metadata and URL for a portal product and page.
@@ -285,7 +285,8 @@ const ProductOutputSchema = z.looseObject({
285
285
  portalId: z.string().optional(),
286
286
  description: z.string().optional(),
287
287
  public: z.boolean().optional(),
288
- hidden: z.boolean().optional()
288
+ hidden: z.boolean().optional(),
289
+ url: z.string().optional()
289
290
  });
290
291
  const ProductsListOutputSchema = z.object({
291
292
  page: PageSchema.optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartbear/mcp",
3
- "version": "0.37.0",
3
+ "version": "0.38.0",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },