> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Nine Steps of a Tool Call

> Explains the nine-stage lifecycle of model-initiated tool calls and emphasizes user authorization to prevent unintended production actions.

Alan’s agent just issued a tool call against a live warehouse database and it ran in production — without explicit approval. He only noticed because he happened to be watching the trace.

To prevent surprises like this, it helps to understand the nine discrete stages of a tool call. The [Model Context Protocol Associate (MCPA) Certification](https://learn.kodekloud.com/user/courses/model-context-protocol-associate-mcpa-certification) walks these stages in order:

1. Declaration
2. Discovery
3. Exposure
4. Selection
5. Authorization
6. Invocation
7. Execution
8. Result
9. Integration

Five of these stages occur before any network traffic reaches a server. Below we review those pre-call stages first, then continue through invocation, execution, and result handling.

![A horizontal infographic titled "Nine Stages of a Tool Call" showing nine numbered steps (Declaration, Discovery, Exposure, Selection, Authorization, Invocation, Execution, Result, Integration) connected along a pipeline with a server icon above the invocation stage. Each step is represented by a teal circular node and grouped under phase labels like Discovery, Selection, Authorization, Execution, and Integration.](https://mintcdn.com/kodekloud-c4ac6d9a/0UyWJzvxepsOrybu/images/Model-Context-Protocol-Associate-MCPA-Certification/Messages-Tools-and-Sessions/Nine-Steps-of-a-Tool-Call/nine-stages-tool-call-infographic.jpg?fit=max\&auto=format\&n=0UyWJzvxepsOrybu\&q=85\&s=b276f2ca36bd43cdcc50b0b22954db1f)

## Quick overview (summary table)

| Stage | Purpose | Example / key artifact |
| - | - | - |
| Declaration | Server author publishes the tool, name, description, input schema | `warehouse_lookup` with `inputSchema` |
| Discovery | Host finds available tools from server | `tools/list` response |
| Exposure | Host transforms declarations into a model-readable summary | compact textual summaries shown to the model |
| Selection | Model chooses a tool and prepares arguments | model chooses `warehouse_lookup` with `sku` |
| Authorization | Host requests explicit user consent before calling the server | UI shows tool, server, and arguments together |
| Invocation | Host sends the authorized request to the server | `name` + `args` are transmitted by the host |
| Execution | Server runs the request and may stream progress | server-side processing and updates |
| Result | Server returns content and a `resultType` (complete or input\_required) | structured JSON payload |
| Integration | Client consumes and integrates the result into the session | agent acts on result or asks user for next steps |

## Stage 1 — Declaration

The tool author (server author) publishes each tool with:

* a name,
* a human-readable description, and
* an input schema that declares accepted arguments and types.

This schema is authoritative for what the tool expects.

## Stage 2 — Discovery

The host (client) queries the server for available tools (e.g., `tools/list`) and learns which tools exist. A minimal declaration might look like:

```json theme={null}
{
  "name": "warehouse_lookup",
  "description": "Stock by SKU",
  "inputSchema": {
    "sku": { "type": "string" }
  }
}
```

Hosts may cache tool lists, but see the determinism rules below.

## Stage 3 — Exposure

The host converts the server-provided declaration into a concise representation the model can read — names, descriptions, and schemas only. No secrets or internal metadata should be exposed. For example:

```text theme={null}
name: warehouse_lookup
description: Stock by SKU
inputSchema: { sku: string }
```

This is the representation the model uses to decide whether and how to use a tool.

## Stage 4 — Selection

After seeing exposed tool definitions, the model selects a tool and prepares the arguments it intends to supply. This selection is entirely the model’s output (it proposes the request), but the request is not yet executed.

## Stage 5 — Authorization (informed consent)

Before the host sends any network requests, it must obtain explicit informed consent from the user. The UI presented to the user must include the tool, the target server, and the exact arguments together — not just a generic statement that “the assistant wants to call a tool.”

Example UI mockup:

```text theme={null}
Allow tool call?
Tool: warehouse_lookup  ✓
Server: warehouse        ✓
Arguments:
  sku: "MILK-2L"        ✓

[Allow]  [Deny]
```

Always show the tool name, the server it will call, and the concrete arguments in the confirmation prompt. A vague confirmation like “assistant wants to use a tool” is insufficient for informed consent.

Only when the user explicitly allows the call does the host proceed to invocation.

## Stage 6 — Invocation and Stage 7 — Execution

Once authorized, the host sends the model’s requested tool name plus arguments to the server. The host owns the network connection; the model only generates the request content.

Typical request shape (with optional progress token in `_meta`):

```json theme={null}
{
  "name": "warehouse_lookup",
  "_meta": { "progressToken": "job-7" },
  "args": { "sku": "MILK-2L" }
}
```

The server executes the request. Responses can take several forms:

* Text: plain text results (e.g., "14 cartons of milk left on the fifth shelf").
* Media blocks: images or audio (base64-encoded with a MIME type).
* Resource links: pointers (e.g., `stock://milk`) that the server continues to manage.
* Structured content: data matching the declared output schema for client parsing.

Long-running calls can report incremental progress. If the host provided `_meta.progressToken`, the server should publish progress notifications with strictly increasing numeric values, for example:

```text theme={null}
progress: 25
progress: 50
progress: 75
```

Request timeouts are enforced by the host. If a user cancels:

* Over stdio: client sends `notification/cancelled` with the request ID.
* Over streamable HTTP: client closes the response stream.

## Result: response shape and semantics

Every result in the current revision includes a required `resultType`. Two values exist:

* `complete` — the server finished producing an answer.
* `input_required` — the server needs additional input from the user to continue.

Example (complete result):

```json theme={null}
{
  "content": [
    { "type": "text", "text": "14 cartons of MILK-2L left on shelf 5" }
  ],
  "resultType": "complete"
}
```

Example (server requests more input):

```json theme={null}
{
  "content": [
    { "type": "text", "text": "Which warehouse zone should be checked for this SKU?" }
  ],
  "resultType": "input_required",
  "outputSchema": {
    "zone": { "type": "string" }
  }
}
```

Compatibility note: older servers may omit `resultType`. Clients must treat such responses as `complete` for backward compatibility.

### Application-level errors

If a tool encounters an application-level error (e.g., item not found, service unavailable), the server returns an HTTP/JSON response whose payload indicates the error; this is not a transport/protocol failure. Example:

```json theme={null}
{
  "isError": true,
  "content": [
    { "type": "text", "text": "PL-4417 not found" }
  ],
  "resultType": "complete"
}
```

This ensures the model can see and react to application-level failures. Transport-level errors (e.g., dropped connections) remain separate and are not surfaced as model-readable payload.

Annotations provided by servers (e.g., `readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`) are untrusted metadata. Do not make authorization or security decisions based solely on these hints.

## Progress updates and continuations

When the server requests further input mid-call, it returns `resultType: "input_required"`, includes prompt text in `content`, and supplies an `outputSchema` describing required fields. The host displays the prompt (with context and any partial results), collects user input, and either resumes the existing call via the transport’s continuation mechanism or sends a follow-up invocation.

Example server prompt seeking more detail:

```json theme={null}
{
  "content": [
    { "type": "text", "text": "Please confirm warehouse zone to continue:" }
  ],
  "resultType": "input_required",
  "outputSchema": {
    "zone": { "type": "string", "description": "Zone identifier, e.g., A1, B2" }
  }
}
```

When the user replies, the host passes these values back to the server in the continuation request.

## Caching and determinism

Hosts do not need to refresh the tool list before every call, but `tools/list` must return a deterministic ordering so clients can cache safely. Example:

```text theme={null}
tools/list
1 check_shipment
2 book_slot
3 warehouse_lookup

tools/list (again)
1 check_shipment
2 book_slot
3 warehouse_lookup
```

Servers may mark results as cacheable with a TTL (milliseconds) and a cache scope (per-user or global) to indicate whether other clients on the server can reuse the response.

## End-to-end flow

Putting it together: declaration → discovery → exposure → selection → authorization → invocation → execution → result → integration.

Understanding and enforcing these stages — especially the authorization step — prevents models from performing unexpected actions on production systems and ensures users retain control over tool-driven side effects.

> [card] [Watch Video](https://learn.kodekloud.com/user/courses/model-context-protocol-associate-mcpa-certification/module/282d97e2-04f7-4beb-8301-695ecb3f3f99/lesson/8b349643-7700-49dd-8c20-6668639a27fe)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.