@smartbear/mcp 0.44.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.
- package/dist/bugsnag/client/api/Project.js +1 -1
- package/dist/bugsnag/input-schemas.js +31 -13
- package/dist/bugsnag/tool/error/get-error.js +5 -4
- package/dist/bugsnag/tool/error/list-project-errors.js +7 -5
- package/dist/bugsnag/tool/error/update-error.js +7 -4
- package/dist/bugsnag/tool/event/get-event-details-from-dashboard-url.js +3 -2
- package/dist/bugsnag/tool/event/get-event.js +4 -0
- package/dist/bugsnag/tool/event/list-error-events.js +16 -4
- package/dist/bugsnag/tool/performance/get-span-group.js +1 -0
- package/dist/bugsnag/tool/performance/get-trace.js +13 -5
- package/dist/bugsnag/tool/performance/list-span-groups.js +7 -3
- package/dist/bugsnag/tool/performance/list-spans.js +5 -2
- package/dist/bugsnag/tool/performance/list-trace-fields.js +1 -1
- package/dist/bugsnag/tool/performance/set-network-endpoint-groupings.js +3 -2
- package/dist/bugsnag/tool/project/get-current-project.js +3 -3
- package/dist/bugsnag/tool/project/list-project-event-filters.js +3 -3
- package/dist/bugsnag/tool/project/list-projects.js +6 -3
- package/dist/bugsnag/tool/release/get-build.js +4 -1
- package/dist/bugsnag/tool/release/get-release.js +4 -1
- package/dist/bugsnag/tool/release/list-releases.js +5 -4
- package/dist/common/cache.js +21 -2
- package/dist/common/server.js +1 -1
- package/dist/common/transport-http.js +116 -5
- package/dist/package.json.js +1 -1
- package/dist/zephyr/common/rest-api-schemas.js +12 -3
- package/dist/zephyr/tool/test-case/get-test-cases.js +9 -0
- package/package.json +1 -1
- package/src/pactflow/drift/README.md +2 -2
|
@@ -144,7 +144,7 @@ class ProjectAPI extends BaseAPI {
|
|
|
144
144
|
async listBuildsInRelease(releaseId) {
|
|
145
145
|
const localVarFetchArgs = ProjectsApiFetchParamCreator(
|
|
146
146
|
this.configuration
|
|
147
|
-
).
|
|
147
|
+
).listReleaseGroupReleases(releaseId);
|
|
148
148
|
return await this.requestArray(
|
|
149
149
|
localVarFetchArgs.url,
|
|
150
150
|
localVarFetchArgs.options,
|
|
@@ -1,40 +1,58 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
const filterValueSchema = z.object({
|
|
3
|
-
type: z.enum(["eq", "ne", "empty"])
|
|
4
|
-
|
|
3
|
+
type: z.enum(["eq", "ne", "empty"]).describe(
|
|
4
|
+
"Comparison: 'eq' equals, 'ne' not equals, 'empty' matches when the field has no value (set 'value' to true, or false to match non-empty)"
|
|
5
|
+
),
|
|
6
|
+
value: z.union([z.string(), z.boolean(), z.number()]).describe("Value to compare with")
|
|
5
7
|
});
|
|
6
8
|
const filtersSchema = z.record(z.string(), z.array(filterValueSchema));
|
|
7
9
|
const toolInputParameters = {
|
|
8
10
|
empty: z.object({}).describe("No parameters are required for this tool"),
|
|
9
|
-
buildId: z.string().describe(
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
buildId: z.string().describe(
|
|
12
|
+
"ID of the app build. Get it from the 'builds' list returned by Get Release."
|
|
13
|
+
),
|
|
14
|
+
errorId: z.string().describe(
|
|
15
|
+
"ID of the error (a group of similar events). Get it from List Project Errors."
|
|
16
|
+
),
|
|
17
|
+
eventId: z.string().describe(
|
|
18
|
+
"ID of a single event (one occurrence of an error). Get it from Get Events on an Error, or from the 'event_id' parameter of a dashboard URL."
|
|
19
|
+
),
|
|
12
20
|
projectId: z.string().optional().describe(
|
|
13
|
-
"
|
|
21
|
+
"The BugSnag project ID: an opaque 24-character hex string such as '515fb9337c1074f6fd000003'. This is NOT the project name or slug (the 'my-project' part of a dashboard URL). Get it from the 'id' field returned by List Projects. Optional if a current project is configured (see Get Current Project). When no project is configured, the project provided here becomes the current project for subsequent calls."
|
|
14
22
|
),
|
|
15
|
-
releaseId: z.string().describe("
|
|
16
|
-
direction: z.enum(["asc", "desc"]).describe(
|
|
23
|
+
releaseId: z.string().describe("ID of the release (release group). Get it from List Releases."),
|
|
24
|
+
direction: z.enum(["asc", "desc"]).describe(
|
|
25
|
+
"Sort direction: 'desc' (default) returns the highest/newest values first, 'asc' the lowest/oldest first"
|
|
26
|
+
).default("desc"),
|
|
17
27
|
performanceFilters: filtersSchema.describe(
|
|
18
|
-
"
|
|
28
|
+
"Filters for spans, as an object keyed by field name, where each value is an array of { type: 'eq' | 'ne' | 'empty', value }. Multiple filters are combined with AND. Use the List Trace Fields tool to discover available filter fields. Time filters support extended ISO 8601 format (e.g. 2018-05-20T00:00:00Z) or relative format (e.g. 7d, 24h). If omitted this defaults to span.since=7d, so older spans are excluded - pass 'span.since' (e.g. 30d) to look further back."
|
|
19
29
|
).default({
|
|
20
30
|
"span.since": [{ type: "eq", value: "7d" }]
|
|
21
31
|
}),
|
|
22
32
|
filters: filtersSchema.describe(
|
|
23
|
-
"
|
|
33
|
+
"Filters on event fields, as an object keyed by field name, where each value is an array of { type: 'eq' | 'ne' | 'empty', value }. Multiple filters are combined with AND. Use the List Project Event Filters tool to discover available filter fields. Time filters (event.since, event.before) support extended ISO 8601 format (e.g. 2018-05-20T00:00:00Z) or relative format (e.g. 7d, 24h). If omitted this defaults to event.since=30d and error.status=open, so older events and errors that are not open are excluded. Any filter you do not specify keeps its default, so pass 'event.since' to look further back or 'error.status' to include other statuses."
|
|
24
34
|
).default({
|
|
25
35
|
"event.since": [{ type: "eq", value: "30d" }],
|
|
26
36
|
"error.status": [{ type: "eq", value: "open" }]
|
|
27
37
|
}),
|
|
38
|
+
// For tools that already target a single, specific error: no implicit time or status restriction.
|
|
39
|
+
errorScopedFilters: filtersSchema.describe(
|
|
40
|
+
"Optional filters on event fields, as an object keyed by field name, where each value is an array of { type: 'eq' | 'ne' | 'empty', value }. Multiple filters are combined with AND. Use the List Project Event Filters tool to discover available filter fields. Time filters (event.since, event.before) support extended ISO 8601 format (e.g. 2018-05-20T00:00:00Z) or relative format (e.g. 7d, 24h). No filters are applied by default, so events of any age are included."
|
|
41
|
+
).default({}),
|
|
28
42
|
nextUrl: z.string().describe(
|
|
29
43
|
"URL for retrieving the next page of results. Use the value in the previous response to get the next page when more results are available. Only values provided in the output from this tool can be used. Do not attempt to construct it manually."
|
|
30
44
|
).optional(),
|
|
31
45
|
page: z.number().describe("Page number to return (starts from 1)").default(1),
|
|
32
46
|
perPage: z.number().describe("How many results to return per page.").min(1).max(100).default(30),
|
|
33
47
|
releaseStage: z.string().describe(
|
|
34
|
-
"
|
|
48
|
+
"Only include releases from this release stage (e.g. production, staging, development). Defaults to 'production'"
|
|
35
49
|
).default("production"),
|
|
36
|
-
sort: z.enum(["first_seen", "last_seen", "events", "users", "unsorted"]).describe(
|
|
37
|
-
|
|
50
|
+
sort: z.enum(["first_seen", "last_seen", "events", "users", "unsorted"]).describe(
|
|
51
|
+
"Field to sort errors by: 'last_seen' (default), 'first_seen', 'events' (number of events), 'users' (number of users affected) or 'unsorted'"
|
|
52
|
+
).default("last_seen"),
|
|
53
|
+
spanGroupId: z.string().describe(
|
|
54
|
+
"ID of the span group, e.g. '[HttpClient]GET-api.example.com'. Get it from List Span Groups and pass it as returned (do not URL-encode it)."
|
|
55
|
+
)
|
|
38
56
|
};
|
|
39
57
|
export {
|
|
40
58
|
toolInputParameters
|
|
@@ -7,15 +7,15 @@ const inputSchema = z.object({
|
|
|
7
7
|
errorId: toolInputParameters.errorId.describe(
|
|
8
8
|
"Unique identifier of the error to retrieve"
|
|
9
9
|
),
|
|
10
|
-
filters: toolInputParameters.
|
|
11
|
-
"
|
|
10
|
+
filters: toolInputParameters.errorScopedFilters.describe(
|
|
11
|
+
"Optional filters that restrict which events of this error are used for the latest event and the pivot summaries, as an object keyed by field name where each value is an array of { type: 'eq' | 'ne' | 'empty', value }. Use the List Project Event Filters tool to discover available filter fields. Time filters (event.since, event.before) support extended ISO 8601 format (e.g. 2018-05-20T00:00:00Z) or relative format (e.g. 7d, 24h). No filters are applied by default, so events of any age are considered."
|
|
12
12
|
)
|
|
13
13
|
});
|
|
14
14
|
class GetError extends Tool {
|
|
15
15
|
specification = {
|
|
16
16
|
title: "Get Error",
|
|
17
17
|
toolset: "Errors",
|
|
18
|
-
summary: "Get full details on an error
|
|
18
|
+
summary: "Get full details on an error: aggregated data across its events (occurrences), the latest event (with stacktrace, breadcrumbs and metadata) and pivot summaries. Use the filters parameter to restrict which events are considered.",
|
|
19
19
|
purpose: "Retrieve all the information required on a specified error to understand who it is affecting and why.",
|
|
20
20
|
useCases: [
|
|
21
21
|
"Investigate a specific error found through the List Project Errors tool",
|
|
@@ -38,7 +38,8 @@ class GetError extends Tool {
|
|
|
38
38
|
"Error IDs can be found using the List Project Errors tool",
|
|
39
39
|
"Use this after filtering errors to get detailed information about specific errors",
|
|
40
40
|
"Use Get Event Details tool if you need detailed information about a specific event (occurrence) rather than the aggregated error",
|
|
41
|
-
"If you used
|
|
41
|
+
"If you used filters to find this error, you can pass the same filters here to restrict the latest event and pivots to the same events",
|
|
42
|
+
"To list more than the latest event, use the Get Events on an Error tool",
|
|
42
43
|
"The URL provided in the response points should be shown to the user in all cases as it allows them to view the error in the dashboard and perform further analysis"
|
|
43
44
|
]
|
|
44
45
|
};
|
|
@@ -4,7 +4,7 @@ import { toolInputParameters } from "../../input-schemas.js";
|
|
|
4
4
|
const inputSchema = z.object({
|
|
5
5
|
projectId: toolInputParameters.projectId,
|
|
6
6
|
filters: toolInputParameters.filters.describe(
|
|
7
|
-
"
|
|
7
|
+
"Filters that narrow down the error list, as an object keyed by field name where each value is an array of { type: 'eq' | 'ne' | 'empty', value }. Multiple filters are combined with AND. Use the List Project Event Filters tool to discover available filter fields. Time filters (event.since, event.before) support extended ISO 8601 format (e.g. 2018-05-20T00:00:00Z) or relative format (e.g. 7d, 24h). Defaults: 'event.since' is 30d and 'error.status' is 'open' unless you specify them, so errors that are fixed, ignored or snoozed, or have no events in the last 30 days, are excluded by default."
|
|
8
8
|
),
|
|
9
9
|
sort: toolInputParameters.sort,
|
|
10
10
|
direction: toolInputParameters.direction,
|
|
@@ -33,7 +33,7 @@ class ListProjectErrors extends Tool {
|
|
|
33
33
|
"event.since": [{ type: "eq", value: "24h" }]
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
|
-
expectedOutput: "JSON object with a list of errors in the 'data' field, a count of the current page of results in the '
|
|
36
|
+
expectedOutput: "JSON object with a list of errors in the 'data' field, a count of the current page of results in the 'data_count' field, and a total count of all results in the 'total_count' field"
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
description: "Get the 10 open errors with the most users affected in the last 30 days",
|
|
@@ -46,7 +46,7 @@ class ListProjectErrors extends Tool {
|
|
|
46
46
|
direction: "desc",
|
|
47
47
|
perPage: 10
|
|
48
48
|
},
|
|
49
|
-
expectedOutput: "JSON object with a list of errors in the 'data' field, a count of the current page of results in the '
|
|
49
|
+
expectedOutput: "JSON object with a list of errors in the 'data' field, a count of the current page of results in the 'data_count' field, and a total count of all results in the 'total_count' field"
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
description: "Get the next 50 results",
|
|
@@ -62,9 +62,11 @@ class ListProjectErrors extends Tool {
|
|
|
62
62
|
"Combine multiple filters to narrow results - filters are applied with AND logic",
|
|
63
63
|
"For time filters: use relative format (7d, 24h) for recent periods or ISO 8601 UTC format (2018-05-20T00:00:00Z) for specific dates",
|
|
64
64
|
"Common time filters: event.since (from this time), event.before (until this time)",
|
|
65
|
-
"The 'event.since' filter and 'error.status' filters are always applied and if not specified are set to '30d' and 'open' respectively",
|
|
65
|
+
"The 'event.since' filter and 'error.status' filters are always applied and if not specified are set to '30d' and 'open' respectively. To see errors that are fixed, ignored or snoozed, or older errors, set these filters explicitly (e.g. 'event.since' of '365d')",
|
|
66
|
+
"If no errors are returned, the default 30d/open filters may be excluding them - try widening 'event.since' or changing 'error.status' before concluding there are none",
|
|
67
|
+
"Use the 'id' of an error with Get Error or Get Events on an Error to investigate it further",
|
|
66
68
|
"There may not be any errors matching the filters - this is not a problem with the tool, in fact it might be a good thing that the user's application had no errors",
|
|
67
|
-
"This tool returns paged results. The '
|
|
69
|
+
"This tool returns paged results. The 'data_count' field indicates the number of results returned in the current page, and the 'total_count' field indicates the total number of results across all pages.",
|
|
68
70
|
"If the output contains a 'next_url' value, there are more results available - call this tool again supplying the next URL as a parameter to retrieve the next page.",
|
|
69
71
|
"Do not modify the next URL as this can cause incorrect results. The only other parameter that can be used with 'next' is 'per_page' to control the page size."
|
|
70
72
|
]
|
|
@@ -22,9 +22,11 @@ const PERMITTED_REOPEN_CONDITIONS = [
|
|
|
22
22
|
const inputSchema = z.object({
|
|
23
23
|
projectId: toolInputParameters.projectId,
|
|
24
24
|
errorId: toolInputParameters.errorId,
|
|
25
|
-
operation: z.enum(PERMITTED_UPDATE_OPERATIONS).describe(
|
|
25
|
+
operation: z.enum(PERMITTED_UPDATE_OPERATIONS).describe(
|
|
26
|
+
"The operation to apply: 'open' reopens the error; 'fix' marks it fixed; 'ignore' ignores it until manually reopened; 'snooze' ignores it until the condition in reopenRules is met; 'discard' stops storing new events for it and 'undiscard' resumes; 'override_severity' changes its severity (the user will be asked to choose the value); 'link_issue' links it to an external issue (requires issue_url) and 'unlink_issue' removes that link"
|
|
27
|
+
),
|
|
26
28
|
issue_url: z.string().optional().describe(
|
|
27
|
-
"The URL of the issue to link to the error - required when operation is 'link_issue'"
|
|
29
|
+
"The URL of the issue (e.g. a Jira issue) to link to the error - required when operation is 'link_issue'"
|
|
28
30
|
),
|
|
29
31
|
reopenRules: z.object({
|
|
30
32
|
reopenIf: z.enum(PERMITTED_REOPEN_CONDITIONS).describe("Condition for when the error should be reopened"),
|
|
@@ -41,7 +43,7 @@ const inputSchema = z.object({
|
|
|
41
43
|
"for n_occurrences_in_m_hours reopen rules, the number of hours."
|
|
42
44
|
),
|
|
43
45
|
additionalOccurrences: z.number().min(1).optional().describe(
|
|
44
|
-
"
|
|
46
|
+
"for n_additional_occurrences reopen rules, the number of additional occurrences allowed before reopening."
|
|
45
47
|
)
|
|
46
48
|
}).optional().describe(
|
|
47
49
|
"Reopen rules for snooze operation - required when operation is 'snooze'"
|
|
@@ -134,7 +136,8 @@ class UpdateError extends Tool {
|
|
|
134
136
|
"For 'n_additional_users' reopen rules, specify 'additionalUsers' parameter (max 100,000)",
|
|
135
137
|
"For 'n_occurrences_in_m_hours' reopen rules, specify both 'occurrences' and 'hours' parameters",
|
|
136
138
|
"For 'n_additional_occurrences' reopen rules, specify 'additionalOccurrences' parameter",
|
|
137
|
-
"Snoozing temporarily silences an error until the specified reopen condition is met"
|
|
139
|
+
"Snoozing temporarily silences an error until the specified reopen condition is met",
|
|
140
|
+
"This changes the error's workflow state in the BugSnag dashboard for the whole team - confirm with the user before any state-changing operation, including snoozing, fixing, ignoring, discarding, reopening, severity changes or issue links"
|
|
138
141
|
],
|
|
139
142
|
readOnly: false,
|
|
140
143
|
idempotent: false
|
|
@@ -2,7 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { Tool, ToolError } from "../../../common/tools.js";
|
|
3
3
|
const inputSchema = z.object({
|
|
4
4
|
link: z.string().describe(
|
|
5
|
-
"Full URL
|
|
5
|
+
"Full URL of an event in the BugSnag dashboard (web interface), e.g. https://app.bugsnag.com/<org-slug>/<project-slug>/errors/<errorId>?event_id=<eventId>. It must contain the project slug in the path and the event_id query parameter."
|
|
6
6
|
)
|
|
7
7
|
});
|
|
8
8
|
class GetEventDetailsFromDashboardUrl extends Tool {
|
|
@@ -28,7 +28,8 @@ class GetEventDetailsFromDashboardUrl extends Tool {
|
|
|
28
28
|
],
|
|
29
29
|
hints: [
|
|
30
30
|
"The URL must contain both project slug in the path and event_id in query parameters",
|
|
31
|
-
"This is useful when users share BugSnag dashboard URLs and you need to extract the event data"
|
|
31
|
+
"This is useful when users share BugSnag dashboard URLs and you need to extract the event data",
|
|
32
|
+
"The project slug in the URL is resolved to a project for you - you do not need to look up the project ID first"
|
|
32
33
|
]
|
|
33
34
|
};
|
|
34
35
|
handle = async (args, _ctx) => {
|
|
@@ -23,6 +23,10 @@ class GetEvent extends Tool {
|
|
|
23
23
|
},
|
|
24
24
|
expectedOutput: "JSON object with complete event details including stack trace (error trace and other threads, if present), metadata, and context"
|
|
25
25
|
}
|
|
26
|
+
],
|
|
27
|
+
hints: [
|
|
28
|
+
"Event IDs can be found using the Get Events on an Error tool, or in the 'event_id' parameter of a dashboard URL",
|
|
29
|
+
"If you only have a dashboard URL, use the Get Event Details From Dashboard URL tool instead"
|
|
26
30
|
]
|
|
27
31
|
};
|
|
28
32
|
handle = async (args, _ctx) => {
|
|
@@ -4,9 +4,7 @@ import { toolInputParameters } from "../../input-schemas.js";
|
|
|
4
4
|
const inputSchema = z.object({
|
|
5
5
|
projectId: toolInputParameters.projectId,
|
|
6
6
|
errorId: toolInputParameters.errorId,
|
|
7
|
-
filters: toolInputParameters.
|
|
8
|
-
"Apply filters to narrow down the event list. Use the List Project Event Filters tool to discover available filter fields. Time filters support extended ISO 8601 format (e.g. 2018-05-20T00:00:00Z) or relative format (e.g. 7d, 24h)."
|
|
9
|
-
),
|
|
7
|
+
filters: toolInputParameters.errorScopedFilters,
|
|
10
8
|
direction: toolInputParameters.direction,
|
|
11
9
|
perPage: toolInputParameters.perPage,
|
|
12
10
|
nextUrl: toolInputParameters.nextUrl
|
|
@@ -15,7 +13,7 @@ class ListErrorEvents extends Tool {
|
|
|
15
13
|
specification = {
|
|
16
14
|
title: "Get Events on an Error",
|
|
17
15
|
toolset: "Events",
|
|
18
|
-
summary: "
|
|
16
|
+
summary: "List the individual events (occurrences) of one error, newest first by default",
|
|
19
17
|
purpose: "Show the events that make up an error to see individual occurrences of the error for detailed analysis",
|
|
20
18
|
useCases: [
|
|
21
19
|
"Retrieving all the events for comparison to find commonalities or differences in stack traces, breadcrumbs and metadata"
|
|
@@ -29,7 +27,21 @@ class ListErrorEvents extends Tool {
|
|
|
29
27
|
errorId: "6863e2af012caf1d5c320000"
|
|
30
28
|
},
|
|
31
29
|
expectedOutput: "A list of events, ordered by timestamp, with complete details including stack trace, breadcrumbs, metadata, and context"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
description: "Get events of an error from the last 7 days only",
|
|
33
|
+
parameters: {
|
|
34
|
+
errorId: "6863e2af012caf1d5c320000",
|
|
35
|
+
filters: { "event.since": [{ type: "eq", value: "7d" }] }
|
|
36
|
+
},
|
|
37
|
+
expectedOutput: "A list of events that occurred in the last 7 days"
|
|
32
38
|
}
|
|
39
|
+
],
|
|
40
|
+
hints: [
|
|
41
|
+
"No time filter is applied by default, so events of any age are returned. Use 'event.since' / 'event.before' in filters to restrict the time range",
|
|
42
|
+
"Event stack traces and metadata are included, so keep perPage small when you only need a few events",
|
|
43
|
+
"Use the 'id' of an event with the Get Event tool if you need to look at one event on its own",
|
|
44
|
+
"This tool returns paged results - if the output contains a 'next_url' value, call this tool again with it as the nextUrl parameter to get more events"
|
|
33
45
|
]
|
|
34
46
|
};
|
|
35
47
|
handle = async (args, _ctx) => {
|
|
@@ -37,6 +37,7 @@ class GetSpanGroup extends Tool {
|
|
|
37
37
|
],
|
|
38
38
|
hints: [
|
|
39
39
|
"Use List Span Groups first to discover available span group IDs",
|
|
40
|
+
"Statistics only cover the filtered time window (last 7 days by default) - pass span.since in filters to change it",
|
|
40
41
|
"IDs are automatically URL-encoded - provide the raw ID",
|
|
41
42
|
"Statistics include p50, p75, p90, p95, p99 percentiles"
|
|
42
43
|
]
|
|
@@ -3,10 +3,18 @@ import { Tool, ToolError } from "../../../common/tools.js";
|
|
|
3
3
|
import { toolInputParameters } from "../../input-schemas.js";
|
|
4
4
|
const inputSchema = z.object({
|
|
5
5
|
projectId: toolInputParameters.projectId,
|
|
6
|
-
traceId: z.string().describe(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
traceId: z.string().describe(
|
|
7
|
+
"ID of the trace, from the trace ID of a span returned by List Spans"
|
|
8
|
+
),
|
|
9
|
+
from: z.string().describe(
|
|
10
|
+
"Start of the time window to search, ISO 8601 UTC (e.g. 2024-01-01T00:00:00Z). Must be before the time the trace occurred"
|
|
11
|
+
),
|
|
12
|
+
to: z.string().describe(
|
|
13
|
+
"End of the time window to search, ISO 8601 UTC. Must be after the time the trace occurred - use the span timestamp plus a few minutes"
|
|
14
|
+
),
|
|
15
|
+
targetSpanId: z.string().optional().describe(
|
|
16
|
+
"Optional ID of a span in the trace; results are focused around this span"
|
|
17
|
+
),
|
|
10
18
|
perPage: toolInputParameters.perPage,
|
|
11
19
|
nextUrl: toolInputParameters.nextUrl
|
|
12
20
|
});
|
|
@@ -46,7 +54,7 @@ class GetTrace extends Tool {
|
|
|
46
54
|
],
|
|
47
55
|
hints: [
|
|
48
56
|
"Traces show the complete execution path of a request",
|
|
49
|
-
"
|
|
57
|
+
"The from/to window must contain the trace - take the timestamp of a span from List Spans and use a window around it",
|
|
50
58
|
"targetSpanId can be used to focus on a specific span in the trace"
|
|
51
59
|
]
|
|
52
60
|
};
|
|
@@ -33,10 +33,14 @@ const inputSchema = z.object({
|
|
|
33
33
|
"rendering_metrics_fps_mean_p99",
|
|
34
34
|
"http_response_4xx_percentage",
|
|
35
35
|
"http_response_5xx_percentage"
|
|
36
|
-
]).optional().describe(
|
|
36
|
+
]).optional().describe(
|
|
37
|
+
"Field to sort by, e.g. duration_p95 or duration_p99 for the slowest operations, total_spans for the most frequently used, last_seen for the most recent"
|
|
38
|
+
),
|
|
37
39
|
direction: toolInputParameters.direction,
|
|
38
40
|
perPage: toolInputParameters.perPage,
|
|
39
|
-
starredOnly: z.boolean().optional().describe(
|
|
41
|
+
starredOnly: z.boolean().optional().describe(
|
|
42
|
+
"If true, only include span groups that have been starred as important in the dashboard"
|
|
43
|
+
),
|
|
40
44
|
nextUrl: toolInputParameters.nextUrl,
|
|
41
45
|
filters: toolInputParameters.performanceFilters
|
|
42
46
|
});
|
|
@@ -76,7 +80,7 @@ class ListSpanGroups extends Tool {
|
|
|
76
80
|
hints: [
|
|
77
81
|
"Span groups represent different operation types (page loads, API calls, etc.)",
|
|
78
82
|
"Use sort by duration_p95 or duration_p99 to find the slowest operations",
|
|
79
|
-
"
|
|
83
|
+
"Only span groups with spans in the filtered time window are returned (last 7 days by default) - pass span.since in filters to look further back",
|
|
80
84
|
"Use nextUrl for pagination"
|
|
81
85
|
]
|
|
82
86
|
};
|
|
@@ -20,7 +20,9 @@ const inputSchema = z.object({
|
|
|
20
20
|
"rendering_metrics_fps_minimum",
|
|
21
21
|
"rendering_metrics_fps_maximum",
|
|
22
22
|
"http_response_code"
|
|
23
|
-
]).optional().describe(
|
|
23
|
+
]).optional().describe(
|
|
24
|
+
"Field to sort by, e.g. duration for the slowest spans or timestamp for the newest"
|
|
25
|
+
),
|
|
24
26
|
direction: toolInputParameters.direction,
|
|
25
27
|
perPage: toolInputParameters.perPage,
|
|
26
28
|
nextUrl: toolInputParameters.nextUrl,
|
|
@@ -64,7 +66,8 @@ class ListSpans extends Tool {
|
|
|
64
66
|
],
|
|
65
67
|
hints: [
|
|
66
68
|
"Sort by duration descending to find the slowest instances",
|
|
67
|
-
"Each span includes trace ID for further investigation"
|
|
69
|
+
"Each span includes trace ID for further investigation with the Get Trace tool",
|
|
70
|
+
"Only spans from the filtered time window are returned (last 7 days by default) - pass span.since in filters to look further back"
|
|
68
71
|
]
|
|
69
72
|
};
|
|
70
73
|
handle = async (args, _ctx) => {
|
|
@@ -25,7 +25,7 @@ class ListTraceFields extends Tool {
|
|
|
25
25
|
],
|
|
26
26
|
hints: [
|
|
27
27
|
"Trace fields are custom attributes added to spans",
|
|
28
|
-
"Use these
|
|
28
|
+
"Use these field names as keys in the filters parameter of List Span Groups, Get Span Group and List Spans"
|
|
29
29
|
]
|
|
30
30
|
};
|
|
31
31
|
handle = async (args, _ctx) => {
|
|
@@ -55,11 +55,12 @@ class SetNetworkEndpointGroupings extends Tool {
|
|
|
55
55
|
}
|
|
56
56
|
],
|
|
57
57
|
hints: [
|
|
58
|
-
"Use Get Network
|
|
58
|
+
"Use Get Network Endpoint Groupings first to see current patterns",
|
|
59
59
|
"Use OpenAPI path templating with curly braces for path parameters: /users/{userId}, /orders/{orderId}/items/{itemId}",
|
|
60
60
|
"Convert colon-prefixed parameters to curly braces: :organizationSlug becomes {organizationSlug}, :projectSlug becomes {projectSlug}",
|
|
61
61
|
"Wildcards (*) can be used in domains to match subdomains: https://*.example.com/api",
|
|
62
|
-
"This
|
|
62
|
+
"This REPLACES all existing patterns - call Get Network Endpoint Groupings first and send back the full list with your changes, otherwise existing patterns are lost",
|
|
63
|
+
"Confirm with the user before calling this tool, as it changes the endpoint grouping configuration for the whole project",
|
|
63
64
|
"Well-designed patterns reduce noise in performance monitoring"
|
|
64
65
|
],
|
|
65
66
|
readOnly: false,
|
|
@@ -11,15 +11,15 @@ class GetCurrentProject extends Tool {
|
|
|
11
11
|
hints: [
|
|
12
12
|
"If a project is returned, it can be assumed that the user expects interactions with BugSnag tools to refer to this project",
|
|
13
13
|
"If this tool returns no current project then other BugSnag tools will require an explicit project ID parameter",
|
|
14
|
-
"Call the List Projects tool to see all projects that the user has access to.
|
|
15
|
-
"You might find a BugSnag API key in the user's code where they configure the BugSnag SDK that can be matched to a project '
|
|
14
|
+
"Call the List Projects tool to see all projects that the user has access to. Find the project in this list by the name or slug the user gives you, then use its 'id' field (not the name or slug) as the projectId parameter",
|
|
15
|
+
"You might find a BugSnag API key in the user's code where they configure the BugSnag SDK that can be matched to a project's 'api_key' field from the project list"
|
|
16
16
|
]
|
|
17
17
|
};
|
|
18
18
|
handle = async (_args, _ctx) => {
|
|
19
19
|
const project = await this.client.getCurrentProject();
|
|
20
20
|
if (!project) {
|
|
21
21
|
throw new ToolError(
|
|
22
|
-
"No current project is configured in the MCP server - use List Projects to see the available projects and use the project ID as a parameter to other BugSnag tools. You can ask the user to select the project
|
|
22
|
+
"No current project is configured in the MCP server - use List Projects to see the available projects and use the project ID as a parameter to other BugSnag tools. You can ask the user to select the project by name or slug and then use that project's 'id' from the list as projectId, or use the apiKey field and see if there's a BugSnag API key set in the user's code when they configure the BugSnag SDK"
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
25
|
return {
|
|
@@ -9,7 +9,7 @@ class ListProjectEventFilters extends Tool {
|
|
|
9
9
|
title: "List Project Event Filters",
|
|
10
10
|
toolset: "Projects",
|
|
11
11
|
summary: "Get available event filter fields for a project",
|
|
12
|
-
purpose: "Discover
|
|
12
|
+
purpose: "Discover the filter field names (including custom metadata fields) that are valid for this project, for use in the 'filters' parameter of List Project Errors, Get Error and Get Events on an Error",
|
|
13
13
|
useCases: [
|
|
14
14
|
"Discover what filter fields are available before searching for errors",
|
|
15
15
|
"Find the correct field names for filtering by user, environment, or custom metadata",
|
|
@@ -24,8 +24,8 @@ class ListProjectEventFilters extends Tool {
|
|
|
24
24
|
}
|
|
25
25
|
],
|
|
26
26
|
hints: [
|
|
27
|
-
"Use this tool before the List Errors or Get Error tools to understand available filters",
|
|
28
|
-
"Look for display_id field in the response - these are the field names to use in filters"
|
|
27
|
+
"Use this tool before the List Project Errors, Get Error or Get Events on an Error tools to understand available filters",
|
|
28
|
+
"Look for display_id field in the response - these are the field names to use as keys in the filters parameter (e.g. 'error.status', 'event.since', 'user.email')"
|
|
29
29
|
]
|
|
30
30
|
};
|
|
31
31
|
handle = async (args, _ctx) => {
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { Tool, ToolError } from "../../../common/tools.js";
|
|
3
3
|
const inputSchema = z.object({
|
|
4
|
-
apiKey: z.string().optional().describe(
|
|
4
|
+
apiKey: z.string().optional().describe(
|
|
5
|
+
"The notifier API key of the BugSnag project (found where the BugSnag SDK is configured in the user's code). If provided, only the project with this key is returned."
|
|
6
|
+
)
|
|
5
7
|
});
|
|
6
8
|
class ListProjects extends Tool {
|
|
7
9
|
specification = {
|
|
8
10
|
toolset: "Projects",
|
|
9
11
|
title: "List Projects",
|
|
10
|
-
summary: "List
|
|
12
|
+
summary: "List the projects the current user has access to, or find the project matching an API key. Each project includes its 'id', 'name', 'slug' and 'api_key'.",
|
|
11
13
|
purpose: "Retrieve available projects for browsing and selecting which project to analyze.",
|
|
12
14
|
useCases: [
|
|
13
15
|
"Get an overview of all projects in the organization",
|
|
@@ -15,7 +17,8 @@ class ListProjects extends Tool {
|
|
|
15
17
|
],
|
|
16
18
|
inputSchema,
|
|
17
19
|
hints: [
|
|
18
|
-
"
|
|
20
|
+
"Use the 'id' field (not the name or slug) as the projectId parameter of other BugSnag tools when no current project is configured",
|
|
21
|
+
"To find a project the user refers to by name or slug, look it up in this list and use its 'id'"
|
|
19
22
|
]
|
|
20
23
|
};
|
|
21
24
|
handle = async (args, _ctx) => {
|
|
@@ -26,7 +26,10 @@ class GetBuild extends Tool {
|
|
|
26
26
|
expectedOutput: "JSON object with build details including version, source control info, error counts and stability data."
|
|
27
27
|
}
|
|
28
28
|
],
|
|
29
|
-
hints: [
|
|
29
|
+
hints: [
|
|
30
|
+
"Build IDs can be found in the list of builds returned by the Get Release tool",
|
|
31
|
+
"user_stability and session_stability are fractions between 0 and 1; meets_target_stability and meets_critical_stability compare them with the project's stability targets"
|
|
32
|
+
],
|
|
30
33
|
readOnly: true,
|
|
31
34
|
idempotent: true,
|
|
32
35
|
outputDescription: "JSON object containing build details along with stability metrics such as user and session stability, and whether it meets project targets"
|
|
@@ -26,7 +26,10 @@ class GetRelease extends Tool {
|
|
|
26
26
|
expectedOutput: "JSON object with release details including version, source control info, error counts and stability data."
|
|
27
27
|
}
|
|
28
28
|
],
|
|
29
|
-
hints: [
|
|
29
|
+
hints: [
|
|
30
|
+
"Release IDs can be found using the List Releases tool",
|
|
31
|
+
"user_stability and session_stability are fractions between 0 and 1; meets_target_stability and meets_critical_stability compare them with the project's stability targets"
|
|
32
|
+
],
|
|
30
33
|
readOnly: true,
|
|
31
34
|
idempotent: true,
|
|
32
35
|
outputDescription: "JSON object containing release details along with stability metrics such as user and session stability, and whether it meets project targets"
|
|
@@ -5,7 +5,7 @@ const inputSchema = z.object({
|
|
|
5
5
|
projectId: toolInputParameters.projectId,
|
|
6
6
|
releaseStage: toolInputParameters.releaseStage,
|
|
7
7
|
visibleOnly: z.boolean().describe(
|
|
8
|
-
"
|
|
8
|
+
"If true, excludes releases that have been hidden in the dashboard. Defaults to false (include all)"
|
|
9
9
|
).default(false),
|
|
10
10
|
perPage: toolInputParameters.perPage,
|
|
11
11
|
nextUrl: toolInputParameters.nextUrl
|
|
@@ -14,7 +14,7 @@ class ListReleases extends Tool {
|
|
|
14
14
|
specification = {
|
|
15
15
|
title: "List Releases",
|
|
16
16
|
toolset: "Releases",
|
|
17
|
-
summary: "List
|
|
17
|
+
summary: "List release groups (versions of the app) for a project, with stability metrics",
|
|
18
18
|
purpose: "Retrieve a list of release summaries to analyze deployment history and associated errors",
|
|
19
19
|
useCases: [
|
|
20
20
|
"View recent releases to correlate with error spikes",
|
|
@@ -24,7 +24,7 @@ class ListReleases extends Tool {
|
|
|
24
24
|
examples: [
|
|
25
25
|
{
|
|
26
26
|
description: "List production releases for a project",
|
|
27
|
-
parameters: {},
|
|
27
|
+
parameters: { projectId: "515fb9337c1074f6fd000003" },
|
|
28
28
|
expectedOutput: "JSON array of release objects in the production stage"
|
|
29
29
|
},
|
|
30
30
|
{
|
|
@@ -43,7 +43,8 @@ class ListReleases extends Tool {
|
|
|
43
43
|
}
|
|
44
44
|
],
|
|
45
45
|
hints: [
|
|
46
|
-
"Use the Get Release tool to get more details
|
|
46
|
+
"Use the Get Release tool with a release's id to get more details, including the builds it contains",
|
|
47
|
+
"Only the production stage is listed by default - set releaseStage to list releases from another stage",
|
|
47
48
|
"The release stage defaults to 'production' if not specified",
|
|
48
49
|
"Use visibleOnly to filter out releases that have been marked as hidden in the dashboard"
|
|
49
50
|
],
|
package/dist/common/cache.js
CHANGED
|
@@ -10,11 +10,23 @@ function isCachingEnabled() {
|
|
|
10
10
|
class CacheService {
|
|
11
11
|
cache;
|
|
12
12
|
enabled;
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* @param options.sweepExpired Run node-cache's periodic expiry sweep
|
|
15
|
+
* (default true). The sweep re-arms a timer forever, and that pending timer
|
|
16
|
+
* keeps the cache - and everything in it - reachable until `close()` is
|
|
17
|
+
* called. Short-lived owners (one cache per server instance, which can mean
|
|
18
|
+
* one per request) must pass false so the cache can be garbage collected
|
|
19
|
+
* along with its owner; expired entries are still dropped lazily on `get`.
|
|
20
|
+
* Only process-lifetime singletons should leave the sweep on.
|
|
21
|
+
*/
|
|
22
|
+
constructor(options = {}) {
|
|
14
23
|
this.enabled = isCachingEnabled();
|
|
15
24
|
const ttl = getConfiguredCacheTtlSeconds();
|
|
16
25
|
this.cache = this.enabled ? new NodeCache({
|
|
17
|
-
stdTTL: ttl
|
|
26
|
+
stdTTL: ttl,
|
|
27
|
+
// Only set when disabling: an explicit `undefined` would override
|
|
28
|
+
// node-cache's default sweep period rather than fall back to it.
|
|
29
|
+
...options.sweepExpired === false ? { checkperiod: 0 } : {}
|
|
18
30
|
}) : null;
|
|
19
31
|
}
|
|
20
32
|
/**
|
|
@@ -51,6 +63,13 @@ class CacheService {
|
|
|
51
63
|
isEnabled() {
|
|
52
64
|
return this.enabled;
|
|
53
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Stop the expiry sweep timer and drop all entries.
|
|
68
|
+
*/
|
|
69
|
+
close() {
|
|
70
|
+
this.cache?.flushAll();
|
|
71
|
+
this.cache?.close();
|
|
72
|
+
}
|
|
54
73
|
/**
|
|
55
74
|
* Clear all cache entries
|
|
56
75
|
*/
|
package/dist/common/server.js
CHANGED
|
@@ -70,7 +70,7 @@ class SmartBearMcpServer extends McpServer {
|
|
|
70
70
|
...isCachingEnabled() ? { cacheHints: buildCacheHints() } : {}
|
|
71
71
|
}
|
|
72
72
|
);
|
|
73
|
-
this.cache = new CacheService();
|
|
73
|
+
this.cache = new CacheService({ sweepExpired: false });
|
|
74
74
|
if (enabledToolsets) {
|
|
75
75
|
this.enabledToolsets = enabledToolsets.split(",").map((s) => s.trim().toLowerCase());
|
|
76
76
|
}
|
|
@@ -16,6 +16,45 @@ import { registerShutdownHandler, isDraining } from "./shutdown.js";
|
|
|
16
16
|
import "node:module";
|
|
17
17
|
import "@modelcontextprotocol/server/stdio";
|
|
18
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
|
+
}
|
|
19
58
|
const IDENTITY_KEY = randomBytes(32);
|
|
20
59
|
function resolveCredentialIdentity(server) {
|
|
21
60
|
const parts = [];
|
|
@@ -115,6 +154,37 @@ function getBaseUrlFromHeaders(headers) {
|
|
|
115
154
|
function getBaseUrl(req) {
|
|
116
155
|
return getBaseUrlFromHeaders(req.headers);
|
|
117
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
|
+
}
|
|
118
188
|
async function runHttpMode() {
|
|
119
189
|
const PORT = process.env.PORT ? Number.parseInt(process.env.PORT, 10) : 3e3;
|
|
120
190
|
const allowedOrigins = process.env.ALLOWED_ORIGINS?.split(",") || [
|
|
@@ -223,7 +293,18 @@ ${headerHelp.join("\n")}`
|
|
|
223
293
|
);
|
|
224
294
|
}
|
|
225
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();
|
|
226
306
|
registerShutdownHandler("http-transport", async () => {
|
|
307
|
+
if (reaper) clearInterval(reaper);
|
|
227
308
|
try {
|
|
228
309
|
await modernHandler.close();
|
|
229
310
|
} catch (err) {
|
|
@@ -301,7 +382,14 @@ async function createNewTransport(req, res, transports) {
|
|
|
301
382
|
console.log(
|
|
302
383
|
`[MCP] New session initialized: ${redactSessionId(newSessionId)}`
|
|
303
384
|
);
|
|
304
|
-
|
|
385
|
+
const entry = {
|
|
386
|
+
server,
|
|
387
|
+
transport,
|
|
388
|
+
lastActivity: Date.now(),
|
|
389
|
+
identity
|
|
390
|
+
};
|
|
391
|
+
transports.set(newSessionId, entry);
|
|
392
|
+
trackExchange(entry, res);
|
|
305
393
|
attachSessionAnalytics(server, newSessionId, "streamable-http");
|
|
306
394
|
}
|
|
307
395
|
});
|
|
@@ -311,9 +399,10 @@ async function createNewTransport(req, res, transports) {
|
|
|
311
399
|
console.log(
|
|
312
400
|
`[MCP] Session closed: ${redactSessionId(transport.sessionId)}`
|
|
313
401
|
);
|
|
314
|
-
transports.delete(transport.sessionId)
|
|
315
|
-
|
|
316
|
-
|
|
402
|
+
if (transports.delete(transport.sessionId)) {
|
|
403
|
+
endSessionAnalytics(server);
|
|
404
|
+
server.cleanupSession(transport.sessionId);
|
|
405
|
+
}
|
|
317
406
|
}
|
|
318
407
|
};
|
|
319
408
|
await server.connect(transport);
|
|
@@ -362,6 +451,7 @@ function createModernHandler() {
|
|
|
362
451
|
);
|
|
363
452
|
}
|
|
364
453
|
async function handleMcpEndpoint(req, res, transports, modern) {
|
|
454
|
+
if (rejectExpiredBearerToken(req, res)) return;
|
|
365
455
|
if (req.headers["mcp-session-id"]) {
|
|
366
456
|
await handleStreamableHttpRequest(req, res, transports);
|
|
367
457
|
return;
|
|
@@ -407,6 +497,7 @@ function extractModernClientMetaFromBody(parsedBody) {
|
|
|
407
497
|
}
|
|
408
498
|
async function handleStreamableHttpRequest(req, res, transports, preParsed) {
|
|
409
499
|
try {
|
|
500
|
+
if (rejectExpiredBearerToken(req, res)) return;
|
|
410
501
|
const sessionId = req.headers["mcp-session-id"];
|
|
411
502
|
const sessionEntry = sessionId ? transports.get(sessionId) : void 0;
|
|
412
503
|
if (sessionId && !sessionEntry) {
|
|
@@ -417,6 +508,8 @@ async function handleStreamableHttpRequest(req, res, transports, preParsed) {
|
|
|
417
508
|
if (sessionEntry && !authorizeSessionRequest(req, res, sessionEntry)) {
|
|
418
509
|
return;
|
|
419
510
|
}
|
|
511
|
+
const existingEntry = sessionId ? transports.get(sessionId) : void 0;
|
|
512
|
+
if (existingEntry) trackExchange(existingEntry, res);
|
|
420
513
|
const parsedBody = preParsed ? preParsed.body : await parseRequestBody(req);
|
|
421
514
|
let transport;
|
|
422
515
|
if (sessionId) {
|
|
@@ -459,6 +552,7 @@ async function handleStreamableHttpRequest(req, res, transports, preParsed) {
|
|
|
459
552
|
}
|
|
460
553
|
}
|
|
461
554
|
async function handleLegacySseRequest(req, res, transports) {
|
|
555
|
+
if (rejectExpiredBearerToken(req, res)) return;
|
|
462
556
|
const server = await newServer(req, res);
|
|
463
557
|
if (!server) {
|
|
464
558
|
return;
|
|
@@ -466,7 +560,15 @@ async function handleLegacySseRequest(req, res, transports) {
|
|
|
466
560
|
const identity = requestIdentity(req, server) ?? void 0;
|
|
467
561
|
const transport = new SSEServerTransport("/message", res);
|
|
468
562
|
transport.onmessage = (message) => handleSessionMessage(server, message);
|
|
469
|
-
transports.set(transport.sessionId, {
|
|
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
|
+
});
|
|
470
572
|
attachSessionAnalytics(server, transport.sessionId, "sse");
|
|
471
573
|
res.on("close", () => {
|
|
472
574
|
transports.delete(transport.sessionId);
|
|
@@ -480,6 +582,7 @@ function writeLegacySessionNotFound(res) {
|
|
|
480
582
|
res.end("Session not found");
|
|
481
583
|
}
|
|
482
584
|
async function handleLegacyMessageRequest(req, res, url, transports) {
|
|
585
|
+
if (rejectExpiredBearerToken(req, res)) return;
|
|
483
586
|
const sessionId = url.searchParams.get("sessionId");
|
|
484
587
|
if (!sessionId) {
|
|
485
588
|
res.writeHead(400, { "Content-Type": "text/plain" });
|
|
@@ -491,6 +594,7 @@ async function handleLegacyMessageRequest(req, res, url, transports) {
|
|
|
491
594
|
writeLegacySessionNotFound(res);
|
|
492
595
|
return;
|
|
493
596
|
}
|
|
597
|
+
trackExchange(session, res);
|
|
494
598
|
if (!(session.transport instanceof SSEServerTransport)) {
|
|
495
599
|
res.writeHead(400, { "Content-Type": "text/plain" });
|
|
496
600
|
res.end("Invalid transport for this endpoint");
|
|
@@ -658,12 +762,19 @@ export {
|
|
|
658
762
|
getBaseUrlFromHeaders,
|
|
659
763
|
getHeaderName,
|
|
660
764
|
getQueryStringName,
|
|
765
|
+
getSessionIdleTimeoutMs,
|
|
661
766
|
handleHealthRequest,
|
|
767
|
+
handleLegacyMessageRequest,
|
|
768
|
+
handleLegacySseRequest,
|
|
769
|
+
handleMcpEndpoint,
|
|
662
770
|
handleReadyRequest,
|
|
663
771
|
handleSessionMessage,
|
|
664
772
|
handleStreamableHttpRequest,
|
|
773
|
+
hasExpiredBearerJwt,
|
|
665
774
|
newServer,
|
|
666
775
|
newServerFromWebRequest,
|
|
776
|
+
reapIdleSessions,
|
|
777
|
+
rejectExpiredBearerToken,
|
|
667
778
|
resolveCredentialIdentity,
|
|
668
779
|
runHttpMode
|
|
669
780
|
};
|
package/dist/package.json.js
CHANGED
|
@@ -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(
|
|
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(
|
|
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(
|
|
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."),
|
|
@@ -41,6 +41,15 @@ class GetTestCases extends Tool {
|
|
|
41
41
|
},
|
|
42
42
|
expectedOutput: "One Test Case from project PROJ with its details"
|
|
43
43
|
},
|
|
44
|
+
{
|
|
45
|
+
description: "Get Test Cases having name containing 'tool' from the project PROJ",
|
|
46
|
+
parameters: {
|
|
47
|
+
projectKey: "PROJ",
|
|
48
|
+
nameOrKey: "tool",
|
|
49
|
+
limit: 10
|
|
50
|
+
},
|
|
51
|
+
expectedOutput: "The first 10 Test Cases from project PROJ having 'tool' in the title"
|
|
52
|
+
},
|
|
44
53
|
{
|
|
45
54
|
description: "Get one Test Case from the folder with ID 123",
|
|
46
55
|
parameters: {
|
package/package.json
CHANGED
|
@@ -16,8 +16,8 @@ server's calls to PactFlow APIs; these cover what the server offers to MCP clien
|
|
|
16
16
|
## Running
|
|
17
17
|
|
|
18
18
|
```sh
|
|
19
|
-
npm install -g @pactflow/drift
|
|
20
|
-
drift component install mcp # the MCP plugin is optional and in beta
|
|
19
|
+
npm install -g @pactflow/drift@2610.0.0 # the version CI pins (DRIFT_VERSION in .github/workflows/drift.yml)
|
|
20
|
+
drift component install mcp --version 2610.0.0 # the MCP plugin is optional and in beta; keep it on the CLI's release
|
|
21
21
|
|
|
22
22
|
npm run build
|
|
23
23
|
export PACT_BROKER_BASE_URL=... PACT_BROKER_TOKEN=... # Drift authenticates with PactFlow
|