Build Your Own MCP Client in Python
from mcp.client import Client
async def inspect_server(url: str):
async with Client(url) as client:
print("protocol:", client.protocol_version)
print("capabilities:", client.server_capabilities)
tools = await client.list_tools()
for tool in tools.tools:
print(tool.name, tool.description)Do not hardcode one protocol era
The current SDK can negotiate with modern and older servers. Let the SDK handle protocol compatibility unless you have a specific interoperability requirement.
Validate what you expose to the model
Your client can list 200 tools, but your agent may need only 8. Filter and namespace before converting server capabilities into model tools.
Capture server identity for diagnostics, not trust
Self-reported server metadata is useful for logs and UI, but it should not be your authorization decision.