|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Essential Development Commands |
| 6 | + |
| 7 | +### Testing and Linting |
| 8 | +```bash |
| 9 | +pytest tests/ # Run all tests |
| 10 | +pytest tests/test_specific.py # Run specific test file |
| 11 | +ruff check # Run linting |
| 12 | +ruff check --fix # Auto-fix linting issues |
| 13 | +``` |
| 14 | + |
| 15 | +### Development CLI Testing |
| 16 | +```bash |
| 17 | +./test_cli.py --help # Test CLI without installation |
| 18 | +./test_cli.py <command> # Run any CLI command in development |
| 19 | +``` |
| 20 | + |
| 21 | +### Environment Setup |
| 22 | +```bash |
| 23 | +uv venv --seed # Create virtual environment |
| 24 | +source .venv/bin/activate # Activate environment (Unix/Mac) |
| 25 | +uv pip install -e . # Install in development mode |
| 26 | +``` |
| 27 | + |
| 28 | +### Version Management |
| 29 | +```bash |
| 30 | +./bump_version.sh 1.2.3 # Bump version to 1.2.3 |
| 31 | +git push && git push --tags # Push version changes |
| 32 | +``` |
| 33 | + |
| 34 | +### Website Development |
| 35 | +```bash |
| 36 | +./dev.sh # Start Jekyll development server with file watching |
| 37 | +``` |
| 38 | + |
| 39 | +## Architecture Overview |
| 40 | + |
| 41 | +MCPM is a Python CLI tool for managing Model Context Protocol (MCP) servers across different AI clients. The architecture consists of several key components: |
| 42 | + |
| 43 | +### Core Architecture |
| 44 | + |
| 45 | +**Client Management System**: The `src/mcpm/clients/` directory contains the abstraction layer for different MCP clients (Claude Desktop, Cursor, Windsurf, etc.). Each client has its own manager that handles configuration file formats and locations. |
| 46 | + |
| 47 | +**Profile System**: MCPM supports grouping server configurations into named profiles (`src/mcpm/profile/`). This allows users to switch between different sets of MCP servers easily. |
| 48 | + |
| 49 | +**Router Component**: The `src/mcpm/router/` module implements a sophisticated HTTP router that aggregates multiple MCP servers behind a single endpoint. Key features: |
| 50 | +- Maintains persistent connections to MCP servers |
| 51 | +- Enables session sharing between multiple clients |
| 52 | +- Provides namespacing to prevent conflicts |
| 53 | +- Supports real-time configuration changes |
| 54 | + |
| 55 | +**Registry Integration**: MCPM includes an internal registry (`mcp-registry/`) with curated MCP servers. The registry data is processed by Python scripts in `scripts/` to generate API endpoints. |
| 56 | + |
| 57 | +**Monitor System**: The `src/mcpm/monitor/` directory contains access monitoring capabilities using DuckDB for local analytics. |
| 58 | + |
| 59 | +### Key Design Patterns |
| 60 | + |
| 61 | +**Target System**: MCPM uses a "target" concept where commands operate on either a specific client (`@client_name`) or profile (`%profile_name`). The active target is managed by `ClientConfigManager`. |
| 62 | + |
| 63 | +**Scope Modifiers**: Commands support scope syntax like `@CLIENT_NAME/SERVER_NAME` or `%PROFILE_NAME/SERVER_NAME` for precise targeting across the system. |
| 64 | + |
| 65 | +**Configuration Management**: All client configurations are abstracted through the `clients/base.py` interface, allowing uniform operations across different client types. |
| 66 | + |
| 67 | +## Project Structure Highlights |
| 68 | + |
| 69 | +- `src/mcpm/cli.py`: Main CLI entry point with Click framework |
| 70 | +- `src/mcpm/commands/`: Individual CLI command implementations |
| 71 | +- `src/mcpm/clients/managers/`: Client-specific configuration handlers |
| 72 | +- `src/mcpm/router/`: HTTP router for MCP server aggregation |
| 73 | +- `src/mcpm/schemas/`: Pydantic models for configuration validation |
| 74 | +- `mcp-registry/`: Internal registry of curated MCP servers |
| 75 | +- `scripts/`: Registry processing and website generation tools |
| 76 | + |
| 77 | +## Development Guidelines |
| 78 | + |
| 79 | +### Commit Messages |
| 80 | +Follow conventional commit format: |
| 81 | +- `feat: add new feature` |
| 82 | +- `fix: resolve bug issue` |
| 83 | +- `docs: update documentation` |
| 84 | +- `chore: maintenance tasks` |
| 85 | + |
| 86 | +### Code Quality |
| 87 | +- Always run `ruff check --fix` after code changes |
| 88 | +- Always run `pytest` after major changes |
| 89 | +- Use the development CLI script `./test_cli.py` for testing commands |
| 90 | + |
| 91 | +### Version Management |
| 92 | +- Version is managed in `src/mcpm/version.py` as single source of truth |
| 93 | +- Use `./bump_version.sh` script for version updates |
| 94 | +- `pyproject.toml` uses dynamic versioning to read from version.py |
| 95 | + |
| 96 | +## Testing Strategy |
| 97 | + |
| 98 | +The test suite covers: |
| 99 | +- CLI command functionality (`tests/test_cli.py`) |
| 100 | +- Client manager operations (`tests/test_client.py`) |
| 101 | +- Router functionality (`tests/test_router.py`) |
| 102 | +- Profile management (`tests/test_profile.py`) |
| 103 | +- Server operations (add/remove/stash/pop) |
| 104 | + |
| 105 | +Tests use pytest with configuration in `pyproject.toml`. Individual test files can be run independently for targeted testing. |
0 commit comments