@smartbear/mcp 0.5.0 → 0.7.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 (36) hide show
  1. package/README.md +22 -111
  2. package/dist/api-hub/client/api.js +253 -0
  3. package/dist/api-hub/client/configuration.js +27 -0
  4. package/dist/api-hub/client/index.js +5 -0
  5. package/dist/api-hub/client/portal-types.js +131 -0
  6. package/dist/api-hub/client/registry-types.js +55 -0
  7. package/dist/api-hub/client/tools.js +86 -0
  8. package/dist/api-hub/client.js +64 -404
  9. package/dist/bugsnag/client/api/CurrentUser.js +18 -13
  10. package/dist/bugsnag/client/api/Error.js +35 -35
  11. package/dist/bugsnag/client/api/Project.js +137 -9
  12. package/dist/bugsnag/client/api/base.js +27 -13
  13. package/dist/bugsnag/client/api/filters.js +9 -9
  14. package/dist/bugsnag/client.js +584 -145
  15. package/dist/common/info.js +1 -1
  16. package/dist/common/server.js +44 -27
  17. package/dist/index.js +13 -6
  18. package/dist/pactflow/client/ai.js +33 -2
  19. package/dist/pactflow/client/base.js +51 -3
  20. package/dist/pactflow/client/prompt-utils.js +89 -0
  21. package/dist/pactflow/client/prompts.js +131 -0
  22. package/dist/pactflow/client/tools.js +39 -7
  23. package/dist/pactflow/client/utils.js +1 -1
  24. package/dist/pactflow/client.js +147 -9
  25. package/dist/qmetry/client/api/client-api.js +39 -0
  26. package/dist/qmetry/client/handlers.js +11 -0
  27. package/dist/qmetry/client/project.js +27 -0
  28. package/dist/qmetry/client/testcase.js +104 -0
  29. package/dist/qmetry/client/tools.js +222 -0
  30. package/dist/qmetry/client.js +95 -0
  31. package/dist/qmetry/config/constants.js +12 -0
  32. package/dist/qmetry/config/rest-endpoints.js +11 -0
  33. package/dist/qmetry/types/common.js +174 -0
  34. package/dist/qmetry/types/testcase.js +19 -0
  35. package/dist/reflect/client.js +14 -14
  36. package/package.json +9 -6
@@ -1,24 +1,24 @@
1
- import { BaseAPI } from './base.js';
2
- import { toQueryString } from './filters.js';
1
+ import { BaseAPI } from "./base.js";
2
+ import { toQueryString } from "./filters.js";
3
3
  export const ErrorOperations = [
4
- 'override_severity',
5
- 'assign',
6
- 'create_issue',
7
- 'link_issue',
8
- 'unlink_issue',
9
- 'open',
10
- 'snooze',
11
- 'fix',
12
- 'ignore',
13
- 'delete',
14
- 'discard',
15
- 'undiscard'
4
+ "override_severity",
5
+ "assign",
6
+ "create_issue",
7
+ "link_issue",
8
+ "unlink_issue",
9
+ "open",
10
+ "snooze",
11
+ "fix",
12
+ "ignore",
13
+ "delete",
14
+ "discard",
15
+ "undiscard",
16
16
  ];
17
17
  export const ReopenConditions = [
18
- 'occurs_after',
19
- 'n_occurrences_in_m_hours',
20
- 'n_additional_occurrences',
21
- 'n_additional_users'
18
+ "occurs_after",
19
+ "n_occurrences_in_m_hours",
20
+ "n_additional_occurrences",
21
+ "n_additional_users",
22
22
  ];
23
23
  // --- API Class ---
