
Product
Socket Now Protects the Firefox Extension Ecosystem
Socket is bringing experimental protection to Firefox, scanning 97,000+ extensions in Mozilla's official directory for malware and risky updates.
mainbook-mcp
Advanced tools
A finance MCP server scoped to one job: turning PDF bank statements into checked JSON, Excel or
CSV — not a general accounting MCP. It runs locally with your MainBook API key, or over MainBook's
hosted endpoint at https://mcp.mainbook.ai/mcp with that same key.
Point your assistant at a statement and ask for a spreadsheet. The PDF goes to
MainBook, which extracts every transaction, normalises dates to
YYYY-MM-DD, keeps money as exact amounts, and re-adds the statement so that
opening balance + credits − debits has to match the closing balance. Rows that do not fit are
flagged instead of being passed on quietly.
> Convert ~/Downloads/march-statement.pdf and save the Excel next to it.
mainbook - convert_bank_statement (MCP)
63 transactions · 4 pages · 4 credits
Totals reconciled against the statement
Saved to ~/Downloads/march-statement.xlsx
Done — 63 transactions. Opening 4,127.50 and closing 3,881.05 both match
the statement, and nothing was flagged.
It does not connect to bank accounts and is not an Open Banking or bank-data API. It reads statement files you already have. Nothing is scraped and no banking credentials are involved.
A MainBook account and the folders holding your statements. Conversion is the only tool that spends
page credits. Of the other four, get_balance and list_conversions only read, get_conversion
may write a result file, and output_folder changes a local preference; none of them changes
anything in your MainBook account.
Sign in once from a terminal:
uvx mainbook-mcp auth login
The command opens MainBook in your browser, shows the same short code in both places, and waits for
your approval. It stores the credential in the OS keyring when the optional keyring package is
installed and working. Otherwise it uses ~/.config/mainbook/credentials.json with private
directory and file permissions. Use mainbook-mcp auth status to check the active credential
server-side without spending page credits. mainbook-mcp auth logout revokes that stored key first,
then removes the local copy; if MainBook cannot be reached, it says plainly that the key may still be
active. Signing in again revokes the previously stored key before saving its replacement. The device
token response does not include an email or account ID, so status says that account identity was not
provided instead of guessing.
Then add one entry to your client's MCP configuration. This is the same block for Claude Desktop (Settings → Developer → Edit Config), Claude Code, and Cursor; no key is copied into it:
{
"mcpServers": {
"mainbook": {
"command": "uvx",
"args": ["mainbook-mcp", "~/Downloads", "~/Desktop", "~/Documents"]
}
}
}
Codex reads TOML, so put the same thing in ~/.codex/config.toml:
[mcp_servers.mainbook]
command = "uvx"
args = ["mainbook-mcp", "~/Downloads", "~/Desktop", "~/Documents"]
uvx comes with uv; install it once with brew install uv or
curl -LsSf https://astral.sh/uv/install.sh | sh. It fetches and runs the published package, so
there is nothing to download by hand and nothing to update. If you would rather not add uv, run
pip install mainbook-mcp and use "command": "mainbook-mcp" with the same arguments — you then
upgrade it yourself with pip install -U mainbook-mcp.
The folder arguments are the only places the server may read a statement from or write a result to;
anything outside them is refused. MAINBOOK_ALLOWED_DIRS sets the same list through the
environment instead, separated by the platform's os.pathsep (: on macOS/Linux, ; on Windows).
MAINBOOK_API_KEY takes precedence over any stored login. Keep the manual method for automation
where an interactive browser is not available. auth login warns when this variable will keep
overriding the newly stored credential:
export MAINBOOK_API_KEY="mb_live_REPLACE_ME"
mainbook-mcp
Create and revoke manual keys at https://mainbook.ai/developer. Never commit them.
Claude Desktop also accepts a one-file bundle: Extensions → Install Extension… and pick
mainbook.mcpb. It asks for the API key and the folders in a dialog and manages its own Python
runtime, so nothing needs installing first. The config block above does the same job and is the
better fit if you already keep other servers there. Build the bundle from this directory with:
npx --yes @anthropic-ai/mcpb@2.1.2 validate manifest.json
npx --yes @anthropic-ai/mcpb@2.1.2 pack . dist/mainbook.mcpb
convert_bank_statement: creates a paid page-credit job, uploads one PDF, starts conversion,
polls for up to 30-900 seconds, and returns the reviewed result. JSON stays inline. In local
stdio mode, XLSX/CSV bytes are written to disk and only the full path enters model context.get_conversion: checks a job after a timeout and returns JSON inline or writes XLSX/CSV to a
chosen local destination.list_conversions: returns one cursor page of account jobs plus next_cursor.get_balance: returns total, reserved, and available credits, all measured in PDF pages.output_folder: reads or changes the default local result folder.Local stdio mode lists all five tools. Hosted HTTP mode lists exactly the first four;
output_folder is not advertised remotely because the server's disk does not belong to the client.
There are no tools for buying credits, payments, deleting jobs, or changing account data.
Tools that can create a conversion, write a local result file, or change the output preference are
marked non-read-only. get_conversion is read-only over hosted HTTP, where it writes no file, and
non-read-only over local stdio, where it may write XLSX or CSV. None is marked destructive because
existing result files are never replaced.
For local stdio clients (Claude Desktop, Claude Code, Cursor, and Codex), XLSX and CSV results are written to the first available destination in this order:
output_path supplied to convert_bank_statement or get_conversion (an absolute filename or
an existing folder);output_folder;get_conversion cannot infer the original PDF folder. Without output_path or a valid remembered
folder it returns a clear error instead of guessing a destination. Every successful file response
contains the absolute path and explains which rule selected it. Existing files are never replaced:
statement.xlsx is followed by statement (2).xlsx, then (3), and so on.
Ask the client to call output_folder with no argument to see the current setting and every allowed
folder. Set it with an allowed absolute directory, or pass next_to_source to restore the default.
The preference is shared by local clients on the same machine in ~/.mainbook/preferences.json.
A saved folder that is missing or no longer allowed is ignored, and that fallback is stated in the
result.
JSON remains inline. It is also written to a .json file only when an explicit output_path is
provided. In remote HTTP mode, local paths and output_folder are unavailable; XLSX/CSV continues
to return a REST download instruction because the server disk does not belong to the client.
From this directory:
python3 -m venv .venv
.venv/bin/python -m pip install .
To prefer the OS keyring over the private JSON fallback, install the optional extra in every environment that runs the login command or the local server:
.venv/bin/python -m pip install '.[keyring]'
Use a plain install, not pip install -e .. In this checkout the editable install writes a .pth
file that the interpreter does not pick up, so python -m mainbook_mcp fails with "No module named
mainbook_mcp" while the package looks installed. An identical file under another name is honoured,
so the content is fine and the cause is still unexplained — a plain install sidesteps it entirely.
If you use the manual method for automation, keep mb_live_... values in a secret environment or
client configuration. Never commit them.
MainBook runs this server for you at https://mcp.mainbook.ai/mcp, so a client that speaks remote
MCP needs nothing installed. Point it at that URL and send your own key:
Authorization: Bearer mb_live_REPLACE_ME
The key is read from each request, so every user of a client reaches their own MainBook account and
spends their own page credits. initialize and tools/list answer without a key; every tool call
requires one. Local file paths and output_folder do not exist over HTTP — pass file_url instead
of file_path, and XLSX or CSV results come back as a REST download instruction, because the
server's disk is not yours.
You can also run the same remote mode yourself. It is stateless Streamable HTTP with JSON responses:
mainbook-mcp --transport http --host 127.0.0.1 --port 8000
The MCP endpoint is then http://127.0.0.1:8000/mcp. Each client should send its own header:
Authorization: Bearer mb_live_REPLACE_ME
The header is read from each tool-call request and never stored in global state. Hosted HTTP mode
does not inspect MAINBOOK_API_KEY, the OS keyring, or the local credential file. For Codex remote
mode:
[mcp_servers.mainbook]
url = "https://mcp.mainbook.ai/mcp"
bearer_token_env_var = "MAINBOOK_API_KEY"
tool_timeout_sec = 920
default_tools_approval_mode = "writes"
Replace the URL with your own host if you deploy this yourself; a self-hosted deployment still needs normal HTTPS termination and access controls.
MAINBOOK_API_KEY: optional in stdio and takes precedence over a stored login; ignored in HTTP
mode, where every tool call must carry its own Bearer header.MAINBOOK_API_BASE_URL: REST host, default https://api.mainbook.ai. The server appends
/api/v1/developer.MAINBOOK_ALLOWED_DIRS: local folders allowed for source reads and result writes, separated by the platform's
os.pathsep (: on macOS/Linux and ; on Windows). Positional directory arguments take
priority. If neither is supplied, the defaults are ~/Downloads, ~/Desktop, and
~/Documents.MAINBOOK_MCP_TRANSPORT: stdio (default) or http.MAINBOOK_MCP_HOST: HTTP bind host, default 127.0.0.1.MAINBOOK_MCP_PORT: HTTP bind port, default 8000.file_path and file_url are mutually exclusive. file_path is accepted only over local
stdio; HTTP mode rejects it before the filesystem loader runs and requires file_url.file_path access and result-file writes use the same configured folders. Positional CLI directories take
priority over MAINBOOK_ALLOWED_DIRS; the environment takes priority over the defaults
~/Downloads, ~/Desktop, and ~/Documents. Every root is expanded and resolved, missing
roots are ignored, and the active roots are printed to stderr when the server starts. If no
roots remain, local access fails closed while the server continues running.~/.mainbook/preferences.json is replaced atomically. The .mainbook directory is mode 0700
and the preference file is mode 0600; malformed or unreadable preferences are ignored safely.~/.config/mainbook/credentials.json is replaced atomically inside a mode 0700 directory and
is mode 0600; its top-level entries are keyed by API base URL... and symlinks
cannot make an outside target appear to be inside an allowed folder. The resolved path must be
strictly below a root, not equal to the root itself.fstat on that descriptor to require a regular
file and enforce the 50 MiB limit, then performs the bounded read through the same descriptor.
This closes the check-versus-read replacement window, but it does not fully eliminate the race
between resolving the path and opening it; the path can still be replaced during that interval.%PDF- within its first 1024 bytes before pypdf is invoked. Filename
extensions are not used to decide whether a file is a PDF.Host header, closing DNS-rebinding races.Content-Length and the actual streamed byte count are independently capped at 50 MiB.pypdf and capped at 500 pages..venv/bin/python -m pip install '.[dev]'
.venv/bin/pytest
.venv/bin/pytest --cov=mainbook_mcp --cov-report=term-missing --cov-report=annotate:cov_annotate
.venv/bin/ruff check .
All REST tests use mocks or a local stub. No test requires or accepts a real MainBook API key.
FAQs
MCP server for the MainBook bank-statement conversion API
We found that mainbook-mcp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket is bringing experimental protection to Firefox, scanning 97,000+ extensions in Mozilla's official directory for malware and risky updates.

Research
/Security News
Three compromised Rust crates pulled in a malicious dependency that downloaded and executed cross-platform malware during Cargo builds.

Research
/Security News
Socket uncovered 77 linked Firefox extensions, including 40 that steal wallet secrets or credentials and 37 deceptive sports-score shells.