Avanza MCP
Independent local Streamable HTTP MCP server for Avanza authentication, account data, instruments, market data, and orders. It uses the unofficial avanza-api package. Order tools can affect real money, so keep MCP approval enabled and use AVANZA_MCP_ALLOWED_ACCOUNT_ID when authenticated.
[!WARNING]This is an unofficial community project. It is not affiliated with, endorsedby, or supported by Avanza Bank AB. Avanza does not provide an official publicAPI for this integration, so endpoints may change without notice. You areresponsible for complying with Avanza's terms and for every action performedthrough your account.
Setup and run
uv sync --extra test
Copy-Item .env.example .env
uv run python -c "import secrets; print(secrets.token_urlsafe(32))"
uv run avanza-mcp-http
Paste the generated random value into AVANZA_MCP_BEARER_TOKEN in .envbefore starting the server. Tokens shorter than 32 characters and the publishedexample placeholder are rejected.
The endpoint is http://127.0.0.1:8765/mcp by default. Public market-data tools work without Avanza login credentials; the local MCP bearer token is always required. See docs/tool-matrix.md for risk classifications.
Keep the server bound to localhost. Do not expose it directly to the publicinternet, reuse the bearer token elsewhere, or commit credentials. Tools thatplace, edit, or cancel orders can affect real money and should always requireinteractive MCP approval.
Money-affecting tools are blocked even after login unless bothAVANZA_MCP_ENABLE_LIVE_TRADING=true andAVANZA_MCP_ALLOWED_ACCOUNT_ID=<account-id> are configured. Keep live tradingdisabled for read-only account access. The tools also publish standard MCPread-only and destructive annotations so compatible clients can apply theirnormal approval policies.
Environment ownership
This project exclusively owns all AVANZA_* variables shown in .env.example. Never commit .env.
Tests
uv run pytest
Tests use mocked clients and do not place orders.
Contributing and security
See CONTRIBUTING.md before submitting changes. Reportsecurity issues according to SECURITY.md, never in an issue thatcontains credentials, account data, or bearer tokens.
License
MIT. See LICENSE.