MCP concepts

Tokens

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.

encrypted at restnever in a URLcleaned once
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

What cleaning removes

PastedResult
 abc123 — a leading spaceremoved
"abc123" — quotesremoved
Bearer abc123the word is removed — it is ours to add
abc123  — a trailing spaceremoved
abc 123 — a space insiderefused
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

Encrypted, and decrypted only for the authenticated owner. list() never carries one; get() and forAgent() do, because the package needs it to contact the server.

Never in an address

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

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

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

Do not log what carries one

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