[ ABORT TO HUD ]
SEQ. 1
SEQ. 2
SEQ. 3

Defining Tool Schemas

🛠️ Tools & Functions9 min70 BASE XP

Tools Give AI Hands

Tools are functions the AI can call to fetch data or mutate state. They are the most powerful part of MCP.

Registering a Tool with Zod

The TypeScript SDK highly recommends using the zod library for argument validation.

import { z } from "zod";

server.tool(
  "calculate_tax",
  "Calculate sales tax for a given purchase amount",
  {
    amount: z.number().describe("The total purchase amount"),
    param_state: z.string().describe("Two-letter state code")
  },
  async ({ amount, param_state }) => {
    return { content: [{ type: "text", text: `Tax is high in ${param_state}` }] };
  }
);
🎯 Pro Tip: The LLM reads the description of the tool and the descriptions of every parameter. The clearer your Zod descriptions, the better the AI performs!
SYNAPSE VERIFICATION
QUERY 1 // 3
What are MCP Tools used for?
Compressing text data
Allowing the AI to fetch dynamic data or mutate external state
Styling user interfaces
Encrypting database passwords
Watch: 139x Rust Speedup
Defining Tool Schemas | Tools & Functions — MCP Academy