urlstringrequiredThe server's address. https only.
namestringIts name here. Derived from the domain when absent.
tokenstringThe access token. Encrypted at rest, never put in a URL.
toolsstring[]noneWhich tools are allowed. Without this list, none is.
categorystringexecread · write · exec — the permission its tools carry.
labelstringA display name.
The four steps
- The address is checked by the platform — scheme, and that it resolves to a public address.
- The package shakes hands with the checked address and negotiates a revision.
- It reads the server's tool list.
- The connection is saved, with the catalogue and the revision that was agreed.
In an application the package often runs on a server of yours. An unchecked address would be a request from inside your network to wherever the address pointed — and the answer handed back. Checking first is what makes an address somebody typed safe to accept.
Nothing is allowed unless you list it
// Connected, and completely inert — no tool is allowed
await api.mcp.connect({ url, name: "example" });
// Two tools, read-only
await api.mcp.connect({ url, name: "example", tools: ["search_docs", "get_issue"], category: "read" });# Connected, and completely inert — no tool is allowed
api.mcp.connect(url=url, name="example")
# Two tools, read-only
api.mcp.connect(url=url, name="example", tools=["search_docs", "get_issue"], category="read")A declaration costs tokens on every turn, so a server offering ninety tools would add a fixed cost to every step of every run without anyone asking for it. Connecting first and choosing afterwards with update() is the usual shape.
exec by default, deliberately
The protocol carries a read-only hint, but the server declares it about itself. exec means its tools are asked in every mode but full access — set read only when you know what the tools do.
The token is cleaned once
Surrounding spaces, quotes and a copied « Bearer » are removed — they make some servers refuse the header without ever reading the token. A space inside is refused rather than patched: guessing which token was meant is worse than saying so.
Errors
| Code | Status | When |
|---|---|---|
| url_required | 400 | No address. |
| url_not_https | 400 | Plain http would send the token unencrypted. |
| url_blocked | 400 | The address does not resolve publicly. |
| mcp_token_malformed | 400 | The token contains a space. |
| mcp_token_required · mcp_unauthorized | 401 | The server wants a token, or refused the one given. |
| mcp_redirect | 502 | The server answered with a redirect. They are never followed. |
| mcp_protocol_unsupported | 502 | No revision in common. |
| mcp_unreachable · mcp_timeout | 502 · 504 | No answer in time. |