MCP Control of a Running Potato Task
The mcp block lets an agent query and change a live Potato server through tools you name, with a revocable token for each agent and an audit log.
Potato's mcp config block lets an agent read a running study's progress, add items, record annotations, and export results over the Model Context Protocol (MCP). MCP is an open protocol through which an AI application calls tools that another program exposes. Potato keeps the surface off until an admin enables the block and names every tool an agent may call, and Potato has no default set of tools. Each agent gets a separate token bound to a role, and Potato appends every call, granted or refused, to an audit log in the task directory. Potato 2.14.0 offers 17 tools, of which one destroys work and needs a second opt-in.
Two MCP servers in Potato
Potato has two MCP servers, and the mcp block configures only the second one. potato mcp serve is the first server and runs on your own machine while a study is being designed. The design-time server speaks MCP over stdio. It answers from Potato's registries and bundled examples, validates a config with Potato's own validator, and boots a temporary local copy of the task to return a screenshot with any browser errors. It never contacts a running server, and its file access is confined to the folder given by --root. Quick Start with a Coding Agent covers potato mcp serve. The second server is part of a running Potato task and answers on the task's own address, under /api/mcp/. The rest of this page covers the second server.
Configuration options
The block below turns the surface on for an agent that labels items as the annotator llm-annotator and checks the study's progress. Add the block to an existing config:
mcp:
enabled: true
tools:
- get_status
- get_progress
- list_items
- get_item
- submit_annotation
destructive: []
scope:
users: [llm-annotator]
audit_log: mcp_audit.jsonlThe scope.users list keeps the agent from writing annotations for any annotator other than llm-annotator. Each option of the block and the option's default are listed below:
| Option | Default | What the option controls |
|---|---|---|
enabled | false | Registers the /api/mcp/ routes. While enabled is false, the routes do not exist and Potato skips every other check of the block. |
tools | none | The tools an agent may call, by name. A tool left off the list is refused. |
destructive | none | The destructive tools an agent may call. A destructive tool has to appear in both tools and destructive. |
scope.users | none | The annotators an agent may act on. With no list, or with an empty list, an agent may name any annotator. |
audit_log | mcp_audit.jsonl | The file Potato appends each call to. A relative path is read from task_dir. |
auth.tokens_file | mcp_tokens.json | The file that holds the token digests. A relative path is read from task_dir. |
allow_debug | false | Lets the surface run on a server with debug: true. Without the option, Potato refuses the combination. |
Potato treats the block as a security allowlist and fails at startup on a mistake rather than logging a warning. With enabled: true, Potato rejects a config in which tools or destructive names a tool that does not exist, destructive lists a tool that destroys no work, or destructive lists a tool that tools leaves out. The error message names the unknown tool, such as a mistyped get_itme, and lists the 17 valid names. With a non-empty tools list, the validator also refuses debug: true written in the YAML unless allow_debug is set. Potato checks only that scope is a mapping. A misspelt sub-key such as scope: {usrs: [...]} therefore restricts nothing and raises no error. Granting an engine_ tool while the labeling engine is off produces a warning, because every call to the tool would then be refused.
Agent tokens
Each agent presents a token issued on the machine that holds the task's files. Three commands issue, list, and revoke tokens:
potato mcp issue-token --config config.yaml --name ops-agent --role admin
potato mcp tokens --config config.yaml
potato mcp revoke-token --config config.yaml --name ops-agentThe first command prints the token once, and Potato never shows the token again. Potato stores only the token's SHA-256 digest in mcp_tokens.json under task_dir and sets the file's permissions to owner-only. Beside the digest, the file records the agent's name, the role, the creation time, and an optional --note. potato mcp tokens lists each token's name, role, creation time, and whether the token is active or revoked, and --json prints the same records as JSON. revoke-token revokes every token issued under the name. Potato reads the token file on every request. A revoked token therefore stops working at the agent's next call, with no restart.
The --role option takes admin, adjudicator, or annotator, and the default is annotator. A token's role grants the permissions of Potato's built-in role of the same name. Potato pins a token's own role to the built-in permissions, so custom roles in the rbac block do not change what the token role grants. A token whose name matches a user also gets that user's permissions. Potato looks the name up in rbac.user_role_assignments, in adjudication.adjudicator_users, and in the legacy user_roles map, and custom roles in rbac.roles do apply to a permission that comes through the name. The built-in roles reach the tools as follows:
| Token role | Permissions | Tools the role can call |
|---|---|---|
admin | all seven | every tool |
adjudicator | adjudicate, export_data, annotate | submit_annotation, export_data, engine_certificate |
annotator | annotate | submit_annotation |
The read tools need view_admin_dashboard, which only the admin role holds among the built-in roles. An agent that checks progress therefore needs an admin token, and scope.users is the setting that keeps an admin token from acting on every annotator.
Tools and permissions
Each tool declares the permission a token needs and whether the tool destroys work. Potato 2.14.0 has the 17 tools below:
| Tool | Permission | Arguments | What the tool does |
|---|---|---|---|
get_status | view_admin_dashboard | none | Returns the task name, the number of items, and the number of annotators. |
get_progress | view_admin_dashboard | none | Returns the study's overall annotation progress. |
list_annotators | view_admin_dashboard | none | Lists each annotator with the number of items assigned, the number annotated, and the current phase. |
list_items | view_admin_dashboard | limit (default 50), offset (default 0) | Lists item IDs with the usernames of each item's annotators. |
get_item | view_admin_dashboard | instance_id | Returns one item's data and the usernames of the item's annotators. |
get_agreement | view_admin_dashboard | none | Returns the inter-annotator agreement that the admin dashboard reports. |
get_config | view_admin_dashboard | none | Returns the task's config with live secrets in plaintext. Only secret_key, admin_api_key, the mcp block, and top-level keys that start with _ are removed. See the warning below the table. |
engine_status | view_admin_dashboard | none | Returns the labeling engine's predictions, requests, contracts, and spend. |
engine_requests | view_admin_dashboard | purpose, status, limit (default 100, at most 1,000) | Lists the labeling engine's requests for human labels. |
add_items | manage_assignment | items | Adds items, each carrying the task's id_key. |
engine_run | manage_assignment | none | Runs one pass of the labeling engine's planner. |
engine_certify | manage_assignment | retest (default false) | Evaluates every labeling-engine contract. |
engine_certificate | export_data | format (json, md, or html) | Returns the labeling engine's quality certificate. |
assign_items | manage_assignment | username, max_instances | Sets how many items an annotator may receive. |
submit_annotation | annotate | username, instance_id, annotations, span_annotations, behavioral_data | Records an annotation as the named annotator. |
export_data | export_data | format, output, options | Runs a registered export format on the server. |
delete_annotations | manage_assignment | username, instance_id, confirm | Clears one annotator's annotations for one item. Destructive. |
Warning: get_config returns live secrets in plaintext. Potato expands ${ENV} references into the config when Potato loads the config, so moving a secret into an environment variable does not hide the secret from the agent. Potato removes only secret_key, admin_api_key, the mcp block, and top-level keys whose names start with _. The response therefore carries the credentials below:
- the
api_keyof eachai_configblock inai_support,live_agent,live_coding_agent,solo_mode,labeling_engine,judge_calibration,agent_proxy, andchat_support trace_ingestion.api_keyandhuggingface_backup.token- the tokens and S3 keys of backup sinks
- each
client_secretunderauthentication.providers database_url- the Prolific, clickworker, and Sona credentials
Do not list get_config in mcp.tools for any agent you would not hand those credentials to.
The five engine_ tools answer 404 unless the study enables the labeling engine, and the labeling engine's CLI and API page covers the engine side.
Four write tools apply the rules below:
add_itemsrecords each item in<output_annotation_dir>/runtime_items.jsonl, and Potato loads the recorded items again after a restart. Whenmax_annotations_per_useris set to anything but-1, the response carries a note that Potato assigns items added at runtime only while the cap is-1. A call that stops partway through the list with an error keeps the items added before the error.assign_itemsnever lowers an annotator's cap below the number of items the annotator has already annotated. A lower value is raised to the annotated count.submit_annotationtakesannotationsas{scheme: {label: value}}, or as{scheme: label}for a scheme with one answer. A single answer to a scheme that declares labels has to name one of the labels. The named annotator has to exist and be in the annotation phase. For an annotator in any other phase, such as a consent page, the tool answers 409 and writes nothing. The tool does not check thatinstance_idnames an existing item. A call that stops partway through with an error can leave the labels written before the error in place.export_datawrites under<output_annotation_dir>/exports/. Theoutputargument names a folder inside the exports directory and defaults to the format name, and a path that leads outside the directory is refused. A failed export answers 500.
Order of checks on each call
Every call passes through one gate, and the gate stops the call at the first check that fails, with a message the agent can act on. Potato runs the checks in the order below:
| Check | Passes when | Answer on failure |
|---|---|---|
| Enabled | mcp.enabled is true | 404, because the routes do not exist |
| Known tool | the URL names one of the 17 tools | Flask's plain 404, with no list of valid names and no audit line |
| Token | the request carries a valid token that has not been revoked | 401 |
| Granted | the tool appears in mcp.tools | 403, with the granted tools |
| Destructive opt-in | a destructive tool also appears in mcp.destructive | 403 |
| Confirmation | a destructive call passes "confirm": true | 400 |
| Permission | the token's role carries the tool's permission | 403, naming the missing permission |
| Scope | a call that names a username names one on mcp.scope.users, when the list is not empty | 403 |
Each of the 17 tools has a fixed route, and Flask answers a mistyped tool name before any check of the gate runs. Potato compares token digests in constant time across the whole token table, and the token check never consults debug mode. The shared admin key does not open the surface, because Potato reads tokens only from the Authorization: Bearer and X-Agent-Token headers and ignores X-API-Key.
HTTP endpoints and the stdio bridge
The surface speaks plain HTTP with JSON bodies. GET /api/mcp/manifest returns the task name, the agent's name and role, the granted tools with the arguments of each, the destructive tools enabled, and the scope. Each tool answers POST /api/mcp/tools/<tool>, with the tool's arguments as the JSON body. The request below lists the first ten items of a task running on port 8000:
curl -X POST http://localhost:8000/api/mcp/tools/list_items \
-H "Authorization: Bearer $POTATO_AGENT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"limit": 10}'potato mcp connect bridges the HTTP surface to an MCP client that runs tool servers over standard input and output. pip install 'potato-annotation[mcp]' installs the MCP SDK that the bridge needs on the agent's machine. The token comes from --token or from the POTATO_AGENT_TOKEN environment variable:
export POTATO_AGENT_TOKEN=...
potato mcp connect --url https://annotation.example.orgThe bridge serves the local design-time tools and adds the remote tools with a live_ prefix, such as live_get_progress. The list of remote tools comes from the server's manifest. The manifest lists every tool in mcp.tools with no filtering by role, so an annotator token also sees read tools that answer the token with 403. A refused call comes back as a tool error carrying the server's message. Each request through the bridge times out after 30 seconds.
Audit log
Potato appends one JSON line to the audit log for every granted call and every refused attempt to call a tool. Each line records the time in UTC, the event, and the caller's IP address. A granted call writes a call line with the agent's name, the role, and the names of the arguments passed, without the argument values. A refused call writes one of auth_failed, not_granted, destructive_not_opted_in, destructive_unconfirmed, permission_denied, or out_of_scope. A mistyped tool name matches no route and writes no line. A tool that raises an exception adds an error line with the exception's text, and a tool that answers with an HTTP error adds a refused line with the status.
The write tools add a second line naming what changed:
items_added, with the number of itemsannotation_submitted, with the annotator, the item, and the numbers of labels and spans writtenassignment_changed, with the annotator and the new capexported, with the format and the output folderannotations_deleted, with the annotator and the itemengine_runandengine_certify
The call line leaves out argument values, but other lines carry values, such as the target annotator, the instance_id, the export path, and the exception text. No setting turns the audit log off, and a blank audit_log falls back to mcp_audit.jsonl. A failed write to the log goes to the server log as a warning and never fails the call.
Safety on a live study
The surface gives an agent control of a study that people are working on, so grant the fewest tools the agent's job needs and the lowest role whose permissions cover the granted tools. Potato's own checks cover several failure modes, and the settings below cover the rest:
- Debug mode.
debug: trueopens admin pages without a key to requests from the server's own machine, and a tunnel or reverse proxy on that machine can make every caller look local. Potato refusesmcp.enabledwith debug mode in two places. The config validator refusesdebug: truewritten in the YAML whenmcp.toolsis not empty. The--debugand--debug-phasecommand-line options take effect after validation. With either option, or with an emptytoolslist, the debug check runs only once, when Potato registers the routes.potato mcp issue-tokennever checks debug mode.mcp.allow_debug: trueoverrides both refusals, and the token check still applies. - Deleting annotations.
delete_annotationsclears every label and span that one annotator recorded on one item and saves the annotator's state, and the deletion cannot be undone. The annotator's span links, event annotations, and behavioral data for the item stay. In 2.14.0 the item still lists the annotator afterward and still counts the annotator toward the item's completion, and an unknowninstance_idanswers"status": "deleted"while deleting nothing. A change made after 2.14.0, in no release yet, removes the annotator from the item and stops an unknowninstance_idfrom answeringdeleted. Span links, event annotations, and behavioral data stay after the change as well. Take a project snapshot before granting the tool. - Scope.
scope.usersapplies only to the three tools that take ausername(submit_annotation,assign_items, anddelete_annotations). Tools such aslist_annotators,get_item, andexport_datastill read every annotator's work. An emptyscope.userslist restricts nothing, and warning D020 fires only when the key is missing, so an empty list also passespotato deploy check. A string in place of the list becomes a substring match, andusers: llm-annotatorthen admitsllmandannotatoras well. - Config contents. Potato expands
${ENV}references when Potato loads the config, andget_configreturns the expanded credentials in plaintext. Moving a secret into an environment variable therefore does not hide the secret from an agent. Do not listget_configinmcp.toolsfor any agent you would not hand the config's credentials to. The warning under the tools table lists the credentials involved. - Rate limits. Potato 2.14.0 applies no rate limit to
/api/mcp/. A reverse proxy in front of the server is the place to limit how often an agent can call.
potato deploy check config.yaml runs four MCP checks before you deploy. Errors D017 and D018 flag mcp.enabled on a server with debug: true and an enabled surface with no active token. Warnings D019 and D020 flag any tool in mcp.destructive and an active admin token with no scope.users list. The deployment guide covers the rest of potato deploy.
Further reading
- Quick Start with a Coding Agent, for potato-skill, which takes an agent through designing a whole study, and for the design-time MCP server
- User management, for the seven permissions and the
rbacblock - Labeling engine CLI, REST API, MCP tools and SDK, for the five
engine_tools - Admin dashboard, for the progress and agreement figures the read tools return
- Project snapshots, for a hashed copy of the annotations before an agent changes them
- Deploying an annotation server, for
potato deploy check
For implementation details, see the source documentation.