Skip to content
Open
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
2 changes: 1 addition & 1 deletion packages/mcp-server-mocks/src/fixtures/issue.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"severity": 0,
"severity_reason": "ml",
"initial_priority": 50,
"title": null
"title": "Error: Tool list_organizations is already registered"
},
"numComments": 0,
"assignedTo": null,
Expand Down
197 changes: 197 additions & 0 deletions packages/mcp-server-mocks/src/fixtures/performance-event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
{
"id": "a1b2c3d4e5f6789012345678901234567",
"groupID": "7890123456",
"eventID": "a1b2c3d4e5f6789012345678901234567",
"projectID": "4509062593708032",
"size": 8432,
"type": "transaction",
"title": "GET /api/users",
"message": "",
"platform": "python",
"datetime": "2025-08-06T18:00:00.000000Z",
"dateCreated": "2025-08-06T18:00:00.000000Z",
"contexts": {
"trace": {
"trace_id": "abcdef1234567890abcdef1234567890",
"span_id": "1234567890abcdef",
"op": "http.server",
"status": "ok",
"exclusive_time": 250.5,
"data": {
"http.request.method": "GET",
"url.path": "/api/users"
}
}
},
"occurrence": {
"id": "occ_123456789",
"projectId": 4509062593708032,
"eventId": "a1b2c3d4e5f6789012345678901234567",
"fingerprint": [
"n_plus_one_db_queries",
"SELECT * FROM users WHERE id = %s"
],
"issueTitle": "N+1 Query: SELECT * FROM users WHERE id = %s",
"subtitle": "Database query repeated 25 times",
"resourceId": null,
"type": 1006,
"detectionTime": 1722963600,
"level": "warning",
"culprit": "SELECT * FROM users WHERE id = %s",
"priority": 50,
"assignee": null,
"evidenceData": {
"transactionName": "/api/users",
"parentSpan": "GET /api/users",
"parentSpanIds": ["parent123"],
"repeatingSpansCompact": "SELECT * FROM users WHERE id = %s",
"repeatingSpansDescription": "SELECT * FROM users WHERE id = %s",
"repeatingSpansCount": 25,
"numberRepeatingSpans": "25",
"offenderSpanIds": [
"span001",
"span002",
"span003",
"span004",
"span005",
"span006",
"span007",
"span008",
"span009",
"span010",
"span011",
"span012",
"span013",
"span014",
"span015",
"span016",
"span017",
"span018",
"span019",
"span020",
"span021",
"span022",
"span023",
"span024",
"span025"
],
"op": "db"
},
"evidenceDisplay": [
{
"name": "Offending Spans",
"value": "SELECT * FROM users WHERE id = %s",
"important": true
},
{
"name": "Repeated",
"value": "25 times",
"important": true
}
]
},
"entries": [
{
"type": "spans",
"data": [
{
"span_id": "parent123",
"trace_id": "abcdef1234567890abcdef1234567890",
"parent_span_id": "1234567890abcdef",
"op": "http.server",
"description": "GET /api/users",
"status": "ok",
"start_timestamp": 1722963600.0,
"timestamp": 1722963600.25,
"data": {
"http.request.method": "GET",
"url.path": "/api/users"
}
},
{
"span_id": "span001",
"trace_id": "abcdef1234567890abcdef1234567890",
"parent_span_id": "parent123",
"op": "db.query",
"description": "SELECT * FROM users WHERE id = 1",
"status": "ok",
"start_timestamp": 1722963600.01,
"timestamp": 1722963600.015,
"data": {
"db.system": "postgresql",
"db.operation": "SELECT"
}
},
{
"span_id": "span002",
"trace_id": "abcdef1234567890abcdef1234567890",
"parent_span_id": "parent123",
"op": "db.query",
"description": "SELECT * FROM users WHERE id = 2",
"status": "ok",
"start_timestamp": 1722963600.02,
"timestamp": 1722963600.025,
"data": {
"db.system": "postgresql",
"db.operation": "SELECT"
}
},
{
"span_id": "span003",
"trace_id": "abcdef1234567890abcdef1234567890",
"parent_span_id": "parent123",
"op": "db.query",
"description": "SELECT * FROM users WHERE id = 3",
"status": "ok",
"start_timestamp": 1722963600.03,
"timestamp": 1722963600.035,
"data": {
"db.system": "postgresql",
"db.operation": "SELECT"
}
},
{
"span_id": "span004",
"trace_id": "abcdef1234567890abcdef1234567890",
"parent_span_id": "parent123",
"op": "db.query",
"description": "SELECT * FROM users WHERE id = 4",
"status": "ok",
"start_timestamp": 1722963600.04,
"timestamp": 1722963600.045,
"data": {
"db.system": "postgresql",
"db.operation": "SELECT"
}
},
{
"span_id": "span005",
"trace_id": "abcdef1234567890abcdef1234567890",
"parent_span_id": "parent123",
"op": "db.query",
"description": "SELECT * FROM users WHERE id = 5",
"status": "ok",
"start_timestamp": 1722963600.05,
"timestamp": 1722963600.055,
"data": {
"db.system": "postgresql",
"db.operation": "SELECT"
}
}
]
},
{
"type": "request",
"data": {
"method": "GET",
"url": "https://api.example.com/api/users",
"query": [],
"headers": [["Accept", "application/json"], ["Host", "api.example.com"]]
}
}
],
"tags": [
{ "key": "environment", "value": "production" },
{ "key": "transaction", "value": "/api/users" }
]
}
20 changes: 20 additions & 0 deletions packages/mcp-server-mocks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import autofixStateFixture from "./fixtures/autofix-state.json" with {
};
import issueFixture from "./fixtures/issue.json" with { type: "json" };
import eventsFixture from "./fixtures/event.json" with { type: "json" };
import performanceEventFixture from "./fixtures/performance-event.json" with {
type: "json",
};
import eventAttachmentsFixture from "./fixtures/event-attachments.json" with {
type: "json",
};
Expand Down Expand Up @@ -809,6 +812,23 @@ export const restHandlers = buildHandlers([
fetch: () => HttpResponse.json(eventsFixture),
},

// Performance issue with N+1 query detection
{
method: "get",
path: "/api/0/organizations/sentry-mcp-evals/issues/PERF-N1-001/events/latest/",
fetch: () => HttpResponse.json(performanceEventFixture),
},
{
method: "get",
path: "/api/0/organizations/sentry-mcp-evals/issues/7890123456/events/latest/",
fetch: () => HttpResponse.json(performanceEventFixture),
},
{
method: "get",
path: "/api/0/organizations/sentry-mcp-evals/issues/PERF-N1-001/events/a1b2c3d4e5f6789012345678901234567/",
fetch: () => HttpResponse.json(performanceEventFixture),
},

{
method: "get",
path: "/api/0/organizations/sentry-mcp-evals/releases/",
Expand Down
40 changes: 36 additions & 4 deletions packages/mcp-server/src/api-client/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ export const IssueSchema = z.object({
culprit: z.string(),
type: z.union([z.literal("error"), z.literal("transaction"), z.unknown()]),
assignedTo: AssignedToSchema.optional(),
issueType: z.string().optional(),
issueCategory: z.string().optional(),
metadata: z
.object({
title: z.string().optional(),
location: z.string().optional(),
value: z.string().optional(),
})
.optional(),
});

export const IssueListSchema = z.array(IssueSchema);
Expand Down Expand Up @@ -371,10 +380,33 @@ export const TransactionEventSchema = BaseEventSchema.omit({
type: true,
}).extend({
type: z.literal("transaction"),
occurrence: z.object({
issueTitle: z.string(),
culprit: z.string().nullable(),
}),
occurrence: z
.object({
id: z.string().optional(),
projectId: z.number().optional(),
eventId: z.string().optional(),
fingerprint: z.array(z.string()).optional(),
issueTitle: z.string(),
subtitle: z.string().optional(),
resourceId: z.string().nullable().optional(),
evidenceData: z.record(z.string(), z.any()).optional(),
evidenceDisplay: z
.array(
z.object({
name: z.string(),
value: z.string(),
important: z.boolean().optional(),
}),
)
.optional(),
type: z.number().optional(),
detectionTime: z.number().optional(),
level: z.string().optional(),
culprit: z.string().nullable(),
priority: z.number().optional(),
assignee: z.string().nullable().optional(),
})
.optional(),
});

export const UnknownEventSchema = BaseEventSchema.omit({
Expand Down
Loading
Loading