Skip to main content
Glama
quick_query.py•4.34 kB
#!/usr/bin/env python3 """ Quick Query Tool Simple command-line tool for single queries """ import requests import sys from datetime import datetime def quick_query(query): """Send a quick query and display results.""" print("šŸš€ MCP QUICK QUERY") print("=" * 50) print(f"šŸ“¤ Query: {query}") print("=" * 50) try: # Check if server is running health_response = requests.get("http://localhost:8000/api/health", timeout=5) if health_response.status_code != 200: print("āŒ Server not running!") print("šŸ’” Start server: python production_mcp_server.py") return False health = health_response.json() print(f"āœ… Server: Ready") print(f"āœ… MongoDB: {'Connected' if health.get('mongodb_connected') else 'Disconnected'}") print(f"āœ… Agents: {health.get('system', {}).get('loaded_agents', 0)} loaded") print() # Send query print("ā³ Processing...") response = requests.post( "http://localhost:8000/api/mcp/command", json={"command": query}, timeout=30 ) if response.status_code == 200: result = response.json() print("šŸ“Š RESULT:") print("-" * 30) print(f"šŸ¤– Agent: {result.get('agent_used', 'Unknown')}") print(f"āœ… Status: {result.get('status', 'Unknown').upper()}") if result.get('status') == 'success': # Math results if 'result' in result: print(f"šŸ”¢ Answer: {result['result']}") # Weather results elif 'city' in result and 'weather_data' in result: weather = result['weather_data'] print(f"šŸŒ Location: {result['city']}, {result.get('country', '')}") print(f"šŸŒ”ļø Temperature: {weather.get('temperature', 'N/A')}°C") print(f"ā˜ļø Conditions: {weather.get('description', 'N/A')}") print(f"šŸ’§ Humidity: {weather.get('humidity', 'N/A')}%") print(f"šŸ’Ø Wind: {weather.get('wind_speed', 'N/A')} m/s") # Document results elif 'total_documents' in result: print(f"šŸ“„ Documents: {result['total_documents']} processed") if result.get('authors_found'): print(f"šŸ‘¤ Authors: {', '.join(result['authors_found'])}") # General message elif 'message' in result: print(f"šŸ’¬ Message: {result['message']}") else: print(f"āŒ Error: {result.get('message', 'Unknown error')}") print(f"šŸ’¾ MongoDB: {'āœ… Stored' if result.get('stored_in_mongodb') else 'āŒ Not Stored'}") print(f"šŸ• Time: {datetime.now().strftime('%H:%M:%S')}") return True else: print(f"āŒ Server error: HTTP {response.status_code}") return False except requests.exceptions.ConnectionError: print("āŒ Cannot connect to server!") print("šŸ’” Start server: python production_mcp_server.py") return False except Exception as e: print(f"āŒ Error: {e}") return False def main(): """Main function.""" if len(sys.argv) < 2: print("šŸš€ MCP QUICK QUERY TOOL") print("=" * 50) print("Usage: python quick_query.py \"Your question here\"") print() print("Examples:") print(" python quick_query.py \"Calculate 25 * 4\"") print(" python quick_query.py \"What is the weather in Mumbai?\"") print(" python quick_query.py \"Analyze this text: Hello world\"") print() print("šŸ’” For interactive mode: python user_friendly_interface.py") print("🌐 For web interface: http://localhost:8000") return query = " ".join(sys.argv[1:]) success = quick_query(query) if success: print("\nāœ… Query completed successfully!") else: print("\nāŒ Query failed!") if __name__ == "__main__": main()

Latest Blog Posts

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/tensorwhiz141/MCP2'

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