We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Agarwal-Saurabh/multiapimcpserver'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
simple_petstore_test.pyā¢1.61 kB
#!/usr/bin/env python3
"""
Simple test to verify Petstore MCP server works with LangChain.
"""
import asyncio
import sys
sys.path.append('src')
from langchain_mcp_adapters.client import MultiServerMCPClient
async def test_petstore_connection():
"""Test connection to Petstore MCP server."""
print("š¶ Testing Petstore MCP Server Connection")
try:
# Connect to running Petstore server
print("š Connecting to Petstore server on port 8081...")
client = MultiServerMCPClient({
"petstore": {
"url": "http://127.0.0.1:8081/mcp",
"transport": "streamable_http",
}
})
# Get available tools
print("š Getting available tools...")
tools = await client.get_tools()
print(f"ā Successfully connected! Found {len(tools)} tools:")
# Show Petstore tools
petstore_tools = [tool for tool in tools if 'pet' in tool.name.lower()]
for i, tool in enumerate(petstore_tools[:5]):
print(f" {i+1}. {tool.name}: {tool.description}")
if len(petstore_tools) > 5:
print(f" ... and {len(petstore_tools) - 5} more pet-related tools")
print(f"\nš Total tools available: {len(tools)}")
print("ā Petstore end-to-end test completed successfully!")
except Exception as e:
print(f"ā Error connecting to Petstore server: {e}")
print(" Make sure the server is running on port 8081")
if __name__ == "__main__":
asyncio.run(test_petstore_connection())