LangChain Agent Tools in 2026: Every Built-in Tool and How to Use It
LangChain agent tools explained one by one: search, Wikipedia, arXiv, Python execution, SQL toolkit, custom tools and MCP integration, with code examples.
💡 What You Will Learn
LangChain agent tools explained one by one: search, Wikipedia, arXiv, Python execution, SQL toolkit, custom tools and MCP integration, with code examples.
📜 Table of Contents
LangChain Agent Tools: Built-in Tools and How to Use Them
LLMs can think but not act: they do not know today's news, cannot run code or query your database. LangChain (143k+ stars on GitHub) solves this by giving models tools. This article explains each built-in tool with ready-to-copy code.
How Tools Work in an Agent
The agent loop: model receives a question โ decides it needs information โ the framework calls the right tool โ results are fed back into context โ model continues until a final answer. The tool's name and description decide whether the model picks it, so descriptions matter more than implementations.
Built-in Tools
TavilySearchResults โ web search requiring a Tavily API key; returns results with source links. Best for real-time info (news, prices, docs). Free tier has monthly quota; check the official site. WikipediaQueryRun โ free, no key. Good for factual questions; content can lag behind breaking news. ArxivQueryRun โ free. Searches arXiv papers by keyword; useful for literature review. PythonREPLTool โ lets the model write and execute Python. Security warning: the model runs code on your machine; only use in trusted environments. SQLDatabaseToolkit โ converts natural language into SQL. Includes sub-tools for listing schemas, executing queries and checking errors. Great for "chat with your database". Others: DuckDuckGoSearchRun (free, no key), Requests tools (HTTP), ShellTool (shell commands, risky), SerpAPI/GoogleSearch (need keys).
Custom Tools with @tool
from langchain_core.tools import tool
@tool
def get_stock_price(symbol: str) -> str:
"""Get the latest price for a stock. symbol is a ticker like AAPL."""
return f"{symbol}: $XXX"
The docstring must say what the tool does, what parameters mean, and an example. Type annotations are converted into the JSON schema the model sees.
MCP Integration (2026 trend)
from langchain_mcp_adapters.tools import load_mcp_tools
tools = await load_mcp_tools(session)
Any MCP server can be loaded as tools directly, no adapter code needed. Thousands of ready-made MCP servers exist on GitHub.
Best Practices
- Be specific in tool descriptions
- Add
handle_tool_error=Trueso a tool crash does not kill the agent - Use
llm.bind_tools(tools)for native tool-calling instead of parsing JSON - Keep tool count small (5-8 works best)
- Gate dangerous tools (code exec, shell, DB writes) behind human approval
FAQ
Q: How is tool calling different from hallucination? A: With tools bound, the model emits a structured call request; the framework executes it and returns real results into context. Q: Are free search tools enough? A: DuckDuckGo is free and keyless, fine for low volume; for stable results consider paid search APIs (see official pricing). Q: Do custom tools require retraining? A: No. Tools are injected at runtime; changing a description takes effect immediately.
Note: LangChain APIs evolve quickly; check the official docs for the latest version.
❓ FAQ
Do I need a Tavily API key?
TavilySearchResults requires a free API key; DuckDuckGoSearchRun does not.
Can tools call other tools?
Yes, through agent routing or sub-agents in LangGraph.
Written by our editorial team; tools listed here are tested or verified against public sources. Links point to official sites or GitHub repos for reference only โ no paid placements.
