graphiti/.github/workflows/mcp-server-tests.yml
Daniel Chalef 3c25268afc feat: Major MCP server refactor with improved structure and CI/CD
- Reorganized MCP server into clean, scalable directory structure:
  - `src/config/` - Configuration modules (schema, managers, provider configs)
  - `src/services/` - Services (queue, factories)
  - `src/models/` - Data models (entities, responses)
  - `src/utils/` - Utilities (formatting, helpers)
  - `tests/` - All test files
  - `config/` - Configuration files (YAML, examples)
  - `docker/` - Docker setup files
  - `docs/` - Documentation

- Added `main.py` wrapper for seamless transition
- Maintains existing command-line interface
- All deployment scripts continue to work unchanged

- **Queue Service Interface Fix**: Fixed missing `add_episode()` and `initialize()` methods
  - Server calls at `graphiti_mcp_server.py:276` and `:755` now work correctly
  - Eliminates runtime crashes on startup and episode processing
- Updated imports throughout restructured codebase
- Fixed Python module name conflicts (renamed `types/` to `models/`)

- **MCP Server Tests Action** (`.github/workflows/mcp-server-tests.yml`)
  - Runs on PRs targeting main with `mcp_server/**` changes
  - Configuration validation, syntax checking, unit tests
  - Import structure validation, dependency verification
  - Main.py wrapper functionality testing

- **MCP Server Lint Action** (`.github/workflows/mcp-server-lint.yml`)
  - Code formatting with ruff (100 char line length, single quotes)
  - Comprehensive linting with GitHub-formatted output
  - Type checking with pyright (baseline approach for existing errors)
  - Import sorting validation

- Added ruff and pyright configuration to `mcp_server/pyproject.toml`
- Proper tool configuration for the new structure
- Enhanced development dependencies with formatting/linting tools

- All existing tests moved and updated for new structure
- Import paths updated throughout test suite
- Validation scripts enhanced for restructured codebase

- **Improved Maintainability**: Clear separation of concerns
- **Better Scalability**: Organized structure supports growth
- **Enhanced Developer Experience**: Proper linting, formatting, type checking
- **Automated Quality Gates**: CI/CD ensures code quality on every PR
- **Zero Breaking Changes**: Maintains full backwards compatibility

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-30 08:50:48 -07:00

95 lines
No EOL
2.8 KiB
YAML

name: MCP Server Tests
on:
pull_request:
branches:
- main
paths:
- 'mcp_server/**'
workflow_dispatch:
jobs:
test-mcp-server:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: Set up Python
run: uv python install
- name: Install MCP server dependencies
run: |
cd mcp_server
uv sync --extra dev
- name: Run configuration tests
run: |
cd mcp_server
uv run tests/test_configuration.py
- name: Run syntax validation tests
run: |
cd mcp_server
uv run tests/test_simple_validation.py
- name: Run unit tests (if pytest tests exist)
run: |
cd mcp_server
# Check if there are pytest-compatible test files
if find tests/ -name "test_*.py" -exec grep -l "def test_" {} \; | grep -q .; then
echo "Found pytest-compatible tests, running with pytest"
uv add --group dev pytest pytest-asyncio || true
uv run pytest tests/ -v --tb=short
else
echo "No pytest-compatible tests found, skipping pytest"
fi
- name: Test main.py wrapper
run: |
cd mcp_server
uv run main.py --help > /dev/null
echo "✅ main.py wrapper works correctly"
- name: Verify import structure
run: |
cd mcp_server
# Test that main modules can be imported from new structure
uv run python -c "
import sys
sys.path.insert(0, 'src')
# Test core imports
from config.schema import GraphitiConfig
from services.factories import LLMClientFactory, EmbedderFactory, DatabaseDriverFactory
from services.queue_service import QueueService
from models.entity_types import ENTITY_TYPES
from models.response_types import StatusResponse
from utils.formatting import format_fact_result
print('✅ All core modules import successfully')
"
- name: Check for missing dependencies
run: |
cd mcp_server
echo "📋 Checking MCP server dependencies..."
uv run python -c "
try:
import mcp
print('✅ MCP library available')
except ImportError:
print('❌ MCP library missing')
exit(1)
try:
import graphiti_core
print('✅ Graphiti Core available')
except ImportError:
print('⚠️ Graphiti Core not available (may be expected in CI)')
"