Skip to main content
Glama

Agent Knowledge MCP

test_error_messages.pyโ€ข4.88 kB
#!/usr/bin/env python3 """ Test Elasticsearch error message formatting without MCP dependencies. """ import sys import os import json from pathlib import Path def simulate_elasticsearch_error_handling(): """Simulate the enhanced error handling logic.""" def format_connection_error(): """Format connection error message like the enhanced handlers.""" error_message = "โŒ Failed to index document:\n\n" error_message += "๐Ÿ”Œ **Connection Error**: Cannot connect to Elasticsearch server\n" error_message += "๐Ÿ“ Check if Elasticsearch is running at the configured address\n" error_message += "๐Ÿ’ก Try: Use 'setup_elasticsearch' tool to start Elasticsearch\n" error_message += "๐Ÿ”ง Or check configuration with 'get_config' tool\n\n" error_message += "๐Ÿ” **Technical Details**: Connection refused to Elasticsearch" return error_message def format_search_error(): """Format search error message like the enhanced handlers.""" error_message = "โŒ Search failed:\n\n" error_message += "๐Ÿ”Œ **Connection Error**: Cannot connect to Elasticsearch server\n" error_message += "๐Ÿ“ Check if Elasticsearch is running at the configured address\n" error_message += "๐Ÿ’ก Try: Use 'setup_elasticsearch' tool to start Elasticsearch\n\n" error_message += "๐Ÿ” **Technical Details**: Connection refused to Elasticsearch" return error_message def format_timeout_error(): """Format timeout error message like the enhanced handlers.""" error_message = "โŒ Failed to index document:\n\n" error_message += "โฑ๏ธ **Timeout Error**: Elasticsearch server is not responding\n" error_message += "๐Ÿ“ Server may be overloaded or slow to respond\n" error_message += "๐Ÿ’ก Try: Wait and retry, or check server status\n\n" error_message += "๐Ÿ” **Technical Details**: timeout error: request timed out" return error_message return format_connection_error, format_search_error, format_timeout_error def test_error_message_formatting(): """Test the enhanced error message formatting.""" print("๐Ÿงช Testing Enhanced Elasticsearch Error Messages") print("=" * 60) print() # Get the error formatters format_connection, format_search, format_timeout = simulate_elasticsearch_error_handling() # Test 1: Connection error during index_document print("๐Ÿ“‹ Test 1: Connection error during index_document") error_msg = format_connection() print(" โœ… Error message generated") print(" ๐Ÿ“„ Error message preview:") lines = error_msg.split('\n')[:6] # First 6 lines for line in lines: print(f" {line}") print(" ...") # Check if it contains helpful information if "๐Ÿ”Œ **Connection Error**" in error_msg and "setup_elasticsearch" in error_msg: print(" โœ… Contains helpful suggestions and clear error categorization") else: print(" โŒ Missing helpful suggestions") print() # Test 2: Connection error during search print("๐Ÿ“‹ Test 2: Connection error during search") error_msg = format_search() print(" โœ… Error message generated") print(" ๐Ÿ“„ Error message preview:") lines = error_msg.split('\n')[:5] # First 5 lines for line in lines: print(f" {line}") print(" ...") # Check if it contains helpful information if "๐Ÿ”Œ **Connection Error**" in error_msg and "setup_elasticsearch" in error_msg: print(" โœ… Contains helpful suggestions and clear error categorization") else: print(" โŒ Missing helpful suggestions") print() # Test 3: Timeout error print("๐Ÿ“‹ Test 3: Timeout error during index_document") error_msg = format_timeout() print(" โœ… Error message generated") print(" ๐Ÿ“„ Error message preview:") lines = error_msg.split('\n')[:5] # First 5 lines for line in lines: print(f" {line}") print(" ...") # Check if it contains helpful information if "โฑ๏ธ **Timeout Error**" in error_msg and "Wait and retry" in error_msg: print(" โœ… Contains helpful suggestions and clear error categorization") else: print(" โŒ Missing helpful suggestions") print() print("๐ŸŽฏ Enhanced error message formatting tests completed!") print("๐Ÿ’ก All error messages now provide:") print(" ๐Ÿ“Š Clear error categorization with icons") print(" ๐Ÿ“ Specific problem description") print(" ๐Ÿ’ก Actionable solutions and tool suggestions") print(" ๐Ÿ” Technical details for debugging") print("๐Ÿ”ง Agents will receive detailed guidance for every error type") if __name__ == "__main__": test_error_message_formatting()

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/itshare4u/AgentKnowledgeMCP'

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