AI can think. But it can't DO anything — until you give it tools.
In 30 minutes you'll build a tool system, create a skill, and understand MCP.
For absolute beginners. No assumed knowledge.
Ask any AI model to write you a sonnet about quantum physics. It'll do it beautifully. Ask it what time it is. It can't tell you.
An LLM without tools is a brain without hands. Let's prove it.
The AI can talk about math, but it can't actually calculate. It can describe weather patterns, but can't check today's forecast. It knows about files and databases, but can't read your documents.
Pure language models are brilliant but helpless.
GPT-4 Paper — Why even the most advanced models need tools
Function calling is how you give AI hands. You describe a tool as a JSON schema. The model reads the schema and decides when to call it.
Let's build the simplest possible tool: a calculator.
const calculatorTool = {
type: 'function',
function: {
name: 'calculator',
description: 'Evaluate a math expression like 847 * 293',
parameters: {
type: 'object',
properties: {
expression: {
type: 'string',
description: 'The math expression to evaluate'
}
},
required: ['expression']
}
}
};
// The actual function that does the work
function calculator({ expression }) {
try {
return eval(expression); // Don't use eval in production!
} catch (error) {
return `Error: ${error.message}`;
}
}
Here's what happens when the AI wants to use your tool:
// 1. You send the tool description with your message
{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "What's 847 × 293?"}],
"tools": [calculatorTool]
}
// 2. The AI responds with a tool_call (not text!)
{
"role": "assistant",
"tool_calls": [{
"id": "call_abc123",
"type": "function",
"function": {
"name": "calculator",
"arguments": "{\"expression\": \"847 * 293\"}"
}
}]
}
// 3. You execute the function and send the result back
{
"role": "tool",
"tool_call_id": "call_abc123",
"content": "248071"
}
// 4. The AI sees the result and responds normally
{
"role": "assistant",
"content": "847 × 293 = 248,071"
}
The AI never sees your code. It only sees the JSON description. If your description is wrong, the AI will use the tool incorrectly.
OpenAI Function Calling Guide — Complete documentation
What happens when the model needs multiple tools? Or needs to call the same tool twice? Welcome to the ReAct loop: Reason → Act → Observe → Repeat.
In Build Your Own AI Agent, you'll see ReAct in action — chaining multiple tools together in a real conversation loop. Instead of one calculator call, you'll build an agent that:
The ReAct pattern you're learning here becomes the foundation for agents that can orchestrate complex, multi-step workflows.
Let's build an agent with multiple tools: calculator, clock, and weather.
const tools = [
{
type: 'function',
function: {
name: 'calculator',
description: 'Evaluate math expressions',
parameters: {
type: 'object',
properties: {
expression: { type: 'string' }
},
required: ['expression']
}
}
},
{
type: 'function',
function: {
name: 'get_current_time',
description: 'Get the current time',
parameters: { type: 'object', properties: {} }
}
},
{
type: 'function',
function: {
name: 'get_weather',
description: 'Get weather for a city',
parameters: {
type: 'object',
properties: {
city: { type: 'string' }
},
required: ['city']
}
}
}
];
// The agent loop that handles multiple tool calls
async function agentLoop(userMessage) {
const messages = [{ role: 'user', content: userMessage }];
while (true) {
const response = await fetch(API_ENDPOINT, {
method: 'POST',
headers: { /* auth headers */ },
body: JSON.stringify({
model: 'gpt-4o-mini',
messages: messages,
tools: tools
})
});
const data = await response.json();
const message = data.choices[0].message;
messages.push(message);
// If no tool calls, we're done
if (!message.tool_calls) {
return message.content;
}
// Execute each tool call
for (const toolCall of message.tool_calls) {
const result = executeFunction(toolCall.function.name, toolCall.function.arguments);
messages.push({
role: 'tool',
tool_call_id: toolCall.id,
content: result
});
}
// Loop back — model will see the results and decide what to do next
}
}
ReAct Paper — The original research on reasoning and acting
A tool is one function. A skill is a package: multiple tools + instructions + context.
Let's build a complete file management skill with multiple related tools.
read_file — Read contents of a filewrite_file — Write content to a filelist_directory — List files in a directorysearch_files — Search for files by name or content// SKILL.md — Instructions for the AI agent
/*
# File Manager Skill
## Purpose
This skill gives you complete file system access. Use it to help users organize, read, and manipulate files.
## When to use
- User asks about files or directories
- User wants to read, write, or search files
- User needs help organizing their filesystem
## Guidelines
- Always use list_directory before trying to read files
- Ask for confirmation before writing/deleting files
- Use relative paths when possible
- Be helpful but respectful of user's file structure
*/
const fileManagerTools = [
{
type: 'function',
function: {
name: 'read_file',
description: 'Read the contents of a file',
parameters: {
type: 'object',
properties: {
filepath: { type: 'string', description: 'Path to the file to read' }
},
required: ['filepath']
}
}
},
{
type: 'function',
function: {
name: 'write_file',
description: 'Write content to a file',
parameters: {
type: 'object',
properties: {
filepath: { type: 'string', description: 'Path to write to' },
content: { type: 'string', description: 'Content to write' }
},
required: ['filepath', 'content']
}
}
},
{
type: 'function',
function: {
name: 'list_directory',
description: 'List files and folders in a directory',
parameters: {
type: 'object',
properties: {
path: { type: 'string', description: 'Directory path to list' }
},
required: ['path']
}
}
},
{
type: 'function',
function: {
name: 'search_files',
description: 'Search for files by name or content',
parameters: {
type: 'object',
properties: {
query: { type: 'string', description: 'Search query' },
directory: { type: 'string', description: 'Directory to search in' }
},
required: ['query']
}
}
}
];
Skills are how you teach an agent a new job. The SKILL.md file is like a job description — it tells the agent when and how to use the tools.
LangChain Tools — How frameworks organize tools into skills
Model Context Protocol is USB-C for AI tools. One standard way for any AI to connect to any tool server.
Every model needs custom integration with every tool = 9 different APIs
Every model speaks MCP = one standard, everything connects
MCP is JSON-RPC over stdio. Your tool server speaks a standard protocol.
// A minimal MCP server in JavaScript
const { Server } = require('@modelcontextprotocol/sdk/server/index.js');
const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js');
class CalculatorServer {
constructor() {
this.server = new Server({
name: 'calculator-server',
version: '1.0.0'
}, {
capabilities: {
tools: {}
}
});
// Register our calculator tool
this.server.setRequestHandler('tools/list', async () => ({
tools: [{
name: 'calculator',
description: 'Evaluate mathematical expressions',
inputSchema: {
type: 'object',
properties: {
expression: {
type: 'string',
description: 'The mathematical expression to evaluate'
}
},
required: ['expression']
}
}]
}));
// Handle tool calls
this.server.setRequestHandler('tools/call', async (request) => {
if (request.params.name === 'calculator') {
const { expression } = request.params.arguments;
try {
const result = eval(expression); // Don't use eval in production!
return {
content: [{
type: 'text',
text: `Result: ${result}`
}]
};
} catch (error) {
return {
content: [{
type: 'text',
text: `Error: ${error.message}`
}],
isError: true
};
}
}
});
}
async run() {
const transport = new StdioServerTransport();
await this.server.connect(transport);
}
}
// Start the server
const server = new CalculatorServer();
server.run().catch(console.error);
MCP Specification — The complete protocol documentation
MCP on GitHub — Reference implementations and examples
You just built the foundation of every AI agent system:
This isn't a demo. This is how ChatGPT Code Interpreter works. How Cursor writes code. How every AI agent that "does things" actually does them.
The difference between a chatbot and an agent? Tools.
With tools, your AI can control anything with an API.
The question isn't what's possible. Everything with an API is possible.
The question is what you'll build first.
Test yourself. No peeking. These questions cover everything you just learned.
1. Why do large language models need tools to be truly useful?
2. What is the key component needed to define a tool for function calling?
3. In the ReAct loop, what do the four steps represent?
4. What's the difference between a tool and a skill?
5. What problem does the Model Context Protocol (MCP) solve?