graphiti/.github/workflows/mcp-server-lint.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

106 lines
No EOL
3.1 KiB
YAML

name: MCP Server Formatting and Linting
on:
pull_request:
branches:
- main
paths:
- 'mcp_server/**'
workflow_dispatch:
jobs:
format-and-lint:
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: Add ruff to dependencies
run: |
cd mcp_server
uv add --group dev "ruff>=0.7.1"
- name: Check code formatting with ruff
run: |
cd mcp_server
echo "🔍 Checking code formatting..."
uv run ruff format --check --diff .
if [ $? -eq 0 ]; then
echo "✅ Code formatting is correct"
else
echo "❌ Code formatting issues found"
echo "💡 Run 'ruff format .' in mcp_server/ to fix formatting"
exit 1
fi
- name: Run ruff linting
run: |
cd mcp_server
echo "🔍 Running ruff linting..."
uv run ruff check --output-format=github .
- name: Add pyright for type checking
run: |
cd mcp_server
uv add --group dev pyright
- name: Install graphiti-core for type checking
run: |
cd mcp_server
# Install graphiti-core as it's needed for type checking
uv add --group dev "graphiti-core>=0.16.0"
- name: Run type checking with pyright
run: |
cd mcp_server
echo "🔍 Running type checking..."
# Run pyright and capture output
if uv run pyright . > pyright_output.txt 2>&1; then
echo "✅ Type checking passed with no errors"
cat pyright_output.txt
else
echo "⚠️ Type checking found issues:"
cat pyright_output.txt
# Count errors
error_count=$(grep -c "error:" pyright_output.txt || echo "0")
warning_count=$(grep -c "warning:" pyright_output.txt || echo "0")
echo ""
echo "📊 Type checking summary:"
echo " - Errors: $error_count"
echo " - Warnings: $warning_count"
# Only fail if there are more than 50 errors (current baseline)
if [ "$error_count" -gt 50 ]; then
echo "❌ Too many type errors (>50). Please fix critical issues."
exit 1
else
echo "⚠️ Type errors under threshold, continuing..."
fi
fi
- name: Check import sorting
run: |
cd mcp_server
echo "🔍 Checking import sorting..."
uv run ruff check --select I --output-format=github .
- name: Summary
if: success()
run: |
echo "✅ All formatting and linting checks passed!"
echo "✅ Code formatting: OK"
echo "✅ Ruff linting: OK"
echo "✅ Type checking: OK"
echo "✅ Import sorting: OK"