sentry-investigator
Automatically reads Sentry issues, investigates them by analyzing your Ruby codebase, explains why issues happened, and provides fix suggestions.
README
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
š 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
- Clone or download this MCP server:
git clone https://github.com/doraemon0905/sentry-mcp
cd sentry-mcp
- Install dependencies:
npm install
- Build the project:
npm run build
š§ Setup
1. Get Sentry API Token
- Go to Sentry (https://your_domain.sentry.io) ā Settings ā Personal Tokens
- Create a new token with the following scopes:
org:readproject:readevent:readalerts:readteam: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 tokenSENTRY_ORGANIZATION: Your Sentry organization slugSENTRY_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,.rakefiles - Stack Trace Parsing: Ruby-specific error format recognition
- Method Detection: Ruby method definitions (
def,self., lambdas, procs) - Import Analysis:
require,require_relative,include,extend,gemstatements - Error Types:
NoMethodError,NameError,ArgumentError,TypeError, etc. - Fix Suggestions: Ruby-specific error handling patterns
Scripts
npm run build- Build the TypeScript projectnpm run dev- Build in watch mode for developmentnpm start- Run the built server
Building from Source
npm install
npm run build
š¤ Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
š License
MIT License - see LICENSE file for details.
š Troubleshooting
Common Issues
"Sentry service not configured"
- Ensure
SENTRY_AUTH_TOKENandSENTRY_ORGANIZATIONenvironment 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_PROJECTenvironment 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
š Links
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.