Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 72 additions & 21 deletions packages/mcp-core/src/tools/catalog/get-issue-details.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,30 @@ describe("get_issue_details", () => {
"url": "https://sentry-mcp-evals.sentry.io/issues/CLOUDFLARE-MCP-41",
"usersImpacted": 1,
},
"relatedIssues": {
"issues": [
{
"project": "CLOUDFLARE-MCP",
"relations": [
"similar_stacktrace",
"same_trace",
],
"shortId": "CLOUDFLARE-MCP-42",
"status": "resolved",
"title": "Error: Tool list_projects is already registered",
},
{
"project": "web",
"relations": [
"same_trace",
],
"shortId": "WEB-1A2",
"status": "unresolved",
"title": "TypeError: Failed to fetch",
},
],
"unavailableTypes": [],
},
"replays": null,
"seer": null,
"sideQuests": [
Expand All @@ -384,25 +408,26 @@ describe("get_issue_details", () => {
"issueId": "CLOUDFLARE-MCP-41",
"organizationSlug": "sentry-mcp-evals",
},
"reason": "Chart this issue's events and affected users over time.",
"toolName": "render_issue_chart",
"reason": "List every related issue with its similarity score before resolving or ignoring this one.",
"toolName": "find_related_issues",
"type": "tool_call",
},
{
"arguments": {
"issueId": "CLOUDFLARE-MCP-41",
"organizationSlug": "sentry-mcp-evals",
"traceId": "3032af8bcdfe4423b937fc5c041d5d82",
},
"reason": "Inspect the distributed trace this event belongs to.",
"toolName": "get_trace_details",
"reason": "Chart this issue's events and affected users over time.",
"toolName": "render_issue_chart",
"type": "tool_call",
},
{
"arguments": {
"issueUrl": "https://sentry-mcp-evals.sentry.io/issues/CLOUDFLARE-MCP-41",
"organizationSlug": "sentry-mcp-evals",
"traceId": "3032af8bcdfe4423b937fc5c041d5d82",
},
"reason": "Read the breadcrumb trail leading up to this event.",
"toolName": "get_issue_breadcrumbs",
"reason": "Inspect the distributed trace this event belongs to.",
"toolName": "get_trace_details",
"type": "tool_call",
},
],
Expand Down Expand Up @@ -2023,7 +2048,7 @@ describe("structuredContent", () => {
expect(() => getIssueDetailsOutputSchema.parse(payload)).not.toThrow();
});

it("returns the same structured payload outside experimental mode, apart from related issues", async () => {
it("returns the same structured payload outside experimental mode", async () => {
mockLatestEvent();

const result = await getIssueDetails.handler(params, baseContext);
Expand All @@ -2034,15 +2059,8 @@ describe("structuredContent", () => {
experimentalContext,
);

// related issues are experimental only until the Seer load is checked
const { relatedIssues, ...rest } = parsePayload(experimental);
expect(relatedIssues).toBeDefined();
expect(parsePayload(result)).toEqual({
...rest,
suggestedActions: rest.suggestedActions.filter(
(action) => action.toolName !== "find_related_issues",
),
});
expect(parsePayload(result).relatedIssues).toBeDefined();
expect(parsePayload(result)).toEqual(parsePayload(experimental));
expect(
parsePayload(result).suggestedActions.map((action) => action.toolName),
).toContain("render_issue_chart");
Expand Down Expand Up @@ -2112,15 +2130,15 @@ describe("structuredContent", () => {
});
});

it("doesn't look them up outside experimental mode", async () => {
it("looks them up outside experimental mode too", async () => {
mockLatestEvent();
const requests = captureRelatedRequest();

const result = await getIssueDetails.handler(params, baseContext);
const payload = parsePayload(result);

expect(requests).toHaveLength(0);
expect(payload).not.toHaveProperty("relatedIssues");
expect(requests).toHaveLength(1);
expect(payload.relatedIssues?.issues).toHaveLength(2);
});

it("keeps an empty list when nothing is related, without the suggestion", async () => {
Expand Down Expand Up @@ -3022,6 +3040,30 @@ describe("selected event package versions", () => {
"url": "https://sentry-mcp-evals.sentry.io/issues/CLOUDFLARE-MCP-41",
"usersImpacted": 1,
},
"relatedIssues": {
"issues": [
{
"project": "CLOUDFLARE-MCP",
"relations": [
"similar_stacktrace",
"same_trace",
],
"shortId": "CLOUDFLARE-MCP-42",
"status": "resolved",
"title": "Error: Tool list_projects is already registered",
},
{
"project": "web",
"relations": [
"same_trace",
],
"shortId": "WEB-1A2",
"status": "unresolved",
"title": "TypeError: Failed to fetch",
},
],
"unavailableTypes": [],
},
"replays": null,
"seer": null,
"sideQuests": [
Expand All @@ -3037,6 +3079,15 @@ describe("selected event package versions", () => {
},
],
"suggestedActions": [
{
"arguments": {
"issueId": "CLOUDFLARE-MCP-41",
"organizationSlug": "sentry-mcp-evals",
},
"reason": "List every related issue with its similarity score before resolving or ignoring this one.",
"toolName": "find_related_issues",
"type": "tool_call",
},
{
"arguments": {
"issueId": "CLOUDFLARE-MCP-41",
Expand Down
22 changes: 7 additions & 15 deletions packages/mcp-core/src/tools/catalog/get-issue-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,6 @@ export default defineTool({
organizationSlug: orgSlug,
issue,
seerEnabled: isSeerGranted(context),
includeRelatedIssues: context.experimentalMode ?? false,
// same_trace follows the event's trace, so it must be the event shown
eventId,
}),
Expand Down Expand Up @@ -792,8 +791,6 @@ export default defineTool({
organizationSlug: orgSlug,
issue,
seerEnabled: isSeerGranted(context),
// experimental only until the Seer load and rate limits are checked
includeRelatedIssues: context.experimentalMode ?? false,
}),
]);

Expand Down Expand Up @@ -920,22 +917,19 @@ async function maybeFetchCommitters({
* Fetches supplementary data for an issue in parallel: Seer analysis, external links, replays
* and related issues. All calls are non-blocking -- failures are caught so they never
* prevent the primary issue details from being returned. Seer analysis is
* skipped entirely when the `seer` skill is not granted, and related issues unless
* `includeRelatedIssues` is set.
* skipped entirely when the `seer` skill is not granted.
*/
async function fetchIssueEnrichmentData({
apiService,
organizationSlug,
issue,
seerEnabled,
includeRelatedIssues,
eventId,
}: {
apiService: SentryApiService;
organizationSlug: string;
issue: Issue;
seerEnabled: boolean;
includeRelatedIssues: boolean;
/** The event the response shows; related issues come from the latest event when omitted. */
eventId?: string;
}): Promise<{
Expand Down Expand Up @@ -963,14 +957,12 @@ async function fetchIssueEnrichmentData({
dataSource: getReplayDataSource(issue),
})
.catch(() => undefined),
includeRelatedIssues
? maybeFetchRelatedIssues({
apiService,
organizationSlug,
issueId,
eventId,
})
: undefined,
maybeFetchRelatedIssues({
apiService,
organizationSlug,
issueId,
eventId,
}),
]);

return { autofixState, externalIssues, relatedReplayIds, relatedIssues };
Expand Down
33 changes: 33 additions & 0 deletions packages/mcp-core/src/tools/catalog/get-sentry-resource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,30 @@ describe("event package selection", () => {
"url": "https://sentry-mcp-evals.sentry.io/issues/CLOUDFLARE-MCP-41",
"usersImpacted": 1,
},
"relatedIssues": {
"issues": [
{
"project": "CLOUDFLARE-MCP",
"relations": [
"similar_stacktrace",
"same_trace",
],
"shortId": "CLOUDFLARE-MCP-42",
"status": "resolved",
"title": "Error: Tool list_projects is already registered",
},
{
"project": "web",
"relations": [
"same_trace",
],
"shortId": "WEB-1A2",
"status": "unresolved",
"title": "TypeError: Failed to fetch",
},
],
"unavailableTypes": [],
},
"replays": null,
"seer": null,
"sideQuests": [
Expand All @@ -1350,6 +1374,15 @@ describe("event package selection", () => {
},
],
"suggestedActions": [
{
"arguments": {
"issueId": "CLOUDFLARE-MCP-41",
"organizationSlug": "sentry-mcp-evals",
},
"reason": "List every related issue with its similarity score before resolving or ignoring this one.",
"toolName": "find_related_issues",
"type": "tool_call",
},
{
"arguments": {
"issueId": "CLOUDFLARE-MCP-41",
Expand Down
Loading