Spaces:
Sleeping
Sleeping
File size: 1,257 Bytes
cbc8469 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 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()) |