Skip to the workspace
Pebellslearn by building
Tools and the Model Context Protocol  ›  Lesson

Tool Definition — Describing a Tool So It Gets Used Well

Tool Definition 12 minA tool definition gives the model a specific name, a description of what the tool does and when to use it, and an input schema with types, required fields and allowed values.

ai agents / Tool Definition — Describing a Tool So It Gets Used Well

Explore each scene at your own pace.

01 · The rule

The rule

Tool Definition — Describing a Tool So It Gets Used Well

Tripmate has a tool called lookup with the description "Looks things up." It gets called for weather, for trains, for Asha's calendar — and fails at most of them. The code behind it is fine. The model simply cannot tell what the tool is for, because the definition is the only thing it sees.

The rule

The model sees only the definition — write it like documentation for a stranger.

A tool definition has three parts, and the model relies on each:

  • Name — short, specific, verb-first: search_trains, not lookup or tool2.
  • Description — what it does, when to use it, when not to, and what comes back.
  • Input schema — the arguments, their types, which are required, and allowed values. Most providers use JSON Schema for this.
{
  "name": "search_trains",
  "description": "Search scheduled trains between two stations on one date. Use this to find options before booking. Returns up to 10 trains with departure, arrival, class and fare. Does not book anything.",
  "input_schema": {
    "type": "object",
    "properties": {
      "from": { "type": "string", "description": "Origin station code, e.g. PUNE" },
      "to":   { "type": "string", "description": "Destination station code, e.g. JP" },
      "date": { "type": "string", "description": "Travel date as YYYY-MM-DD" },
      "class": { "type": "string", "enum": ["SL", "3A", "2A", "1A"] }
    },
    "required": ["from", "to", "date"]
  }
}

The enum limits class to four real values, the date format is spelled out, and "Does not book anything" tells the model this tool is safe to call freely.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.