Skip to content
undertext developers
Skip to Content
undertext developers

MCP tools

The MCP server your users' agents connect to, how agents are authorised, and every tool they can call.

Your users' agents (Claude, Codex, or any client that speaks the Model Context Protocol) reach their documents through one MCP server per platform, run by Undertext. Agents talk to Undertext directly: your server approves each agent once, and never relays its edits or holds its tokens. For the approval step, see Connect agents.

Your platform's server

https://mcp.undertext.sh/acme

The last part is your platform's slug, from the console. Show the address wherever your users connect agents; GET /v1/platform gives it as mcp_url. An agent's tokens work only on the platform that issued them, so someone who uses two Undertext platforms connects their agent to each, and the agent keeps the two apart by server name (acme's read_document, say, beside another platform's).

The server names itself to agents by your slug and platform name, with your icon if you set icon_url on the platform. It speaks Streamable HTTP, statelessly, with JSON responses. It supports MCP protocol versions 2025-11-25, 2025-06-18, 2025-03-26 and 2024-11-05, and answers a client asking for another with the newest. A request may batch up to 20 messages.

How an agent is authorised

An agent needs nothing but the address. The rest follows the MCP authorization spec, with OAuth 2.1:

  1. The agent calls the server without a token and gets 401 with a WWW-Authenticate header pointing at the protected resource metadata, https://mcp.undertext.sh/.well-known/oauth-protected-resource/acme.
  2. That names the authorization server, whose issuer is the same address as the MCP server. Its metadata is at https://mcp.undertext.sh/.well-known/oauth-authorization-server/acme.
  3. The agent identifies itself in one of two ways. Most use a client ID metadata document: its client_id is the https address of a JSON document describing it, of at most 64 kB, which Undertext fetches (from public addresses only). Others register with dynamic client registration and get a client_id back; one that asks for client_secret_basic or client_secret_post, as Gemini's connected apps do, gets a client_secret too, and gives it with its client_id at the token endpoint, by HTTP Basic or in the form. Either way, it gives at most 10 redirect URIs of up to 2,000 characters, each over https, on a loopback address or in an app's own scheme, and the name it gives is the name people see, with the domain it comes from shown beside it.
  4. The agent opens the person's browser at the authorize endpoint, with PKCE (S256; plain is refused). Its redirect URI must be one it registered, or for one on a loopback address, the same on any port.
  5. Undertext has no sign-in of its own, so it sends the browser to your consent page with an agent request. You sign the person in, ask them, and approve or deny from your server.
  6. Undertext sends the browser back to the agent with an authorization code, and the agent exchanges it for tokens.

One address (an IPv6 one by its /64) can register 100 clients, and start 100 authorizations, an hour.

Access tokens last an hour, and work only at the address that issued them. Refresh tokens change each time they are used, and lapse after 90 days without use. A client with a secret keeps its refresh token instead, each use giving it another 90 days. One used again within a minute of its first use, as by two requests at once, gets new tokens too; used again after that, it ends all the agent's tokens, as someone else may hold a copy. Revoking the agent, through DELETE /v1/agents/:agent_id or by deleting its person, ends both at once.

What an agent may do

An agent acts for one person, and can never do more than they can:

  • With access: "all", it reaches every document its person can open, editing at most.
  • With access: "chosen", it reaches only the documents its person, or your server, gave it a role in: editor, suggester or viewer.

What it may do in a document is the lower of that and its person's role there now, checked on every call. If Ada becomes a viewer of a document, Ada's agent can only read it from that moment. An agent never owns a document, though it can start one for its person with create_document.

A document the agent may not open answers as if it didn't exist: "You have no access to document doc_8Hq2Lm4R."

Credit

Everything an agent writes, suggests or comments is credited to it, under the name its person gave it (at first, what its client calls itself) and its person's current name: Claude Code (Ada Lovelace's agent). Its words count as AI on the seal until a person shapes them. See Provenance.

Writing tools take an optional instruction: what the person asked for, in their words where the agent has them. It is shown beside the text the agent wrote, labelled as reported by the agent.

Suggest by default

The server's instructions tell agents to propose their changes, with suggest: true, unless their person asked them to edit the document directly. Each suggestion shows in the editor for people to accept or reject, and its optional comment starts the suggestion's discussion. Where the agent may only suggest, every edit is a suggestion whatever it passes.

Tools

Every tool that works on one document takes its document_id. Every tool that writes to a document also takes these optional arguments:

ArgumentTypeWhat it does
instructionstringWhat the person asked for, shown beside the text written.
suggestbooleanPropose the change instead of making it.
commentstringWith suggest, a note for whoever reviews the suggestion.

Blocks are addressed by the ids read_document gives them, such as 1234:5. Content goes in and comes out as GitHub-flavoured Markdown, with a person mentioned in the text written as a comment writes them, @[Grace Hopper](user:usr_9Tb3Wc1X), and an agent as @[Research](agent:agt_4Rk8Vn2Lp7Qs).

Inbox

ToolArgumentsWhat it does
list_inboxnoneWhat the agent's person, or another of their agents, asked of it by mentioning it and it hasn't dealt with yet, oldest first, 20 at a time: each item with its document, who mentioned it, and the whole comment thread as it is now, or the block and the words around a mention in the text.
mark_inbox_readitem_idsTakes items out of the inbox once the agent has dealt with them.

An MCP server can't call an agent, so the agent looks: the server's instructions tell it to check list_inbox when it starts working and whenever its person asks what's waiting, and list_documents and read_document add a line when its inbox holds something. Replying in or resolving a comment's thread takes that item out too. An item leaves on its own once its message is deleted or no longer mentions the agent, its thread is resolved or gone with its text or suggestion, or the agent may no longer open the document. Items are kept 90 days.

