|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +## 🔴 CRITICAL Requirements |
| 4 | + |
| 5 | +**MANDATORY before ANY code:** |
| 6 | +1. TypeScript: NEVER use `any`. Use `unknown` or proper types |
| 7 | +2. Security: NO API keys in logs. NO vulnerabilities |
| 8 | +3. Validation: `pnpm run tsc && pnpm run lint && pnpm run test` |
| 9 | +4. Tools limit: ≤20 (hard limit: 25) |
| 10 | + |
| 11 | +**MANDATORY reads:** |
| 12 | +- Start here: CLAUDE.md — Contributor doc map |
| 13 | +- Tools → @docs/adding-tools.mdc |
| 14 | +- Prompts → @docs/adding-prompts.mdc |
| 15 | +- Resources → @docs/adding-resources.mdc |
| 16 | +- Testing → @docs/testing.mdc |
| 17 | +- PRs → @docs/pr-management.mdc |
| 18 | + |
| 19 | +## 🟡 MANDATORY Workflow |
| 20 | + |
| 21 | +```bash |
| 22 | +# BEFORE coding (parallel execution) |
| 23 | +cat docs/[component].mdc & ls -la neighboring-files & git status |
| 24 | + |
| 25 | +# AFTER coding (sequential - fail fast) |
| 26 | +pnpm run tsc && pnpm run lint && pnpm run test # ALL must pass |
| 27 | +``` |
| 28 | + |
| 29 | +## Repository Map |
| 30 | + |
| 31 | +``` |
| 32 | +sentry-mcp/ |
| 33 | +├── packages/ |
| 34 | +│ ├── mcp-server/ # Main MCP server |
| 35 | +│ │ ├── src/ |
| 36 | +│ │ │ ├── tools/ # 19 tool modules |
| 37 | +│ │ │ ├── prompts.ts # MCP prompts |
| 38 | +│ │ │ ├── resources.ts # MCP resources |
| 39 | +│ │ │ ├── server.ts # MCP protocol |
| 40 | +│ │ │ ├── api-client/ # Sentry API |
| 41 | +│ │ │ └── internal/ # Shared utils |
| 42 | +│ │ └── scripts/ # Build scripts |
| 43 | +│ ├── mcp-cloudflare/ # Web app |
| 44 | +│ ├── mcp-server-evals/ # AI tests |
| 45 | +│ ├── mcp-server-mocks/ # MSW mocks |
| 46 | +│ └── mcp-test-client/ # Test client |
| 47 | +└── docs/ # All docs |
| 48 | +``` |
| 49 | + |
| 50 | +## AI-Powered Search Tools |
| 51 | + |
| 52 | +**search_events** (`packages/mcp-server/src/tools/search-events/`): |
| 53 | +- Natural language → DiscoverQL queries |
| 54 | +- GPT-4o agent with structured outputs |
| 55 | +- Tools: `datasetAttributes`, `otelSemantics`, `whoami` |
| 56 | +- Requires: `OPENAI_API_KEY` |
| 57 | + |
| 58 | +**search_issues** (`packages/mcp-server/src/tools/search-issues/`): |
| 59 | +- Natural language → issue search syntax |
| 60 | +- GPT-4o agent with structured outputs |
| 61 | +- Tools: `issueFields`, `whoami` |
| 62 | +- Requires: `OPENAI_API_KEY` |
| 63 | + |
| 64 | +## 🟢 Key Commands |
| 65 | + |
| 66 | +```bash |
| 67 | +# Development |
| 68 | +pnpm run dev # Start development |
| 69 | +pnpm run build # Build all packages |
| 70 | +pnpm run generate-otel-namespaces # Update OpenTelemetry docs |
| 71 | + |
| 72 | +# Quality checks (combine for speed) |
| 73 | +pnpm run tsc && pnpm run lint && pnpm run test |
| 74 | + |
| 75 | +# Common workflows |
| 76 | +pnpm run build && pnpm run test # Before PR |
| 77 | +grep -r "TODO\|FIXME" src/ # Find tech debt |
| 78 | +``` |
| 79 | + |
| 80 | +## Quick Reference |
| 81 | + |
| 82 | +**Defaults:** |
| 83 | +- Organization: `sentry` |
| 84 | +- Project: `mcp-server` |
| 85 | +- Transport: stdio |
| 86 | +- Auth: access tokens (NOT OAuth) |
| 87 | + |
| 88 | +**Doc Index:** |
| 89 | + |
| 90 | +- Core Guidelines |
| 91 | + - @docs/coding-guidelines.mdc — Code standards and patterns |
| 92 | + - @docs/common-patterns.mdc — Reusable patterns and conventions |
| 93 | + - @docs/quality-checks.mdc — Required checks before changes |
| 94 | + - @docs/error-handling.mdc — Error handling patterns |
| 95 | + |
| 96 | +- API and Tools |
| 97 | + - @docs/adding-tools.mdc — Add new MCP tools |
| 98 | + - @docs/adding-prompts.mdc — Add prompts |
| 99 | + - @docs/adding-resources.mdc — Add resources |
| 100 | + - @docs/api-patterns.mdc — Sentry API usage |
| 101 | + - @docs/search-events-api-patterns.md — search_events specifics |
| 102 | + |
| 103 | +- Infrastructure and Operations |
| 104 | + - @docs/architecture.mdc — System design |
| 105 | + - @docs/deployment.mdc — Deploy (Cloudflare) |
| 106 | + - @docs/monitoring.mdc — Monitoring/telemetry |
| 107 | + - @docs/security.mdc — Security and authentication |
| 108 | + - @docs/cursor.mdc — Cursor IDE integration |
| 109 | + |
| 110 | +- LLM-Specific |
| 111 | + - @docs/llms/documentation-style-guide.mdc — How to write LLM docs |
| 112 | + - @docs/llms/document-scopes.mdc — Doc scopes and purposes |
| 113 | + |
| 114 | +## Rules |
| 115 | + |
| 116 | +1. **Code**: Follow existing patterns. Check adjacent files |
| 117 | +2. **Errors**: Try/catch all async. Log: `console.error('[ERROR]', error.message, error.stack)` |
| 118 | + - Sentry API 429: Retry with exponential backoff |
| 119 | + - Sentry API 401/403: Check token permissions |
| 120 | +3. **Docs**: Update when changing functionality |
| 121 | +4. **PR**: Follow `docs/pr-management.mdc` for commit/PR guidelines (includes AI attribution) |
| 122 | +5. **Tasks**: Use TodoWrite for 3+ steps. Batch tool calls when possible |
| 123 | + |
| 124 | +--- |
| 125 | +*Optimized for Codex CLI (OpenAI) and Claude Code* |
0 commit comments