#!/usr/bin/env python3 """Test MCP server JSON-RPC communication""" import json import asyncio import sys from pathlib import Path # Add project root to path sys.path.insert(0, str(Path(__file__).parent)) from src.connector.config import Config from src.server.mcp_server import GPTEditMCPServer async def test_server(): """Test server methods""" config = Config() if not config.validate(): print("Configuration validation failed") return mcp_server = GPTEditMCPServer(config) server = mcp_server.get_server() print("Testing MCP Server methods...") print("=" * 50) # Test list_tools print("\n1. Testing list_tools:") tools = await server.list_tools() print(f" Found {len(tools)} tools") for tool in tools: print(f" - {tool.name}: {tool.description[:50]}...") # Test list_prompts print("\n2. Testing list_prompts:") try: prompts = await server.list_prompts() print(f" Found {len(prompts)} prompts") for prompt in prompts: print(f" - {prompt.name}: {prompt.description}") except Exception as e: print(f" Error: {e}") # Test list_resources print("\n3. Testing list_resources:") try: resources = await server.list_resources() print(f" Found {len(resources)} resources") except Exception as e: print(f" Error: {e}") print("\n" + "=" * 50) print("Test complete!") if __name__ == "__main__": asyncio.run(test_server())