Tools reference

The Mbox Viewer MCP server provides 13 tools. Seven of them read data from the shared mailboxes. Five change tags and virtual folders and need Allow changes to tags and folders. The last one, save_attachment, writes a file and needs an export directory. Every tool except list_mailboxes takes a mailbox parameter, which is the id of 16 hexadecimal characters that list_mailboxes returns.

Which tools are there?

Tool What it does Access
list_mailboxes Lists the shared mailboxes with their id, name, path, status, message count, date range and labels. Read
search_messages Searches one mailbox with the query language of the app and returns one page of summaries. Read
get_message Gives the headers, the plain text and the list of attachments of one message. Read
get_thread Gives the messages of a conversation in date order and shortens their text. Read
list_labels Lists the Gmail labels of a mailbox with their message counts. Read
list_tags_and_folders Lists the tags and virtual folders of a mailbox with their counts. Read
suggest_senders Suggests up to 10 sender addresses that start with a prefix and puts the most frequent first. Read
create_tag Creates a tag, or returns the existing one with created: false. Write
set_message_tags Adds tags to messages or removes them. Write
create_folder Creates a virtual folder, or returns the existing one with created: false. Write
add_to_folder Adds messages to a virtual folder. Write
remove_from_folder Removes messages from a virtual folder. Write
save_attachment Saves one attachment into the export directory and returns the path written. Export

Which parameters does each tool take?

Integers also accept a string of digits such as "20". A clamped value outside its range is brought back into it, and the answer reports the value used. Any other value out of range answers invalid_argument.

Tool Required Optional
list_mailboxes None None
search_messages mailbox query (up to 2,000 characters, empty for all messages), limit (1 to 50, default 20, clamped), offset (0 to 10,000), sort (date_desc by default, date_asc or relevance)
get_message mailbox, id max_chars (1,000 to 20,000, default 20,000, clamped)
get_thread mailbox, id limit (1 to 50, default 10, clamped)
list_labels mailbox None
list_tags_and_folders mailbox None
suggest_senders mailbox prefix (up to 200 characters, empty for the most frequent senders)
create_tag mailbox, name (up to 60 characters, no quotation marks) color (0 to 15 or a color name, default 0)
set_message_tags mailbox, ids (1 to 200 message ids) add and remove (up to 20 tag names or ids each, at least one of the two)
create_folder mailbox, name (up to 60 characters, no quotation marks) query (the search the folder came from)
add_to_folder mailbox, folder (name or id), ids (1 to 200) None
remove_from_folder mailbox, folder (name or id), ids (1 to 200) None
save_attachment mailbox, id, attachment_index (from get_message) file_name (a plain name, up to 255 characters), overwrite (default false)

The 16 color names of create_tag are red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, pink and rose, in palette order from 0 to 15.

Tag and folder references match an exact id first. Otherwise they match a name, and case does not matter. An unknown tag or folder answers not_found and changes nothing. Create the tag with create_tag first.

What does each tool return?

Every answer is one block of compact JSON. Empty fields are left out. Addresses have the form Name <address>, and dates use RFC 3339 with the local time offset.

Tool Main fields of the answer
list_mailboxes mailboxes with id, name, path, status, message_count, date_min, date_max and labels, plus a hint when no mailbox is shared
search_messages total, offset, limit, next_offset (null at the end) and items with id, date, from, to, subject, snippet, has_attachment, labels, tags, folders and flags
get_message The headers, message_id, attachments (index, file name, type and size), text, text_source (plain or html), truncated, max_chars and flags
get_thread thread_id, total, limit, omitted and messages, each with its summary and text
list_labels labels with name and count
list_tags_and_folders tags with id, name, color and count, and folders with id, name, count and query
suggest_senders senders with address and count
create_tag, create_folder The tag or folder, and created
set_message_tags, add_to_folder, remove_from_folder updated (the number of messages found) and unknown_ids
save_attachment path, file_name and size

