Skip to main content
Glama
sentry-investigator

sentry-investigator

Sentry Investigator MCP (Ruby-Focused)

A Model Context Protocol (MCP) server that automatically reads Sentry issues, investigates them by analyzing your Ruby codebase, explains why issues happened, and provides fix suggestions tailored for Ruby applications.

šŸš€ Features

  • šŸ” Sentry Integration: Fetch and analyze issues directly from your Sentry projects

  • šŸ’Ž Ruby-Focused Analysis: Specialized support for Ruby, Rails, and ERB files

  • šŸ“Š Codebase Analysis: Automatically analyze your Ruby code to understand issue context

  • 🧠 Smart Investigation: Combine Sentry data with Ruby code analysis for comprehensive insights

  • šŸ”§ Ruby Fix Suggestions: Get specific, actionable fix recommendations for Ruby errors

  • šŸ“ˆ Impact Analysis: Understand user impact and frequency patterns

  • ⚔ Stack Trace Analysis: Deep dive into Ruby stack traces with code context

Related MCP server: mcp-sentry

šŸ“‹ Prerequisites

  • Node.js 18 or higher

  • A Sentry account with API access

  • Ruby/Rails project (primary focus)

  • Cursor editor (or any MCP-compatible client)

āš™ļø Installation

  1. Clone or download this MCP server:

git clone https://github.com/doraemon0905/sentry-mcp
cd sentry-mcp
  1. Install dependencies:

npm install
  1. Build the project:

npm run build

šŸ”§ Setup

