#!/usr/bin/env python3
"""
Minimal test to check if FastMCP can handle stdio protocol
"""
import asyncio
import os
import sys
async def test_fastmcp_stdio():
"""Test FastMCP stdio handling"""
try:
# Import and create the app
from src.ocr_mcp.server import app
print("FastMCP app created successfully", file=sys.stderr)
print(f"App name: {app.name}", file=sys.stderr)
print(f"Number of tools: {len(app._tools)}", file=sys.stderr)
# Simulate the stdio protocol manually
print("Simulating stdio protocol...", file=sys.stderr)
# Send initialize message
init_msg = {
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": {"name": "TestClient", "version": "1.0.0"},
},
}
# This would normally be handled by FastMCP's stdio runner
# For now, just check if the app was created successfully
print("Test completed - app is ready for stdio protocol", file=sys.stderr)
except Exception as e:
print(f"Error: {e}", file=sys.stderr)
import traceback
traceback.print_exc(file=sys.stderr)
if __name__ == "__main__":
# Change to the script directory
os.chdir(os.path.dirname(__file__))
asyncio.run(test_fastmcp_stdio())