Skip to main content
Glama
toshl-mcp-server

toshl-mcp-server

by hktari

Toshl MCP Server

An MCP (Model Context Protocol) server for integrating Toshl Finance with AI agents.

Overview

The Toshl MCP Server provides a bridge between AI agents and the Toshl Finance API. It allows AI agents to access financial data from Toshl, analyze it, and provide insights and advice based on the data.

Related MCP server: Actual Budget MCP Server

Features

  • READ access to Toshl Finance API endpoints:

    • Accounts

    • Categories

    • Tags

    • Budgets

    • User information

    • Planning

  • MCP Resources:

    • List accounts

    • Get account details

    • List categories

    • Get category details

    • List tags

    • Get tag details

    • Create tag

    • List budgets

    • Get budget details

    • Get budget history

    • Get user profile

    • Get account summary

    • List entries

  • MCP Tools:

    • Account tools (list accounts, get account details)

    • Category tools (list categories, get category details, create category, update category, delete category)

    • Tag tools (list tags, get tag details, create tag, update tag, delete tag)

    • Budget tools (list budgets, get budget details, get budget history)

    • User tools (get profile, get summary, get payment types, get payments)

    • Entry tools (list entries, get entry details, get entry sums, get entry timeline, create entry, update entry, delete entry, manage entries, split entry, undo split)

    • Analysis tools (analyze spending by category, analyze budget performance, analyze account balances)

Prerequisites

  • Node.js (v18.x or higher)

  • npm (v8.x or higher)

  • Toshl Finance API token

Get API Token

  1. go to https://developer.toshl.com/apps/

  2. create new personal token. Insert name for token under "Description" and your account password under "Password"

Installation

  1. Clone the repository:

git clone https://github.com/hktari/toshl-mcp-server.git
cd toshl-mcp-server
  1. Install dependencies:

npm install
  1. Create a .env file based on the .env.example file:

cp .env.example .env
  1. Edit the .env file and add your Toshl API token:

TOSHL_API_TOKEN=your_api_token

Building

Build the project:

npm run build

Running

Start the server:

npm start

Configure MCP server

The server speaks MCP over stdio. Point your client at dist/index.js and pass TOSHL_API_TOKEN in its environment — step-by-step instructions for Claude Code, OpenCode, and Codex CLI are in docs/mcp-clients.md.

For any other client that takes a generic mcpServers config:

{
    "mcpServers": {
        "toshl": {
            "command": "node",
            "args": ["/absolute/path/to/toshl-mcp-server/dist/index.js"],
            "env": {
                "TOSHL_API_TOKEN": "your-token"
            }
        }
    }
}

Remote use (Streamable HTTP)

stdio is the default and needs nothing below. To reach the server from clients that can't spawn a local process (web and mobile apps, a server you run elsewhere), switch it to Streamable HTTP:

MCP_TRANSPORT=http MCP_AUTH_TOKEN="$(openssl rand -hex 32)" TOSHL_API_TOKEN=your-token npm start

It serves:

Path

Methods

Checks

Purpose

/mcp

POST, GET, DELETE

Host, Origin, bearer token (static or OAuth)

MCP endpoint, one session per client

/healthz

GET, HEAD

Host

Liveness check. Returns {"status":"ok"} and nothing else

