Get started building your own client that can integrate with all MCP servers.
uv
installeduv
:.env
file to store it:.env
file:.env
to your .gitignore
:ANTHROPIC_API_KEY
secure!client.py
file here.MCPClient
class initializes with session management and API clientsAsyncExitStack
for proper resource managementprocess_query()
to handle specific tool typespython client.py .../quickstart-resources/weather-server-python/weather.py
AsyncExitStack
for proper cleanup.env
FileNotFoundError
: Check your server pathConnection refused
: Ensure the server is running and the path is correctTool execution failed
: Verify the tool’s required environment variables are setTimeout error
: Consider increasing the timeout in your client configuration