get_single_event
Retrieve detailed information about a Sentry issue event by providing the event URL or ID, optimizing output size with mode settings for efficient processing.
Instructions
get issue event by inputting sentry issue event url or sentry issue event id
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | mode for output, it can be undefined, it used to control LLM token usage | tiny |
| organization_id_or_slug | No | sentry organization id or slug, it can be undefined | |
| project_id_or_slug | No | sentry project name or slug, it can be undefined | |
| url_or_id | Yes | sentry issue event url or sentry issue event id |
Implementation Reference
- src/index.ts:48-93 (handler)The asynchronous handler function for the 'get_single_event' tool. It extracts the event ID from the input URL or ID, fetches the event data using fetchSentryEvent, and returns a formatted JSON response based on the mode.async ({ url_or_id, organization_id_or_slug, project_id_or_slug, mode }) => { let EVENT_ID = ""; if (url_or_id.includes("http") || url_or_id.includes("https")) { EVENT_ID = url_or_id.match(/events\/([a-f0-9]+)/)?.[1] || ""; } else { EVENT_ID = url_or_id; } if (!EVENT_ID) { return { content: [ { type: "text", text: "Invalid Event ID", }, ], }; } const eventEventData = await fetchSentryEvent<{ entries: any[]; }>(EVENT_ID, organization_id_or_slug, project_id_or_slug); if (!eventEventData) { return { content: [ { type: "text", text: "Failed to Get Event", }, ], }; } return { content: [ { type: "text", text: JSON.stringify( mode === "tiny" ? eventEventData.entries : eventEventData ), }, ], }; }
- src/index.ts:26-47 (schema)The input schema for the 'get_single_event' tool defined using Zod, including parameters for event URL/ID, organization, project, and output mode.{ url_or_id: z .string() .describe("sentry issue event url or sentry issue event id"), organization_id_or_slug: z .string() .optional() .default(process.env.SENTRY_ORG as string) .describe("sentry organization id or slug, it can be undefined"), project_id_or_slug: z .string() .optional() .default(process.env.SENTRY_PROJ as string) .describe("sentry project name or slug, it can be undefined"), mode: z .enum(["tiny", "huge"]) .optional() .default("tiny") .describe( "mode for output, it can be undefined, it used to control LLM token usage" ), },
- src/index.ts:23-94 (registration)The registration of the 'get_single_event' tool using McpServer's tool method, specifying name, description, input schema, and handler function.server.tool( "get_single_event", "get issue event by inputting sentry issue event url or sentry issue event id", { url_or_id: z .string() .describe("sentry issue event url or sentry issue event id"), organization_id_or_slug: z .string() .optional() .default(process.env.SENTRY_ORG as string) .describe("sentry organization id or slug, it can be undefined"), project_id_or_slug: z .string() .optional() .default(process.env.SENTRY_PROJ as string) .describe("sentry project name or slug, it can be undefined"), mode: z .enum(["tiny", "huge"]) .optional() .default("tiny") .describe( "mode for output, it can be undefined, it used to control LLM token usage" ), }, async ({ url_or_id, organization_id_or_slug, project_id_or_slug, mode }) => { let EVENT_ID = ""; if (url_or_id.includes("http") || url_or_id.includes("https")) { EVENT_ID = url_or_id.match(/events\/([a-f0-9]+)/)?.[1] || ""; } else { EVENT_ID = url_or_id; } if (!EVENT_ID) { return { content: [ { type: "text", text: "Invalid Event ID", }, ], }; } const eventEventData = await fetchSentryEvent<{ entries: any[]; }>(EVENT_ID, organization_id_or_slug, project_id_or_slug); if (!eventEventData) { return { content: [ { type: "text", text: "Failed to Get Event", }, ], }; } return { content: [ { type: "text", text: JSON.stringify( mode === "tiny" ? eventEventData.entries : eventEventData ), }, ], }; } );
- src/fetcher.ts:1-26 (helper)The fetchSentryEvent helper function that performs the HTTP GET request to the Sentry API to retrieve a single event by its ID, handling errors and returning the parsed JSON or null./** get sentry event by <ID> */ export async function fetchSentryEvent<T>( eventId: string, organization_id_or_slug: string, project_id_or_slug: string ): Promise<T | null> { try { const issueRes = await fetch( `https://${process.env.SENTRY_HOST}/api/0/projects/${organization_id_or_slug}/${project_id_or_slug}/events/${eventId}/`, { method: "GET", headers: { Authorization: `Bearer ${process.env.SENTRY_USER_TOKEN}`, }, } ); if (!issueRes.ok) { throw new Error(`HTTP error! status: ${issueRes.status}`); } return (await issueRes.json()) as T; } catch (error) { console.error("Error making request:", error); return null; } }