Skip to main content
Glama

Google Search MCP Server

by jspv
test_mcp_container.pyβ€’7.13 kB
#!/usr/bin/env python3 """ Test containerized MCP service deployment (example helper) """ import json import os import subprocess import time import httpx BASE_URL = os.environ.get("MCP_BASE_URL", "http://localhost:8000").rstrip("/") ASSUMED_MODE = os.environ.get("MCP_MODE", "http-stream").strip() # http | http-stream def test_container_local(): """Test the container running locally""" print("🐳 Testing Local Container Deployment") print("=" * 50) try: # In http mode, check /sse existence (200 or 405 is acceptable) if ASSUMED_MODE == "http": print("πŸ₯ Checking SSE endpoint...") response = httpx.get(f"{BASE_URL}/sse", timeout=5) if response.status_code in (200, 405): print("βœ… SSE route reachable (/sse)") else: print(f"❌ SSE route check failed: {response.status_code}") return False except httpx.RequestError as e: print(f"❌ Cannot connect to container: {e}") print("πŸ’‘ Make sure container is running:") print( " docker run -p 8000:8000 -e GOOGLE_API_KEY=your_key -e GOOGLE_CX=your_cx google-search-mcp:latest" ) return False try: # Basic check: messages route present (OPTIONS preflight OK via CORS) print("πŸ”§ Checking MCP messages route...") r = httpx.options( f"{BASE_URL}/messages", headers={ "Origin": "http://localhost", "Access-Control-Request-Method": "POST", }, timeout=5, ) if r.status_code in (200, 204): print("βœ… Messages route reachable (/messages)") else: print(f"❌ Messages route check failed: {r.status_code}") return False except httpx.RequestError as e: print(f"❌ Tools endpoint error: {e}") return False try: # Note: actual tool execution is over MCP messages; keep example non-invasive. print("πŸ” Skipping direct tool call (use an MCP client for full flow)") return True except httpx.RequestError as e: print(f"❌ Search test error: {e}") return False def test_container_modes(): """Test different MCP modes in the container""" print("\nπŸ”„ Testing Different MCP Modes") print("=" * 50) modes = [ ("http", 8000, "HTTP (SSE capable)"), ("http-stream", 8001, "HTTP Streaming (no SSE route)"), ] for mode, port, description in modes: print(f"\nπŸ§ͺ Testing {description} mode...") # This would require running containers on different ports # For now, just document the approach print(f" Mode: {mode}") print(f" Port: {port}") print( f" Command: docker run -p {port}:8000 -e MCP_MODE={mode} --env-file .env google-search-mcp:latest" ) if mode == "http": print(f" Routes: http://localhost:{port}/sse and /messages") else: print(f" Routes: http://localhost:{port}/messages (no /sse)") def get_ecs_service_info(): """Get information about ECS deployment""" print("\n☁️ ECS Service Information") print("=" * 50) try: # Get ECS service status result = subprocess.run( [ "aws", "ecs", "describe-services", "--cluster", "google-search-mcp-cluster", "--services", "google-search-mcp-service", "--region", "us-east-1", ], capture_output=True, text=True, ) if result.returncode == 0: services = json.loads(result.stdout) if services.get("services"): service = services["services"][0] print(f"βœ… Service Status: {service.get('status')}") print(f" Desired Count: {service.get('desiredCount')}") print(f" Running Count: {service.get('runningCount')}") print(f" Pending Count: {service.get('pendingCount')}") # Get task ARNs if service.get("taskArns"): print(f" Active Tasks: {len(service['taskArns'])}") return True else: print(" No active tasks") return False else: print("❌ No services found") return False else: print(f"❌ Failed to get service info: {result.stderr}") return False except Exception as e: print(f"❌ Error getting ECS info: {e}") return False def show_deployment_summary(): """Show summary of all deployment options""" print("\nπŸ“Š MCP Deployment Options Summary") print("=" * 60) deployments = [ ("1. stdio Mode", "βœ… Working", "Direct MCP protocol", "Local/dev"), ("2. HTTP REST", "βœ… Working", "REST API endpoints", "Web integration"), ("3. HTTP Streaming", "βœ… Working", "Server-Sent Events", "Real-time apps"), ( "4. Lambda + Gateway", "βœ… Working", "Serverless (388ms tested)", "AWS managed", ), ( "5. Container (ECS)", "πŸ”§ Deployed", "Containerized MCP service", "Scalable cloud", ), ] print(f"{'Option':<20} {'Status':<12} {'Protocol':<20} {'Use Case'}") print("-" * 60) for option, status, protocol, use_case in deployments: print(f"{option:<20} {status:<12} {protocol:<20} {use_case}") print( "\n🎯 All deployment patterns demonstrate the same Google Search MCP functionality" ) print(" - No AI models needed") print(" - Pure MCP tool service") print(" - Different transport/deployment methods") print(" - Same search tool API across all patterns") if __name__ == "__main__": print("πŸš€ MCP Container Deployment Test Suite") print("=" * 60) # Test local container if available local_success = test_container_local() # Show different modes test_container_modes() # Check ECS deployment ecs_success = get_ecs_service_info() # Show summary show_deployment_summary() print("\nπŸ“‹ Test Results:") print( f" Local Container: {'βœ… Working' if local_success else '❌ Not available'}" ) print(f" ECS Deployment: {'βœ… Deployed' if ecs_success else '❌ Not deployed'}") if local_success or ecs_success: print("\nπŸŽ‰ Containerized MCP service deployment successful!") print(" This completes our 5th deployment pattern demonstration.") else: print("\nπŸ’‘ To test locally, run:") print( " ./deploy/deploy_mcp_container.sh google-search-mcp us-east-1 standalone" ) print( " docker run -p 8000:8000 -e GOOGLE_API_KEY=key -e GOOGLE_CX=cx google-search-mcp:latest" )

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/jspv/google_search_mcp'

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