A tool is an executable capability that an agent or language-model application invokes to perform actions or access external functionality. Standardized interfaces let agents use search services, calculators, databases, files, and APIs without embedding each integration in the agent itself. section 9.3.1 section 13.1.4
from langchain_core.tools import Tool
from langchain_community.utilities import SerpAPIWrapper
os.environ["SERPAPI_API_KEY"] = "<SERPAPI_KEY>" #1
serpapi = SerpAPIWrapper() #2
search_tool = Tool(
name = "SerpAPI", #3
func = serpapi.run, #4
description = "A search engine tool to query real-time information
from the web."
)
Wrap a SerpAPIWrapper in a LangChain Tool, give it a name, connect its run function, and describe its purpose and expected input. section 9.4.3
Utility wrappers are not directly available to agents: embed each wrapper in a Tool instance before adding it to an agent’s toolset. The description matters because the language model uses it to decide whether and how to call the tool. section 9.3.1 section 9.4.3
A useful tool integration specifies:
- A callable function that performs one focused action and returns usable data or an error. section 13.2.7
- A name and description that identify the capability, its purpose, and the input it expects. section 9.3.1 section 9.4.3
- An execution path in which the agent decides whether to call the tool, receives its result, and produces a final response. section 9.4.3
- A protocol boundary when using MCP, where tools are distinct from resources and prompts and use standardized JSON-RPC requests. section 13.1.4
Search-enabled agent
Configure SerpAPI and OpenAI credentials, create a Search Tool from SerpAPIWrapper, and pass it to initialize_agent(). For a question about current events or a person, the agent can issue a search query, inspect the returned observation, and formulate an answer. The same pattern supports current-weather queries and structured weather results. section 9.3.1
MCP tools extend the pattern beyond LangChain. Register functions with @mcp.tool(); examples fetch weather, convert temperature, and retrieve PDF or text-file contents. The MCP Inspector can list and run these tools to validate their behavior. section 13.2.7 section 13.2.9













