|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Commands |
| 6 | + |
| 7 | +### Testing and Development |
| 8 | +- **Run smoke tests**: `uv run scripts/test_mcp_server.py server/zenml_server.py` |
| 9 | +- **Format code**: `./scripts/format.sh` (uses ruff for linting and formatting) |
| 10 | +- **Run MCP server locally**: `uv run server/zenml_server.py` |
| 11 | + |
| 12 | +### Code Quality |
| 13 | +- **Format**: `bash scripts/format.sh` |
| 14 | + |
| 15 | +## Architecture |
| 16 | + |
| 17 | +### Core Components |
| 18 | + |
| 19 | +The project is a Model Context Protocol (MCP) server that provides AI assistants with access to ZenML API functionality. |
| 20 | + |
| 21 | +**Main Server File**: `server/zenml_server.py` |
| 22 | +- Uses FastMCP framework for MCP protocol implementation |
| 23 | +- Implements lazy initialization of ZenML client to avoid startup delays |
| 24 | +- Provides comprehensive exception handling with the `@handle_exceptions` decorator |
| 25 | +- Configures minimal logging to prevent JSON protocol interference |
| 26 | + |
| 27 | +**Key Features**: |
| 28 | +- Reads ZenML server configuration from environment variables (`ZENML_STORE_URL`, `ZENML_STORE_API_KEY`) |
| 29 | +- Provides MCP tools for accessing ZenML entities (users, stacks, pipelines, runs, etc.) |
| 30 | +- Supports triggering new pipeline runs via run templates |
| 31 | +- Includes automated CI/CD testing with GitHub Actions |
| 32 | + |
| 33 | +### Environment Setup |
| 34 | + |
| 35 | +The server requires: |
| 36 | +- Python 3.12+ |
| 37 | +- Dependencies managed via `uv` (preferred) or pip |
| 38 | +- ZenML server URL and API key configured as environment variables |
| 39 | + |
| 40 | +### Testing Infrastructure |
| 41 | + |
| 42 | +- **PR Testing**: GitHub Actions runs tests on every PR (formatting checks + smoke tests) |
| 43 | +- **Scheduled testing**: Comprehensive smoke tests run every 3 days with automated issue creation on failures |
| 44 | +- **Manual testing**: Use the test script to verify MCP protocol functionality |
| 45 | +- **CI/CD**: Uses UV with caching for fast dependency installation |
| 46 | + |
| 47 | +### Project Structure |
| 48 | + |
| 49 | +- `server/` - Main MCP server implementation |
| 50 | +- `scripts/` - Development and testing utilities |
| 51 | +- `assets/` - Project assets and images |
| 52 | + |
| 53 | +- Root files include configuration for Desktop Extensions (DXT) support |
| 54 | + |
| 55 | +### Important Implementation Details |
| 56 | + |
| 57 | +- **Logging**: Configured to use stderr and suppress ZenML internal logging to prevent JSON protocol conflicts |
| 58 | +- **Error Handling**: All tool functions wrapped with exception handling decorator |
| 59 | +- **Lazy Loading**: ZenML client initialized only when needed to improve startup performance |
| 60 | +- **Environment Variables**: Server configuration via `ZENML_STORE_URL` and |
| 61 | + `ZENML_STORE_API_KEY` |
0 commit comments