sentry_capture_exception
Capture and send application exceptions to Sentry for error monitoring and debugging purposes.
Instructions
Capture and send an exception to Sentry
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| error | Yes | Error message or description | |
| level | No | Severity level of the error | error |
| tags | No | Key-value pairs to tag the error | |
| context | No | Additional context data | |
| user | No | User information |
Implementation Reference
- src/index.ts:721-758 (handler)The handler for the 'sentry_capture_exception' tool. It extracts parameters, creates an Error object if needed, sets scope with level, tags, context, and user, then calls Sentry.captureException.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}`, }, ], }; }
- src/index.ts:96-134 (schema)The input schema and metadata for the 'sentry_capture_exception' tool, defining parameters like error, level, tags, context, and user.{ 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"], }, },
- src/index.ts:694-703 (helper)Helper function to map string severity levels to Sentry SeverityLevel enum values, used in the handler.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"; }