Finding documents

ToolArgumentsWhat it does
list_documentscursorThe documents the agent may open, newest first, 100 at a time, with what it may do in each: its person's documents with access: "all", or those it was given. Pass the next_cursor it returns for more.
search_documentsqueryBlocks matching words across those documents, best first, at most 20, each with its document_id, block id and the text around the match. "quotes" match a phrase, or goes between alternatives, and -word excludes.

Managing documents

ToolArgumentsWhat it does
create_documentmarkdown, instructionStarts a document owned by the agent's person, with the agent as an editor. Its first line is its title. Returns its document_id and link.
rename_documentdocument_id, nameNames the document for everyone; an empty name calls it by its first line again. Needs edit access.
list_trashnoneThe documents in its person's trash that the agent may restore.
trash_documentdocument_idMoves a document to its person's trash: for everyone if they own it, from their own list if it was shared with them. Deleted for good after 30 days.
restore_documentdocument_idBrings a document back from its person's trash, as it was.

The three trash tools work only on documents the agent was given edit access to, or with access: "all", and agents are told to use them only when their person asks. So are rename_document and create_document.

Reading

ToolArgumentsWhat it does
read_documentdocument_id, from_block_idThe document as Markdown, each block with its id, and its pending suggestions with theirs. About 40,000 characters at a time: each part says the from_block_id to continue from, and the first part has the outline.

Editing

ToolArgumentsWhat it does
replace_textdocument_id, find, replace, block_id, allReplaces plain text inside blocks, keeping its formatting. Matches within one run of text. block_id limits it to one block; all replaces every match instead of the first.
insert_markdowndocument_id, after_block_id, markdownInserts Markdown after a block, or at the top with "start".
replace_blockdocument_id, block_id, markdownReplaces one block with Markdown, which may be several blocks.
delete_blockdocument_id, block_idDeletes one block, images included.
append_markdowndocument_id, markdownAdds Markdown at the end.

All five also take instruction, suggest and comment, and answer with the blocks they changed.

Suggestions

ToolArgumentsWhat it does
accept_suggestiondocument_id, suggestion_idMakes a pending suggestion part of the document. Needs edit access.
reject_suggestiondocument_id, suggestion_idRejects a pending suggestion. Needs edit access, except to withdraw the agent's own.

Comments

ToolArgumentsWhat it does
list_commentsdocument_id, include_resolved, from_thread_idThe document's threads, oldest first: the block each is on, the text or suggestion it's about, and every message with its author. About 40,000 characters at a time.
add_commentdocument_id, block_id, quote, suggestion_id, commentStarts a thread on the first quote in a block, or on a suggestion with suggestion_id. A suggestion has one thread, so commenting on one that has it adds a reply.
reply_to_commentdocument_id, thread_id, commentReplies in a thread. Replying to a resolved thread reopens it.
resolve_commentdocument_id, thread_id, resolvedResolves a thread, or reopens it with resolved: false.
edit_commentdocument_id, thread_id, message_id, commentRewrites one of the agent's own messages.
delete_commentdocument_id, thread_id, message_idDeletes one of the agent's own messages. Deleting a thread's first message deletes the thread, which it may do only while nobody else has replied.

Agents may comment wherever they may suggest. To mention someone, which notifies them through your webhook, an agent writes @[Grace Hopper](user:usr_9Tb3Wc1X) with an id from list_people, in a comment or in the Markdown it writes into the document, as a suggestion or not.

Mentioning agents

A person can mention their own agents, and only theirs, as they mention people: by typing @ in a comment or the text, where the list shows their agents after the people, or as @[Research](agent:agt_4Rk8Vn2Lp7Qs) in Markdown. The agent finds it in its inbox: at once from a comment, or a minute after it's written in the text, as the text reads then. Only agents that may open the document can be mentioned, and an agent can mention its person's other agents the same way. An agent can mention its person too, to tell them what it did, which notifies them as anyone's mention does. A mention of someone else's agent is only its name: no inbox hears of it, and none of your webhooks do.

People

ToolArgumentsWhat it does
list_peopledocument_idWhom the agent may mention here: the document's members, and others who wrote in it or its comments and can still open it, its person among them, then its person's other agents that may open it. Each person comes with their Undertext user id, their name, the detail you gave them (such as an email address), and how to write their mention; each agent with its id, its name and its mention.

Images

ToolArgumentsWhat it does
read_imagedocument_id, srcReturns an image stored with the document, as read_document shows its address, for the agent to see.
add_imagedocument_id, after_block_id, url or data, altAdds a PNG, JPEG, GIF or WebP image after a block, from an https address or base64 data, stored with the document. alt describes it for people who can't see it.

Several tools answer with a link to the document, so the agent can hand it to its person. The link follows the Document URL pattern you set in the console or as document_url with PATCH /v1/platform, such as https://acme.com/docs/{document}. Without one, answers give the document's id alone.

Limits

WhatLimit
One part of read_document or list_commentsAbout 40,000 characters
list_documents100 documents a call
search_documents20 results
list_inbox20 items a call
One image1,900,000 bytes
Images in one document100 MB, shared with people's uploads
Messages in one request20

Agents share the editor with people, and people come first. Their edits go ahead of agents' in every document, and each agent request gets a short slice of work at a time, so a burst from an agent never holds typing back by more than a moment.

Your own tools

Undertext's server has the tools for documents: their text, suggestions, comments, people and images, and an agent's inbox. Folders, pins, workspaces and anything else your product keeps for itself aren't Undertext's. To give agents those, register tools of your own: the server lists them after its own, adds your instructions to its own, and forwards each call to your server. See Add your own agent tools.

On this page