24
24
  export class ErrorAPI extends BaseAPI {
@@ -40,7 +40,7 @@ export class ErrorAPI extends BaseAPI {
40
40
  ? `/projects/${projectId}/errors/${errorId}?${params}`
41
41
  : `/projects/${projectId}/errors/${errorId}`;
42
42
  return (await this.request({
43
- method: 'GET',
43
+ method: "GET",
44
44
  url,
45
45
  }));
46
46
  }
@@ -58,7 +58,7 @@ export class ErrorAPI extends BaseAPI {
58
58
  ? `/errors/${errorId}/latest_event?${params}`
59
59
  : `/errors/${errorId}/latest_event`;
60
60
  return (await this.request({
61
- method: 'GET',
61
+ method: "GET",
62
62
  url,
63
63
  }));
64
64
  }
@@ -66,10 +66,10 @@ export class ErrorAPI extends BaseAPI {
66
66
  * List the Events on a Project
67
67
  * GET /projects/{project_id}/events
68
68
  */
69
- async listEventsOnProject(projectId, queryString = '') {
69
+ async listEventsOnProject(projectId, queryString = "") {
70
70
  const url = `/projects/${projectId}/events${queryString}`;
71
71
  return await this.request({
72
- method: 'GET',
72
+ method: "GET",
73
73
  url,
74
74
  });
75
75
  }
@@ -87,7 +87,7 @@ export class ErrorAPI extends BaseAPI {
87
87
  ? `/projects/${projectId}/events/${eventId}?${params}`
88
88
  : `/projects/${projectId}/events/${eventId}`;
89
89
  return (await this.request({
90
- method: 'GET',
90
+ method: "GET",
91
91
  url,
92
92
  }));
93
93
  }
@@ -101,7 +101,7 @@ export class ErrorAPI extends BaseAPI {
101
101
  if (options.next !== undefined) {
102
102
  const nextUrl = new URL(options.next);
103
103
  if (options.per_page !== undefined) {
104
- nextUrl.searchParams.set('per_page', options.per_page.toString());
104
+ nextUrl.searchParams.set("per_page", options.per_page.toString());
105
105
  }
106
106
  url = nextUrl.toString();
107
107
  }
@@ -116,23 +116,23 @@ export class ErrorAPI extends BaseAPI {
116
116
  }
117
117
  // Add pagination and sorting parameters
118
118
  if (options.base !== undefined) {
119
- params.append('base', options.base);
119
+ params.append("base", options.base);
120
120
  }
121
121
  if (options.sort !== undefined) {
122
- params.append('sort', options.sort);
122
+ params.append("sort", options.sort);
123
123
  }
124
124
  if (options.direction !== undefined) {
125
- params.append('direction', options.direction);
125
+ params.append("direction", options.direction);
126
126
  }
127
127
  if (options.per_page !== undefined) {
128
- params.append('per_page', options.per_page.toString());
128
+ params.append("per_page", options.per_page.toString());
129
129
  }
130
130
  if (params.size > 0) {
131
131
  url = `/projects/${projectId}/errors?${params}`;
132
132
  }
133
133
  }
134
134
  return (await this.request({
135
- method: 'GET',
135
+ method: "GET",
136
136
  url,
137
137
  }));
138
138
  }
@@ -150,7 +150,7 @@ export class ErrorAPI extends BaseAPI {
150
150
  ? `/projects/${projectId}/errors/${errorId}?${params}`
151
151
  : `/projects/${projectId}/errors/${errorId}`;
152
152
  return (await this.request({
153
- method: 'PATCH',
153
+ method: "PATCH",
154
154
  url,
155
155
  body: data,
156
156
  }));
@@ -168,21 +168,21 @@ export class ErrorAPI extends BaseAPI {
168
168
  });
169
169
  }
170
170
  if (options.summary_size !== undefined) {
171
- params.append('summary_size', options.summary_size.toString());
171
+ params.append("summary_size", options.summary_size.toString());
172
172
  }
173
173
  if (options.pivots && options.pivots.length > 0) {
174
- options.pivots.forEach(pivot => {
175
- params.append('pivots[]', pivot);
174
+ options.pivots.forEach((pivot) => {
175
+ params.append("pivots[]", pivot);
176
176
  });
177
177
  }
178
178
  if (options.per_page !== undefined) {
179
- params.append('per_page', options.per_page.toString());
179
+ params.append("per_page", options.per_page.toString());
180
180
  }
181
181
  const url = params.toString()
182
182
  ? `/projects/${projectId}/errors/${errorId}/pivots?${params}`
183
183
  : `/projects/${projectId}/errors/${errorId}/pivots`;
184
184
  return await this.request({
185
- method: 'GET',
185
+ method: "GET",
186
186
  url,
187
187
  });
188
188
  }
@@ -1,12 +1,48 @@
1
- import { BaseAPI, pickFieldsFromArray } from "./base.js";
1
+ import { BaseAPI, pickFields, pickFieldsFromArray, } from "./base.js";
2
2
  // --- API Class ---
3
3
  export class ProjectAPI extends BaseAPI {
4
- static filterFields = ["errors_url", "events_url", "url", "html_url"];
4
+ static filterFields = [
5
+ "errors_url",
6
+ "events_url",
7
+ "url",
8
+ "html_url",
9
+ ];
5
10
  static eventFieldFields = [
6
- 'custom',
7
- 'display_id',
8
- 'filter_options',
9
- 'pivot_options'
11
+ "custom",
12
+ "display_id",
13
+ "filter_options",
14
+ "pivot_options",
15
+ ];
16
+ static buildFields = [
17
+ "id",
18
+ "release_time",
19
+ "app_version",
20
+ "release_stage",
21
+ "errors_introduced_count",
22
+ "errors_seen_count",
23
+ "total_sessions_count",
24
+ "unhandled_sessions_count",
25
+ "accumulative_daily_users_seen",
26
+ "accumulative_daily_users_with_unhandled",
27
+ ];
28
+ static releaseFields = [
29
+ "id",
30
+ "release_stage_name",
31
+ "app_version",
32
+ "first_released_at",
33
+ "first_release_id",
34
+ "releases_count",
35
+ "visible",
36
+ "total_sessions_count",
37
+ "unhandled_sessions_count",
38
+ "sessions_count_in_last_24h",
39
+ "accumulative_daily_users_seen",
40
+ "accumulative_daily_users_with_unhandled",
41
+ ];
42
+ static stabilityFields = [
43
+ "critical_stability",
44
+ "target_stability",
45
+ "stability_target_type",
10
46
  ];
11
47
  constructor(configuration) {
12
48
  super(configuration, ProjectAPI.filterFields);
@@ -20,13 +56,13 @@ export class ProjectAPI extends BaseAPI {
20
56
  async listProjectEventFields(projectId) {
21
57
  const url = `/projects/${projectId}/event_fields`;
22
58
  const data = await this.request({
23
- method: 'GET',
59
+ method: "GET",
24
60
  url,
25
61
  });
26
62
  // Only return allowed fields
27
63
  return {
28
64
  ...data,
29
- body: pickFieldsFromArray(data.body || [], ProjectAPI.eventFieldFields)
65
+ body: pickFieldsFromArray(data.body || [], ProjectAPI.eventFieldFields),
30
66
  };
31
67
  }
32
68
  /**
@@ -39,9 +75,101 @@ export class ProjectAPI extends BaseAPI {
39
75
  async createProject(organizationId, data) {
40
76
  const url = `/organizations/${organizationId}/projects`;
41
77
  return await this.request({
42
- method: 'POST',
78
+ method: "POST",
43
79
  url,
44
80
  body: data,
45
81
  });
46
82
  }
83
+ /**
84
+ * Retrieves the stability targets for a specific project.
85
+ * GET /projects/{project_id} (with internal header)
86
+ * @param projectId The ID of the project.
87
+ * @returns A promise that resolves to the project's stability targets.
88
+ */
89
+ async getProjectStabilityTargets(projectId) {
90
+ const url = `/projects/${projectId}`;
91
+ const response = await this.request({
92
+ method: "GET",
93
+ url,
94
+ });
95
+ return pickFields(response.body || {}, ProjectAPI.stabilityFields);
96
+ }
97
+ /**
98
+ * Lists builds for a specific project.
99
+ * GET /projects/{project_id}/releases
100
+ * @param projectId The ID of the project.
101
+ * @param opts Options for listing releases, including filtering by release stage.
102
+ * @returns A promise that resolves to an array of `ListReleasesResponse` objects.
103
+ */
104
+ async listBuilds(projectId, opts) {
105
+ const url = opts.next_url ??
106
+ `/projects/${projectId}/releases${opts.release_stage ? `?release_stage=${opts.release_stage}` : ""}`;
107
+ const response = await this.request({
108
+ method: "GET",
109
+ url,
110
+ });
111
+ return {
112
+ ...response,
113
+ body: pickFieldsFromArray(response.body || [], ProjectAPI.buildFields),
114
+ };
115
+ }
116
+ /**
117
+ * Retrieves a specific build from a project.
118
+ * GET /projects/{project_id}/releases/{release_id}
119
+ * @param projectId The ID of the project.
120
+ * @param buildId The ID of the release to retrieve.
121
+ * @returns A promise that resolves to the release data.
122
+ */
123
+ async getBuild(projectId, buildId) {
124
+ const url = `/projects/${projectId}/releases/${buildId}`;
125
+ return await this.request({
126
+ method: "GET",
127
+ url,
128
+ });
129
+ }
130
+ /**
131
+ * Lists releases for a specific project.
132
+ * GET /projects/{project_id}/release_groups
133
+ * @param projectId The ID of the project.
134
+ * @param opts Options for listing releases, including filtering by release stage and visibility.
135
+ * @returns A promise that resolves to an array of `ReleaseSummaryResponse` objects.
136
+ */
137
+ async listReleases(projectId, opts) {
138
+ const url = opts.next_url ??
139
+ `/projects/${projectId}/release_groups?release_stage_name=${opts.release_stage_name}&visible_only=${opts.visible_only}&top_only=true`;
140
+ const response = await this.request({
141
+ method: "GET",
142
+ url,
143
+ });
144
+ return {
145
+ ...response,
146
+ body: pickFieldsFromArray(response.body || [], ProjectAPI.releaseFields),
147
+ };
148
+ }
149
+ /**
150
+ * Retrieves a specific release by its ID.
151
+ * GET /release_groups/{release_id}
152
+ * @param releaseId The ID of the release to retrieve.
153
+ * @returns A promise that resolves to the release data.
154
+ */
155
+ async getRelease(releaseId) {
156
+ const url = `/release_groups/${releaseId}`;
157
+ return await this.request({
158
+ method: "GET",
159
+ url,
160
+ });
161
+ }
162
+ /**
163
+ * Lists builds associated with a specific release group.
164
+ * GET /release_groups/{release_id}/releases
165
+ * @param releaseId The ID of the release group.
166
+ * @return A promise that resolves to an array of `BuildResponse` objects.
167
+ */
168
+ async listBuildsInRelease(releaseId) {
169
+ const url = `/release_groups/${releaseId}/releases`;
170
+ return await this.request({
171
+ method: "GET",
172
+ url,
173
+ }, true);
174
+ }
47
175
  }
@@ -10,7 +10,25 @@ export function pickFields(obj, keys) {
10
10
  }
11
11
  // Utility to pick only allowed fields from an array of objects
12
12
  export function pickFieldsFromArray(arr, keys) {
13
- return arr.map(obj => pickFields(obj, keys));
13
+ return arr.map((obj) => pickFields(obj, keys));
14
+ }
15
+ // Utility to extract next URL path from Link header
16
+ export function getNextUrlPathFromHeader(headers, basePath) {
17
+ if (!headers)
18
+ return null;
19
+ const link = headers.get("link") || headers.get("Link");
20
+ if (!link)
21
+ return null;
22
+ const match = link.match(/<([^>]+)>;\s*rel="next"/)?.[1];
23
+ if (!match)
24
+ return null;
25
+ return match.replace(basePath, "");
26
+ }
27
+ // Ensure URL is absolute
28
+ // The MCP tools exposed use only the path for pagination
29
+ // For making requests, we need to ensure the URL is absolute
30
+ export function ensureFullUrl(url, basePath) {
31
+ return url.startsWith("http") ? url : `${basePath}${url}`;
14
32
  }
15
33
  export class BaseAPI {
16
34
  configuration;
@@ -24,17 +42,20 @@ export class BaseAPI {
24
42
  ...this.configuration.headers,
25
43
  ...options.headers,
26
44
  };
27
- headers['Authorization'] = `token ${this.configuration.authToken}`;
45
+ headers.Authorization = `token ${this.configuration.authToken}`;
28
46
  const fetchOptions = {
29
47
  method: options.method,
30
48
  headers,
31
49
  body: options.body ? JSON.stringify(options.body) : undefined,
32
50
  };
33
- const url = options.url.startsWith('http') ? options.url : `${this.configuration.basePath || ''}${options.url}`;
34
51
  let results = [];
35
- let nextUrl = url;
52
+ let nextUrl = options.url;
36
53
  let apiResponse;
37
54
  do {
55
+ if (!this.configuration.basePath) {
56
+ throw new Error("Base path is not configured for API requests");
57
+ }
58
+ nextUrl = ensureFullUrl(nextUrl, this.configuration.basePath);
38
59
  const response = await fetch(nextUrl, fetchOptions);
39
60
  if (!response.ok) {
40
61
  const errorText = await response.text();
@@ -42,19 +63,12 @@ export class BaseAPI {
42
63
  }
43
64
  apiResponse = {
44
65
  status: response.status,
45
- headers: response.headers
66
+ headers: response.headers,
46
67
  };
47
68
  const data = await response.json();
48
69
  if (paginate) {
49
70
  results = results.concat(data);
50
- const link = response.headers.get('Link');
51
- if (link) {
52
- const match = link.match(/<([^>]+)>;\s*rel="next"/);
53
- nextUrl = match ? match[1] : undefined;
54
- }
55
- else {
56
- nextUrl = undefined;
57
- }
71
+ nextUrl = getNextUrlPathFromHeader(response.headers, this.configuration.basePath);
58
72
  }
59
73
  else {
60
74
  apiResponse.body = data;
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { z } from "zod";
8
8
  export const FilterValueSchema = z.object({
9
- type: z.enum(['eq', 'ne', 'empty']),
9
+ type: z.enum(["eq", "ne", "empty"]),
10
10
  value: z.union([z.string(), z.boolean(), z.number()]),
11
11
  });
12
12
  export const FilterObjectSchema = z.record(z.array(FilterValueSchema));
@@ -18,7 +18,7 @@ export const FilterObjectSchema = z.record(z.array(FilterValueSchema));
18
18
  */
19
19
  export function equals(value) {
20
20
  return {
21
- type: 'eq',
21
+ type: "eq",
22
22
  value,
23
23
  };
24
24
  }
@@ -30,7 +30,7 @@ export function equals(value) {
30
30
  */
31
31
  export function notEquals(value) {
32
32
  return {
33
- type: 'ne',
33
+ type: "ne",
34
34
  value,
35
35
  };
36
36
  }
@@ -42,7 +42,7 @@ export function notEquals(value) {
42
42
  */
43
43
  export function empty(isEmpty) {
44
44
  return {
45
- type: 'empty',
45
+ type: "empty",
46
46
  value: isEmpty.toString(),
47
47
  };
48
48
  }
@@ -55,7 +55,7 @@ export function empty(isEmpty) {
55
55
  */
56
56
  export function relativeTime(value, unit) {
57
57
  return {
58
- type: 'eq',
58
+ type: "eq",
59
59
  value: `${value}${unit}`,
60
60
  };
61
61
  }
@@ -67,7 +67,7 @@ export function relativeTime(value, unit) {
67
67
  */
68
68
  export function isoTime(date) {
69
69
  return {
70
- type: 'eq',
70
+ type: "eq",
71
71
  value: date.toISOString(),
72
72
  };
73
73
  }
@@ -128,8 +128,8 @@ export function addFilter(filters, field, filterValue) {
128
128
  * @returns The updated FilterObject for chaining
129
129
  */
130
130
  export function addTimeRange(filters, since, before) {
131
- addFilter(filters, 'event.since', isoTime(since));
132
- addFilter(filters, 'event.before', isoTime(before));
131
+ addFilter(filters, "event.since", isoTime(since));
132
+ addFilter(filters, "event.before", isoTime(before));
133
133
  return filters;
134
134
  }
135
135
  /**
@@ -141,7 +141,7 @@ export function addTimeRange(filters, since, before) {
141
141
  * @returns The updated FilterObject for chaining
142
142
  */
143
143
  export function addRelativeTimeRange(filters, amount, unit) {
144
- addFilter(filters, 'event.since', relativeTime(amount, unit));
144
+ addFilter(filters, "event.since", relativeTime(amount, unit));
145
145
  return filters;
146
146
  }
147
147
  /**