sentry_create_alert_rule
Define custom alert rules for project monitoring by specifying conditions, actions, and frequency. Streamline error tracking and application health management with MCP Sentry para Cursor integration.
Instructions
Create an alert rule for a project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| actions | No | Alert actions | |
| conditions | No | Alert conditions | |
| frequency | No | Check frequency in minutes | |
| name | Yes | Alert rule name | |
| projectSlug | Yes | Project slug/identifier |
Implementation Reference
- src/index.ts:1103-1137 (handler)MCP tool handler that processes input arguments, applies defaults for conditions and actions, calls SentryAPIClient.createAlertRule, and returns confirmation.case "sentry_create_alert_rule": { if (!apiClient) { throw new Error("Sentry API client not initialized. Provide auth token."); } const { projectSlug, name, conditions = [], actions = [], frequency } = args as any; // Default alert rule if not provided const rule = { name, conditions: conditions.length > 0 ? conditions : [ { id: 'sentry.rules.conditions.first_seen_event.FirstSeenEventCondition', } ], actions: actions.length > 0 ? actions : [ { id: 'sentry.rules.actions.notify_event.NotifyEventAction', } ], actionMatch: 'all', frequency: frequency || 30, }; const createdRule = await apiClient.createAlertRule(projectSlug, rule); return { content: [ { type: "text", text: `Alert rule created: ${createdRule.name} for project ${projectSlug}`, }, ], }; }
- src/index.ts:484-514 (schema)Input schema definition for the sentry_create_alert_rule tool, including properties for project, name, conditions, actions, and frequency.{ name: "sentry_create_alert_rule", description: "Create an alert rule for a project", inputSchema: { type: "object", properties: { projectSlug: { type: "string", description: "Project slug/identifier", }, name: { type: "string", description: "Alert rule name", }, conditions: { type: "array", description: "Alert conditions", }, actions: { type: "array", description: "Alert actions", }, frequency: { type: "number", description: "Check frequency in minutes", default: 30, }, }, required: ["projectSlug", "name"], }, },
- src/sentry-api-client.ts:126-131 (helper)Helper method in SentryAPIClient that sends a POST request to the Sentry API endpoint to create the alert rule.async createAlertRule(projectSlug: string, rule: any) { return this.request(`/projects/${this.org}/${projectSlug}/rules/`, { method: 'POST', body: JSON.stringify(rule), }); }
- src/index.ts:484-514 (registration)Tool registration in the listTools response, defining name, description, and schema for discovery.{ name: "sentry_create_alert_rule", description: "Create an alert rule for a project", inputSchema: { type: "object", properties: { projectSlug: { type: "string", description: "Project slug/identifier", }, name: { type: "string", description: "Alert rule name", }, conditions: { type: "array", description: "Alert conditions", }, actions: { type: "array", description: "Alert actions", }, frequency: { type: "number", description: "Check frequency in minutes", default: 30, }, }, required: ["projectSlug", "name"], }, },