/.well-known/oauth-*, /oauth/*

see Sign-in with OAuth

Host

Only when OAuth is on

Variable

Default

Meaning

MCP_TRANSPORT

stdio

stdio or http

MCP_HTTP_HOST

127.0.0.1

Interface to bind

MCP_HTTP_PORT

3000

Port to bind

MCP_AUTH_TOKEN

unset

/mcp requires Authorization: Bearer <token>. At least 32 characters. Required in HTTP mode unless OAuth is on or MCP_ALLOW_NO_AUTH=true

MCP_ALLOW_NO_AUTH

unset

true (exactly) lets HTTP mode start without MCP_AUTH_TOKEN. Only for a proxy that authenticates every request

MCP_ALLOWED_HOSTS

unset

Comma-separated Host names accepted besides localhost, 127.0.0.1 and [::1]

MCP_ALLOWED_ORIGINS

unset

Comma-separated origins (https://host[:port]) accepted in an Origin header on /mcp

Security

Anyone who can get a request through to /mcp can read and change your Toshl data. Each layer below closes a different path to it:

  • Authentication is mandatory. In HTTP mode the server refuses to start without MCP_AUTH_TOKEN or the built-in OAuth server, which is how claude.ai connectors sign in. To use an authenticating proxy in front instead, set MCP_ALLOW_NO_AUTH=true. The server then logs a SECURITY WARNING at error level on every start. Never expose /mcp without authentication, and don't count on an unguessable URL to protect it.

  • TLS and loopback. Keep the default loopback bind and reach the server only through a TLS-terminating reverse proxy. The bearer token travels in a header, so plain HTTP across a network gives it away.

  • Host check (DNS rebinding). Every request's Host must be loopback or listed in MCP_ALLOWED_HOSTS. That stops a web page you visit from pointing its own name at 127.0.0.1 and driving a local server. A proxy usually forwards the public name as Host, so list that name.

  • Origin check. As the MCP spec requires, /mcp validates Origin. Requests without one are accepted, because native clients, CLIs and server-side connectors don't send it. A present Origin, including the opaque null, must be listed in MCP_ALLOWED_ORIGINS or the request gets 403, before authentication is even checked. The list is empty by default, so no browser page can call /mcp unless you allow it.

# Caddyfile: automatic TLS, forwards Host unchanged
example.com {
    reverse_proxy 127.0.0.1:3000
}
MCP_ALLOWED_HOSTS=example.com

Sign-in with OAuth

claude.ai connectors (on the web, Desktop, mobile and Cowork) sign in with OAuth rather than a fixed header. The server has a small OAuth 2.1 authorization server of its own for that. There is a single user, and approving a client means typing a passphrase you set. Add https://<your host>/mcp as a custom connector in Claude and leave the OAuth client on "Use Claude's published identity".

Variable

Meaning

MCP_PUBLIC_URL

Public origin, e.g. https://example.com, without a path. The MCP URL is <MCP_PUBLIC_URL>/mcp. Its host is added to MCP_ALLOWED_HOSTS automatically

MCP_OAUTH_PASSPHRASE

Typed on the sign-in page to approve a client. At least 20 characters

MCP_OAUTH_SIGNING_KEY

Signs access tokens and sign-in forms. At least 32 characters (openssl rand -hex 32)

MCP_OAUTH_SIGNING_KEY_PREVIOUS

Optional. A retired key that still verifies, for rotation without signing everyone out

MCP_OAUTH_STATE_DIR

Where refresh-token hashes are kept. Must survive restarts (/app/state in the image)

MCP_TRUST_PROXY

true to rate-limit by the client address the proxy appends to X-Forwarded-For. Turn it on behind a proxy, where otherwise every client shares the proxy's address and one IP's lockout locks out everyone. Leave it off when clients can reach the port directly, because they could then forge the header

MCP_CLIENT_IP_HEADER

A header the proxy in front overwrites with the client address, e.g. x-real-ip on Railway. Used for rate limiting instead of the last X-Forwarded-For entry, which behind Railway is one of Railway's own hops and changes per request. Needs MCP_TRUST_PROXY=true

OAuth turns on when the passphrase and signing key are set. It works alongside MCP_AUTH_TOKEN, so Claude Code or a script can keep using a static token.

How it behaves:

  • Clients. Only Claude (callback https://claude.ai/api/mcp/auth_callback) and Claude Code (loopback callbacks on localhost and 127.0.0.1, any port, RFC 8252) are accepted. Both are pinned by their published client IDs. The server never fetches the metadata documents, so it still contacts no host but the Toshl API. Dynamic client registration is not offered.

  • PKCE with S256 is required. The resource parameter must name this server, and tokens are bound to it.

  • Access tokens last 1 hour. They are signed with MCP_OAUTH_SIGNING_KEY and not stored anywhere. Changing the key without keeping the old one as _PREVIOUS invalidates every access token at once.

  • Refresh tokens rotate on every use, expire after 30 days unused and 180 days at most, and are stored only as SHA-256 hashes in MCP_OAUTH_STATE_DIR/refresh-tokens.json.

    • An already-used refresh token may be retried once within 30 seconds, which covers a client's two concurrent refreshes.

    • Any other reuse revokes every token from that sign-in.

    • Deleting the file signs every client out.

  • Authorization codes work once. A failed exchange burns the code. A replayed code revokes the tokens the first exchange issued.

  • The sign-in page:

    • five wrong passphrases from one IP (or one IPv6 /64) lock that address out for 15 minutes

    • twenty from anywhere close sign-in for an hour. Tokens already issued keep working, but this means anyone can delay a new sign-in by an hour.

    • every failure is delayed by half a second

    • the form only accepts posts from its own origin, and has no scripts, no external assets and a strict Content Security Policy

  • Logs record sign-ins, failures, lockouts and token reuse, with the client ID and IP. Passphrases, codes and tokens are never logged.

Sign in with Toshl (one server, many users)

The passphrase mode above serves one person. With a Toshl OAuth app, one hosted server serves anyone with a Toshl account: they add https://<your host>/mcp as a custom connector in Claude, click Connect, sign in to Toshl and approve. No personal token, no passphrase.

  1. Register an app at developer.toshl.com/apps with the redirect URI https://<your host>/oauth/toshl/callback and the scopes the tools need (user:r, entries:rw, accounts:r, budgets:r, categories:rw, tags:rw). Until Toshl approves the app for other users, only your own account can sign in.

  2. Set TOSHL_OAUTH_CLIENT_ID and TOSHL_OAUTH_CLIENT_SECRET instead of MCP_OAUTH_PASSPHRASE, alongside MCP_PUBLIC_URL, MCP_OAUTH_SIGNING_KEY and MCP_OAUTH_STATE_DIR. Leave TOSHL_API_TOKEN and MCP_AUTH_TOKEN unset; the server refuses to start with either.

How it works: Claude's sign-in is handed to Toshl's, and our callback stores the user's Toshl tokens in <MCP_OAUTH_STATE_DIR>/toshl-tokens.json, encrypted (AES-256-GCM, key derived from MCP_OAUTH_SIGNING_KEY). Every /mcp request runs as the user its access token names: that user's Toshl token (refreshed before it expires), that user's cache entries, and only sessions that user opened. If Toshl revokes the grant, the user's tokens are deleted and Claude asks them to connect again. Design notes: docs/superpowers/specs/2026-11-13-sign-in-with-toshl-design.md.

Personal-token sign-in (many users, no Toshl OAuth app)

Toshl issues OAuth apps on request only; developer.toshl.com/apps offers personal tokens. Until an OAuth app exists, set MCP_SIGN_IN=personal-token instead of the Toshl client variables. The consent page then asks each person to create a personal token in Toshl and paste it once. The server checks it against Toshl's /me, stores it encrypted under that user, and everything else works as in Sign in with Toshl: per-user requests, cache and sessions. Wrong tokens count towards the sign-in lockout. Deleting the token in Toshl disconnects the user; Claude then asks them to connect again. Each connection is logged with the number of connected users.

Operator, terms and privacy (hosted instances)

A server that holds other people's financial data should say who runs it. Set MCP_OPERATOR_NAME (and optionally MCP_OPERATOR_URL, MCP_TERMS_URL, MCP_PRIVACY_URL, all https) and the consent page shows "Run by …", states that the service is independent of Toshl and Anthropic, and that connecting means agreeing to the terms of use.

Sessions

Sessions are held in memory. A session with no request for 30 minutes is closed, and the client opens a new one on its next call. SIGTERM and SIGINT close every session before exiting.

Docker

The Dockerfile builds an image that starts in HTTP mode, listening on port 3000 as the unprivileged node user. Inside the container it binds 0.0.0.0 so the published port can reach it. Publish that port on loopback only, and pass secrets at run time; the image contains none:

docker build -t toshl-mcp-server .
docker run -d --restart unless-stopped \
    -p 127.0.0.1:3000:3000 \
    --env-file /path/outside/the/repo/toshl-mcp.env \
    toshl-mcp-server

The env file holds TOSHL_API_TOKEN, MCP_ALLOWED_HOSTS, and either MCP_AUTH_TOKEN or the OAuth settings. Without any of them the container exits at startup unless MCP_ALLOW_NO_AUTH=true. Make the file readable only by its owner (chmod 600). .dockerignore keeps every .env* file out of the build context.

With OAuth on, mount a volume at /app/state (writable by uid 1000) so sign-ins survive redeploys, e.g. -v /srv/toshl-mcp/state:/app/state.

Development

Run the server in development mode:

npm run dev

Documentation

Project Structure

toshl-mcp-server/
├── src/
│   ├── index.ts                 # Entry point
│   ├── server/                  # MCP server implementation
│   │   └── server.ts            # Main server class
│   ├── api/                     # Toshl API client
│   │   ├── toshl-client.ts      # Base API client
│   │   ├── auth.ts              # Authentication module
│   │   └── endpoints/           # Endpoint-specific clients
│   │       ├── accounts.ts      # Accounts API client
│   │       ├── categories.ts    # Categories API client
│   │       ├── tags.ts          # Tags API client
│   │       ├── budgets.ts       # Budgets API client
│   │       ├── entries.ts       # Entries API client
│   │       ├── me.ts            # User API client
│   │       └── planning.ts      # Planning API client
│   ├── resources/               # MCP resource handlers
│   │   ├── account-resources.ts # Account resources
│   │   ├── category-resources.ts# Category resources
│   │   ├── tag-resources.ts     # Tag resources
│   │   ├── budget-resources.ts  # Budget resources
│   │   └── user-resources.ts    # User resources
│   ├── tools/                   # MCP tool handlers
│   │   ├── account-tools.ts     # Account tools
│   │   ├── category-tools.ts    # Category tools
│   │   ├── tag-tools.ts         # Tag tools
│   │   ├── budget-tools.ts      # Budget tools
│   │   ├── user-tools.ts        # User tools
│   │   └── analysis-tools.ts    # Financial analysis tools
│   └── utils/                   # Utility functions
│       ├── cache.ts             # Caching utilities
│       ├── error-handler.ts     # Error handling utilities
│       ├── logger.ts            # Logging utilities
│       └── types.ts             # TypeScript type definitions
├── dist/                        # Compiled JavaScript files
├── .env                         # Environment variables
├── .env.example                 # Example environment variables
├── package.json                 # Project dependencies
├── tsconfig.json                # TypeScript configuration
└── README.md                    # Project documentation

Configuration

The server can be configured using environment variables:

  • TOSHL_API_TOKEN: Your Toshl API token

  • TOSHL_API_BASE_URL: The base URL for the Toshl API (default: https://api.toshl.com)

  • MCP_SERVER_NAME: The name of the MCP server (default: toshl-mcp-server)

  • MCP_SERVER_VERSION: The version of the MCP server (default: 0.1.0)

  • CACHE_TTL: Time to live for cached data in seconds (default: 3600)

  • CACHE_ENABLED: Whether caching is enabled (default: true)

  • LOG_LEVEL: Logging level (default: info)

  • API_TIMEOUT: How long one attempt at a Toshl request may take, in milliseconds (default: 12000)

  • API_RETRIES: Extra attempts for a read that timed out or that Toshl answered 502/503/504 (default: 1). Writes are never repeated: one that Toshl did not answer may still have been applied, so it is reported instead. Keep API_TIMEOUT × (API_RETRIES + 1) inside your MCP client's tool timeout.

  • API_RETRY_DELAY_MS: Pause before the first retry, doubled for each further one (default: 500)

  • MCP_TRANSPORT, MCP_HTTP_HOST, MCP_HTTP_PORT, MCP_AUTH_TOKEN, MCP_ALLOW_NO_AUTH, MCP_ALLOWED_HOSTS, MCP_ALLOWED_ORIGINS: see Remote use (Streamable HTTP)

License

MIT

Available Tools

27 tools
account_getB

Get details of a specific account in Toshl Finance

Inputs: id (required).

account_listA

List all accounts in Toshl Finance

Inputs: no named parameters.

analyze_account_balanceC

Analyze account balances

Inputs: no named parameters.

analyze_budget_performanceC

Analyze budget adherence

Inputs: no named parameters.

analyze_spending_by_categoryB

Analyze spending patterns by category

Inputs: no named parameters.

budget_getA

Get details of a specific budget in Toshl Finance

Inputs: id (required).

budget_historyB

Get history of a specific budget in Toshl Finance

Inputs: id (required).

budget_listB

List all budgets in Toshl Finance

Inputs: no named parameters.

category_createA

Create a new category in Toshl Finance

Inputs: name (required), type (required).

category_getA

Get details of a specific category in Toshl Finance

Inputs: id (required).

category_listB

List all categories in Toshl Finance

Inputs: no named parameters.

entry_convert_to_transferA

Convert a regular entry to a transfer between accounts in Toshl Finance

Inputs: id (required), destination_account (required), description.

entry_createA

Create a new entry in Toshl Finance. To create a transfer between accounts, include a transaction object with the destination account ID and currency.

Inputs: date (required), amount (required), account (required), category (required), +4 more.

entry_deleteB

Delete an entry in Toshl Finance

Inputs: id (required), deleteMode.

entry_getA

Get details of a specific entry in Toshl Finance

Inputs: id (required).

entry_listC

List entries in Toshl Finance

Inputs: to (required), from (required), tags, type, +3 more.

entry_manageD

Manage entries in bulk in Toshl Finance.

Inputs: with (required), add, set, remove.

entry_sumsC

Get daily sums of entries in Toshl Finance

Inputs: to (required), from (required), currency (required), tags, +4 more.

entry_timelineC

Get timeline of entries in Toshl Finance

Inputs: to (required), from (required), tags, accounts, +1 more.

entry_updateC

Update an existing entry in Toshl Finance

Inputs: id (required), date, desc, tags, +5 more.

tag_createB

Create a new tag in Toshl Finance

Inputs: name (required), type (required), category.

tag_getA

Get details of a specific tag in Toshl Finance

Inputs: id (required).

tag_listA

List all tags in Toshl Finance

Inputs: no named parameters.

user_paymentsB

Get payments from Toshl Finance

Inputs: no named parameters.

user_payment_typesB

Get payment types from Toshl Finance

Inputs: no named parameters.

user_profileB

Get user profile information from Toshl Finance

Inputs: no named parameters.

user_summaryC

Get account summary from Toshl Finance

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.7/5.0

    Scored across 27 tools

    Disambiguation3/5

    Several tools overlap in scope: entry_list, entry_sums, and entry_timeline all query entries in different ways, and entry_manage may subsume create/update/delete operations. user_summary and account_list could be confused. However, most resource-specific tools are distinct.

    Naming Consistency3/5

    Most tools use a resource_verb pattern (account_list, entry_get), but analyze_* breaks the pattern with verb_noun, and tools like user_profile, budget_history are noun-only. This mixing is inconsistent but still readable.

    Tool Count2/5

    27 tools is above the 25 threshold, making the surface feel heavy. Although the finance domain has many resources, the count is excessive and some tools (e.g., entry_manage) could be merged with CRUD operations.

    Completeness3/5

    Entries have full CRUD coverage, but accounts, categories, tags, and budgets lack update/delete operations, and accounts have no create at all. This creates significant gaps for full lifecycle management, though read and analysis are well covered.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to manage personal finances through MCP tools for transaction management, spending analytics, and goal tracking.
      1
      -
    • A
      license
      C
      quality
      B
      maintenance
      Enables AI assistants and agents to securely query, reconcile, analyze, and manage personal finances in Actual Budget through MCP tools and APIs.
      87
      MIT
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI assistants and other MCP clients to access and manage personal finance data, including transactions, budgets, accounts, categories, tags, recurring items, and cryptocurrency. It provides automated financial insights and comprehensive CRUD operations through LunchMoney's API.
      41 npm
      -
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI assistants and other MCP clients to access and manage personal finance data through LunchMoney's API, including transactions, budgets, categories, tags, accounts, recurring items, and crypto.
      41 npm
      MIT