docs: update CLAUDE.md with new project structure

This commit is contained in:
2025-12-30 20:49:59 -05:00
parent 3d68de4c54
commit c9e51c71d8

View File

@@ -17,11 +17,23 @@ grist-mcp is an MCP (Model Context Protocol) server that enables AI agents to in
## Commands ## Commands
```bash ```bash
# Run tests # Run unit tests
uv run pytest -v make test-unit
# or: uv run pytest tests/unit/ -v
# Run a specific test file # Run integration tests (manages containers automatically)
uv run pytest tests/test_auth.py -v make test-integration
# or: ./scripts/run-integration-tests.sh
# Full pre-deploy pipeline
make pre-deploy
# Development environment
make dev-up # Start
make dev-down # Stop
# Build Docker image
make build
# Run the server (requires config and token) # Run the server (requires config and token)
CONFIG_PATH=./config.yaml GRIST_MCP_TOKEN=your-token uv run python -m grist_mcp.main CONFIG_PATH=./config.yaml GRIST_MCP_TOKEN=your-token uv run python -m grist_mcp.main
@@ -30,7 +42,7 @@ CONFIG_PATH=./config.yaml GRIST_MCP_TOKEN=your-token uv run python -m grist_mcp.
## Project Structure ## Project Structure
``` ```
src/grist_mcp/ src/grist_mcp/ # Source code
├── main.py # Entry point, runs stdio server ├── main.py # Entry point, runs stdio server
├── server.py # MCP server setup, tool registration, call_tool dispatch ├── server.py # MCP server setup, tool registration, call_tool dispatch
├── config.py # YAML config loading with env var substitution ├── config.py # YAML config loading with env var substitution
@@ -41,6 +53,14 @@ src/grist_mcp/
├── read.py # list_tables, describe_table, get_records, sql_query ├── read.py # list_tables, describe_table, get_records, sql_query
├── write.py # add_records, update_records, delete_records ├── write.py # add_records, update_records, delete_records
└── schema.py # create_table, add_column, modify_column, delete_column └── schema.py # create_table, add_column, modify_column, delete_column
tests/
├── unit/ # Unit tests (no containers)
└── integration/ # Integration tests (with Docker)
deploy/
├── dev/ # Development docker-compose
├── test/ # Test docker-compose (ephemeral)
└── prod/ # Production docker-compose
scripts/ # Test automation scripts
``` ```
## Key Patterns ## Key Patterns
@@ -71,11 +91,18 @@ The optional `client` parameter enables dependency injection for testing.
## Testing ## Testing
Tests use pytest-httpx to mock Grist API responses. Each test file has fixtures for common setup: ### Unit Tests (`tests/unit/`)
Fast tests using pytest-httpx to mock Grist API responses. Run with `make test-unit`.
- `test_auth.py`: Uses in-memory Config objects - `test_auth.py`: Uses in-memory Config objects
- `test_grist_client.py`: Uses HTTPXMock for API mocking - `test_grist_client.py`: Uses HTTPXMock for API mocking
- `test_tools_*.py`: Combine auth fixtures with mocked clients - `test_tools_*.py`: Combine auth fixtures with mocked clients
### Integration Tests (`tests/integration/`)
Tests against real Grist containers. Run with `make test-integration`.
- Automatically manages Docker containers via `scripts/run-integration-tests.sh`
- Uses environment variables for configuration (no hardcoded URLs)
- Containers are ephemeral and cleaned up after tests
## Configuration ## Configuration
See `config.yaml.example` for the configuration format. Key points: See `config.yaml.example` for the configuration format. Key points: