====== Common Tool Definitions ======
Pre-built function/tool JSON schemas for AI agents. Each tool is shown in both OpenAI and Anthropic format. Copy-paste ready.
**Last updated:** March 2026
===== web_search =====
==== OpenAI Format ====
{
"type": "function",
"function": {
"name": "web_search",
"description": "Search the web for current information on any topic.",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "The search query"
},
"num_results": {
"type": "integer",
"description": "Number of results to return (default: 5)",
"default": 5
}
},
"required": ["query"]
}
}
}
==== Anthropic Format ====
{
"name": "web_search",
"description": "Search the web for current information on any topic.",
"input_schema": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "The search query"
},
"num_results": {
"type": "integer",
"description": "Number of results to return (default: 5)",
"default": 5
}
},
"required": ["query"]
}
}
===== read_file =====
==== OpenAI Format ====
{
"type": "function",
"function": {
"name": "read_file",
"description": "Read the contents of a file at the given path.",
"parameters": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Absolute or relative file path to read"
},
"offset": {
"type": "integer",
"description": "Line number to start reading from (0-indexed)"
},
"limit": {
"type": "integer",
"description": "Maximum number of lines to read"
}
},
"required": ["path"]
}
}
}
==== Anthropic Format ====
{
"name": "read_file",
"description": "Read the contents of a file at the given path.",
"input_schema": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Absolute or relative file path to read"
},
"offset": {
"type": "integer",
"description": "Line number to start reading from (0-indexed)"
},
"limit": {
"type": "integer",
"description": "Maximum number of lines to read"
}
},
"required": ["path"]
}
}
===== write_file =====
==== OpenAI Format ====
{
"type": "function",
"function": {
"name": "write_file",
"description": "Write or overwrite a file with the given content.",
"parameters": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "File path to write to"
},
"content": {
"type": "string",
"description": "Content to write to the file"
},
"mode": {
"type": "string",
"enum": ["overwrite", "append"],
"description": "Write mode (default: overwrite)",
"default": "overwrite"
}
},
"required": ["path", "content"]
}
}
}
==== Anthropic Format ====
{
"name": "write_file",
"description": "Write or overwrite a file with the given content.",
"input_schema": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "File path to write to"
},
"content": {
"type": "string",
"description": "Content to write to the file"
},
"mode": {
"type": "string",
"enum": ["overwrite", "append"],
"description": "Write mode (default: overwrite)",
"default": "overwrite"
}
},
"required": ["path", "content"]
}
}
===== execute_code =====
==== OpenAI Format ====
{
"type": "function",
"function": {
"name": "execute_code",
"description": "Execute code in a sandboxed environment and return the output.",
"parameters": {
"type": "object",
"properties": {
"language": {
"type": "string",
"enum": ["python", "javascript", "bash"],
"description": "Programming language to execute"
},
"code": {
"type": "string",
"description": "Source code to execute"
},
"timeout": {
"type": "integer",
"description": "Execution timeout in seconds (default: 30)",
"default": 30
}
},
"required": ["language", "code"]
}
}
}
==== Anthropic Format ====
{
"name": "execute_code",
"description": "Execute code in a sandboxed environment and return the output.",
"input_schema": {
"type": "object",
"properties": {
"language": {
"type": "string",
"enum": ["python", "javascript", "bash"],
"description": "Programming language to execute"
},
"code": {
"type": "string",
"description": "Source code to execute"
},
"timeout": {
"type": "integer",
"description": "Execution timeout in seconds (default: 30)",
"default": 30
}
},
"required": ["language", "code"]
}
}
===== http_request =====
==== OpenAI Format ====
{
"type": "function",
"function": {
"name": "http_request",
"description": "Make an HTTP request to a URL and return the response.",
"parameters": {
"type": "object",
"properties": {
"method": {
"type": "string",
"enum": ["GET", "POST", "PUT", "PATCH", "DELETE"],
"description": "HTTP method"
},
"url": {
"type": "string",
"description": "Full URL to request"
},
"headers": {
"type": "object",
"description": "HTTP headers as key-value pairs",
"additionalProperties": { "type": "string" }
},
"body": {
"type": "string",
"description": "Request body (for POST/PUT/PATCH)"
}
},
"required": ["method", "url"]
}
}
}
==== Anthropic Format ====
{
"name": "http_request",
"description": "Make an HTTP request to a URL and return the response.",
"input_schema": {
"type": "object",
"properties": {
"method": {
"type": "string",
"enum": ["GET", "POST", "PUT", "PATCH", "DELETE"],
"description": "HTTP method"
},
"url": {
"type": "string",
"description": "Full URL to request"
},
"headers": {
"type": "object",
"description": "HTTP headers as key-value pairs",
"additionalProperties": { "type": "string" }
},
"body": {
"type": "string",
"description": "Request body (for POST/PUT/PATCH)"
}
},
"required": ["method", "url"]
}
}
===== database_query =====
==== OpenAI Format ====
{
"type": "function",
"function": {
"name": "database_query",
"description": "Execute a read-only SQL query against the database.",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "SQL query to execute (SELECT only)"
},
"database": {
"type": "string",
"description": "Database name or connection identifier"
},
"limit": {
"type": "integer",
"description": "Max rows to return (default: 100)",
"default": 100
}
},
"required": ["query"]
}
}
}
==== Anthropic Format ====
{
"name": "database_query",
"description": "Execute a read-only SQL query against the database.",
"input_schema": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "SQL query to execute (SELECT only)"
},
"database": {
"type": "string",
"description": "Database name or connection identifier"
},
"limit": {
"type": "integer",
"description": "Max rows to return (default: 100)",
"default": 100
}
},
"required": ["query"]
}
}
===== calculator =====
==== OpenAI Format ====
{
"type": "function",
"function": {
"name": "calculator",
"description": "Evaluate a mathematical expression and return the result.",
"parameters": {
"type": "object",
"properties": {
"expression": {
"type": "string",
"description": "Mathematical expression to evaluate (e.g., '2 * (3 + 4)')"
}
},
"required": ["expression"]
}
}
}
==== Anthropic Format ====
{
"name": "calculator",
"description": "Evaluate a mathematical expression and return the result.",
"input_schema": {
"type": "object",
"properties": {
"expression": {
"type": "string",
"description": "Mathematical expression to evaluate (e.g., '2 * (3 + 4)')"
}
},
"required": ["expression"]
}
}
===== send_email =====
==== OpenAI Format ====
{
"type": "function",
"function": {
"name": "send_email",
"description": "Send an email to the specified recipient.",
"parameters": {
"type": "object",
"properties": {
"to": {
"type": "string",
"description": "Recipient email address"
},
"subject": {
"type": "string",
"description": "Email subject line"
},
"body": {
"type": "string",
"description": "Email body content (plain text or HTML)"
},
"cc": {
"type": "array",
"items": { "type": "string" },
"description": "CC recipients"
},
"reply_to": {
"type": "string",
"description": "Reply-to email address"
}
},
"required": ["to", "subject", "body"]
}
}
}
==== Anthropic Format ====
{
"name": "send_email",
"description": "Send an email to the specified recipient.",
"input_schema": {
"type": "object",
"properties": {
"to": {
"type": "string",
"description": "Recipient email address"
},
"subject": {
"type": "string",
"description": "Email subject line"
},
"body": {
"type": "string",
"description": "Email body content (plain text or HTML)"
},
"cc": {
"type": "array",
"items": { "type": "string" },
"description": "CC recipients"
},
"reply_to": {
"type": "string",
"description": "Reply-to email address"
}
},
"required": ["to", "subject", "body"]
}
}
===== Format Differences Cheat Sheet =====
^ Aspect ^ OpenAI Format ^ Anthropic Format ^
| Wrapper | ''{"type":"function","function":{...}}'' | Top-level object |
| Schema key | ''parameters'' | ''input_schema'' |
| JSON Schema | Standard JSON Schema | Standard JSON Schema |
| Tool choice | ''tool_choice: "auto"'' | ''tool_choice: {"type":"auto"}'' |
| Tool result | ''role: "tool"'' message | ''tool_result'' content block |