Skip to main content
Glama
avanza-mcp

avanza-mcp

by truls27a

avanza-mcp

An MCP server that lets an AI assistant read your Avanza accounts, holdings and transactions, and look up public market data. You log in with BankID through a small login panel shown right in the chat.

Unofficial. Avanza has no public API. This server uses the same internal endpoints as avanza.se's own web app. They can change or break at any time, and automated use may be against Avanza's terms. Not affiliated with Avanza or BankID. Use at your own risk.

What it can do

Read-only. There are no tools for orders or transfers.

Tool

Login needed

What it returns

connect_avanza

Shows the BankID login panel

avanza_status

Whether you're logged in, and how old the snapshot is

disconnect_avanza

Logs out and deletes the stored session

get_accounts

snapshot without login

Accounts with total value and cash

get_holdings

snapshot without login

Positions and cash, for one account or all

get_transactions

yes

Trades, deposits, dividends and fees

search_instruments

no

Stocks, funds, ETFs etc. by name, ticker or ISIN

get_instrument

no

Quote, key ratios, dividends, or fund details

get_price_history

no

Closing prices from one week to five years

Avanza ends a web session after at most 24 hours. Every time you log in, the server saves a snapshot of your accounts and holdings. While you're logged out, get_accounts and get_holdings answer from that snapshot, with holdings re-priced from live public quotes.

Related MCP server: Avanza MCP Server

The login panel

connect_avanza returns an interactive MCP Apps panel instead of a link:

  • On a computer it shows a live BankID QR code. Scan it with the BankID app.

  • On a phone it shows an Open BankID button that opens the BankID app on the same device.

The login only starts when the panel asks for it. That matters because BankID cancels a login the app hasn't picked up within about 30 seconds. A link written out by the assistant often arrives too late; the panel avoids that. The QR code is refreshed every second, and a new login is started automatically if nobody scans within 30 seconds.

You need a client that renders MCP Apps panels, such as ChatGPT. In a client without MCP Apps support the market-data tools still work, but there is no way to log in.

Install

Requires Python 3.12+ and uv.

git clone https://github.com/truls27a/avanza-mcp.git
cd avanza-mcp
uv sync
uv run avanza-mcp --help

Local clients (stdio)

For a client that starts the server itself, add something like this to its MCP config:

{
  "mcpServers": {
    "avanza": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/avanza-mcp", "avanza-mcp"]
    }
  }
}

Remote clients (HTTP)

AVANZA_MCP_TOKEN="$(openssl rand -hex 32)" uv run avanza-mcp --transport http --port 8000

The MCP endpoint is http://127.0.0.1:8000/mcp, and /healthz is a health check.

  • By default it listens on 127.0.0.1 only.

  • If AVANZA_MCP_TOKEN is set, every request must send Authorization: Bearer <token>.

  • It refuses to listen on a non-loopback address without a token. The exception is --allow-unauthenticated, meant for a private container network where the only way in is a tunnel you control.

ChatGPT needs to reach the server over the internet. Put it behind a tunnel or reverse proxy that handles authentication, and never expose an unauthenticated port.

Docker

docker build -t avanza-mcp .
docker run -d --name avanza-mcp -p 127.0.0.1:8000:8000 \
  -e AVANZA_MCP_TOKEN=change-me -v avanza-mcp-data:/data avanza-mcp

Configuration

Setting

Default

--transport

stdio

stdio or http

--host / --port

127.0.0.1 / 8000

HTTP only

--data-dir / AVANZA_MCP_DATA_DIR

~/.local/state/avanza-mcp

Where the session and snapshot are stored

AVANZA_MCP_TOKEN

unset

Bearer token required on HTTP

--allow-unauthenticated

off

Allow a non-loopback HTTP address without a token

Security

Read this before you run it.

  • One user per server. The server stores one Avanza session. Anyone who can call the server can read that person's accounts, holdings and transactions. Run your own instance and keep it private.

  • The stored session can do more than this server does. The tools are read-only, but the stored cookies are a normal Avanza web session, which can also place orders. Anyone who gets hold of the data directory can act on the account until the session ends (at most 24 hours). The directory is created 0700 and the database 0600. Use disconnect_avanza to log out early.

  • No credentials are stored. Login is BankID only; the server never sees a password or a personal identity number.

  • Instrument names and descriptions come from Avanza. The server tells the model to treat them as data, not instructions.

