LangChain Python
langchain-mcp-adapters for MCP; community RequestsToolkit for OpenAPI.Recap: the @tool decorator turns a function into a tool; pass the list to create_agent.
from langchain.tools import tool
from langchain.agents import create_agent
@tool
def search_database(query: str) -> str:
"""Search the customer database."""
return f"results for {query}"
agent = create_agent("openai:gpt-4o", tools=[search_database])
The langchain-mcp-adapters package ships MultiServerMCPClient, which connects to one or many MCP servers (stdio, SSE, or streamable HTTP) and returns a list of LangChain tools.
from langchain_mcp_adapters.client import MultiServerMCPClient
from langchain.agents import create_agent
client = MultiServerMCPClient({
"math": {
"transport": "stdio",
"command": "python",
"args": ["/path/to/math_server.py"],
},
"weather": {
"transport": "streamable_http",
"url": "http://localhost:8000/mcp",
},
})
tools = await client.get_tools()
agent = create_agent("anthropic:claude-sonnet-4-6", tools=tools)
Use RequestsToolkit from langchain_community to expose generic HTTP verbs, then pair with prompt-based OpenAPI guidance. There is no auto-generator from spec to typed tools in core; the langchain-community openapi planner is the closest first-class option.
from langchain_community.agent_toolkits.openapi.toolkit import RequestsToolkit
from langchain_community.utilities.requests import TextRequestsWrapper
toolkit = RequestsToolkit(
requests_wrapper=TextRequestsWrapper(headers={"Authorization": "Bearer …"}),
allow_dangerous_requests=True,
)
agent = create_agent(model, tools=toolkit.get_tools())
Not first-class in LangChain core. The recommended path is LangGraph's RemoteGraph (see next card) — wrap a deployed graph and embed it as a tool or subgraph.
Open the gRPC / Thrift / custom-RPC client inside the body of an @tool-decorated function. LangChain doesn't add anything special; the tool is just a callable.
Mechanism
All external tool sources are converted to LangChain BaseTool instances by adapter packages.
Notes
Each remote source requires a separate adapter package. Connection lifecycle and authentication are configured per-adapter.