MCP in an agent
Agentic AI Foundations · Lesson 8 of 20 · 50:40
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the Oracle Agentic AI Foundations Associate exam (1Z0-1157-26). In this lesson: a FastMCP server in Python, tools on a server, connecting a LangChain agent to one or more MCP servers, and running a server published by a cloud vendor. Includes three original practice questions, with Fairhaven Furniture, a fictional furniture seller, as the example.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
Moving tools to a server
Fairhaven's order tools are still defined inside its LangChain agent. To share them with the coding assistant and with the other team's agent, the developers move them to an MCP server. In this lesson, they build that server, connect their agent to it, and try a server that a cloud vendor publishes.
A FastMCP server
In Python, FastMCP builds an MCP server in a few lines, and it comes with the official MCP software development kit. You create a server with a name, here the Fairhaven orders server. The tool decorator turns a function into an MCP tool: its name becomes the tool's name, its docstring the description, and its type hints the input schema. Other decorators expose resources and prompts, the two other primitives. And run starts the server, over standard input and output by default, or over Streamable HTTP when you ask for it.
Tools on a server
Compare this with lesson five. There, each tool was defined inside the agent with the tool decorator, so every agent had to define it again, and changing a tool meant changing every agent. Now the tools sit on a server and are discovered at runtime, so changing a tool means updating one server, and the same tools also work in IDEs, assistants, and other frameworks.
Connecting the agent
On the agent side, the course uses MultiServerMCPClient, from LangChain's MCP adapters package. You give it a dictionary of servers, with one entry per server. A stdio entry gives the command that launches a server locally, and an HTTP entry gives the URL of a remote server. get_tools connects to every server, lists their tools, and turns each one into a LangChain tool, and it's asynchronous, because it starts processes and calls the network. Then create_agent takes these tools like any others, and the agent's loop does not change. Since version 1.4, LangChain also has a newer MCPAdapter, still in beta, which infers the transport from its target, but the course uses MultiServerMCPClient.
A vendor's server
Many vendors also publish MCP servers for their own services, and the course uses one from Oracle that summarizes OCI usage and costs. You launch it like your own server, with a stdio entry, but the command is uvx, which runs a published Python package in a temporary environment, without installing it in your project. The server then calls the cloud API with your credentials, here a profile from your OCI configuration, passed to it through environment variables. The agent's code does not change: get_tools lists the vendor's tools, and the model calls them like any others. Because such a server acts with your credentials, give its account only the permissions that it needs, and only run servers from publishers that you trust.
Recap
Let's recap. FastMCP turns decorated Python functions into MCP tools, resources, and prompts, and runs the server over stdio by default. Tools on a server are discovered at runtime, so a change on one server reaches every agent. MultiServerMCPClient connects an agent to several servers, with stdio and HTTP entries, and get_tools turns their tools into LangChain tools. And vendor servers often launch locally with uvx, and call the cloud with your credentials, so trust and least privilege matter.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
Fairhaven’s developer starts the orders server by calling run(), with no argument. How does an agent reach it?
- Over Streamable HTTP, at a URL
- Through a notification from the model
- Through the agent’s system prompt
- As a local subprocess, over stdio
Show the answer
As a local subprocess, over stdio
Run uses standard input and output by default, so the client launches the server as a local subprocess. “Over Streamable HTTP, at a URL” would need the server to be started with the Streamable HTTP transport. “Through a notification from the model” is not a transport, and a model never sends notifications to a server. And “Through the agent’s system prompt” sets the agent's behavior, and connects nothing.
Fairhaven’s agent must use the orders server, which runs on the developer’s laptop, and the shared warehouse server, reached over the network. How should the developer connect them?
- Two agents, one per server
- One client: stdio and HTTP entries
- One client, stdio for both
- Each remote tool rewritten with @tool
Show the answer
One client: stdio and HTTP entries
One MultiServerMCPClient can hold several servers, with a stdio entry for the local one, and an HTTP entry for the remote one. “Two agents, one per server” would split one conversation between two agents, when one agent can use both servers. “One client, stdio for both” would launch a local process, and stdio cannot reach a server on another machine. And “Each remote tool rewritten with @tool” would bring back the duplication that MCP removes.
Fairhaven’s agent uses a cloud provider’s MCP server, launched locally with uvx, to report monthly cloud costs. Where do the server’s cloud credentials come from?
- The system prompt of the agent’s model
- The text of the user’s chat message
- A local profile, via the environment
- The tool descriptions from get_tools
Show the answer
A local profile, via the environment
The server reads a profile from the local configuration, passed through environment variables, and calls the cloud API with it. “The system prompt of the agent’s model” would expose secrets to the model, and a prompt is never the place for credentials. “The text of the user’s chat message” is untrusted input, and a customer has no access to Fairhaven's cloud account. And “The tool descriptions from get_tools” only describes the tools, with no secrets in it.