get_project_events
Retrieve issue events from Sentry projects using organization and project identifiers. Control output format to manage token usage effectively.
Instructions
get issue events by inputting sentry organization id or slug and sentry project name or slug
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| 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 | |
| mode | No | mode for output, it can be undefined, it used to control LLM token usage | tiny |
Implementation Reference
- src/index.ts:119-151 (handler)The MCP tool handler function for 'get_project_events'. It fetches events using the helper fetchSentryEvents, processes the output based on the 'mode' parameter ('tiny' summarizes to id/title/dateCreated, 'huge' full data), handles errors, and returns MCP-formatted content.async ({ organization_id_or_slug, project_id_or_slug, mode }) => { const eventsData = await fetchSentryEvents< { id: string; title: string; dateCreated: string }[] >(organization_id_or_slug, project_id_or_slug); if (!eventsData) { return { content: [ { type: "text", text: "Failed to Get Issue", }, ], }; } return { content: [ { type: "text", text: JSON.stringify( mode === "tiny" ? eventsData.map(({ id, title, dateCreated }) => ({ id, title, dateCreated, })) : eventsData ), }, ], }; }
- src/index.ts:100-118 (schema)Input schema for the 'get_project_events' tool using Zod, defining optional organization/project slugs (defaulting to env vars) and mode enum.{ 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:97-152 (registration)Registration of the 'get_project_events' tool on the MCP server using server.tool(), including description, input schema, and execution handler.server.tool( "get_project_events", "get issue events by inputting sentry organization id or slug and sentry project name or slug", { 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 ({ organization_id_or_slug, project_id_or_slug, mode }) => { const eventsData = await fetchSentryEvents< { id: string; title: string; dateCreated: string }[] >(organization_id_or_slug, project_id_or_slug); if (!eventsData) { return { content: [ { type: "text", text: "Failed to Get Issue", }, ], }; } return { content: [ { type: "text", text: JSON.stringify( mode === "tiny" ? eventsData.map(({ id, title, dateCreated }) => ({ id, title, dateCreated, })) : eventsData ), }, ], }; } );
- src/fetcher.ts:28-52 (helper)Supporting utility function fetchSentryEvents that makes the API call to retrieve Sentry project events, used by the tool handler./** get sentry events */ export async function fetchSentryEvents<T>( 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/`, { 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; } }