A mailbox has one of five statuses. The status ready means the tools can use it. indexing means the app is building its index. stale means the file changed since indexing, missing means the file is gone, and error covers the other cases.

What limits apply to the answers?

The server bounds every answer to keep the context of the agent small.

Item Limit
Search results per page 20 by default, 50 at most
Search snippet 200 characters, without markup
Text of one message 20,000 characters, with truncated: true beyond
Messages of one thread 10 by default, 50 at most
Text per thread message 2,000 characters, and 40,000 for the whole thread
Attachments listed per message 100, inline images excluded
Header field 1,000 characters
Addresses per list 50, with a from_more or to_more count beyond
Labels per message 100, with a labels_more count beyond
Messages per write call 200
Whole answer 120,000 characters, with truncated: true beyond
Calls running at once 2 per server process

What do the flags mean?

Flag Meaning
invisible_chars_removed The server removed invisible or bidirectional characters from the message.
hidden_html_suspected The HTML hides some text, for example with display:none, a tiny font or text in the background color.
alternative_mismatch The plain-text version differs from the HTML that you see in the app. The text then comes from the HTML, and text_source is html.

What do the error codes mean?

An error answer starts with a stable code, followed by one sentence and the next step.

Code Cause Fix
mcp_disabled The server is off in Settings. Tick Enable the MCP server. No client restart is needed.
invalid_token The client holds an old or wrong token. Copy the token or the configuration again and restart the client.
mailbox_not_allowed The mailbox is not ticked, or the id does not exist. Tick the mailbox under Mailboxes the agent may see.
mailbox_not_ready The mailbox is being indexed, or its file changed or is missing. Open the mailbox in Mbox Viewer and let indexing finish.
writes_not_allowed A write tool was called while changes are off. Tick Allow changes to tags and folders.
export_dir_not_set No usable export directory is set. Choose an Export directory for attachments.
not_found The message, attachment, tag or folder does not exist. Check the id or create the tag or folder first.
invalid_argument A parameter is missing, has the wrong type or is out of range. The message names the parameter and the allowed range.
internal The server could not complete the call. Retry once, then check the server log.

What resources does the server expose?

Some clients read MCP resources in addition to the tools.

Resource Content
mbox://<mailbox id> One shared mailbox, as JSON with the same fields as an item of list_mailboxes
mbox://<mailbox id>/messages/<id> One message as plain text, between untrusted-content markers

Resources apply the same permission checks and the same cleaning as the tools, and the audit log records them. A mailbox you share later appears in the resource list only after a client restart, while the tools see it at once.

Frequently asked questions

Which tool should an agent call first?

The agent should call list_mailboxes first. Every other tool takes a mailbox id of 16 hexadecimal characters, and only this tool returns the ids of the shared mailboxes.

Which query syntax does search_messages accept?

It accepts the same query language as the search bar of the app. Operators such as from:, subject:, has:attachment, label:, after:, newer_than:, larger:, tag: and folder: work, as do -term, OR and quoted phrases.

How many results does one search return?

One search returns 20 results by default and 50 at most. The agent reads the next page by passing next_offset as offset. The offset can go up to 10,000.

Does get_message return the HTML of an email?

No. It converts HTML to plain text and returns at most 20,000 characters. It never returns HTML, raw headers, images or attachment bytes.

Which tools change something?

Six tools change something. create_tag, set_message_tags, create_folder, add_to_folder and remove_from_folder change tags and folders, and save_attachment writes a file.

Why does a write tool answer writes_not_allowed?

Allow changes to tags and folders is off in Settings. Turn it on in the MCP server (AI agents) section, and the next call works without a client restart.

Can the agent delete a tag or a folder?

No. The server has no tool to rename or delete a tag or a folder, and no tool that deletes a message. You do these things in the app.

What are the mbox:// resources?

Each shared mailbox is a resource named mbox://<mailbox id>, and each message can be read as plain text at mbox://<mailbox id>/messages/<id>. They apply the same permission checks as the tools.

How many calls can run at the same time?

Two calls run at the same time in one server process. Each client starts its own process.