Skip to main content
Glama

Remote Calculator MCP Server

by sdhekale
test_mcp_client.py•3.46 kB
#!/usr/bin/env python3 """ Fixed MCP client to test the remote EKS MCP server without strands dependency. """ import asyncio from mcp.client.streamable_http import streamablehttp_client from mcp import ClientSession async def test_remote_mcp(): """Test the remote MCP server running in EKS.""" print("šŸš€ Testing Remote MCP Server in EKS") print("=" * 50) # URL of the remote MCP server server_url = "<insert your loadbalancer URL>/mcp/" print(f"šŸ“” Connecting to: {server_url}") try: # Create streamable HTTP client async with streamablehttp_client(server_url) as (read, write, get_session_id): print("āœ… Connected to remote MCP server") print(f"šŸ“‹ Session ID: {get_session_id()}") # Create client session async with ClientSession(read, write) as session: print("šŸ”„ Initializing session...") # Initialize the session await session.initialize() print("āœ… Session initialized successfully") # List available tools print("\nšŸ› ļø Listing available tools...") tools_result = await session.list_tools() if tools_result.tools: print(f"šŸ“‹ Found {len(tools_result.tools)} tool(s):") for tool in tools_result.tools: print(f" - {tool.name}: {tool.description}") if hasattr(tool, 'inputSchema') and tool.inputSchema: print(f" Parameters: {tool.inputSchema.get('properties', {}).keys()}") else: print("āŒ No tools found") return # Test the add_numbers tool print(f"\n🧮 Testing add_numbers tool...") test_case = {"a": 15.5, "b": 24.3} try: print(f"\n Testing: {test_case['a']} + {test_case['b']}") result = await session.call_tool("add_numbers", test_case) if result.content: for content in result.content: if hasattr(content, 'text'): print(f" āœ… Result: {content.text}") else: print(f" āœ… Result: {content}") else: print(f" āš ļø No content in result: {result}") except Exception as tool_error: print(f" āŒ Tool call failed: {tool_error}") print(f"\nšŸŽ‰ Remote MCP testing completed!") except Exception as e: print(f"āŒ Connection failed: {e}") print(f" Error type: {type(e).__name__}") # Print more detailed error information import traceback print(f" Full traceback:") traceback.print_exc() print(f"\n This could be due to:") print(f" - Network connectivity issues") print(f" - MCP server not responding") print(f" - Session management problems") print(f" - Protocol version mismatch") if __name__ == "__main__": asyncio.run(test_remote_mcp())

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sdhekale/Remote-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server