Skip to main content
Glama

Agent Knowledge MCP

test_real_search_error.pyโ€ข3.06 kB
#!/usr/bin/env python3 """ Real-world test: Search a non-existent index to verify server returns suggestions. """ import asyncio import sys import os # Add the parent directory to the Python path to access src sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) from src.elasticsearch_handlers import handle_search async def test_real_search_nonexistent_index(): """Test real search with non-existent index to verify suggestions are returned.""" print("๐Ÿงช REAL-WORLD TEST: Search Non-Existent Index") print("=" * 60) print("Testing if server returns 4-step agent guidance for non-existent index...") print() # Test with completely non-existent index test_index = "nonexistent_test_index_12345" print(f"๐Ÿ“ Testing search with non-existent index: '{test_index}'") print(f"๐Ÿ” Query: 'test search'") print() try: # Perform the actual search result = await handle_search({ "index": test_index, "query": "test search", "size": 10 }) print("๐Ÿ“„ SERVER RESPONSE:") print("-" * 40) for content in result: response_text = content.text print(response_text) # Check if response contains the expected 4-step guidance has_suggestions = "Suggestions for agents" in response_text has_4_steps = all(step in response_text for step in ["1.", "2.", "3.", "4."]) has_list_indices = "list_indices" in response_text has_index_error = "Index Error" in response_text or "Index Not Found" in response_text print() print("โœ… VALIDATION RESULTS:") print(f" ๐ŸŽฏ Contains agent suggestions: {'โœ…' if has_suggestions else 'โŒ'}") print(f" ๐Ÿ“ Has 4-step guidance: {'โœ…' if has_4_steps else 'โŒ'}") print(f" ๐Ÿ› ๏ธ Mentions list_indices tool: {'โœ…' if has_list_indices else 'โŒ'}") print(f" ๐Ÿ“ Identifies as index error: {'โœ…' if has_index_error else 'โŒ'}") all_checks_pass = has_suggestions and has_4_steps and has_list_indices and has_index_error print(f" ๐Ÿ† OVERALL TEST RESULT: {'โœ… PASS' if all_checks_pass else 'โŒ FAIL'}") if all_checks_pass: print() print("๐ŸŽ‰ SUCCESS: Server correctly returns 4-step agent guidance!") print("๐Ÿ“‹ Error handling enhancement is working as expected.") else: print() print("โš ๏ธ WARNING: Some expected suggestions are missing.") print("๐Ÿ“‹ Error handling may need further improvement.") except Exception as e: print(f"โŒ TEST ERROR: {str(e)}") print("๐Ÿ“‹ Could not complete the test due to technical issues.") print() print("=" * 60) print("๐Ÿ Test completed!") if __name__ == "__main__": asyncio.run(test_real_search_nonexistent_index())

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