# MCP for AI agents

Run the Open Books MCP server with npx to verify bank statements and tax files with an AI agent, then inspect the proof in one batched call.

Source: https://books.openlumeo.com/docs/mcp

Model Context Protocol (MCP) lets an AI client call tools supplied by another program. The Open Books MCP server, published as the npm package `@lumeo_hq/openbooks`, lets a compatible client check a financial file and read the proof behind the decision. Choose the setup path that matches what you want to do.

| Goal | Start here |
| --- | --- |
| Verify that your client can connect | Use the connection test below. |
| Process files from a folder you control | Run the server over stdio with `--root`, so the client starts it as a subprocess. |
| Send uploads to a private shared service | Run Streamable HTTP with a bearer token, bound to localhost. |

## Requirements [#requirements]

- Node.js 20 or newer, for `npx`.
- Python 3.11 or newer on the same machine. The verification engine is Python, and the npm packages provision it. Python is a current prerequisite of the engine; you do not install the server with pip.

## Test your client's connection [#test-your-clients-connection]

1. Add the setup server shown below to your client.
2. Copy the generated prompt and paste it into the agent. The agent calls `confirm_connection` with the setup code.
3. Watch for confirmation on this page. If the code expires after ten minutes, generate a fresh code.

The setup endpoint confirms connectivity. Install the full server to process financial files.

<AgentOnboarding />

## 1. Start the server [#1-start-the-server]

The server runs on demand, so there is nothing to install globally:

~~~bash
npx -y -p @lumeo_hq/openbooks openbooks-mcp
~~~

On first use, ask the agent to run the `doctor` operation. It reports whether the Python engine is available. If it is not, run the engine setup once and then check again:

~~~bash
npx -y @lumeo_hq/openbooks install-engine --scan
~~~

## 2. Connect an MCP client [#2-connect-an-mcp-client]

Add the server with your client's command. Claude Code:

~~~bash
claude mcp add openbooks -- npx -y -p @lumeo_hq/openbooks openbooks-mcp
~~~

Codex:

~~~bash
codex mcp add openbooks -- npx -y -p @lumeo_hq/openbooks openbooks-mcp
~~~

Claude Desktop, Cursor, Cline and Gemini CLI use an `mcpServers` entry:

~~~json
{
  "mcpServers": {
    "openbooks": {
      "command": "npx",
      "args": ["-y", "-p", "@lumeo_hq/openbooks", "openbooks-mcp"]
    }
  }
}
~~~

To let the agent read files from one folder, add `--root` and an absolute path to your input folder. Create a dedicated folder and put a synthetic file there for your first run.

~~~json
{
  "mcpServers": {
    "openbooks": {
      "command": "npx",
      "args": ["-y", "-p", "@lumeo_hq/openbooks", "openbooks-mcp", "--root", "/absolute/path/financial-inbox"]
    }
  }
}
~~~

Restart the MCP client and check that it lists `search` and `execute`. Start with the synthetic sample; without `--root` the server works with the sample and inline uploads only. The MCP client may send tool responses to its model provider, so check your client's data settings before exposing financial records.

## 3. Discover and run operations [#3-discover-and-run-operations]

`search` returns operation names and descriptions for a keyword. For example, send `{"query":"sample","details":true}` to get the operation and its argument schema. Then pass named steps to `execute`. A step that reads records points to an earlier processing step by its ID.

| Operation | What it returns |
| --- | --- |
| `doctor` | Engine status, with the install command if the engine is missing. |
| `formats` | Installed layouts, supported extensions, engine contract and file limits. |
| `process_sample` | Release or refusal summary for a synthetic bank CSV. |
| `process_upload` | A decision for up to 1 MiB of standard base64 file bytes. |
| `process_file` | A decision for a path relative to the `--root` folder. Available only with `--root`. |
| `records` | A page of one collection from an earlier processing step. |
| `document` | The full release or refusal document from an earlier processing step, subject to the response limit. |

### Process and inspect a statement in one call [#process-and-inspect-a-statement-in-one-call]

