|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Common Development Commands |
| 6 | + |
| 7 | +### Environment Setup |
| 8 | +- **Node Version Management**: This project requires Node.js 22.16.0 (specified in `.nvmrc`) |
| 9 | + - Always run `nvm use` when switching to this project |
| 10 | + - Use `./setup.sh` for automated environment setup including nvm and dependencies |
| 11 | + - Alternative: manually run `nvm use` followed by `npm ci` |
| 12 | + |
| 13 | +### Development Commands |
| 14 | +- `npm run dev` - Start both client and server in development mode (uses concurrently) |
| 15 | +- `npm run client:dev` - Start only the React client (Vite dev server) |
| 16 | +- `npm run server:dev` - Start only the Express server with tsx watch mode |
| 17 | +- `npm run build` - Build both client and server for production |
| 18 | +- `npm run lint` - Run ESLint across the entire project |
| 19 | +- `npm run preview` - Preview production build of client |
| 20 | + |
| 21 | +### Testing |
| 22 | +- `cd server && npm run test` - Run all tests with Vitest |
| 23 | +- `cd server && npm run test:watch` - Run tests in watch mode |
| 24 | +- `cd server && npm run test:integration` - Run integration tests only |
| 25 | +- `cd server && npm run test:mock` - Run mock/unit tests only |
| 26 | + |
| 27 | +### Data Processing Scripts (Server) |
| 28 | +- `cd server && npm run crawl-servers` - Crawl MCP servers from the main repository |
| 29 | +- `cd server && npm run crawl-servers-postprocess` - Post-process crawled server data |
| 30 | +- `cd server && npm run clean-duplicates` - Remove duplicate entries |
| 31 | +- `cd server && npm run process_categories` - Process and organize category data |
| 32 | +- `cd server && npm run process_locales` - Process internationalization data |
| 33 | +- `cd server && npm run process_githubinfo` - Enrich servers with GitHub metadata |
| 34 | + |
| 35 | +## Architecture Overview |
| 36 | + |
| 37 | +### Project Structure |
| 38 | +This is a **monorepo workspace** with two main packages: |
| 39 | +- **client/**: React frontend (Vite + TypeScript + Tailwind CSS) |
| 40 | +- **server/**: Express.js backend (TypeScript + Node.js) |
| 41 | + |
| 42 | +### Backend Architecture (server/) |
| 43 | + |
| 44 | +#### Core Server Files |
| 45 | +- **server.ts**: Main Express application with route registration |
| 46 | +- **routes/**: API route handlers |
| 47 | + - `mcp.ts`: MCP server-related endpoints |
| 48 | + - `hub.ts`: Hub-specific endpoints |
| 49 | +- **lib/**: Core business logic |
| 50 | + - `mcpServers.ts`: MCP server data management with locale-aware caching |
| 51 | + - `config.ts`: Environment configuration |
| 52 | + - `githubEnrichment.ts`: GitHub API integration for server metadata |
| 53 | + - `llm.ts` & `llmTools.ts`: LLM integration for data processing |
| 54 | + |
| 55 | +#### Data Management |
| 56 | +- **src/data/split/**: Individual JSON files for each MCP server (enables efficient caching) |
| 57 | +- **Caching Strategy**: In-memory cache with TTL (1 hour) and locale-specific storage |
| 58 | +- **Data Processing Pipeline**: Crawling → GitHub enrichment → Localization → Split storage |
| 59 | + |
| 60 | +#### Key Data Structures |
| 61 | +- **McpServer Interface**: Primary server data model with GitHub metadata |
| 62 | +- **Locale Support**: Multi-language support (en, de, es, ja, zh-hans, zh-hant) |
| 63 | +- **Server Types**: Reference Server, Official Integration, Community Server, Framework, Resource |
| 64 | + |
| 65 | +### Frontend Architecture (client/) |
| 66 | + |
| 67 | +#### Core Structure |
| 68 | +- **React Router**: Client-side routing with pages in `src/pages/` |
| 69 | +- **Context API**: `LanguageContext` for internationalization |
| 70 | +- **Component Structure**: Reusable components in `src/components/` |
| 71 | +- **Data Management**: Static imports from `src/data/servers.ts` |
| 72 | + |
| 73 | +#### Key Pages |
| 74 | +- **Home**: Main landing with server discovery |
| 75 | +- **Listing**: Categorized server browsing with filtering |
| 76 | +- **ServerDetails**: Detailed server information (uses hubId routing) |
| 77 | +- **Submit**: Server submission form |
| 78 | + |
| 79 | +### Data Flow |
| 80 | + |
| 81 | +#### Server Data Pipeline |
| 82 | +1. **Crawling**: `mcp_servers_crawler.ts` extracts servers from official MCP repository |
| 83 | +2. **GitHub Enrichment**: `process_githubinfo.ts` adds stars, forks, commits, license info |
| 84 | +3. **Localization**: `process_locales.ts` generates translated versions |
| 85 | +4. **Categorization**: `process_categories.ts` organizes servers by category |
| 86 | +5. **Split Storage**: Individual JSON files for efficient loading |
| 87 | + |
| 88 | +#### API Layer |
| 89 | +- **Locale-aware endpoints**: All server endpoints support locale parameter |
| 90 | +- **Caching**: Server-side caching with automatic TTL refresh |
| 91 | +- **Error Handling**: Graceful fallbacks to default locale |
| 92 | + |
| 93 | +## Development Guidelines |
| 94 | + |
| 95 | +### Working with MCP Server Data |
| 96 | +- Server data is split into individual files under `server/src/data/split/` |
| 97 | +- Always use the caching functions in `mcpServers.ts` rather than direct file access |
| 98 | +- When adding new server data, run the processing pipeline to maintain consistency |
| 99 | +- GitHub enrichment requires valid GitHub API access |
| 100 | + |
| 101 | +### Internationalization |
| 102 | +- Locale files are in `client/src/locale/` and category translations in `category-*.json` |
| 103 | +- Server data supports locale-specific descriptions and content |
| 104 | +- Always test with multiple locales when modifying server data |
| 105 | + |
| 106 | +### Testing Strategy |
| 107 | +- Integration tests verify GitHub API functionality and data processing |
| 108 | +- Mock tests for isolated unit testing |
| 109 | +- Use `vitest` for all server-side testing |
| 110 | + |
| 111 | +### Environment Variables |
| 112 | +- Server requires GitHub API token for enrichment processes |
| 113 | +- Configuration managed through `config.ts` with environment variable support |
| 114 | +- Production deployment uses Docker with external environment files |
| 115 | + |
| 116 | +### Performance Considerations |
| 117 | +- MCP server data uses in-memory caching to avoid file system overhead |
| 118 | +- Individual server files enable partial loading strategies |
| 119 | +- Client uses static imports for core server data to leverage Vite bundling |
0 commit comments