Skip to main content
Glama

sentry_capture_exception

Capture and log exceptions with detailed context, error severity, and user information for effective monitoring and debugging in applications.

Instructions

Capture and send an exception to Sentry

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextNoAdditional context data
errorYesError message or description
levelNoSeverity level of the errorerror
tagsNoKey-value pairs to tag the error
userNoUser information

Implementation Reference

  • The main handler for the 'sentry_capture_exception' tool. It processes input arguments, creates an Error object if necessary, configures a Sentry scope with level, tags, context, and user data, and captures the exception using Sentry.captureException. Returns a confirmation message.
    case "sentry_capture_exception": { const { error, level = "error", tags, context, user } = args as any; // Create an Error object if string provided const errorObj = error instanceof Error ? error : new Error(error); // Create a new scope for this specific error Sentry.withScope((scope) => { scope.setLevel(mapSeverityLevel(level)); if (tags) { Object.entries(tags).forEach(([key, value]) => { scope.setTag(key, value as string); }); } if (context) { Object.entries(context).forEach(([key, value]) => { scope.setContext(key, value as any); }); } if (user) { scope.setUser(user); } Sentry.captureException(errorObj); }); return { content: [ { type: "text", text: `Exception captured: ${error}`, }, ], }; }
  • Input schema definition for the 'sentry_capture_exception' tool as part of tool registration in ListToolsRequestSchema handler, specifying required 'error' and optional 'level', 'tags', 'context', 'user' properties.
    { name: "sentry_capture_exception", description: "Capture and send an exception to Sentry", inputSchema: { type: "object", properties: { error: { type: "string", description: "Error message or description", }, level: { type: "string", enum: ["fatal", "error", "warning", "info", "debug"], description: "Severity level of the error", default: "error", }, tags: { type: "object", description: "Key-value pairs to tag the error", additionalProperties: { type: "string" }, }, context: { type: "object", description: "Additional context data", additionalProperties: true, }, user: { type: "object", description: "User information", properties: { id: { type: "string" }, email: { type: "string" }, username: { type: "string" }, }, }, }, required: ["error"], }, },
  • Helper function that maps input string severity levels to Sentry's SeverityLevel enum, used by the sentry_capture_exception handler to set the exception level.
    function mapSeverityLevel(level: string): Sentry.SeverityLevel { const severityMap: Record<string, Sentry.SeverityLevel> = { fatal: "fatal", error: "error", warning: "warning", info: "info", debug: "debug", }; return severityMap[level] || "error"; }

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/diegofornalha/sentry-mcp-cursor'

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