1. Get Sentry API Token

  1. Go to Sentry (https://your_domain.sentry.io) → Settings → Personal Tokens

  2. Create a new token with the following scopes:

    • org:read

    • project:read

    • event:read

    • alerts:read

    • team:read

2. Configure Cursor

Add the MCP server to your Cursor configuration. Edit your MCP settings file:

On macOS/Linux: ~/.cursor/mcp.json
On Windows: %APPDATA%\Cursor\mcp.json

{
  "mcpServers": {
    "sentry-investigator": {
      "command": "node",
      "args": ["/path/to/sentry-mcp/dist/index.js"],
      "env": {
        "SENTRY_AUTH_TOKEN": "your-sentry-auth-token-here",
        "SENTRY_ORGANIZATION": "your-sentry-org-slug",
        "SENTRY_PROJECT": "your-default-project-slug"
      }
    }
  }
}

Required Environment Variables:

  • SENTRY_AUTH_TOKEN: Your Sentry API token

  • SENTRY_ORGANIZATION: Your Sentry organization slug

  • SENTRY_PROJECT: (Optional) Your default project slug

Replace /path/to/sentry-mcp with the actual path to this project.

3. Restart Cursor

Restart Cursor to load the new MCP server.

šŸŽÆ Usage

1. List Recent Issues

Use the get_sentry_issues tool to fetch recent issues:
- project: (optional) Specific project slug
- limit: Number of issues (default: 10, max: 100)
- status: unresolved, resolved, or ignored (default: unresolved)

2. Investigate an Issue

Use the investigate_issue tool with:
- issue_id: The Sentry issue ID
- codebase_path: Path to your Ruby codebase (default: current directory)
- include_fix: Whether to include fix suggestions (default: true)

3. Analyze Stack Traces

Use the analyze_stack_trace tool to analyze any Ruby stack trace:
- stack_trace: The stack trace text
- codebase_path: Path to your Ruby codebase (default: current directory)

šŸ”§ Available Tools

Tool

Description

get_sentry_issues

Fetch recent issues from Sentry

investigate_issue

Full investigation of a specific issue (supports short IDs like "ATS-3YJ")

analyze_stack_trace

Analyze any stack trace with Ruby code context

šŸ“ Example Investigation Report

When you investigate a Ruby issue, you'll get a comprehensive report including:

# šŸ› Issue Investigation Report

**Issue:** NoMethodError: undefined method `name' for nil:NilClass
**ID:** 12345 (PROJ-1AB)
**Status:** unresolved
**Level:** error
**Occurrences:** 45 (12 users affected)
**First Seen:** 2024-01-15 10:30:00
**Last Seen:** 2024-01-20 15:45:00

## šŸ” Stack Trace Analysis

**Parsed Stack Trace:**
1. `get_user_data`
   šŸ“ app/services/user_service.rb:25

### šŸ“„ `app/services/user_service.rb` (Line 25)

```ruby
  23: def get_user_data(user_id)
  24:   user = User.find_by(id: user_id)
→ 25:   user.name # Error occurs here
  26: end

šŸ”§ Function: get_user_data

šŸ’” Issue Analysis

Error Type: NoMethodError Ruby error caused by trying to call a method on a nil object.

Frequency Analysis: Medium frequency (9 occurrences/day) Impact Level: 🟔 Medium (12 users affected)

šŸ”§ Suggested Fixes

NoMethodError Fix

# Add method existence checks
if user.respond_to?(:name)
  user.name
else
  # Handle missing method case
end

# Or use safe navigation
user&.name

šŸ› ļø Development

Project Structure

src/
ā”œā”€ā”€ index.ts              # Main MCP server entry point
ā”œā”€ā”€ services/
│   ā”œā”€ā”€ SentryService.ts      # Sentry API integration
│   ā”œā”€ā”€ CodebaseAnalyzer.ts   # Ruby-focused code analysis utilities  
│   └── IssueInvestigator.ts  # Main investigation logic

Ruby Language Support

The MCP is optimized for Ruby applications and includes:

  • File Types: .rb, .erb, .rake files

  • Stack Trace Parsing: Ruby-specific error format recognition

  • Method Detection: Ruby method definitions (def, self., lambdas, procs)

  • Import Analysis: require, require_relative, include, extend, gem statements

  • Error Types: NoMethodError, NameError, ArgumentError, TypeError, etc.

  • Fix Suggestions: Ruby-specific error handling patterns

Scripts

  • npm run build - Build the TypeScript project

  • npm run dev - Build in watch mode for development

  • npm start - Run the built server

Building from Source

npm install
npm run build

šŸ¤ Contributing

  1. Fork the repository

  2. Create a feature branch

  3. Make your changes

  4. Add tests if applicable

  5. Submit a pull request

šŸ“„ License

MIT License - see LICENSE file for details.

šŸ†˜ Troubleshooting

Common Issues

"Sentry service not configured"

  • Ensure SENTRY_AUTH_TOKEN and SENTRY_ORGANIZATION environment variables are set in your MCP configuration

  • Verify your API token has the correct permissions

"No project specified and no default project configured"

  • Either specify a project in the tool call or set SENTRY_PROJECT environment variable

"Failed to connect to Sentry"

  • Check your API token and organization slug

  • Ensure your network allows HTTPS requests to sentry.io

"File not found in codebase"

  • Verify the codebase_path parameter points to your Ruby project root

  • Some files in stack traces may be from gems or external libraries

Ruby-Specific Notes

  • The analyzer prioritizes Ruby files (.rb, .erb, .rake) over other file types

  • Stack trace parsing is optimized for Ruby error formats

  • Method suggestions focus on Ruby patterns and best practices

  • Excludes common Ruby directories (vendor/, tmp/) from analysis

Available Tools

7 tools
analyze_stack_traceB

Analyze a stack trace and find related code in the codebase

Inputs: stack_trace (required), codebase_path.

create_jira_from_sentryB

Create a Jira ticket directly from a Sentry issue with automatic linking and rich context

Inputs: sentry_issue_id (required), board_id (required), issue_type (required), priority, +3 more.

create_jira_ticketA

Create a Jira ticket from a Sentry issue and link them together

Inputs: board_id (required), summary (required), description (required), issue_type (required), +4 more.

get_issue_typesB

Get available issue types for a Jira project

Inputs: project_key (required).

get_jira_boardsA

Get list of available Jira boards for ticket creation

Inputs: no named parameters.

get_sentry_issuesC

Fetch recent issues from Sentry for investigation

Inputs: project, limit, status.

investigate_issueC

Investigate a specific Sentry issue by analyzing the codebase and providing explanations and fixes

Inputs: issue_id (required), codebase_path, include_fix.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 7 tools

    Disambiguation3/5

    The set has two tools for creating Jira tickets from Sentry issues (create_jira_from_sentry and create_jira_ticket) that are nearly identical in purpose, causing ambiguity. Additionally, analyze_stack_trace and investigate_issue have some overlap in context analysis, though not exact duplicates.

    Naming Consistency3/5

    Most tools follow a verb_noun pattern, but 'create_jira_from_sentry' introduces a preposition, and the two Jira creation tools use different naming structures despite similar functions, leading to inconsistency.

    Tool Count5/5

    With 7 tools covering Sentry issue retrieval, analysis, and Jira ticket creation, the count is well-scoped for the server's purpose without being too sparse or bloated.

    Completeness3/5

    The tools cover the primary workflow of investigating Sentry issues and creating Jira tickets, but there are minor gaps such as missing updates to tickets or listing Jira projects, and redundancy reduces overall completeness.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Integrates Sentry error monitoring with AI-powered analysis to automatically capture frontend JavaScript errors and provide intelligent repair suggestions through multiple AI models including OpenAI, Claude, and Gemini.
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to retrieve and analyze Sentry issues, including error reports, stacktraces, and debugging information from Sentry.io.
      1
      MIT
    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables AI to automatically perform Root Cause Analysis for app issues (e.g., sessions not recording, heatmap empty, replica drift) by querying logs, MongoDB, Shopify, and rendering rrweb replays.
      -