Reference
Bring your own LLM (MCP)
Any MCP-capable assistant — Claude Code, Claude Desktop, a hosted web agent, or anything else that
speaks the Model Context Protocol — can connect to a live Studio session: locally via
@tropelang/mcp, or remotely via a host-issued web-agent link. The assistant reads the
document as it's being edited and calls the full analysis engine: validation, trope recognition,
evaluation, coverage. Your editor stays the source of truth.
How it works
The MCP server joins the session like any other participant. The document arrives over the session's
own sync (so trl_read_document is current to the keystroke, including unsaved edits — no
Drive reads), and engine calls travel the same connection to the session host's browser, where the
WASM core runs. Results always reflect the host's engine version and loaded
corpus — the assistant sees exactly what the editor sees.
The connection is visible, not ambient: the client appears in the session's participant list as a "name · MCP" chip, and the host's toolbar shows a ⚙ pill with per-client call counts while serving. Hosts can remove the client like any participant.
Requirements
- a live session
- Sessions are explicit — the file's host starts one from the Live button in editor.tropelang.com. With no session running, tools return a clear "start the live session" error (the engine runs in the host's browser, so there's nothing to call without one).
- Drive access to the file
-
Authorization is the file's own Google Drive ACL — the same rule as joining a session in the
browser. The signed-in account must be able to read the file and must have opened it in
Studio once (the
drive.filescope only covers files picked in the app). - a Google sign-in
-
First run opens a browser sign-in; the token is cached locally
(
~/.config/tropelang/mcp-auth.json) so later runs are silent. Configuration details — including the OAuth client environment variables — are in the package README.
Setup
Claude Code:
claude mcp add tropelang -- npx -y @tropelang/mcp --file <driveFileId> Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"tropelang": {
"command": "npx",
"args": ["-y", "@tropelang/mcp", "--file", "<driveFileId>"]
}
}
} The file id is the Drive id from the document's URL (or the session invite link). The server connects lazily on the first tool call, so registering it never blocks on sign-in.
Web agents (no local process)
Hosted assistants — anything that takes a remote MCP server URL rather than launching a local command —
connect through mcp.tropelang.com. Setup is once per agent, ever: create
the agent under account menu → Web agents…, copy its stable URL, and paste it into the
assistant's MCP configuration. No Google sign-in on the agent's side — the URL is the authorization.
After that, documents connect with no copying at all: the Live panel lists your agents,
and Connect authorizes the current document server-side — the agent's next tool call simply
targets it. One agent, one connector entry, any number of documents;
trl_sessions / trl_connect let the assistant list and switch between
connected documents from inside the conversation.
- host-issued, host-revocable
- Only the document's host (Pro) can connect an agent, and the Live panel lists every access with a one-click revoke that cuts the agent off immediately. Re-connecting flips a document between read-only and editable in place — the agent's URL never changes.
- the URL is shown once
- The agent's stable URL appears once, at creation — copy it then. (The server keeps only a hash, so it can't be re-displayed; if it's lost, create a new agent and update the connector.)
- visible while working
- An agent that's reading the document or calling the engine lights up active on its row in the Live panel — the host always sees who's using the session.
- same engine, same rules
- Calls run in the host's browser with the host's engine and corpus, under the same relay bounds as any participant. A web agent never touches Drive — saving stays with the humans.
- editing is opt-in, per link
-
Attach with Allow this agent to edit checked and the agent gets
trl_edit/trl_insert: string-matched edits applied through the same merge path as human keystrokes, so they compose with concurrent typing instead of clobbering it. The panel marks such links can edit. Unchecked (the default), the link is read-and-analyze — safe even if it leaks. - send work to the agent
-
The host can highlight text in Studio and click ✨ Ask agent to send an instruction
("revise this for me") with the selection attached. The agent receives it through
trl_wait_for_request— tell it to "wait for requests and handle them as they arrive" and it works the document live, edits landing in everyone's editor as they're made.
Clients that require an OAuth handshake for remote servers (rather than accepting a plain URL) can use
the mcp-remote bridge to connect, or the local (stdio) setup above.
Tools
- trl_read_document
- The live text — real-time, includes unsaved edits.
- trl_session_info
- Document name, last-saved Drive revision, who's in the session.
- trl_validate
- Diagnostics — errors and warnings with line numbers.
- trl_suggest
- Trope recognition: confirmed / possible / in-flight, with confidence, bindings, and spans.
- trl_eval
- Evaluation to fixpoint — which rules fired, every derived fact.
- trl_drams
- Coverage — density over coverage with the uncovered-facts gap list.
- trl_format
- Canonical-form preview (comments and original indentation are not preserved).
- trl_symbols · trl_links
- Declarations, and the reference graph between them.
- trl_explain
- Per-trope reasoning over matched and missing terms.
- trl_describe · trl_define
- A token's meaning in this document; a term's corpus definition.
- trl_corpus · trl_corpus_source
- The entire loaded corpus (every trope with bucket, category, and terms); one trope's full
.trlsource. - trl_engine_version
- The host's engine version — what every result above was computed with.
- trl_edit · trl_insert
- Live, merge-safe document edits — web agents only, and only on documents connected with editing allowed.
- trl_wait_for_request
- Long-poll for the host's "✨ Ask agent" requests — web agents only.
- trl_connect · trl_sessions
- Switch between connected documents; list them — web agents only.
Session rules the assistant lives under
The MCP client is a guest like any other: the host's session controls apply. If the host enabled require approval to join, the client knocks and waits for the host to admit it from the Live panel. If the host ends the session, removes the client, or declines the knock, tools report it plainly and stop — they never reconnect around a host's decision. Engine calls are bounded by the session relay (four in flight per client, 256 KB payloads, 30-second timeout), which keeps an enthusiastic assistant from monopolizing the host's machine.
The local (stdio) connection is read-and-analyze: the assistant sees the live document and the engine's full analysis surface, but does not write into the document. Web agents can edit — when, and only when, the host attached the link with editing allowed (see above). The host's mute-all freezes agent edits along with everyone else's.
Local-only mode
A loopback mode — the MCP server talking directly to the editor tab on the same machine, with no network round-trip and no Drive requirement — is designed and on the roadmap. The tool surface is the same; only the transport changes.