# What is a function schema in function calling, and how do you write one a model calls correctly?

The description of a tool that a model reads before calling it, its name, what it does and a JSON Schema of its arguments. The model fills in the arguments; your code checks them and runs the function.

- Page: https://tecyfy.com/concepts/function-schema
- Subject: AI agents (https://tecyfy.com/concepts)
- Level: intermediate
- Also called: Tool Schema, Input Schema, Tool Definition

A function schema is the part of [function calling](https://tecyfy.com/concepts/function-calling) the model actually sees. The model never reads your function's code. It reads a name, a description and a list of arguments with their types, decides whether the tool fits the task, and writes the arguments as JSON. Your code checks them, runs the real function and sends the result back.

On the Claude API a schema looks like this:

```json
{
  "name": "shop_find_order",
  "description": "Look up one of the shop's orders by its order number. Returns the item, the status, the delivery date and the total. Use it whenever the customer gives an order number. It does not search by name: if there is no order number, ask for one.",
  "strict": true,
  "input_schema": {
    "type": "object",
    "properties": {
      "order_id": {"type": "string", "description": "The order number, such as KX-48213."}
    },
    "required": ["order_id"],
    "additionalProperties": false
  }
}
```

The `input_schema` is ordinary JSON Schema. The other fields are where most tools succeed or fail.

## The description does the work

Anthropic's documentation calls the description by far the most important factor in how well a tool is used, and asks for at least 3 to 4 sentences: what the tool does, when to use it and when not to, what each argument means, and what it will not return. A model choosing between 10 tools has nothing else to go on. "Gets an order" leaves it guessing whether the tool takes an order number, a name or an email address.

## Habits that prevent wrong calls

- **Name arguments so they cannot be misread.** `order_id` with an example beats `id`.
- **Prefix names with the service** (`shop_find_order`, `crm_find_customer`), so 2 tools from 2 systems never look alike.
- **Fewer, broader tools.** One tool that does a whole job is easier to pick than 3 that each do a third of it.
- **Return what the model needs, in words.** A product name instead of an internal number, and a short form by default: Anthropic's example result took 72 tokens in its concise form against 206 in full.
- **Write errors as instructions.** "No order KX-9921. Order numbers look like KX-48213" lets the model recover; "error 404" does not.

## Strict schemas

Without help, a model occasionally sends `"2"` where the schema says a number, or leaves out a required field. Setting `strict: true` on a Claude tool constrains the model's output to the schema, so the arguments always parse and always have the required fields. It does not make them right: a well-formed order number can still be the wrong customer's, which is why the function checks every call it runs.

## Related

- [Function Calling](https://tecyfy.com/concepts/function-calling): The developer's name for tool use. The model replies with the name of a function and its arguments in a fixed format, and your code runs it.
- [Tool Use](https://tecyfy.com/concepts/tool-use): Giving a model a list of things it can ask to have done, such as search the web or read a file. The model asks; the program around it does the work and hands back the result.
- [Structured Output](https://tecyfy.com/concepts/structured-output): A setting that makes a model's answer follow a JSON schema you give it, so your code can read fields such as a category or an order number without parsing free text.
- [Model Context Protocol](https://tecyfy.com/concepts/model-context-protocol): An open standard for connecting AI applications to tools and data. A system offered once as an MCP server works in any application that speaks MCP.
- [Agent](https://tecyfy.com/concepts/agent): A model that uses tools in a loop, deciding each next step from what the last one returned, until the task is done.

## Sources

- [Define tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/define-tools)
- [Strict tool use](https://platform.claude.com/docs/en/agents-and-tools/tool-use/strict-tool-use)
- [Writing effective tools for agents, with agents](https://www.anthropic.com/engineering/writing-tools-for-agents)
