Connect agents to MCP servers
Connect agents to MCP servers
The Relay MCP server from the last lesson is running on port 8001 with three tools. It does not know or care what will call it. This lesson points two agents at it: one built with the OpenAI Agents SDK and one built with LangChain's create_agent. Neither imports a Relay module. Each connects, asks the server what it can do, and hands those descriptions to its model as if they were local functions.
The mechanics are the same in both. At start-up the framework opens a client to the server and calls tools/list. It converts each tool's schema into its own tool type. When the model picks one, the framework sends tools/call, waits for the result, and puts it back into the conversation as a tool result. The agent loop is unchanged; only the place the tool runs has moved.
Continue reading
Pro unlocks every video lesson, the full notes and runnable code across the Python with AI course, from the language itself to agents, MCP, Langfuse and deployment.