# Tool Schemas — AI Agents and Tool Use

Source: https://www.geekswithgeeks.com/en/ai-agents-mcp/use-schemas

> Describe a tool with a name, a description and a JSON Schema for its inputs.

## Three parts

A tool definition has a **name**, a **description** and an **input schema** written in JSON Schema. The schema lists each parameter, its type, which are required and what values are allowed (for example an enum). The model uses this to decide when to call the tool and how to fill the arguments.

## From function to tool

A tool is a function plus a description the model can read. Your code validates, runs and reports back.

![Four stages: describe, validate, run, report.](assets/figures/ai-agents-mcp/section-2-map.svg) — Figure 2.1 — Describe, validate, run and report.

## A tool with an enum

The enum stops the model inventing a currency code. Descriptions on each property act as inline documentation.

```json
{
  "name": "convert_currency",
  "description": "Convert an amount between two currencies using today's rate.",
  "input_schema": {
    "type": "object",
    "properties": {
      "amount": { "type": "number", "description": "Amount to convert" },
      "from":   { "type": "string", "enum": ["INR", "USD", "EUR"] },
      "to":     { "type": "string", "enum": ["INR", "USD", "EUR"] }
    },
    "required": ["amount", "from", "to"]
  }
}
```

## Constrain with enums and ranges

The tighter the schema, the fewer invalid calls. Use `enum`, `minimum`, `maximum` and `required` rather than describing limits only in prose.

**Quiz:** What is the main benefit of an enum in a tool schema?

- [ ] It makes the tool faster
- [x] It restricts the model to valid values
- [ ] It hides the tool
- [ ] It replaces the description

*Answer:* It restricts the model to valid values. Listing allowed values prevents invented or misspelt arguments.