Send these arguments to `execute`. It processes two versions of the sample and reads the batch balance and verification assertions in the same call.

~~~json
{
  "steps": [
    { "id": "missing", "operation": "process_sample" },
    { "id": "statement", "operation": "process_sample", "arguments": { "opening": "1000.00" } },
    { "id": "balance", "operation": "records", "arguments": { "from_step": "statement", "collection": "batches" } },
    { "id": "checks", "operation": "records", "arguments": { "from_step": "statement", "collection": "assertions" } }
  ]
}
~~~

The first step is refused with a `PARSE_ERROR` because the opening balance is missing. The second releases the sample, and the balance record shows the closing amount. Use `records` with `offset` and `limit` to retrieve only the items you need. For evidence, use `prefix` to match a record ID such as `txn-00001.`.

### Process a local export [#process-a-local-export]

~~~json
{
  "steps": [
    {
      "id": "bank",
      "operation": "process_file",
      "arguments": { "path": "january.csv", "currency": "INR", "opening": "1000.00", "date_order": "dmy" }
    },
    {
      "id": "rows",
      "operation": "records",
      "arguments": { "from_step": "bank", "collection": "transactions", "limit": 5 }
    }
  ]
}
~~~

One batch accepts up to eight uniquely named steps. Documents referenced by `from_step` are held for the current batch. Results keep the engine's exact decimal strings. A document refusal appears inside its result. An operation error such as `INVALID_PATH` or `RESPONSE_LIMIT` appears on the affected step.

## Resources and prompts [#resources-and-prompts]

The server also exposes three resources: `openbooks://schema/released` (the released document schema), `openbooks://guide/refusals` (refusal codes and fixes) and `openbooks://samples/statement.csv` (the synthetic sample). It provides three prompts: `verify_document`, `explain_refusal` and `try_sample`.

## Troubleshoot a connection or tool call [#troubleshoot-a-connection-or-tool-call]

| Symptom | Check |
| --- | --- |
| The client cannot start the server | Run `npx -y -p @lumeo_hq/openbooks openbooks-mcp` in a terminal and confirm Node.js 20 or newer with `node --version`. |
| `doctor` reports the engine is missing | Run `npx -y @lumeo_hq/openbooks install-engine --scan` and confirm Python 3.11 or newer is installed. |
| The client lists tools but `process_file` is missing | Start the server with `--root` pointing to an existing folder. |
| `INVALID_PATH` | Pass a path relative to the `--root` folder, such as `january.csv`. |
| `RESPONSE_LIMIT` | Use `records` with a smaller `limit` instead of `document`. |
| `BUSY` | Two runs are already active. Retry when one finishes. |
| The document returns `PARSE_ERROR` | Read the document's message and follow the [refusal guide](/docs/refusals). |

## Limits [#limits]

- Local files read through `--root` can be up to 2 GiB. Text files (CSV, OFX, QFX, STA, MT940, TXT, XML) are limited to 64 MB.
- Inline uploads through `process_upload` are limited to 1 MiB after base64 decoding. Use `--root` for larger files.
- Each `execute` response is capped at 48 KiB. Page through long results with `records`.
- One batch runs at most 8 steps. The server runs at most two operations at a time; a call made while both are busy returns `BUSY`.

See [supported formats and limits](/docs/supported-formats-and-limits) for accepted extensions.

## Private HTTP transport [#private-http-transport]

Use Streamable HTTP for a service on one machine. Set `OPENBOOKS_MCP_TOKEN` to a random value of at least 32 ASCII characters, then start the server:

~~~bash
OPENBOOKS_MCP_TOKEN="<at least 32 ASCII characters>" npx -y -p @lumeo_hq/openbooks openbooks-mcp --http --port 8791
~~~

The server listens on localhost only. Clients send the token in an `Authorization: Bearer` header. To reach it from another machine, use a private SSH tunnel or an authenticated TLS gateway that you manage:

~~~bash
ssh -N -L 8791:127.0.0.1:8791 developer@your-vps
~~~

Keep the token in your client's secret store and never commit it to a repository.
