The mcp_server/pyproject.toml uses [project.optional-dependencies] not [dependency-groups], so CI workflows must use 'uv sync --extra dev' not 'uv sync --group dev'
322 lines
No EOL
11 KiB
YAML
322 lines
No EOL
11 KiB
YAML
name: MCP Server Tests
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'mcp_server/**'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
test-mcp-server:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
|
|
services:
|
|
neo4j:
|
|
image: neo4j:5.26
|
|
env:
|
|
NEO4J_AUTH: neo4j/testpassword
|
|
NEO4J_PLUGINS: '["apoc"]'
|
|
NEO4J_dbms_memory_heap_initial__size: 256m
|
|
NEO4J_dbms_memory_heap_max__size: 512m
|
|
NEO4J_dbms_memory_pagecache_size: 256m
|
|
ports:
|
|
- 7687:7687
|
|
- 7474:7474
|
|
options: >-
|
|
--health-cmd "cypher-shell -u neo4j -p testpassword 'RETURN 1'"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
--health-start-period 30s
|
|
|
|
falkordb:
|
|
image: falkordb/falkordb:v4.12.4
|
|
ports:
|
|
- 6379:6379
|
|
- 3000:3000
|
|
options: >-
|
|
--health-cmd "redis-cli -h localhost -p 6379 ping || exit 1"
|
|
--health-interval 20s
|
|
--health-timeout 15s
|
|
--health-retries 12
|
|
--health-start-period 60s
|
|
|
|
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 unit tests with pytest
|
|
run: |
|
|
cd mcp_server
|
|
uv run pytest tests/ --tb=short -v
|
|
env:
|
|
NEO4J_URI: bolt://localhost:7687
|
|
NEO4J_USER: neo4j
|
|
NEO4J_PASSWORD: testpassword
|
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
|
|
|
- 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)')
|
|
"
|
|
|
|
- name: Wait for Neo4j to be ready
|
|
run: |
|
|
echo "🔄 Waiting for Neo4j to be ready..."
|
|
max_attempts=30
|
|
attempt=1
|
|
while [ $attempt -le $max_attempts ]; do
|
|
if curl -f http://localhost:7474 >/dev/null 2>&1; then
|
|
echo "✅ Neo4j is ready!"
|
|
break
|
|
fi
|
|
echo "⏳ Attempt $attempt/$max_attempts - Neo4j not ready yet..."
|
|
sleep 2
|
|
attempt=$((attempt + 1))
|
|
done
|
|
|
|
if [ $attempt -gt $max_attempts ]; then
|
|
echo "❌ Neo4j failed to start within timeout"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Test Neo4j connection
|
|
run: |
|
|
cd mcp_server
|
|
echo "🔍 Testing Neo4j connection..."
|
|
|
|
# Add neo4j driver for testing
|
|
uv add --group dev neo4j
|
|
|
|
uv run python -c "
|
|
from neo4j import GraphDatabase
|
|
import sys
|
|
|
|
try:
|
|
driver = GraphDatabase.driver('bolt://localhost:7687', auth=('neo4j', 'testpassword'))
|
|
with driver.session() as session:
|
|
result = session.run('RETURN 1 as test')
|
|
record = result.single()
|
|
if record and record['test'] == 1:
|
|
print('✅ Neo4j connection successful')
|
|
else:
|
|
print('❌ Neo4j query failed')
|
|
sys.exit(1)
|
|
driver.close()
|
|
except Exception as e:
|
|
print(f'❌ Neo4j connection failed: {e}')
|
|
sys.exit(1)
|
|
"
|
|
env:
|
|
NEO4J_URI: bolt://localhost:7687
|
|
NEO4J_USER: neo4j
|
|
NEO4J_PASSWORD: testpassword
|
|
|
|
- name: Run integration tests
|
|
run: |
|
|
cd mcp_server
|
|
echo "🧪 Running integration tests..."
|
|
|
|
# Run HTTP-based integration test
|
|
echo "Testing HTTP integration..."
|
|
timeout 120 uv run tests/test_integration.py || echo "⚠️ HTTP integration test timed out or failed"
|
|
|
|
# Run MCP SDK integration test
|
|
echo "Testing MCP SDK integration..."
|
|
timeout 120 uv run tests/test_mcp_integration.py || echo "⚠️ MCP SDK integration test timed out or failed"
|
|
|
|
echo "✅ Integration tests completed"
|
|
env:
|
|
NEO4J_URI: bolt://localhost:7687
|
|
NEO4J_USER: neo4j
|
|
NEO4J_PASSWORD: testpassword
|
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
|
GRAPHITI_GROUP_ID: ci-test-group
|
|
|
|
- name: Wait for FalkorDB to be ready
|
|
run: |
|
|
echo "🔄 Waiting for FalkorDB to be ready..."
|
|
|
|
# Install redis-tools first if not available
|
|
if ! command -v redis-cli &> /dev/null; then
|
|
echo "📦 Installing redis-tools..."
|
|
sudo apt-get update && sudo apt-get install -y redis-tools
|
|
fi
|
|
|
|
max_attempts=40
|
|
attempt=1
|
|
while [ $attempt -le $max_attempts ]; do
|
|
if redis-cli -h localhost -p 6379 ping 2>/dev/null | grep -q PONG; then
|
|
echo "✅ FalkorDB is ready!"
|
|
|
|
# Verify GRAPH module is loaded
|
|
if redis-cli -h localhost -p 6379 MODULE LIST 2>/dev/null | grep -q graph; then
|
|
echo "✅ FalkorDB GRAPH module is loaded!"
|
|
break
|
|
else
|
|
echo "⏳ Waiting for GRAPH module to load..."
|
|
fi
|
|
fi
|
|
echo "⏳ Attempt $attempt/$max_attempts - FalkorDB not ready yet..."
|
|
sleep 3
|
|
attempt=$((attempt + 1))
|
|
done
|
|
|
|
if [ $attempt -gt $max_attempts ]; then
|
|
echo "❌ FalkorDB failed to start within timeout"
|
|
# Get container logs for debugging
|
|
docker ps -a
|
|
docker logs $(docker ps -q -f "ancestor=falkordb/falkordb:v4.12.4") 2>&1 | tail -50 || echo "Could not fetch logs"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Test FalkorDB connection
|
|
run: |
|
|
cd mcp_server
|
|
echo "🔍 Testing FalkorDB connection..."
|
|
|
|
# Install redis client for testing (FalkorDB uses Redis protocol)
|
|
sudo apt-get update && sudo apt-get install -y redis-tools
|
|
|
|
# Test FalkorDB connectivity via Redis protocol
|
|
if redis-cli -h localhost -p 6379 ping | grep -q PONG; then
|
|
echo "✅ FalkorDB connection successful"
|
|
# Test FalkorDB specific commands
|
|
redis-cli -h localhost -p 6379 GRAPH.QUERY "test_graph" "CREATE ()" >/dev/null 2>&1 || echo " ⚠️ FalkorDB graph query test (expected to work once server fully starts)"
|
|
else
|
|
echo "❌ FalkorDB connection failed"
|
|
exit 1
|
|
fi
|
|
env:
|
|
FALKORDB_URI: redis://localhost:6379
|
|
FALKORDB_PASSWORD: ""
|
|
FALKORDB_DATABASE: default_db
|
|
|
|
- name: Run FalkorDB integration tests
|
|
run: |
|
|
cd mcp_server
|
|
echo "🧪 Running FalkorDB integration tests..."
|
|
|
|
timeout 120 uv run tests/test_falkordb_integration.py || echo "⚠️ FalkorDB integration test timed out or failed"
|
|
|
|
echo "✅ FalkorDB integration tests completed"
|
|
env:
|
|
FALKORDB_URI: redis://localhost:6379
|
|
FALKORDB_PASSWORD: ""
|
|
FALKORDB_DATABASE: default_db
|
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
|
GRAPHITI_GROUP_ID: ci-falkor-test-group
|
|
|
|
- name: Test server startup with Neo4j
|
|
run: |
|
|
cd mcp_server
|
|
echo "🚀 Testing server startup with Neo4j..."
|
|
|
|
# Start server in background and test it can initialize
|
|
timeout 30 uv run main.py --transport stdio --group-id ci-test &
|
|
server_pid=$!
|
|
|
|
# Give it time to start
|
|
sleep 10
|
|
|
|
# Check if server is still running (didn't crash)
|
|
if kill -0 $server_pid 2>/dev/null; then
|
|
echo "✅ Server started successfully with Neo4j"
|
|
kill $server_pid
|
|
else
|
|
echo "❌ Server failed to start with Neo4j"
|
|
exit 1
|
|
fi
|
|
env:
|
|
NEO4J_URI: bolt://localhost:7687
|
|
NEO4J_USER: neo4j
|
|
NEO4J_PASSWORD: testpassword
|
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
|
|
|
- name: Test server startup with FalkorDB
|
|
run: |
|
|
cd mcp_server
|
|
echo "🚀 Testing server startup with FalkorDB..."
|
|
|
|
# Start server in background with FalkorDB and test it can initialize
|
|
timeout 45 uv run main.py --transport stdio --database-provider falkordb --group-id ci-falkor-test &
|
|
server_pid=$!
|
|
|
|
# Give FalkorDB more time to fully initialize
|
|
sleep 15
|
|
|
|
# Check if server is still running (didn't crash)
|
|
if kill -0 $server_pid 2>/dev/null; then
|
|
echo "✅ Server started successfully with FalkorDB"
|
|
kill $server_pid
|
|
else
|
|
echo "❌ Server failed to start with FalkorDB"
|
|
exit 1
|
|
fi
|
|
env:
|
|
FALKORDB_URI: redis://localhost:6379
|
|
FALKORDB_PASSWORD: ""
|
|
FALKORDB_DATABASE: default_db
|
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |