One library, three agents: how llm-for-zotero connects Claude Code, Codex and Antigravity to Zotero
Published:
llm-for-zotero can run its agent on four runtimes. A runtime is the program that runs the agent loop: it talks to the model, decides when to call a tool, and shows you the answer. One runtime is the plugin’s own built-in agent. The other three are agents you may already pay for: Claude Code, Codex, and Antigravity (Google’s agy).
From the outside, all three do the same job in Zotero. They read your papers, search your library, and write notes. Underneath, each one connects to Zotero in a different way, and those differences explain most of the cases where one runtime behaves differently from the others.
This post describes the design as of llm-for-zotero v3.9.23. The details change between releases, so treat the numbers as a snapshot.
The shared part: one Zotero MCP server
MCP (Model Context Protocol) is an open standard for giving an AI agent tools that another program provides. The tool provider runs an MCP server; the agent connects to it, asks for the list of tools (tools/list), and calls them (tools/call).
llm-for-zotero runs one MCP server inside Zotero, on Zotero’s own local web server:
http://localhost:23119/llm-for-zotero/mcp
Every runtime uses this same server and sees the same Zotero tools, such as paper_read, library_search, library_retrieve and note_write. So a fix to a tool fixes it for every runtime at once.
Two pieces of information travel with every call:
- A bearer token proves that the caller is allowed to use the server.
- A scope token names the chat the call belongs to: which library, which paper, which conversation, and which runtime.
The plugin registers a new scope for each turn. This is how the server knows that a paper_read call is about the paper open in your current chat, and not about some other paper. It is also how Stop works: stopping a turn cancels its scope, and the scope cancels the Zotero tool call that is still running.
Every tool that changes your library goes through the plugin’s central permission policy, whichever runtime asks. That is why the same confirmation card appears for a new note whether Claude Code, Codex, or Antigravity wrote it.
┌────────────────────────────────────────────────────────────┐
│ Zotero + llm-for-zotero │
│ Zotero MCP server (one, shared) │
│ bearer token + per-turn scope token │
└──────────▲───────────────────▲───────────────────▲─────────┘
│ │ │ HTTP MCP calls
│ │ │
Claude bridge codex app-server agy (one per chat)
Claude Agent SDK JSON-RPC ACP over stdio
Three ways to drive an agent
What differs between the runtimes is the outer layer: how the plugin starts the agent, how it tells the agent about the Zotero MCP server, and how the agent shows those tools to its model.
Claude Code: a bridge around the Claude Agent SDK
Claude Code is driven through a small local Node.js server that ships with the plugin, the Claude bridge. The bridge uses Anthropic’s Claude Agent SDK, the library behind Claude Code.
For each turn, the plugin sends the bridge one request that carries everything the turn needs:
- the Zotero MCP server entry, with that turn’s scope token;
- the plugin’s standing instructions, appended to Claude Code’s own system prompt;
- the user’s message, any attached files, and the chat’s saved session to resume.
Because the whole setup is sent again on every turn, Claude Code always sees the current settings. If you turn Zotero MCP off in the middle of a chat, the next turn simply arrives without it.
Claude Code has one habit that matters for speed. It normally hides MCP tools behind its own tool search, so the model has to spend a round loading a tool before it can call it. The plugin marks its main reading and search tools (paper_read, library_search, library_read, library_retrieve) as “always load”, so they are ready from the first round.
Codex: the codex app-server
Codex is driven through codex app-server, a long-running Codex process that other programs control with JSON-RPC messages. JSON-RPC is a simple request-and-reply message format: the plugin sends thread/start, thread/resume, or turn/start, and Codex sends back events and approval requests.
A Codex chat is a thread. The plugin gives each thread its own configuration, including a Zotero MCP server entry with that chat’s scope token. Before each turn, the plugin reloads the MCP configuration and resumes the thread, passing the turn’s current developer instructions: a Zotero “environment manifest” that tells Codex which paper is open, which tools it has, and where files live.
Like Claude Code, Codex therefore gets its standing instructions fresh on every turn.
Codex’s main constraints are about size. It lists every tool to the model, and a very long tool list gets cut off in what the model sees. It also keeps tool results small: the plugin sizes results to about 10,000 tokens for Codex and lets the model page through the rest.
Antigravity: agy over ACP
Antigravity is driven through Google’s agy command-line agent, speaking ACP (Agent Client Protocol). ACP is an open protocol for editors and other clients to drive a coding agent. Messages go over the agent process’s standard input and output: session/new or session/resume to open a chat, session/prompt to send a turn, session/update for progress, and session/request_permission when the agent wants approval.
agy has a tool budget. When a client passes an MCP server with a session, agy offers only the tools whose definitions fit the budget, and silently drops the rest. A server written into agy’s own mcp_config.json keeps all of its tools: the ones marked eager are offered directly, and the model reaches the others through agy’s call_mcp_tool.
So the plugin writes the Zotero server into a config file, in a profile folder of its own. The plugin offers 13 Zotero tools directly and leaves rarely used ones, such as undo, behind call_mcp_tool. And because agy reads that file once, when it starts, and the file carries the chat’s scope token, each Antigravity chat runs in its own agy process.
The same “read once at start” pattern applies to instructions. agy keeps a session’s system prompt from the moment the session was created. The plugin therefore sends its standing instructions once per chat, and sends an update block with a turn only when they have changed.
Side by side
| Claude Code | Codex | Antigravity | |
|---|---|---|---|
| Protocol | Claude bridge (local HTTP) around the Claude Agent SDK | codex app-server, JSON-RPC | agy, ACP over stdio |
| Processes | One bridge for all chats | One app-server for all chats | One agy per chat |
| How it learns about Zotero MCP | Sent with every turn’s request | Per-thread config, reloaded before each turn | mcp_config.json, read once when agy starts |
| How tools reach the model | Tool search; the main Zotero tools are marked “always load” | Full list | 13 eager tools; the rest through call_mcp_tool |
| Standing instructions | System prompt, rebuilt every turn | Developer instructions, passed every turn | Session system prompt, set once; changes sent as an update |
| Tool-result size | Up to about 25,000 tokens, kept inline | About 10,000 tokens; the rest is paged | agy’s own limit; the model is told how to page |
| Approvals | The SDK asks the bridge | App-server approval requests | ACP session/request_permission |
| Chat memory | Claude Code’s saved session | Codex’s saved thread | agy’s saved session |
What this means in practice
Tokens
Every model round starts by reading the tool list, so its size is paid again and again. In v3.9.22, the Zotero tool list was about 111,000 characters, mostly because one long guidance paragraph was repeated on every tool. In v3.9.23, each rule is stated once and results are sent as compact JSON:
| What the model receives (characters) | v3.9.22 | v3.9.23 | Change |
|---|---|---|---|
| Zotero tool list | 110,802 | 49,819 | −55% |
paper_read, question-targeted | 11,186 | 9,330 | −17% |
paper_read, three pages | 13,836 | 6,439 | −53% |
library_search | 616 | 402 | −35% |
These numbers come from calling the plugin’s MCP server directly with the same test paper on both versions. Because all three runtimes share the server, the savings apply to all of them.
Speed
The biggest speed gains came from not making the model work for text it could be given directly:
- A new single-paper chat now receives the paper’s text up front when it fits, instead of spending five or six rounds trying ways to read it.
- A full read of one paper, or of a few short papers, returns the text directly instead of sending it through a second “reader” model.
- Claude Code no longer spends a round loading its Zotero tools.
In one measured run on a real paper, a Claude Code full-read turn went from 95 seconds to 51 seconds. That is a single measurement, not a benchmark, so read it as a direction rather than a promise.
Reliability
Most runtime-specific bugs trace back to one question: does this runtime get this information every turn, or only once?
Claude Code and Codex get their setup fresh every turn, so a changed setting reaches them on the next message. Antigravity fixes several things when a chat starts, and each of those has needed its own care:
- the tool budget, which is why some tools are eager and others go through
call_mcp_tool; - the separate
agyprofile, which at first hid the user’s ownagyskills; - the session system prompt, which is why changed instructions are sent as an update.
When a bug shows up on only one runtime, that question is usually the fastest way to find the cause.
Further reading
- llm-for-zotero manual, including setup for each runtime
- Model Context Protocol
- Agent Client Protocol
- Claude Code documentation, including the Claude Agent SDK
- OpenAI Codex, which includes
codex app-server
