Spaces:
Sleeping
Sleeping
| import asyncio | |
| import json | |
| import sys | |
| from mcp.client.client import Client | |
| from mcp.types import TextContent | |
| async def test_server(): | |
| # Create MCP client | |
| client = Client() | |
| # Connect to the server | |
| print("Connecting to server...") | |
| await client.connect("firstock-docs") | |
| try: | |
| # Test 1: List categories | |
| print("\nTest 1: Listing categories") | |
| result = await client.call_tool("list_categories", {}) | |
| print("Categories:", result[0].text) | |
| # Test 2: Get documentation for a specific section | |
| print("\nTest 2: Getting documentation for 'login'") | |
| result = await client.call_tool("get_documentation", {"section": "login"}) | |
| print("Documentation:", result[0].text[:500] + "..." if len(result[0].text) > 500 else result[0].text) | |
| # Test 3: Search documentation | |
| print("\nTest 3: Searching for 'authentication'") | |
| result = await client.call_tool("search_documentation", {"query": "authentication"}) | |
| print("Search results:", result[0].text) | |
| except Exception as e: | |
| print(f"Error during testing: {str(e)}") | |
| finally: | |
| await client.disconnect() | |
| if __name__ == "__main__": | |
| asyncio.run(test_server()) |