Connectors¶
A connector is a remote MCP server the signed-in user adds to their agent: its tools join their
runs once they sign in to it and choose which tools to allow. django-ag-ui serves the routes
(connectors/, from 0.93.0); this package draws them in two places, as <ag-ui-connectors> and
as a panel inside <ag-ui-chat>. Both are the same view.
<ag-ui-connectors data-connectors-url="/agent/connectors/"></ag-ui-connectors>
<script type="module">
import { defineConnectors } from "@artooi/agents-web-components/connectors";
defineConnectors();
</script>
The element needs only its URL. It binds like the editor elements: for names a
chat's id, the chat property wins over for, and with neither it binds to the chat of an
enclosing <ag-ui-agents>. Bound to a chat directly, it reads the chat's data-connectors-url
when it has none of its own. Under a provider the URL is always the element's own, since the
provider's directory names no connectors route. The first screen has no back arrow. A no-build
page loads @artooi/agents-web-components/connectors/bundle.
In the chat, set data-connectors-url: a Connectors row appears in the header's
More menu, which is then always in the
row, and openConnectors() opens the same panel. Add data-connectors-button for a header
button instead of the row; on a narrow panel it moves into More like the other optional
controls. Under data-editors="external" the row or button fires ag-ui-open-editor with
editor: "connectors" instead of opening the panel. closeConnectors() returns to the
conversation, and Escape or the back arrow steps back one screen at a time.
Attributes¶
| Attribute | Read | Meaning |
|---|---|---|
data-connectors-url |
live on the element; in the chat, at connect | django-ag-ui's connectors/ route. Without it the element shows nothing and openConnectors() does nothing. |
data-connectors-button |
in the chat, at connect | A header button for the panel instead of the More row. |
data-connector-presets |
when the add form opens | A JSON array of {"name", "url", "token"?}. A preset fills the name and fills and locks the URL. "token": true asks for a token instead of opening a sign-in popup, then tests the server at once. On <ag-ui-connectors> its own, else the bound chat's. |
for |
live | The id of the chat to bind to. |
What it shows¶
The list. Each row is a connector with one of five statuses, plus off: connected (with how many of its tools are on), Needs authorization (Connect), Tools changed (Review), Refused by the URL policy (with the server's reason), Not reachable, and Off (Turn on). Opening the list tests each enabled, signed-in connector once, which makes one connection to each server.
Adding. Name and URL, or a preset. Save and connect opens a popup in the same click (so the
browser allows it), creates the connector, and points the popup at its authorize/ route. The
panel waits, with Open again (for a blocked or closed popup) and Cancel. The sign-in completes
only on the callback page's message, and only when both hold:
event.originis the origin ofdata-connectors-urlresolved againstdocument.baseURI;event.sourceis the popup this panel opened.
A message from another origin, or from another window on the right origin, is ignored. A
provider page that sends Cross-Origin-Opener-Policy cuts the popup off from the panel, so its
callback cannot post: when the popup reads closed with no message, the panel reads the list
again, and again each time the page regains focus, and completes once the connector reads signed
in. Until then it keeps waiting. With a
token preset the token is posted to authorize/ as {"token": "..."}; the server's flow reads it.
The tools. After the first test no tool is on, and Turn all on switches them all. Each tool
that is on asks before every call, or, where the server's policy allows it, can be set to Always
allow; where it does not, the choice is locked at Asks every time with the host's rule line.
Saving writes PUT connectors/<id>/, and the next run uses the new choice without a reload: the
server resolves the caller's connectors when each run starts.
Tools changed. When a test finds new, changed or removed tools, only those leave the run until approved: a new tool comes in off, a changed one keeps its choice, and a removed one is listed. Approve changes saves.
Off and Remove. Turn off keeps the sign-in and the choices; Remove deletes the connector and signs out of it.
In the conversation¶
Whose tool it is. django-ag-ui (0.93.0 and later) names the connector on each of its tools'
TOOL_CALL_START, as metadata.connector ({id, name, host}). The chat's card for that call
then carries a line under its head, "From Linear (mcp.linear.app), your connector", in every
data-tool-display mode; a card read back from a stored conversation carries it too, when the
store kept the call's metadata. The name and host are set as text. A tool the server marks
read-only still asks before every call: the line says where the call goes, never that it is safe.
Nothing to opt into.
Asking about a connector's call. The approval interrupt for a connector's call carries the
same metadata.connector, and the approval card shows the same line under its prompt. When
the chat has data-connectors-url, the card also offers "Always allow delete_issue", named by
the tool's own name on the server: the run offers it as <prefix>__<tool> (django-spec-agents'
connector toolset), and the box takes what follows the first __. It is left out for a
connector whose editable is false (django-ag-ui 0.94.0 and later), whose always-allow
answer the server would not apply.
Approving with the box ticked approves the call at once; the write runs beside the resumed
run and never holds it. The write reads the list, finds the connector by id and puts its entry
back whole, every approved tool as it was and this one always allowed, as the tools screen's
Save does. A policy that refuses (a 403 whose JSON body has an error string, such as "You
may not always allow delete_issue.") shows the server's rule in the box's place; any other
failure, a 403 that is not that JSON (Django's CSRF failure page, say: the write goes through
the chat's request(), so it needs the CSRF header the chat's headers or getHeaders set,
as the editors do), or a tool the entry has not approved and
allowed, shows "Always allow delete_issue was not saved, so it will ask again
next time." The call stays approved either way. Unticked, or denied, nothing is written. Two
ticked cards in one batch write one after the other, so the second keeps the first's tool. The
chat's own connectors list reloads once a write is saved; an <ag-ui-connectors> elsewhere on
the page shows it the next time it loads its list, since ag_ui.connectors_changed is the
server's event and the chat does not forge one. A tools screen starts each tool's choices from
the entry that list returned, never from an earlier test, so Save does not undo an Always
allow saved here. A host's own approvalRenderer draws neither
the line nor the box.
No MCP App views from a connector yet. An mcp-apps activity whose serverId starts with
connector- (django-spec-agents names each connector's toolset connector-<id>) is drawn as one
line, the connectorViewWithheld string, in place of the view, whoever registered the
mcp-apps renderer; the call's card stands as a plain result. A view from any other server is
unchanged.
Parts¶
| Part | What it is |
|---|---|
connector-rows |
The list. |
connector-row |
One connector; data-status is connected, auth, changed, refused, unreachable or off. |
connector-status |
The row's status line. |
connector-action |
The row's own button: Connect, Review or Turn on. |
connector-empty |
The empty state, with its Add button. |
connector-form |
The add form. |
connector-notice |
A notice paragraph: on the add form, the waiting screen and a connector's screen. |
connector-wait |
The waiting screen while the popup signs in; its spinner turns at --ag-ui-tool-spin-duration. |
connector-tools |
A connector's tool list. |
connector-tool |
One tool; data-status is the test's approved, changed or new. |
connector-tag |
A tool's New, Changed or Removed tag. |
connector-seg |
A tool's Ask and Always allow pair. |
new-connector-button |
The Add button in the view's bar, beside header-button. |
connector-provenance |
In the chat, the line on a connector's tool-call card and its approval card; data-connector-id is its id. |
approval-always |
On a connector call's approval card, the Always allow box and its label. |
approval-always-note |
The line in the box's place when its write was refused or failed. |
Strings¶
Every label is a key of the strings table, overridable like the chat's
(Internationalization): connectors, connectorAdd, connectorConnected,
connectorNeedsAuth, connectorChanged, connectorRefused, connectorUnreachable,
connectorOff, connectorAsk, connectorAlwaysAllow, connectorAsksEveryTime,
connectorTurnAllOn and the rest of the connector* keys in ConnectorsStrings. Templates take
{name}, {on} and {count}. In the chat, connectorProvenance ({name}, {host}) is the
line on a connector's card and connectorViewWithheld the line in place of its view;
approvalAlwaysAllow ({tool}) labels the approval card's box and approvalAlwaysAllowFailed
({tool}) is the line when its write failed.
Events¶
- A run that saves or removes a connector sends the CUSTOM event
ag_ui.connectors_changed(CONNECTORS_CHANGED_CUSTOM_NAME, value{id, name}). An open list in the chat, or in an element bound to it, loads again. - The popup's callback page posts
{type: "ag_ui.connector_authorized", id, ok}(CONNECTOR_AUTHORIZED_MESSAGE) to its opener. - The element answers
ag-ui-open-editorwitheditor: "connectors", as the editor elements do.