[KongchangAI]
· 1 min read· 924 words

LangChain + MCP in Practice: Understanding Agent Tool Calling from the Ground Up

LangChain + MCP in Practice: Understanding Agent Tool Calling from the Ground Up

Clarifies how LangChain, Agents, and MCP relate — the conceptual foundation for building real AI agents.

This article walks through the three core layers needed to build an AI agent. LLMs provide reasoning but lack access to real-time internal data — tools bridge that gap. Frameworks like LangChain abstract away LLM calls, context management, and tool orchestration so developers can focus on business logic. Agents add a higher-level layer that auto-manages conversation history, actually executes tool calls (rather than just expressing intent), and loops through call→observe→decide cycles. MCP then standardizes how agents connect to external tools, reducing ecosystem fragmentation. Understanding this conceptual chain is the prerequisite for going deeper with MCP.

Why Frameworks Like LangChain Exist

The core value of large language models lies in their reasoning power — they can understand what you mean and transform unstructured text into organized, coherent responses. But there's an inherent limitation: a model's outputs are ultimately grounded in its training data, which means it has no direct access to your organization's real-time internal business information.

To make an LLM useful in a business context, the common approach is to bind it to tools. This way, the model doesn't just understand your questions — it can also call tools to retrieve internal business data or documents, then use its reasoning ability to synthesize an answer.

The problem is that building this from scratch — wiring up LLM APIs, managing tools, handling conversation context — burns your energy on low-level plumbing instead of actual business value. LangChain was built to solve exactly this problem. It's a framework for building LLM-powered applications (AI apps) that abstracts away the underlying complexity, letting developers stand on the shoulders of giants.

An AI that understands your internal business context

Don't Reinvent the Wheel

Beyond LangChain, there are many other options for building AI applications — the Claude SDK, OpenAI's SDK, and more. One important piece of advice: don't build your own framework from scratch just for the sake of it.

Yes, these frameworks were all built from scratch by someone — but for the vast majority of developers, reimplementing LLM invocation, concurrency, state management, and conversation history handling is both time-consuming and unnecessary. Rather than burning effort on the foundation, use a mature framework and keep your focus on business logic.

You'd be wasting all your energy on the wrong things

What an Agent Actually Does Differently

Beyond "chat + tool calls," the more advanced concept is the Agent. An agent typically wraps a large model internally, but it adds a higher layer of abstraction on top of it.

That higher-level abstraction shows up in a few concrete capabilities:

Automatic Conversation History Management

Every conversation with an LLM generates a growing history of messages. When working with a model directly, you have to maintain that context yourself. An agent handles this automatically — no more manually stitching together conversation history.

Actually Executing Tool Calls

This is the most critical difference between an agent and a bare LLM. When a model is given tools on its own, it can decide to call a tool — but it won't actually execute it. An agent closes that gap: it physically carries out the tool call and returns the result.

But the model won't actually execute it on its own

From a technical standpoint, when an LLM expresses intent to call a tool, it outputs structured data (typically JSON) describing which tool to invoke and with what parameters. The raw model only generates that description — the actual function execution, network requests, or database queries must be handled by external code. The agent framework automatically parses that intent, calls the corresponding local function or remote service, and feeds the result back to the model, completing the full execution loop. OpenAI refers to this mechanism as Function Calling; LangChain unifies it under the Tool abstraction. Developers simply define a tool's name, description, and input parameters — the framework handles the orchestration automatically.

Deciding What to Do Next Based on Results

Going further, an agent can continue reasoning after receiving a tool's output and decide whether another tool call is needed. This "call → observe → decide" loop is the defining characteristic that separates an agent from a one-shot Q&A system, and it's the foundation of any genuinely useful AI agent.

Connecting the Framework to MCP

Once you understand that LangChain is a framework for building AI applications and that an agent is a higher-level abstraction on top of an LLM, MCP naturally enters the picture. Every agent may need to interface with multiple tools, and managing and standardizing those tool calls is one of the hardest parts in practice.

Built from the ground up

This is exactly where MCP becomes meaningful — in the scenario where agents need a principled way to connect to all kinds of tools. It provides a more unified approach to collaboration between agents and external tools, moving tool integration from a fragmented, ad hoc process toward something standardized.

MCP (Model Context Protocol) is an open protocol introduced by Anthropic in late 2024. Its goal is to define a common standard for communication between AI models and external tools or data sources. Before MCP, each agent framework or tool platform had its own integration method, meaning the same tool often had to be re-adapted for every different framework. MCP works like a "USB port" for the AI tool ecosystem — a tool developer implements an MCP server once, and any MCP-compatible agent or framework can call it directly, with no additional adaptation required. This standardization dramatically reduces ecosystem fragmentation and means developers no longer have to rewrite tool integrations when switching between agent frameworks.

Summary

This walkthrough clarifies the relationship between three key concepts: LLMs handle reasoning and understanding; frameworks like LangChain abstract away the low-level details so you can focus on business logic; and agents build on top of LLMs to add automatic conversation history management, genuine tool execution, and multi-turn "call → observe → decide" loops. For developers looking to build a working AI agent from scratch, getting this conceptual chain straight before diving into the specifics of MCP is the most solid path forward.

#LangChain#MCP#AI Agent#tool calling#Function Calling#Model Context Protocol#LLM framework#intelligent agent
Share:

Related articles