get-top-items
Retrieve the most frequent or critical error items from a Rollbar project to identify and prioritize issues for debugging and monitoring.
Instructions
Get list of top items in the Rollbar project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| environment | No | Environment name (default: production) | production |
| project | No | Project name (optional when only one project is configured) |
Implementation Reference
- src/tools/get-top-items.ts:19-43 (handler)The handler function that executes the "get-top-items" tool logic by querying the Rollbar API.
async ({ environment, project }) => { const { token, apiBase } = resolveProject(project); const reportUrl = `${apiBase}/reports/top_active_items?hours=24&environments=${environment}&sort=occurrences`; const reportResponse = await makeRollbarRequest< RollbarApiResponse<RollbarTopItemResponse> >(reportUrl, "get-top-items", token); if (reportResponse.err !== 0) { const errorMessage = reportResponse.message || `Unknown error (code: ${reportResponse.err})`; throw new Error(`Rollbar API returned error: ${errorMessage}`); } const topItems = reportResponse.result; return { content: [ { type: "text", text: JSON.stringify(topItems), }, ], }; }, - src/tools/get-top-items.ts:8-45 (registration)The registration function for the "get-top-items" tool.
export function registerGetTopItemsTool(server: McpServer) { server.tool( "get-top-items", "Get list of top items in the Rollbar project", { environment: z.coerce .string() .default("production") .describe("Environment name (default: production)"), project: buildProjectParam(), }, async ({ environment, project }) => { const { token, apiBase } = resolveProject(project); const reportUrl = `${apiBase}/reports/top_active_items?hours=24&environments=${environment}&sort=occurrences`; const reportResponse = await makeRollbarRequest< RollbarApiResponse<RollbarTopItemResponse> >(reportUrl, "get-top-items", token); if (reportResponse.err !== 0) { const errorMessage = reportResponse.message || `Unknown error (code: ${reportResponse.err})`; throw new Error(`Rollbar API returned error: ${errorMessage}`); } const topItems = reportResponse.result; return { content: [ { type: "text", text: JSON.stringify(topItems), }, ], }; }, ); }