22
33This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
44
5+ ## 🚨 IMPORTANT: Development Workflow Guidelines
6+
7+ ** Before starting any task, agents MUST assess if tests are needed for the work requested.**
8+
9+ ### Test-Driven Development (TDD) Approach
10+
11+ When working on this repository, follow these ** mandatory** guidelines:
12+
13+ 1 . ** Assessment Phase** : Before writing any code, determine if the work requires tests:
14+ - ✅ ** Tests Required** : New features, bug fixes, API changes, tool modifications
15+ - ❌ ** Tests Optional** : Documentation updates, minor refactoring without behavior changes
16+
17+ 2 . ** TDD Workflow** (when tests are required):
18+ ``` bash
19+ # 1. Write failing tests FIRST
20+ python -m pytest tests/test_new_feature.py -v # Should fail
21+
22+ # 2. Write minimal code to make tests pass
23+ # Edit source files...
24+
25+ # 3. Run tests to verify they pass
26+ python -m pytest tests/test_new_feature.py -v # Should pass
27+
28+ # 4. Refactor and repeat
29+ ```
30+
31+ 3 . ** Pre-commit Requirements** :
32+ - ** ALWAYS run all tests locally** before committing any changes
33+ - ** ALL tests must pass** before pushing to remote
34+ - ** Format code** with Black before committing
35+ - ** Work incrementally** with small, atomic commits
36+
37+ 4 . ** Incremental Development** :
38+ - Make small, focused changes
39+ - Commit frequently with descriptive messages
40+ - Each commit should represent a working state
41+ - Push regularly to avoid conflicts
42+
43+ ### Mandatory Test Execution
44+
45+ ``` bash
46+ # Before ANY commit, run:
47+ python -m pytest tests/ -v # All tests must pass
48+ black src/ tests/ # Format code
49+ python -m pytest --cov=src tests/ # Verify coverage
50+ ```
51+
52+ ** ⚠️ Never commit or push if tests are failing or not written for new functionality.**
53+
554## Project Overview
655
756This is a ** Model Context Protocol (MCP) server** for Meilisearch, allowing LLM interfaces like Claude to interact with Meilisearch search engines. The project implements a Python-based MCP server that provides comprehensive tools for index management, document operations, search functionality, and system monitoring.
@@ -19,26 +68,29 @@ uv pip install -e .
1968uv pip install -r requirements-dev.txt
2069```
2170
22- ### Testing
71+ ### Testing (MANDATORY for all development)
2372``` bash
24- # Run all tests
73+ # Run all tests (required before any commit)
2574python -m pytest tests/ -v
2675
2776# Run specific test file
28- python -m pytest tests/test_mcp_integration .py -v
77+ python -m pytest tests/test_mcp_client .py -v
2978
30- # Run tests with coverage
79+ # Run tests with coverage (required for new features)
3180python -m pytest --cov=src tests/
3281
33- # Run integration tests (requires running Meilisearch )
34- python -m pytest tests/test_mcp_integration.py -v
82+ # Watch mode for development (optional )
83+ pytest-watch tests/
3584```
3685
37- ### Code Quality
86+ ### Code Quality (MANDATORY before commit)
3887``` bash
39- # Format code (Black >=23.0.0 )
88+ # Format code (required before commit )
4089black src/ tests/
4190
91+ # Check formatting without applying
92+ black --check src/ tests/
93+
4294# Run the MCP server locally for testing
4395python -m src.meilisearch_mcp
4496
@@ -94,21 +146,38 @@ All MCP tools follow a consistent pattern:
94146## Testing Strategy
95147
96148### Test Structure
97- - ** Integration Tests** (` test_mcp_integration.py ` ): End-to-end MCP tool execution with real Meilisearch
98- - ** Synchronous Tests** (` test_mcp_sync.py ` , ` test_mcp_simple.py ` ): Simplified testing avoiding async complications
99- - ** Unit Tests** (` test_server.py ` ): Basic server instantiation
149+ - ** Integration Tests** (` test_mcp_client.py ` ): End-to-end MCP tool execution with real Meilisearch
150+ - ** Unit Tests** (` test_server.py ` ): Basic server instantiation and configuration
151+
152+ ### Test Categories by Development Task
153+
154+ #### When Tests are REQUIRED:
155+ - ** New MCP Tools** : Add tests to ` test_mcp_client.py ` using ` simulate_tool_call() `
156+ - ** Existing Tool Changes** : Update corresponding test methods
157+ - ** Manager Class Changes** : Test through MCP tool integration
158+ - ** Bug Fixes** : Add regression tests to prevent reoccurrence
159+ - ** API Changes** : Update tests to reflect new interfaces
160+
161+ #### When Tests are OPTIONAL:
162+ - ** Documentation Updates** : README.md, CLAUDE.md changes
163+ - ** Code Formatting** : Black formatting, comment changes
164+ - ** Minor Refactoring** : Internal reorganization without behavior changes
100165
101- ### Tool Simulation
166+ ### Tool Simulation Framework
102167Tests use ` simulate_tool_call() ` function that:
103168- Directly invokes server tool handlers
104- - Bypasses MCP protocol overhead
169+ - Bypasses MCP protocol overhead
105170- Returns proper ` TextContent ` responses
106171- Provides comprehensive coverage of all 20+ tools
172+ - Enables fast test execution without MCP protocol complexity
107173
108- ### Test Isolation
174+ ### Test Isolation and Best Practices
109175- ** Unique Index Names** : Timestamped index names prevent test interference
110- - ** Cleanup Fixtures** : Automatic test environment cleanup
176+ - ** Cleanup Fixtures** : Automatic test environment cleanup after each test
111177- ** Service Dependencies** : Tests require running Meilisearch instance
178+ - ** Test Naming** : Use descriptive test method names (e.g., ` test_create_index_with_primary_key ` )
179+ - ** Assertions** : Test both success cases and error handling
180+ - ** Coverage** : New tools must have comprehensive test coverage
112181
113182## Environment Configuration
114183
0 commit comments