Skip to main content
Glama
rollbar

Rollbar MCP Server

Official
by rollbar

get-item-details

Retrieve detailed information about specific error items in Rollbar for troubleshooting and monitoring purposes.

Instructions

Get item details for a Rollbar item

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
counterYesRollbar item counter
max_tokensNoMaximum tokens for occurrence data in response (default: 20000). Occurrence response will be truncated if it exceeds this limit.
projectNoProject name (optional when only one project is configured)

Implementation Reference

  • The async handler function for the get-item-details tool, which fetches item details from the Rollbar API using a counter and occurrence ID, processes the response, and truncates the data.
    async ({ counter, max_tokens, project }) => {
      const { token, apiBase } = resolveProject(project);
      // Redirects are followed, so we get an item response from the counter request
      const counterUrl = `${apiBase}/item_by_counter/${counter}`;
      const itemResponse = await makeRollbarRequest<
        RollbarApiResponse<RollbarItemResponse>
      >(counterUrl, "get-item-details", token);
    
      if (itemResponse.err !== 0) {
        const errorMessage =
          itemResponse.message || `Unknown error (code: ${itemResponse.err})`;
        throw new Error(`Rollbar API returned error: ${errorMessage}`);
      }
    
      const item = itemResponse.result;
    
      const occurrenceUrl = `${apiBase}/instance/${item.last_occurrence_id}`;
      const occurrenceResponse = await makeRollbarRequest<
        RollbarApiResponse<RollbarOccurrenceResponse>
      >(occurrenceUrl, "get-item-details", token);
    
      if (occurrenceResponse.err !== 0) {
        // We got the item but failed to get occurrence. Return just the item data.
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(item),
            },
          ],
        };
      }
    
      const occurrence = occurrenceResponse.result;
    
      // Remove the metadata section from occurrence.data
      if (occurrence.data && occurrence.data.metadata) {
        delete occurrence.data.metadata;
      }
    
      // Combine item and occurrence data
      const responseData = {
        ...item,
        occurrence: truncateOccurrence(occurrence, max_tokens),
      };
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(responseData),
          },
        ],
      };
    },
  • The Zod schema definition for the get-item-details tool inputs (counter, max_tokens, project).
    {
      counter: z.number().int().describe("Rollbar item counter"),
      max_tokens: z
        .number()
        .int()
        .optional()
        .default(20000)
        .describe(
          "Maximum tokens for occurrence data in response (default: 20000). Occurrence response will be truncated if it exceeds this limit.",
        ),
      project: buildProjectParam(),
    },
  • The registration function that defines the get-item-details tool within the MCP server.
    export function registerGetItemDetailsTool(server: McpServer) {
      server.tool(
        "get-item-details",
        "Get item details for a Rollbar item",
        {
          counter: z.number().int().describe("Rollbar item counter"),
          max_tokens: z
            .number()
            .int()
            .optional()
            .default(20000)
            .describe(
              "Maximum tokens for occurrence data in response (default: 20000). Occurrence response will be truncated if it exceeds this limit.",
            ),
          project: buildProjectParam(),
        },
        async ({ counter, max_tokens, project }) => {
          const { token, apiBase } = resolveProject(project);
          // Redirects are followed, so we get an item response from the counter request
          const counterUrl = `${apiBase}/item_by_counter/${counter}`;
          const itemResponse = await makeRollbarRequest<
            RollbarApiResponse<RollbarItemResponse>
          >(counterUrl, "get-item-details", token);
    
          if (itemResponse.err !== 0) {
            const errorMessage =
              itemResponse.message || `Unknown error (code: ${itemResponse.err})`;
            throw new Error(`Rollbar API returned error: ${errorMessage}`);
          }
    
          const item = itemResponse.result;
    
          const occurrenceUrl = `${apiBase}/instance/${item.last_occurrence_id}`;
          const occurrenceResponse = await makeRollbarRequest<
            RollbarApiResponse<RollbarOccurrenceResponse>
          >(occurrenceUrl, "get-item-details", token);
    
          if (occurrenceResponse.err !== 0) {
            // We got the item but failed to get occurrence. Return just the item data.
            return {
              content: [
                {
                  type: "text",
                  text: JSON.stringify(item),
                },
              ],
            };
          }
    
          const occurrence = occurrenceResponse.result;
    
          // Remove the metadata section from occurrence.data
          if (occurrence.data && occurrence.data.metadata) {
            delete occurrence.data.metadata;
          }
    
          // Combine item and occurrence data
          const responseData = {
            ...item,
            occurrence: truncateOccurrence(occurrence, max_tokens),
          };
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(responseData),
              },
            ],
          };
        },
      );
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rollbar/rollbar-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server