# initialize()

Canonical URL: https://developers.iagenify.com/sdk/ref/mcp-client/initialize/
Language: en

`client.initialize({ signal? }) → Promise<{ protocolVersion, … }>`

The handshake. It announces the revisions this client really speaks and settles on the newest both sides know.

Status: 30 s · announces honestly · falls back once

```javascript
const handshake = await client.initialize();
console.log(handshake.protocolVersion);   // what both sides agreed on
console.log(client.protocolVersion);      // the same, kept on the client
```

## It announces what it can speak {#honest}

> **Announcing a revision you do not speak is worse than announcing an old one**
>
> A server that implements the modern revision properly will refuse a handshake that claims it and then omits what it requires; an older server will quietly answer with its own revision, which hides the problem until something subtler breaks.

## How a revision is chosen {#negotiation}

The newest revision both sides know, taken from this client's ordered list. With nothing in common it raises `mcp_protocol_unsupported` rather than guessing.

## It falls back once, and only on the right signal {#fallback}

A modern server that refuses the modern discovery is retried with the older handshake. The fallback happens only on a protocol-level refusal — a 401, a redirect, a silence or a timeout already name the thing to fix, and replacing them with a second attempt would replace the real cause with a different one.

## Errors {#errors}

| Code | Status | When |
| --- | --- | --- |
| mcp_token_required | 401 | The server wants a token and none was given. |
| mcp_unauthorized | 401 | The token was refused. |
| mcp_redirect | 502 | A redirect. They are never followed. |
| mcp_protocol_unsupported | 502 | No revision in common. |
| mcp_unreachable | 502 | No answer. |
| mcp_timeout | 504 | Over 30 seconds. |

## api.mcp does this for you {#api-mcp}

[connect()](/sdk/ref/mcp/connect) initialises, lists and records the agreed revision — and `get(name, { refresh: true })` does it again later.

- [listTools()](/sdk/ref/mcp-client/list-tools): What comes next.
- [Protocol revision](/sdk/mcp/protocol-revision): The list, and why it matters.

```python
handshake = client.initialize()
print(handshake["protocolVersion"])   # what both sides agreed on
print(client.protocol_version)        # the same, kept on the client
```
