Skip to content

Commit 178e347

Browse files
tpayetclaude
andcommitted
Update documentation with comprehensive development guidelines
- Add detailed TDD workflow and testing requirements to CLAUDE.md - Include mandatory test execution and incremental development guidelines - Enhance README.md with development setup and testing instructions - Add comprehensive contribution guidelines with testing requirements - Clarify when tests are required vs optional for different types of work - Document test simulation framework and best practices 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 619bd48 commit 178e347

File tree

2 files changed

+188
-19
lines changed

2 files changed

+188
-19
lines changed

CLAUDE.md

Lines changed: 84 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,55 @@
22

33
This 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

756
This 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 .
1968
uv 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)
2574
python -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)
3180
python -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)
4089
black src/ tests/
4190

91+
# Check formatting without applying
92+
black --check src/ tests/
93+
4294
# Run the MCP server locally for testing
4395
python -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
102167
Tests 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

README.md

Lines changed: 104 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ cd meilisearch-mcp
2525
uv venv
2626
source .venv/bin/activate # On Windows: .venv\Scripts\activate
2727
uv pip install -e .
28+
29+
# Install development dependencies (for testing and development)
30+
uv pip install -r requirements-dev.txt
2831
```
2932

3033
## Requirements
@@ -33,6 +36,68 @@ uv pip install -e .
3336
- Running Meilisearch instance
3437
- Node.js (for testing with MCP Inspector)
3538

39+
## Development Setup
40+
41+
### Prerequisites
42+
43+
1. **Start Meilisearch server**:
44+
```bash
45+
# Using Docker (recommended for development)
46+
docker run -d -p 7700:7700 getmeili/meilisearch:v1.6
47+
48+
# Or using brew (macOS)
49+
brew install meilisearch
50+
meilisearch
51+
52+
# Or download from https://github.com/meilisearch/meilisearch/releases
53+
```
54+
55+
2. **Install development tools**:
56+
```bash
57+
# Install uv for Python package management
58+
pip install uv
59+
60+
# Install Node.js for MCP Inspector testing
61+
# Visit https://nodejs.org/ or use your package manager
62+
```
63+
64+
### Running Tests
65+
66+
This project includes comprehensive integration tests that verify MCP tool functionality:
67+
68+
```bash
69+
# Run all tests
70+
python -m pytest tests/ -v
71+
72+
# Run specific test file
73+
python -m pytest tests/test_mcp_client.py -v
74+
75+
# Run tests with coverage report
76+
python -m pytest --cov=src tests/
77+
78+
# Run tests in watch mode (requires pytest-watch)
79+
pytest-watch tests/
80+
```
81+
82+
**Important**: Tests require a running Meilisearch instance on `http://localhost:7700`. The tests will:
83+
- Create temporary test indices with unique names
84+
- Test all MCP tools end-to-end
85+
- Clean up test data automatically
86+
- Verify error handling and edge cases
87+
88+
### Code Quality
89+
90+
```bash
91+
# Format code with Black
92+
black src/ tests/
93+
94+
# Run type checking (if mypy is configured)
95+
mypy src/
96+
97+
# Lint code (if flake8 is configured)
98+
flake8 src/ tests/
99+
```
100+
36101
## Usage
37102

38103
### Environment Variables
@@ -182,10 +247,45 @@ npx @modelcontextprotocol/inspector python -m src.meilisearch_mcp
182247

183248
## Contributing
184249

185-
1. Fork repository
186-
2. Create feature branch
187-
3. Commit changes
188-
4. Create pull request
250+
We welcome contributions! Please follow these guidelines:
251+
252+
1. **Fork and clone** the repository
253+
2. **Set up development environment** following the Development Setup section above
254+
3. **Create a feature branch** from `main`
255+
4. **Write tests first** if adding new functionality (Test-Driven Development)
256+
5. **Run tests locally** to ensure all tests pass before committing
257+
6. **Format code** with Black and ensure code quality
258+
7. **Commit changes** with descriptive commit messages
259+
8. **Push to your fork** and create a pull request
260+
261+
### Development Workflow
262+
263+
```bash
264+
# Create feature branch
265+
git checkout -b feature/your-feature-name
266+
267+
# Make your changes, write tests first
268+
# Edit files...
269+
270+
# Run tests to ensure everything works
271+
python -m pytest tests/ -v
272+
273+
# Format code
274+
black src/ tests/
275+
276+
# Commit and push
277+
git add .
278+
git commit -m "Add feature description"
279+
git push origin feature/your-feature-name
280+
```
281+
282+
### Testing Guidelines
283+
284+
- All new features should include tests
285+
- Tests should pass before submitting PRs
286+
- Use descriptive test names and clear assertions
287+
- Test both success and error cases
288+
- Ensure Meilisearch is running before running tests
189289

190290
## License
191291

0 commit comments

Comments
 (0)