Here is the complete summary, breakdown of concepts, and comparison formatted in clean Markdown for your post:
Table of Contents
1. Tools Gist (Local Python Functions) Link to heading
- Definition: Tools are regular Python functions provided to an agent to allow it to interact with its environment, run queries, or call APIs. The developer writes them directly inside the codebase.
- Core Concepts:
- The
@toolDecorator: Imported fromlangchain_core.tools, this decorator converts any Python function into a tool schema. The function’s name, type annotations, and docstring act as the natural-language description that the LLM relies on to decide when and how to call it. - Built-in Tool Suites: Deep agents automatically load standard tool suites out of the box, including Filesystem Tools (
ls,read_file,write_file,edit_file,delete), Search Tools (glob,grep), and Execution Tools (execute). - Additive Customization: Passing custom tools via the
toolsparameter increate_deep_agentmerges them directly into the built-in suite rather than overwriting it. - Execution Loop: The LLM requests tool execution by returning an
AIMessagewithtool_calls. The runtime executes them and feeds the results back asToolMessageobjects.
MCP Gist (Model Context Protocol) Link to heading
- Definition: The Model Context Protocol (MCP) is an open protocol that standardizes how external applications and services provide tools and context to LLMs.
Core Concepts:
Decoupled Architecture: Instead of defining tool functions directly inside your agent script, tools live in a separate, independent program called an MCP server, and your agent loads them dynamically over a connection.
Adapters (
langchain-mcp-adapters): The client connects to an MCP server, queries its available tools, and wraps each one as a standard LangChainBaseToolso the agent cannot tell them apart from locally defined tools.Transport Mechanisms: The underlying layer carrying messages between the agent and the MCP server:
stdio: Runs the server locally as a subprocess, passing JSON messages over standard input/output streams without needing internet access.streamable_http/http: The modern MCP standard for remote, network-based servers.sse(Server-Sent Events): A legacy transport mechanism that is deprecated in the latest MCP specifications.Authorization: Supports authentication providers (such as OAuth flows for services like GitHub) to handle secure remote tool calls.
Conceptual Comparison: Tools vs. MCP Link to heading
| Feature | Local Tools (Lesson 5) | Model Context Protocol / MCP (Lesson 6) |
|---|---|---|
| Where Code Lives | Directly inside your agent’s codebase/script. | In a separate, independent MCP server program. |
| How It’s Defined | Using standard Python functions decorated with @tool and type hints. | Implemented in an MCP server (in any language) and exposed over a standardized protocol. |
| Integration Method | Passed directly into create_deep_agent(tools=[...]). | Fetched dynamically via MultiServerMCPClient and await client.get_tools(). |
| Execution Style | Synchronous execution inside the local Python interpreter runtime. | Asynchronous (async/await) communication across a transport layer (stdio or HTTP). |
| Primary Payoff / Benefit | Simplicity and speed: Easiest to implement for custom, single-agent logic. | Reusability and decoupling: Write a tool once as an MCP server, and any MCP-aware agent can reuse it instantly without custom code. |