# CLAUDE.md
## π΄ CRITICAL Requirements
**MANDATORY before ANY code:**
1. TypeScript: NEVER use `any`. Use `unknown` or proper types
2. Security: NO API keys in logs. NO vulnerabilities
3. Validation: `pnpm run tsc && pnpm run lint && pnpm run test`
4. Tools limit: β€20 (hard limit: 25)
**MANDATORY reads:**
- Start here: CLAUDE.md β Contributor doc map
- Tools β @docs/adding-tools.mdc
- Prompts β @docs/adding-prompts.mdc
- Resources β @docs/adding-resources.mdc
- Testing β @docs/testing.mdc
- PRs β @docs/pr-management.mdc
## π‘ MANDATORY Workflow
```bash
# BEFORE coding (parallel execution)
cat docs/[component].mdc & ls -la neighboring-files & git status
# AFTER coding (sequential - fail fast)
pnpm run tsc && pnpm run lint && pnpm run test # ALL must pass
```
## Repository Map
```
sentry-mcp/
βββ packages/
β βββ mcp-server/ # Main MCP server
β β βββ src/
β β β βββ tools/ # 19 tool modules
β β β βββ prompts.ts # MCP prompts
β β β βββ resources.ts # MCP resources
β β β βββ server.ts # MCP protocol
β β β βββ api-client/ # Sentry API
β β β βββ internal/ # Shared utils
β β βββ scripts/ # Build scripts
β βββ mcp-cloudflare/ # Web app
β βββ mcp-server-evals/ # AI tests
β βββ mcp-server-mocks/ # MSW mocks
β βββ mcp-test-client/ # Test client
βββ docs/ # All docs
```
## AI-Powered Search Tools
**search_events** (`packages/mcp-server/src/tools/search-events/`):
- Natural language β DiscoverQL queries
- GPT-4o agent with structured outputs
- Tools: `datasetAttributes`, `otelSemantics`, `whoami`
- Requires: `OPENAI_API_KEY`
**search_issues** (`packages/mcp-server/src/tools/search-issues/`):
- Natural language β issue search syntax
- GPT-4o agent with structured outputs
- Tools: `issueFields`, `whoami`
- Requires: `OPENAI_API_KEY`
## π’ Key Commands
```bash
# Development
pnpm run dev # Start development
pnpm run build # Build all packages
pnpm run generate-otel-namespaces # Update OpenTelemetry docs
# Quality checks (combine for speed)
pnpm run tsc && pnpm run lint && pnpm run test
# Common workflows
pnpm run build && pnpm run test # Before PR
grep -r "TODO\|FIXME" src/ # Find tech debt
```
## Quick Reference
**Defaults:**
- Organization: `sentry`
- Project: `mcp-server`
- Transport: stdio
- Auth: access tokens (NOT OAuth)
**Doc Index:**
- Core Guidelines
- @docs/coding-guidelines.mdc β Code standards and patterns
- @docs/common-patterns.mdc β Reusable patterns and conventions
- @docs/quality-checks.mdc β Required checks before changes
- @docs/error-handling.mdc β Error handling patterns
- API and Tools
- @docs/adding-tools.mdc β Add new MCP tools
- @docs/adding-prompts.mdc β Add prompts
- @docs/adding-resources.mdc β Add resources
- @docs/api-patterns.mdc β Sentry API usage
- @docs/search-events-api-patterns.md β search_events specifics
- Infrastructure and Operations
- @docs/architecture.mdc β System design
- @docs/deployment.mdc β Deploy (Cloudflare)
- @docs/monitoring.mdc β Monitoring/telemetry
- @docs/security.mdc β Security and authentication
- @docs/cursor.mdc β Cursor IDE integration
- LLM-Specific
- @docs/llms/documentation-style-guide.mdc β How to write LLM docs
- @docs/llms/document-scopes.mdc β Doc scopes and purposes
## Rules
1. **Code**: Follow existing patterns. Check adjacent files
2. **Errors**: Try/catch all async. Log: `console.error('[ERROR]', error.message, error.stack)`
- Sentry API 429: Retry with exponential backoff
- Sentry API 401/403: Check token permissions
3. **Docs**: Update when changing functionality
4. **PR**: Follow `docs/pr-management.mdc` for commit/PR guidelines (includes AI attribution)
5. **Tasks**: Use TodoWrite for 3+ steps. Batch tool calls when possible
---
*Optimized for Codex CLI (OpenAI) and Claude Code*