The Tool-Use Landscape
As AI assistants become more capable, the ability to use external tools has become essential. Multiple approaches have emerged, each with different design philosophies, capabilities, and trade-offs. This guide compares the three major standards.
OpenAI Function Calling
Overview
OpenAI's function calling allows GPT models to generate structured JSON output that matches a defined schema. The model decides when to call functions and with what arguments, but execution happens on the client side.
How It Works
response = openai.chat.completions.create(
model="gpt-4-turbo",
messages=[{"role": "user", "content": "What's the weather in Tokyo?"}],
tools=[{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["location"]
}
}
}]
)
Strengths
- Native integration with OpenAI models
- Simple to implement — just define JSON schemas
- Parallel function calling support
- Client controls execution (security benefit)
Limitations
- OpenAI-specific — not a cross-platform standard
- No persistent connections or resource streaming
- Function definitions sent with every request (token cost)
- No built-in discovery mechanism
Anthropic Model Context Protocol (MCP)
Overview
MCP is an open protocol for connecting AI assistants to external systems through standardized servers. It defines tools, resources, and prompts as first-class concepts with persistent connections.
How It Works
MCP uses a client-server architecture with JSON-RPC messaging:
// Server exposes tools
server.setRequestHandler(CallToolRequestSchema, async (request) => {
if (request.params.name === "get_weather") {
const { location } = request.params.arguments;
const weather = await fetchWeather(location);
return { content: [{ type: "text", text: weather }] };
}
});
// Client discovers and calls tools through the protocol
const tools = await client.listTools();
const result = await client.callTool("get_weather", { location: "Tokyo" });
Strengths
- Open standard — not tied to one AI provider
- Persistent connections with efficient resource streaming
- Capability discovery — clients learn what servers offer
- Separation of concerns — servers are independent services
- Growing ecosystem of pre-built servers
Limitations
- More complex to set up than simple function calling
- Currently best supported in Claude Desktop
- Requires running server processes
LangChain Tools
Overview
LangChain provides a framework abstraction for tools that works across different AI models. It's a library-level solution rather than a protocol, focusing on developer experience and composability.
How It Works
from langchain.tools import BaseTool
from langchain.agents import create_react_agent
class WeatherTool(BaseTool):
name = "weather"
description = "Get current weather for a location"
def _run(self, location: str) -> str:
return fetch_weather(location)
tools = [WeatherTool()]
agent = create_react_agent(llm, tools, prompt)
result = agent.invoke({"input": "What's the weather in Tokyo?"})
Strengths
- Model-agnostic — works with OpenAI, Anthropic, local models
- Rich ecosystem of pre-built tools
- Composable chains and agents
- Good developer experience with Python
Limitations
- Framework lock-in — tools are LangChain-specific
- Additional abstraction layer adds complexity
- Not a wire protocol — can't interoperate with non-LangChain systems
Comparison Matrix
| Feature | OpenAI Functions | MCP | LangChain |
|---|---|---|---|
| Protocol Type | API parameter | Wire protocol | Library abstraction |
| Model Support | OpenAI only | Any (via clients) | Multiple |
| Connection | Per-request | Persistent | Per-request |
| Discovery | No | Yes | At runtime |
| Resource Streaming | No | Yes | Limited |
| Complexity | Low | Medium | Medium |
| Ecosystem | Via code | Server packages | Tool packages |
When to Use What
Choose OpenAI Function Calling When:
- You're exclusively using OpenAI models
- You need simple, quick tool integration
- Tools don't need persistent connections
Choose MCP When:
- You want provider-agnostic tool infrastructure
- You need persistent connections to data sources
- You're building for Claude or multiple AI platforms
- You want to contribute to an open ecosystem
Choose LangChain When:
- You're building complex agent workflows
- You need to switch between different AI providers
- You want extensive pre-built integrations
- Your team is comfortable with the LangChain ecosystem
Conclusion
The right choice depends on your specific needs. For simple integrations with OpenAI, function calling is straightforward. For interoperable, persistent tool infrastructure, MCP provides a robust foundation. For complex agent development with flexibility, LangChain offers a comprehensive framework. Many production systems combine these approaches based on specific requirements.