Limitations

  • If one BankID has several Avanza customer profiles (for example private plus a company), login fails: choosing a profile isn't supported yet.

  • Endpoints and response shapes are reverse-engineered and may change without notice.

License

MIT

Available Tools

11 tools
avanza_statusAvanza StatusA
Read-onlyIdempotent

Whether a BankID session is stored, the latest login attempt's status, and the snapshot age. Makes no Avanza call.

Inputs: no named parameters. Returns: object

bankid_login_pollBankid Login PollB
Read-onlyIdempotent

Login panel only: current login status and QR code.

Inputs: no named parameters. Returns: object

bankid_login_startBankid Login StartA

Login panel only: start a BankID login, 'qr' to scan from another device or 'app' for this device.

Inputs: mode. Returns: object

connect_avanzaConnect AvanzaA
Read-only

Show the BankID login panel (live QR code, or a button that opens BankID on this device). The login happens in the panel; this call does not start BankID by itself.

Inputs: no named parameters. Returns: object

disconnect_avanzaDisconnect AvanzaA

Log out of Avanza and delete the stored session. The holdings snapshot is kept.

Inputs: no named parameters. Returns: object

get_accountsGet AccountsA
Read-onlyIdempotent

Accounts with total value and cash. Live with a session, otherwise from the snapshot.

Inputs: no named parameters. Returns: object

get_holdingsGet HoldingsA
Read-onlyIdempotent

Positions (volume, value, acquired value) and cash, for one account or all. Live with a session, otherwise snapshot quantities priced with live public quotes.

Inputs: account_id. Returns: object

get_instrumentGet InstrumentB
Read-onlyIdempotent

Quote, key ratios, dividend and report dates for a stock or ETF; NAV, fees, returns and top holdings for a fund.

Inputs: order_book_id (required). Returns: object

get_price_historyGet Price HistoryC
Read-onlyIdempotent

Closing prices over a period.

Inputs: order_book_id (required), period. Returns: object

get_transactionsGet TransactionsA
Read-onlyIdempotent

Transactions (trades, deposits, dividends, fees), newest first. Needs a live session.

Inputs: limit, date_to, date_from, account_id. Returns: object

search_instrumentsSearch InstrumentsB
Read-onlyIdempotent

Search stocks, funds, ETFs and more by name, ticker or ISIN.

Inputs: query (required), limit, instrument_type. Returns: object

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 11 tools

    Disambiguation3/5

    The market-data tools (get_accounts, get_holdings, get_transactions, search_instruments, get_instrument, get_price_history) are cleanly separated, but the auth cluster is muddier: avanza_status and bankid_login_poll both report login state, and connect_avanza vs bankid_login_start differ only in a subtle panel-vs-login distinction. The descriptions do explicitly disambiguate ('this call does not start BankID by itself', 'Login panel only'), which keeps it from being worse than a 3.

    Naming Consistency3/5

    Mostly verb_noun (get_accounts, search_instruments, disconnect_avanza), but prefixes are inconsistent: some tools carry domain prefixes (avanza_status, bankid_login_start), others are bare verbs (connect_avanza, get_holdings), and avanza_status is a noun phrase rather than an action. Readable, but not a single predictable pattern.

    Tool Count4/5

    Eleven tools is a sensible scope for a brokerage read/query server. Four of them are spent on the BankID auth lifecycle (status, connect, start, poll), which is slightly heavy but justified given the session-based access model.

    Completeness3/5

    Account, holdings, transaction, instrument and price-history reads give decent coverage of a read-only investing workflow, with a working snapshot fallback. However, there are no order/trade tools, no watchlists, and no session-refresh or order-history-by-instrument operations, leaving notable gaps for a brokerage domain.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to securely interact with Charles Schwab accounts through OAuth authentication, providing access to account balances, real-time market quotes, options chains, transaction history, order management, and comprehensive market data.
      1
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Provides access to Avanza's public API for real-time Swedish stock quotes, fund information, and comprehensive market data. It enables users to perform detailed stock analysis, compare funds, and retrieve portfolio holdings through natural language.
      34
      32
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A read-only MCP server that securely connects Swedish/Nordic bank accounts to AI assistants, keeping all financial data local and encrypted.
      33 npm
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables financial data access from connected bank accounts via MCP tools, allowing natural language queries about balances, transactions, subscriptions, investments, and more, with a focus on privacy and read-only access.
      2
      MIT