Feedback

Chat Icon

Practical MCP with FastMCP & LangChain

Engineering the Agentic Experience

MCP Architecture & Workflow Explained
10%

How The AI Agent Selects and Uses MCP Tools

When you connect an AI agent to an MCP server, something "magical" happens: The agent is no longer limited to generating text. It now sees a catalog of available actions it could take.

The keyword could is important. The agent is never forced to use a tool. It must first decide that a tool is appropriate.

To understand how this works, you need to grasp the fundamental nature of language models.

An AI agent does not execute code. It predicts tokens. Every response it generates, including a tool call, is the result of predicting what comes next in a sequence. A tool call is simply a structured pattern of tokens that the AI application recognizes and interprets as an instruction to execute something externally.

So how does the agent know when to produce that pattern?

When the MCP client connects to a server, it retrieves the list of tools. Each tool has a name, a description, an input schema, optionally an output schema, and annotations. This metadata is passed to the agent as part of its context. From the agent’s perspective, each tool looks like a function with a clearly described contract.

The description tells the agent what the tool does in natural language. The input schema tells it what arguments are required and what types they must have. The output schema hints at what kind of result to expect. Annotations provide behavioral hints, such as whether the tool may perform destructive updates (destructiveHint) or interact with external systems (openWorldHint).

Here is an example of how an agent might see a tool definition for controlling smart home lights:

{
  "name": "control_light",
  "description": "Control smart home lighting devices. You can turn lights on or off, and specify the location of the lights.",
  "inputSchema": {
    "type": "object",
    "properties": {
      "location": { "type": "string", "description": "The location of the lights (e.g., living room, kitchen)." },
      "state": { "type": "string", "enum": ["on", "off"], "description": "The desired state of the lights." }
    },
    "required": ["location", "state"]
  },
  "outputSchema": {
    "type": "object"

Practical MCP with FastMCP & LangChain

Engineering the Agentic Experience

Enroll now to unlock current content and receive all future updates for free. Your purchase supports the author and fuels the creation of more exciting content. Act fast, as the price will rise as the course nears completion!