test_simplified_startup.py•3.24 kB
#!/usr/bin/env python3
"""
Test the simplified server startup without --ai-env parameters.
"""
import subprocess
import time
import sys
def test_simplified_startup():
"""Test that server starts correctly with simplified configuration."""
print("🧪 Testing Simplified AI Configuration")
print("="*50)
print("1️⃣ Testing server startup without --ai-env parameter...")
# Start server in background
try:
proc = subprocess.Popen([
'uv', 'run', 'python', 'src/dp_mcp/server.py', '--debug'
], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
# Wait a few seconds for startup
time.sleep(8)
# Check if process is still running
if proc.poll() is None:
print("✅ Server started successfully")
# Try to get some output
try:
output, _ = proc.communicate(timeout=2)
except subprocess.TimeoutExpired:
proc.kill()
output, _ = proc.communicate()
# Check for key indicators in output
if "AI configured" in output or "Auto-detecting AI" in output:
print("✅ AI auto-detection working")
elif "AI features disabled" in output:
print("ℹ️ AI disabled (no models available)")
else:
print("⚠️ AI status unclear")
if "Starting DP-MCP Server" in output:
print("✅ MCP server started")
if "phi3" in output:
print("✅ Ollama phi3 model detected")
# Check for the absence of --ai-env related errors
if "--ai-env" not in output:
print("✅ No --ai-env parameter issues")
print("\n📋 Server Output Sample:")
lines = output.split('\n')
for line in lines[:15]: # Show first 15 lines
if 'AI' in line or 'phi3' in line or 'Starting' in line:
print(f" {line}")
else:
print("❌ Server failed to start")
if proc.stdout:
error_output = proc.stdout.read()
print(f"Error: {error_output}")
except Exception as e:
print(f"❌ Test failed: {e}")
finally:
# Clean up
try:
if proc.poll() is None:
proc.terminate()
proc.wait(timeout=5)
except:
try:
proc.kill()
except:
pass
print("\n🎯 Simplified Configuration Summary:")
print("✅ No --ai-env parameter needed")
print("✅ Server auto-detects available AI models")
print("✅ Works with Ollama, cloud APIs, or demo mode")
print("✅ Single command: uv run python src/dp_mcp/server.py")
print("\n🚀 Usage:")
print(" # Basic startup")
print(" uv run python src/dp_mcp/server.py")
print("")
print(" # With debug logging")
print(" uv run python src/dp_mcp/server.py --debug")
if __name__ == "__main__":
test_simplified_startup()