|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +OWL-Server is a Python server for managing OWL (Web Ontology Language) ontologies. It provides a simplified API for common operations like adding/removing axioms, finding axioms by pattern, and managing prefix mappings. |
| 8 | + |
| 9 | +The project uses: |
| 10 | +- py-horned-owl for OWL ontology manipulation |
| 11 | +- watchdog for file monitoring |
| 12 | +- click for command-line interface |
| 13 | +- FastMCP for Model-Context-Protocol integration |
| 14 | + |
| 15 | +## Architecture |
| 16 | + |
| 17 | +The codebase is organized into these main components: |
| 18 | + |
| 19 | +1. **SimpleOwlAPI** (`owl_api.py`): Core class that provides thread-safe ontology management: |
| 20 | + - Handles file synchronization with disk |
| 21 | + - Provides observer pattern for change notifications |
| 22 | + - Manages prefix mappings |
| 23 | + - Supports adding/removing/finding axioms |
| 24 | + - Respects readonly settings from configuration |
| 25 | + |
| 26 | +2. **Axiom Parser** (`axiom_parser.py`): Handles conversion between string representations of OWL axioms and py-horned-owl objects. |
| 27 | + |
| 28 | +3. **Server CLI** (`server.py`): Command-line interface for starting the server and initializing ontology files. |
| 29 | + |
| 30 | +4. **MCP Tools** (`mcp_tools.py`): ModelContextProtocol wrapper around the core API: |
| 31 | + - Provides MCP tools for OWL operations |
| 32 | + - Handles API instance caching and management |
| 33 | + - Exposes file-path based interfaces for OWL manipulation |
| 34 | + - Includes configuration management tools |
| 35 | + |
| 36 | +5. **Configuration System** (`config.py`): Manages session-wide configuration: |
| 37 | + - Stores ontology paths, metadata, and settings in `~/.owl-mcp/config.yaml` |
| 38 | + - Provides named access to frequently used ontologies |
| 39 | + - Supports readonly ontologies and metadata axioms |
| 40 | + - Offers session-wide settings like default serialization format |
| 41 | + |
| 42 | +## Common Commands |
| 43 | + |
| 44 | +### Installation |
| 45 | + |
| 46 | +```bash |
| 47 | +# Install dependencies and set up development environment |
| 48 | +make install |
| 49 | +``` |
| 50 | + |
| 51 | +### Running Tests |
| 52 | + |
| 53 | +```bash |
| 54 | +# Run all tests |
| 55 | +make test |
| 56 | + |
| 57 | +# Run a specific test |
| 58 | +uv run pytest tests/test_owl_api.py::test_add_axiom |
| 59 | + |
| 60 | +# Run tests with verbose output |
| 61 | +uv run pytest -v |
| 62 | + |
| 63 | +# Run only MCP tool tests |
| 64 | +uv run pytest tests/test_mcp_tools.py |
| 65 | +``` |
| 66 | + |
| 67 | +### Development Workflow |
| 68 | + |
| 69 | +```bash |
| 70 | +# Clean up build artifacts |
| 71 | +make clean |
| 72 | + |
| 73 | +# Run example script |
| 74 | +make example |
| 75 | +``` |
| 76 | + |
| 77 | +### Code Quality |
| 78 | + |
| 79 | +```bash |
| 80 | +# Format code with black |
| 81 | +uv run black src tests |
| 82 | + |
| 83 | +# Sort imports |
| 84 | +uv run isort src tests |
| 85 | + |
| 86 | +# Type checking with mypy |
| 87 | +uv run mypy src |
| 88 | +``` |
| 89 | + |
| 90 | +### Running the MCP Server |
| 91 | + |
| 92 | +```bash |
| 93 | +# Run the MCP server with stdio transport |
| 94 | +python -m owl_server.mcp_tools |
| 95 | +``` |
| 96 | + |
| 97 | +## Known Issues |
| 98 | + |
| 99 | +The project has compatibility issues with py-horned-owl API as documented in KNOWN_ISSUES.md: |
| 100 | + |
| 101 | +1. Methods like `add_default_prefix_names()` and `clazz()` are referenced in the code but may not be available in the installed version of py-horned-owl. |
| 102 | +2. Adaptations may be needed for axiom types (SubClassOf, etc.). |
0 commit comments