What cleaning removes
| Pasted | Result |
|---|---|
abc123 — a leading space | removed |
"abc123" — quotes | removed |
Bearer abc123 | the word is removed — it is ours to add |
abc123 — a trailing space | removed |
abc 123 — a space inside | refused |
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 itimport os
api.mcp.update("example", token=os.environ["EXAMPLE_TOKEN_NEW"])
api.mcp.update("example", token=None) # remove itDo 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.