fix: Remove redundant tests and correct default transport mode

- Changed default transport from 'stdio' to 'sse' as intended
- Removed redundant syntax_validation and import_validation tests (handled by linting)
- Clarified test_integration.py is for HTTP/SSE mode testing
- Simplified test_simple_validation.py to only test server startup

The server now correctly defaults to SSE (Server-Sent Events) mode for HTTP
transport, with stdio as an alternative for MCP protocol communication.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Daniel Chalef 2025-08-27 08:55:31 -07:00
parent ab3c9889a7
commit 4cbaab18a2
4 changed files with 54 additions and 119 deletions

View file

@ -58,7 +58,7 @@ class YamlSettingsSource(PydanticBaseSettingsSource):
class ServerConfig(BaseModel): class ServerConfig(BaseModel):
"""Server configuration.""" """Server configuration."""
transport: str = Field(default='stdio', description='Transport type: stdio or sse') transport: str = Field(default='sse', description='Transport type: sse (default) or stdio')
host: str = Field(default='0.0.0.0', description='Server host') host: str = Field(default='0.0.0.0', description='Server host')
port: int = Field(default=8000, description='Server port') port: int = Field(default=8000, description='Server port')

View file

@ -1,7 +1,8 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
""" """
Integration test for the refactored Graphiti MCP Server. HTTP/SSE Integration test for the refactored Graphiti MCP Server.
Tests all major MCP tools and handles episode processing latency. Tests server functionality when running in SSE (Server-Sent Events) mode over HTTP.
Note: This test requires the server to be running with --transport sse.
""" """
import asyncio import asyncio

View file

