An MCP client bridges a host application and one MCP server. When the host decides that an agent needs a tool, the client discovers available definitions, forwards execution requests, and returns results. section 3.4.1
The client hides protocol details while exposing a practical session interface: establish a connection, initialize the session, list tools, call a named tool with arguments, and parse the returned result. This separates the agent’s reasoning from tool communication. section 3.4.3
A programmatic client commonly performs these steps:
- Configure how to launch the server with StdioServerParameters, including the command, arguments, environment variables, and API key. section 3.4.3
- Open stdio_client as a subprocess context and create a ClientSession over its read and write streams. section 3.4.3
- Call initialize(), then use list_tools() to retrieve names, descriptions, and parameter schemas. section 3.4.3
- Call call_tool() with a tool name and argument dictionary; the server executes the tool and returns the result. section 3.4.3
- Convert MCP schemas into the format required by the selected LLM provider before exposing tools to the model. section 3.4.1
Tavily search client
A Python client launches tavily-mcp@latest through npx, passes TAVILY_API_KEY, initializes a session, lists Tavily tools, and calls tavily_search with a query. Async context managers clean up the subprocess and communication streams.







