Skip to main content
Glama
heritagebanknw-mcp

heritagebanknw-mcp

by jrolstad
README.md
# heritagebanknw-mcp

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

An [MCP (Model Context Protocol)](https://modelcontextprotocol.io) server that provides read-only access to your [Heritage Bank NW](https://www.heritagebanknw.com) accounts via browser automation. Use it with Claude Code or any MCP-compatible client to query account balances and transaction history conversationally.

## What it does

Exposes three tools:

| Tool | Description |
|------|-------------|
| `get_accounts` | Returns all accounts with current balance, available balance, and YTD interest |
| `get_balance` | Returns balance details for a single account by ID |
| `get_transactions` | Returns transaction history for an account (date, description, amount, type, balance) |

Authentication is handled automatically using Playwright to drive a Chromium browser. Sessions are persisted to `session.json` so subsequent calls run headlessly. If the session expires or MFA is required, a visible browser window opens for you to complete login.

Unlike older banking sites that require HTML scraping, Heritage Bank NW's online banking platform exposes a clean JSON API — so responses are structured and reliable.

## Installation

### Prerequisites

- Python 3.11+
- pip

### Steps

1. Clone the repository:
   ```bash
   git clone https://github.com/jrolstad/heritagebanknw-mcp.git
   cd heritagebanknw-mcp
   ```

2. Install dependencies:
   ```bash
   pip install -r requirements.txt
   ```

3. Install Playwright's Chromium browser:
   ```bash
   playwright install chromium
   ```

4. Set your Heritage Bank NW credentials using one of the two options below.

### Configure with Claude Code

Add the server to your Claude Code MCP settings (`~/.claude.json` under `mcpServers`). Credentials can be provided in the MCP config directly (recommended) or via a `.env` file.

**Option A — credentials in MCP config (recommended)**

```json
{
  "mcpServers": {
    "heritagebanknw": {
      "type": "stdio",
      "command": "python",
      "args": ["/path/to/heritagebanknw-mcp/server.py"],
      "env": {
        "HERITAGEBANKNW_USERNAME": "your_username_here",
        "HERITAGEBANKNW_PASSWORD": "your_password_here"
      }
    }
  }
}
```

**Option B — `.env` file**

```bash
cp .env.example .env
```
Then edit `.env`:
```
HERITAGEBANKNW_USERNAME=your_username_here
HERITAGEBANKNW_PASSWORD=your_password_here
```

The server loads this automatically via `python-dotenv` on startup. The `.env` file is gitignored.

## Usage

Once connected, you can ask Claude things like:

- "List my Heritage Bank NW accounts with their balances"
- "What are the last 20 transactions from my checking account?"
- "What's the available balance on my savings account?"
- "How much YTD interest has my savings account earned?"

## Authentication and sessions

- On first run, a Chromium browser window opens and logs in with your credentials.
- If MFA or additional verification is required, you have 60 seconds to complete it in the browser window.
- After a successful login, cookies are saved to `session.json` for future headless runs.
- If a session expires, the browser window opens again automatically.
- `session.json` is gitignored — do not commit it.

## Development

### Project structure

```
heritagebanknw_client.py   # Playwright auth + JSON API client
server.py                  # MCP server (FastMCP) — exposes tools to MCP clients
requirements.txt           # Python dependencies
.env.example               # Credential template
session.json               # Persisted browser session cookies (gitignored)
```

### How it works

`heritagebanknw_client.py` uses Playwright to authenticate against the Heritage Bank NW online banking platform (`/nxg-olb/live/`), then calls the bank's internal JSON API directly using the browser's `fetch` (so session cookies are automatically included).

Key API endpoints:
- `GET /nxg-olb-bff/live/ui/v1/accounts` — all accounts with balances
- `GET /nxg-olb-bff/live/ui/v1/accounts/{id}/transactions` — transaction history

Key functions:
- `_get_json()` — handles auth/session and calls an API endpoint via browser fetch
- `get_accounts()` — returns all accounts
- `get_balance()` — returns one account by ID
- `get_transactions()` — returns transactions for an account with date range

### Running locally

```bash
python server.py
```

Or via the MCP CLI:

```bash
mcp dev server.py
```

### Adding new tools

1. Add a new async function to `heritagebanknw_client.py` that calls the relevant API endpoint via `_get_json()`.
2. Register it as a tool in `server.py` using the `@mcp.tool()` decorator.
3. Reconnect your MCP client to pick up the new tool.

### Dependencies

| Package | Purpose |
|---------|---------|
| `mcp` | MCP server framework (FastMCP) |
| `playwright` | Headless browser automation for authentication |
| `python-dotenv` | Loading credentials from `.env` |

## License

[MIT](LICENSE)