@smartbear/mcp 0.37.0 → 0.39.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/dist/bugsnag/client.js +101 -22
- package/dist/common/initialize.js +0 -3
- package/dist/common/pollyfills.js +1 -43
- package/dist/common/server.js +0 -7
- package/dist/package.json.js +1 -1
- package/dist/pactflow/client/admin-api.js +491 -0
- package/dist/pactflow/client/ai-api.js +139 -0
- package/dist/pactflow/client/ai.js +0 -2
- package/dist/pactflow/client/contract-api.js +366 -0
- package/dist/pactflow/client/environment-api.js +156 -0
- package/dist/pactflow/client/http-client.js +47 -0
- package/dist/pactflow/client/pacticipant-api.js +288 -0
- package/dist/pactflow/client/prompt-utils.js +7 -86
- package/dist/pactflow/client/prompts.js +11 -31
- package/dist/pactflow/client/tools.js +0 -2
- package/dist/pactflow/client/webhook-api.js +113 -0
- package/dist/pactflow/client.js +29 -1998
- package/dist/swagger/client/api.js +25 -4
- package/dist/swagger/client/functional-testing-api.js +39 -17
- package/dist/swagger/client/functional-testing-tools.js +4 -4
- package/dist/swagger/client/functional-testing-types.js +10 -7
- package/dist/swagger/client/portal-types.js +2 -1
- package/package.json +1 -1
package/dist/bugsnag/client.js
CHANGED
|
@@ -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(
|
|
78
|
-
this.
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
212
|
-
if (!
|
|
213
|
-
const
|
|
214
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
271
|
-
this.
|
|
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
|
-
|
|
65
|
-
isElicitationPolyfillResult,
|
|
66
|
-
isSamplingPolyfillResult
|
|
24
|
+
isElicitationPolyfillResult
|
|
67
25
|
};
|
package/dist/common/server.js
CHANGED
|
@@ -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
|
}
|
package/dist/package.json.js
CHANGED