Files
flux1-edit/simple_test.py
2025-08-26 02:50:40 +09:00

127 lines
3.6 KiB
Python

"""
Simple test script for FLUX.1 Edit MCP Server
"""
import sys
import asyncio
import json
from pathlib import Path
# Add src to path
sys.path.insert(0, str(Path(__file__).parent / 'src'))
async def test_server_import():
"""Test if the server can be imported and initialized"""
print("🔍 Testing server import and initialization...")
try:
# Test imports
from src.server.mcp_server import create_server
from src.connector import Config
print("✅ Successfully imported server components")
# Test configuration
config = Config()
if config.validate():
print("✅ Configuration validation passed")
else:
print("❌ Configuration validation failed")
return False
# Test server creation
server = create_server()
print("✅ Server created successfully")
# Test server validation
if server.validate_config():
print("✅ Server configuration validated")
else:
print("❌ Server configuration validation failed")
return False
return True
except Exception as e:
print(f"❌ Error: {e}")
import traceback
traceback.print_exc()
return False
async def test_mcp_protocol():
"""Test MCP protocol basics"""
print("\n🔍 Testing MCP protocol basics...")
try:
import mcp.types as types
from mcp.server import Server
from mcp.server.stdio import stdio_server
print("✅ MCP imports successful")
# Create a minimal server for testing
server = Server("test-server")
@server.list_tools()
async def list_tools():
return [
types.Tool(
name="test_tool",
description="Test tool",
inputSchema={
"type": "object",
"properties": {
"test_param": {
"type": "string",
"description": "Test parameter"
}
},
"required": ["test_param"]
}
)
]
print("✅ MCP server handlers configured")
return True
except Exception as e:
print(f"❌ MCP protocol test failed: {e}")
import traceback
traceback.print_exc()
return False
def main():
"""Main test function"""
print("🚀 FLUX.1 Edit MCP Server - Simple Test")
print("=" * 50)
# Run async tests
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
test1_result = loop.run_until_complete(test_server_import())
test2_result = loop.run_until_complete(test_mcp_protocol())
print("\n" + "=" * 50)
print("📊 TEST RESULTS")
print("=" * 50)
print(f"Server Import & Init: {'✅ PASS' if test1_result else '❌ FAIL'}")
print(f"MCP Protocol Basic: {'✅ PASS' if test2_result else '❌ FAIL'}")
if test1_result and test2_result:
print("\n🎉 All tests passed! Server should be ready.")
print("\n💡 Try running: python main.py")
return True
else:
print("\n🔧 Some tests failed. Check the errors above.")
return False
finally:
loop.close()
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)