Connect agents
Let your users connect Claude, Codex or any MCP client to their documents, with your sign-in on the consent page and Undertext crediting every word the agent writes.
Your users can bring their own AI agents to the documents they keep in your app. An agent reads, suggests, edits and comments through Undertext's MCP server, and everything it writes is credited to it on the record and in the seal.
You build two things: a page that tells people how to connect an agent, and a consent page where they approve one. Undertext does the rest. It runs the MCP server and the OAuth sign-in, issues the agent's tokens, and checks what the agent may do on every call. Your server never holds an agent's token, which is why an agent's words can't be passed off as a person's, or a person's as an agent's.
How connecting works
Each platform has its own MCP address. For Acme Notes it is:
https://mcp.undertext.sh/acmeYour server can read it as mcp_url from GET /v1/platform.
When someone adds that address to their agent:
- The agent calls Undertext, learns it needs to sign in, and registers itself with Undertext's OAuth server. Undertext checks where the agent comes from: its host, such as
claude.ai, which the agent can't claim falsely. - The agent opens the person's browser at Undertext, which sends it straight on to your consent URL with a request id:
https://acme.com/undertext/connect?request=areq_5tNc81. - Your consent page signs the person in, as any page of your app would, and shows which agent is asking.
- When they click Allow, your server approves the request with your secret key, naming the signed-in user. Undertext answers with a URL, and you send the browser there.
- Undertext finishes the sign-in and gives the agent its tokens. From then on the agent talks only to Undertext, as your user's agent.
Tokens for one platform's address don't work on another's. Someone who uses two platforms built on Undertext connects their agent to each separately, and the agent keeps the two apart.
Set your consent URL
In the console, or with PATCH /v1/platform, enter the URL of your consent page, such as https://acme.com/undertext/connect. Until you set one, Undertext answers every connection attempt with an error telling the person that this platform doesn't accept agents yet.
Show people how to connect
Give your settings an Agents section that shows your MCP address and how to add it to the agents people use most. The address is the same for all your users; who they are is settled on the consent page.
claude mcp add --transport http acme https://mcp.undertext.sh/acmeThen run /mcp inside Claude Code and choose acme to sign in.
In every case, signing in opens the person's browser on your consent page.
Name the server after your product (acme above). Agents show tools grouped by server, so your users see acme rather than a name they don't recognise.
Build the consent page
The consent page is a normal page in your app, behind your normal sign-in.
-
Look up the request. Undertext tells you which agent is asking.
client.hostis verified;client.nameis what the agent calls itself. Asked for the signed-in user, it also tells you whether they've connected this client before, asagent, with the name they gave it.connect.ts app.get("/undertext/connect", requireSignIn, async (req, res) => { const request = await undertext.agentRequests.retrieve(String(req.query.request), { user: req.user.undertextUserId }); const documents = await undertext.users.listDocuments(req.user.undertextUserId); res.render("connect-agent", { requestId: request.id, agentName: request.client.name, // "Claude Code" agentHost: request.client.host, // "claude.ai" name: request.agent?.name ?? request.client.name, // what they'll call it documents: documents.data, }); });If the person isn't signed in,
requireSignInshould send them through your sign-in and back to this URL, query string included. Requests last 10 minutes; an expired one returns409 request_expired, and the person starts again from their agent. -
Ask the person. Show the agent's name and host together, such as "Claude Code (claude.ai) wants to work in your Acme Notes documents". Let them name it, as they'd tell apart two Claude Codes, and choose what it reaches:
- All documents: every document they can open, editing at most. This is what most people want.
- Chosen documents: only the ones they pick, each as an editor, suggester or viewer.
Keep it to one screen with Allow and Deny. This is the one moment every connection passes through, however the person set the agent up, so it's the place to name it.
-
Approve or deny on your server. Always name the signed-in user from your session, never from the form.
connect.ts app.post("/undertext/connect", requireSignIn, verifyCsrf, async (req, res) => { const { requestId, decision, name, access, documents } = req.body; if (decision !== "allow") { const { redirect_url } = await undertext.agentRequests.deny(requestId); return res.redirect(303, redirect_url); } const { redirect_url } = await undertext.agentRequests.approve(requestId, { user: req.user.undertextUserId, name, // "Research" access, // "all" or "chosen" documents, // with "chosen": { "doc_8Hq2Lm4R": "suggester", ... } }); res.redirect(303, redirect_url); }); -
Send the browser on. The
redirect_urlreturns the person to Undertext, which finishes the sign-in and hands them back to their agent. The page they land on tells them they can close it.
Approve only from a POST your own page sent, with your usual cross-site request protection. A request id alone proves nothing about who is approving it: someone could send another person a link to your consent page with their own request id. Showing the verified host, and asking before approving, is what protects your users.
Let people manage their agents
List a person's agents in the same Agents section, with what each is called, what each reaches, and a way to remove it.
const agents = await undertext.users.listAgents("usr_5Kq2Lm8R");
// [{ id: "agt_Qe71", name: "Claude Code", client_name: "Claude Code", host: "claude.ai", access: "all",
// connected_at: "2026-10-29T16:02:11Z", last_used_at: "2026-10-30T09:14:52Z" }]Show where each comes from beside its name: its host, as two agents can share a name but not a host, or for a local one, a command-line tool or desktop app, that it's on their computer, as its local address says nothing.
Name an agent. It's called what its client calls itself until its person names it, as they'd tell apart two Claude Codes. The name shows wherever the agent works, at once.
await undertext.agents.update("agt_Qe71", { name: "Research" });Remove an agent. Its tokens stop working at once, mid-task too.
await undertext.agents.revoke("agt_Qe71");Narrow what it reaches. Switch it to chosen documents, then give it a role in each:
await undertext.agents.update("agt_Qe71", { access: "chosen" });
await undertext.agents.putDocument("agt_Qe71", "doc_8Hq2Lm4R", { role: "suggester" });
await undertext.agents.deleteDocument("agt_Qe71", "doc_3pXw9KdA");A good place for per-document choices is your Share dialog: a row for each of the person's agents, with the same roles you offer people. Whatever you set, the agent never gets more than its person's own role in that document. See Share documents.
Hear about agents
Two webhook events keep your Agents section current without polling:
agent.connectedwhen someone approves an agent they hadn't connected before.agent.revokedwhen an agent is removed, by your call or because its user was deleted.
See Send notifications for receiving events, and the event reference for their fields.
What agents see
Agents get Undertext's document tools: listing, searching, reading, writing in Markdown, suggesting, and commenting. They're told to suggest unless their person asked them to edit directly. An assistant your product runs is an agent like any other, approved by each person on your consent page, and is told the same. So when its person asks it for text, such as a first draft, have it write with suggest: false and their request as instruction: where it may edit, that writes directly. Each edit is credited with the agent's name and its person's, such as "Claude Code (Ada Lovelace's agent)", in the margin, in the record and in the seal.
Folders, tags and anything else your app keeps itself aren't in Undertext's tools. To give agents those, register tools of your own, which Undertext's server lists beside its own and forwards to you; see Add your own agent tools.
Next
- MCP tools: every tool and what it may do.
- Agents: how agents are credited and limited.
- Agent requests and Agents in the API reference.