Connectors
A Connector is a cloud capability of your Organization: functions your backend provides to the Sessions of every End User, such as an order lookup or a knowledge base search. Device functions are Client Tools instead. Your Application Server serves a Connector over the same Backend Connection that carries its Session connections, so it needs no public endpoint, no callback verification and no separate registration. The connection’s Organization API Key is the only credential; keep it in your backend. See authentication.
Declare a Connector
Section titled “Declare a Connector”Declaring is registering. The first declaration of a name creates the Organization’s Connector with that name and answers its connectorId. Later declarations of the same name, from any process or Key of the Organization, serve the same Connector and answer the same connectorId. There is nothing to activate, edit or deactivate.
With the official SDK, @tidblink/server 0.5.0 or later, serve it from your Organization client:
import { OrganizationClient } from '@tidblink/server';
const organization = new OrganizationClient({ baseUrl: process.env.AGENT_SERVICE_URL, apiKey: process.env.ORGANIZATION_API_KEY,});
const orders = await organization.serveConnector({ name: 'orders', tools: { get_order: { description: "Read one of the current user's orders", parameters: { type: 'object', properties: { orderId: { type: 'string' } }, required: ['orderId'], }, // Answer only with the data of the End User whose Session made the call. run: async ({ orderId }, { userId, signal }) => JSON.stringify(await db.orders.find(userId, orderId, { signal })), }, }, onError: (error) => log.warn(error),});
orders.connectorId; // reference it from a Templateawait orders.close(); // stop serving, for example on shutdownrun returns text, or a value the SDK sends as JSON; throw to report a failure, whose message the model sees. The SDK keeps a Backend Connection open, declares the Connector on every connection it opens and declares it again after a reconnect or connection.drain.
- The Connector name and each function name are lowercase letters and digits joined by single underscores, 1 to 29 characters. A name that does not follow the rule is refused rather than rewritten.
- The model sees each function as
mcp_<name>__<function>, for examplemcp_orders__get_order, and each call carries the declared function name. - An Organization has one Connector name space: the same name is the same Connector. An Application Server that serves Connectors for several owners keeps their names apart itself.
- A declaration holds at most 64 functions. Each
parametersis a JSON Schema withtype: "object"that may not requireasync, which the platform reserves for the model’s wait choice.
Reference it from a Template
Section titled “Reference it from a Template”A Template references a Connector by its connectorId, exactly like an MCP Server registration:
{ "tools": { "mcp": [{ "serverId": "conn_…" }] } }In Console, an Organization owner adds it under MCP & Connectors in the Template editor; every Connector declared on a Backend Connection is offered there, whether or not a process serves it now. Through the Organization Template API, put the same reference in content.tools.mcp. Connector references do not accept toolNames. Sessions created after the save can call the Connector’s functions; existing Sessions keep the references they started with.
GET /api/v1/org/connectors and GET /api/v1/org/connectors/{connectorId} read Connectors with the Organization API Key. A Connector record carries connectorId, displayName (the declared name), createdAt and updatedAt.
Each Turn freezes the declaration most recently served among the connections serving the Connector when it starts, or the Connector’s latest stored declaration when none serves it. A Connector never declared offers no functions, and the Turn proceeds without them.
The core sends each call as a tool.call to one connection serving the Connector:
| Field | Meaning |
|---|---|
callId |
Unique per call. Use it to deduplicate effects. |
sessionId, turnId |
The calling Session and Turn. |
userId |
The Session’s End User owner, also for Scheduler-started Turns. Act for that user; model arguments never name the caller. |
name |
The declared function name, without the mcp_ prefix. |
connector |
{ id, name } of the Connector. |
arguments |
The model’s arguments, validated against the declared parameters, without the platform’s async. |
claimBy, deadlineAt |
The end of the claim window and the result deadline. |
Calls come from any Session whose Template references the Connector. Map (organization, userId) to your own business account and authorize the call there.
Claim and deadlines
Section titled “Claim and deadlines”Execute a call only after tool.claim answers { "claimed": true }. Only the connection the call was sent to can claim it, within its claim window of 5 seconds, and the claim binds the call to that connection. A call nobody claims in time is reported to the model as not performed, and it is never offered to another connection. Submit the result with tool.result from any Backend Connection of the Organization within 60 seconds of publication. A claimed call without a result by deadlineAt has an unknown effect, and the model is told so. If the claim answer is lost, do not execute the call; submit an error result instead, since the claim may have been granted.
The model chooses for each call whether to wait for it or to continue and collect the result later in the same Turn. Both choices use the same claim window and deadline, and the Turn does not end before its calls have outcomes.
Results and errors
Section titled “Results and errors”output is the text the model receives; serialize structured results yourself. An error with a message tells the model that the function reported an error, with your message. The model sees these outcomes:
| Code | Meaning | Did your function run? |
|---|---|---|
invalid_arguments |
The arguments failed the declared schema. | No. |
forbidden |
The Session’s Organization did not match the Connector’s; the platform raises a security alert. | No. |
provider_unavailable |
No connection could take the call, nobody claimed it in time, or the Turn ended first. | No. |
result_unknown |
The call was claimed, but no result arrived by its deadline or before the Turn ended. | Possibly. |
remote_tool_error |
Your function reported an error; the model sees its message. | Yes. |
The platform never repeats a call. After result_unknown, reconcile by callId before assuming the effect did not happen.
When no process serves it
Section titled “When no process serves it”A Connector stays referenceable while no connection serves it. Turns then freeze its latest stored declaration, and each of its calls ends at once as not performed while the Turn continues. Serving it again makes new calls reach your connections.
Several processes and rolling deploys
Section titled “Several processes and rolling deploys”Any number of processes may serve the same name. The core sends each call to exactly one connection serving the Connector whose declaration of the called function matches the one the Turn froze: the connection holding the Session’s executing attachment when it is one of them, otherwise preferably one on the replica running the Turn. Any connection of the Organization may submit the result.
During a rolling deploy, old and new processes may declare different functions. A Turn freezes the newest declaration served when it starts. A call goes only to a connection whose declaration of that function is identical, so a process that changed or dropped the function never receives it; when no such connection is left, the call is not performed. Keep serving the previous declaration until the Turns that froze it have ended, or accept that their calls of changed functions end not performed. On connection.drain, open a new connection and serve your Connectors there before the old one closes; the SDK does this for you.
Without the SDK
Section titled “Without the SDK”Any language can serve a Connector over the Backend Connection: one WebSocket to /api/v1/org/backend/ws with the tidb-link.backend.v1 subprotocol and Authorization: Bearer <Organization API Key>, one JSON-RPC 2.0 message per text frame. backend-connection-v1.schema.json defines the messages as JSON Schema, and the API reference summarizes them; the examples below are formatted for reading, and each travels as one text frame. After the core’s hello, declare the Connector:
{ "jsonrpc": "2.0", "id": 1, "method": "connector.serve", "params": { "name": "orders", "tools": [ { "type": "function", "name": "get_order", "description": "Read one of the current user's orders", "parameters": { "type": "object", "properties": { "orderId": { "type": "string" } }, "required": ["orderId"] } } ] }}{ "jsonrpc": "2.0", "id": 1, "result": { "connectorId": "conn_…" } }Serving the same name again on this connection replaces its declaration. A call arrives as a notification:
{ "jsonrpc": "2.0", "method": "tool.call", "params": { "callId": "…", "sessionId": "…", "userId": "…", "turnId": "…", "name": "get_order", "connector": { "id": "conn_…", "name": "orders" }, "arguments": { "orderId": "4711" }, "claimBy": "2026-11-19T08:30:05.000Z", "deadlineAt": "2026-11-19T08:31:00.000Z" }}Claim it, and execute only after claimed: true:
{ "jsonrpc": "2.0", "id": 2, "method": "tool.claim", "params": { "callId": "…" } }{ "jsonrpc": "2.0", "id": 2, "result": { "claimed": true } }Then submit its result, or an error:
{ "jsonrpc": "2.0", "id": 3, "method": "tool.result", "params": { "callId": "…", "output": "{\"status\":\"shipped\"}" }}{ "jsonrpc": "2.0", "id": 4, "method": "tool.result", "params": { "callId": "…", "error": { "message": "Order 4711 does not exist." } }}A refused claim answers claimed: false with a reason; a refused result answers accepted: false with a reason. connector.withdraw with {"name":"orders"} ends this connection’s declaration while the connection stays open; closing the connection ends all of its declarations.
Connectors registered before Backend Connections
Section titled “Connectors registered before Backend Connections”Connectors registered for HTTP callbacks or tunnels are retired, and so are their registration, editing, Activation, catalog refresh and deactivation routes and the callback verification keys. Listing and reading Connectors no longer return them. The Template reference catalog, which the Console editor uses, lists them as unavailable, so you can see what an existing reference points at and remove it. A Template that references one keeps the reference and can still be saved; its Turns offer no functions from it and proceed. When such a Connector’s name is a valid Connector name, serving that name on a Backend Connection takes it over in place: it keeps its connectorId, so Templates that reference it need no change.