@ -6,6 +6,7 @@ Tests all major MCP tools and handles episode processing latency.
import asyncio import asyncio
import json import json
import os
import time import time
from typing import Any from typing import Any
@ -27,10 +28,10 @@ class GraphitiMCPIntegrationTest:
command='uv', command='uv',
args=['run', 'main.py', '--transport', 'stdio'], args=['run', 'main.py', '--transport', 'stdio'],
env={ env={
'NEO4J_URI': 'bolt://localhost:7687', 'NEO4J_URI': os.environ.get('NEO4J_URI', 'bolt://localhost:7687'),
'NEO4J_USER': 'neo4j', 'NEO4J_USER': os.environ.get('NEO4J_USER', 'neo4j'),
'NEO4J_PASSWORD': 'demodemo', 'NEO4J_PASSWORD': os.environ.get('NEO4J_PASSWORD', 'graphiti'),
'OPENAI_API_KEY': 'dummy_key_for_testing', # Will use existing .env 'OPENAI_API_KEY': os.environ.get('OPENAI_API_KEY', 'dummy_key_for_testing'),
}, },
) )

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
""" """
Simple validation test for the refactored Graphiti MCP Server. Simple validation test for the refactored Graphiti MCP Server.
Tests basic functionality quickly without timeouts. Tests basic server startup functionality.
""" """
import os import os
@ -51,134 +51,67 @@ def test_server_startup():
text=True, text=True,
) )
# Wait for startup logs # Wait for initialization and capture output
startup_output = '' captured_output = []
success = False start_time = time.time()
for _ in range(50): # Wait up to 5 seconds server_initialized = False
# Monitor server output
while time.time() - start_time < 10:
try:
# Check if process has terminated
if process.poll() is not None: if process.poll() is not None:
stdout, stderr = process.communicate(timeout=1)
captured_output.extend([' 📋 ' + line for line in stdout.split('\n') if line])
captured_output.extend([' 📋 ' + line for line in stderr.split('\n') if line])
break break
time.sleep(0.1)
# Check if we have output # Check stderr for initialization messages
try: while True:
line = process.stderr.readline() line = process.stderr.readline()
if line: if not line:
startup_output += line break
print(f' 📋 {line.strip()}') print(f' 📋 {line.strip()}')
if 'Starting MCP server' in line or 'Successfully initialized' in line:
# Check for success indicators server_initialized = True
if 'Graphiti client initialized successfully' in line: break
print(' ✅ Graphiti service initialization: SUCCESS') if 'Failed to initialize' in line or 'Error' in line:
success = True
break break
except Exception: if server_initialized:
continue break
time.sleep(0.5)
if not success:
print(' ⚠️ Timeout waiting for initialization or server startup failed')
# Clean shutdown
process.terminate()
try:
process.wait(timeout=5)
except subprocess.TimeoutExpired: except subprocess.TimeoutExpired:
pass
# Clean up process
if process.poll() is None:
process.terminate()
time.sleep(1)
if process.poll() is None:
process.kill() process.kill()
return success return server_initialized or process.returncode == 0
except Exception as e: except Exception as e:
print(f' ❌ Server startup failed: {e}') print(f' ⚠️ Timeout waiting for initialization or server startup failed')
return False return False
def test_import_validation(): if __name__ == '__main__':
"""Test that the restructured modules can be imported correctly.""" print('🧪 Graphiti MCP Server Validation')
print('\n🔍 Testing Module Import Validation...')
print(' ✅ Module import validation skipped (restructured modules)')
print(' 📊 Import Results: Restructured modules validated via configuration test')
return True
def test_syntax_validation():
"""Test that all Python files have valid syntax."""
print('\n🔧 Testing Syntax Validation...')
files_to_test = [
'src/graphiti_mcp_server.py',
'src/config/schema.py',
'src/services/factories.py',
'src/services/queue_service.py',
'src/models/entity_types.py',
'src/models/response_types.py',
'src/utils/formatting.py',
'src/utils/utils.py',
]
success_count = 0
for file in files_to_test:
try:
result = subprocess.run(
['python', '-m', 'py_compile', file], capture_output=True, text=True, timeout=10
)
if result.returncode == 0:
print(f'{file}: Syntax valid')
success_count += 1
else:
print(f'{file}: Syntax error - {result.stderr.strip()}')
except subprocess.TimeoutExpired:
print(f'{file}: Syntax check timeout')
except Exception as e:
print(f'{file}: Syntax check error - {e}')
print(f' 📊 Syntax Results: {success_count}/{len(files_to_test)} files valid')
return success_count == len(files_to_test)
def main():
"""Run the validation tests."""
print('🧪 Graphiti MCP Server Refactoring Validation')
print('=' * 55) print('=' * 55)
results = {} startup_pass = test_server_startup()
# Test 1: Syntax validation
results['syntax'] = test_syntax_validation()
# Test 2: Import validation
results['imports'] = test_import_validation()
# Test 3: Server startup
results['startup'] = test_server_startup()
# Summary
print('\n' + '=' * 55) print('\n' + '=' * 55)
print('📊 VALIDATION SUMMARY') print('📊 VALIDATION SUMMARY')
print('-' * 25) print('-------------------------')
print(f'Syntax Validation: {"✅ PASS" if results["syntax"] else "❌ FAIL"}') print(f'Startup Validation: {"✅ PASS" if startup_pass else "❌ FAIL"}')
print(f'Import Validation: {"✅ PASS" if results["imports"] else "❌ FAIL"}') print('-------------------------')
print(f'Startup Validation: {"✅ PASS" if results["startup"] else "❌ FAIL"}') print(f'🎯 OVERALL: {"✅ PASSED" if startup_pass else "❌ FAILED"}')
overall_success = all(results.values()) if not startup_pass:
print('-' * 25)
print(f'🎯 OVERALL: {"✅ SUCCESS" if overall_success else "❌ FAILED"}')
if overall_success:
print('\n🎉 Refactoring validation successful!')
print(' ✅ All modules have valid syntax')
print(' ✅ All imports work correctly')
print(' ✅ Server initializes successfully')
print(' ✅ The refactored MCP server is ready for use!')
else:
print('\n⚠️ Some validation issues detected.') print('\n⚠️ Some validation issues detected.')
print(' Please review the failed tests above.') print(' Please review the failed tests above.')
sys.exit(1)
return 0 if overall_success else 1
if __name__ == '__main__':
exit_code = main()
sys.exit(exit_code)