# Tokens

Canonical URL: https://developers.iagenify.com/sdk/mcp/tokens/
Language: en

Encrypted at rest, returned only to the owner, never in a URL — and cleaned once on the way in, because the thing around a token is what usually breaks it.

Status: encrypted at rest · never in a URL · cleaned once

## What cleaning removes {#cleaning}

| Pasted | Result |
| --- | --- |
| `&nbsp;abc123` — a leading space | removed |
| `"abc123"` — quotes | removed |
| `Bearer abc123` | the word is removed — it is ours to add |
| `abc123&nbsp;` — a trailing space | removed |
| `abc 123` — a space inside | **refused** |

> **Why cleaning is not a politeness**
>
> A leading space, quotes or a copied « Bearer » make some servers refuse the header without ever reading the token — and the refusal points at the token while the problem is what surrounds it. A trailing space leaves the header readable and fails authentication, which is worse because it looks like a wrong token.

A space *inside* is refused with `mcp_token_malformed` rather than patched: rejoining it would be guessing which token was meant.

## At rest {#storage}

Encrypted, and decrypted only for the authenticated owner. [list()](/sdk/ref/mcp/list) never carries one; [get()](/sdk/ref/mcp/get) and [forAgent()](/sdk/ref/mcp/for-agent) do, because the package needs it to contact the server.

## Never in an address {#never-url}

It travels as a header. An address ends up in logs, in referrers and in history; a credential in one is a credential leaked at every hop.

## Rotating one {#rotating}

```javascript
await api.mcp.update("example", { token: process.env.EXAMPLE_TOKEN_NEW });
await api.mcp.update("example", { token: null });   // remove it
```

## Do not log what carries one {#logging}

`get()` and `forAgent()` return the token in the server object. Logging that object writes the credential to wherever your logs go.

- [update()](/sdk/ref/mcp/update): Rotating.
- [Errors](/sdk/mcp/errors): What a refused token looks like.

```python
import os

api.mcp.update("example", token=os.environ["EXAMPLE_TOKEN_NEW"])
api.mcp.update("example", token=None)   # remove it
```
