Satsuj1n
portfolio-mcp
TypeScriptโœจ New

Local-first, read-only MCP server to talk to your XP Investimentos portfolio through Claude Desktop. TypeScript + SQLite. Zero scraping, zero credentials.

Last updated Jul 1, 2026
12
Stars
1
Forks
0
Issues
0
Stars/day
Attention Score
44
Language breakdown
TypeScript 97.4%
JavaScript 2.6%
โ–ธ Files click to expand
README

portfolio-mcp

Talk to your XP Investimentos portfolio through Claude โ€” 100% local, read-only, zero scraping.

TypeScript Node.js MCP License npm Status


What is this?

portfolio-mcp is a Model Context Protocol server that exposes your XP Investimentos portfolio to Claude Desktop (or any MCP-compatible client). You feed it the official PDF/CSV exports XP already gives you โ€” the server parses them, normalizes everything into a local SQLite database, and answers questions through MCP tools.

  • ๐Ÿ”’ Local-first โ€” data lives in ~/.xp-mcp/data.db. Core tools make zero outbound HTTP calls; advisor tools (v0.4+) are opt-in.
  • ๐Ÿ“ต No credentials, no scraping โ€” you control what goes in (PDF/CSV exports).
  • ๐Ÿ‘ Read-only by design โ€” no tool can place orders or modify anything at XP.
  • ๐Ÿงฑ Stdio transport โ€” Claude spawns the process; nothing listens on a port.
Built for personal use, but the architecture works for any custodian that lets you export reports (Rico, NuInvest, Inter, Avenue, ...). PRs welcome.

Why does this exist?

Custodian apps are great at "show me what I have" but terrible at:

  • "Compare my current allocation against my target portfolio."
  • "Which of my CDBs mature in the next 12 months?"
  • "What's my real yield-to-maturity weighted by position size?"
  • "How concentrated am I in a single issuer's FGC limit?"
MCP lets you bolt that intelligence onto Claude without giving the LLM provider your credentials, sending your positions to a third-party SaaS, or trusting browser-scraping that breaks every quarter.

Demo

After connecting the server, just chat with Claude:

You: Liste minhas posiรงรตes agrupadas por classe de ativo.

Claude (using portfolio-mcp.get_positions): TESOURO (53.28%) R$ 16,644.31 โ€ข Tesouro Selic 2031 R$ 14,556.80 โ€ข Tesouro Selic 2028 R$ 2,087.51

RENDAFIXAPRIVADA (20.98%) R$ 6,554.32 โ€ข CDB BANCO XP - AGO/2026 - 15,00% R$ 2,203.85 โ€ข CDB BANCO XP - SET/2026 - 14,95% R$ 2,197.10 โ€ข CDB BANCO XP - OUT/2026 - 14,55% R$ 1,083.63 โ€ข CDB BANCO XP - NOV/2027 - 100,00% CDI R$ 1,069.74

FUNDO (10.48%) R$ 3,273.71 ACAO ( 7.44%) R$ 2,325.12 (BBAS3) FII ( 7.81%) R$ 2,439.20 (MXRF11, GTWR11)

Total: R$ 31,236.66

You: Quais CDBs vencem em 2026?

Claude (filters by assetclass + maturitydate): 3 CDBs maturing in 2026: โ€ข Aug/2026 โ€” 15.00% pre-fixed R$ 2,203.85 โ€ข Sep/2026 โ€” 14.95% pre-fixed R$ 2,197.10 โ€ข Oct/2026 โ€” 14.55% pre-fixed R$ 1,083.63 All issued by BANCO XP S.A. (within single-issuer FGC limit โœ“)

You: Estou bem alocado em relaรงรฃo ao meu target?

Claude (using portfolio-mcp.calculateallocationdrift): Lendo ~/.xp-mcp/allocation.json (target: 40% Tesouro, 20% RF, 15% FII, 15% Aรงรตes, 5% ETF, 5% Fundos, tolerรขncia ยฑ2pp).

Mais fora do alvo: โ€ข TESOURO: 53.28% (target 40%) โ†’ vender ~R$ 4.148 โ€ข ACAO: 7.44% (target 15%) โ†’ comprar ~R$ 2.362 โ€ข FII: 7.81% (target 15%) โ†’ comprar ~R$ 2.247

Dentro da banda: โ€ข RENDAFIXAPRIVADA: 20.98% (target 20%) โœ“

Fora da banda, magnitude menor: โ€ข FUNDO: 10.48% (target 5%) โ€” vender ~R$ 1.712 โ€ข ETF: 0.00% (target 5%) โ€” comprar ~R$ 1.562

Net rebalance: -R$ 152 (aporte pequeno sugerido pra fechar).

You: Me dรก um panorama do meu portfรณlio.

Claude (using portfolio-mcp.getportfoliosummary): Total: R$ 31.236,66 (12 posiรงรตes, ref. 2026-05-21) P&L: +R$ 2.736,66 (+9,60% sobre R$ 28.500 investidos ยท 8/12 com P&L computรกvel)

Por classe: TESOURO 53,28% R$ 16.644,31 RENDAFIXAPRIVADA 20,98% R$ 6.554,32 (+4,04%) FUNDO 10,48% R$ 3.273,71 ACAO 7,44% R$ 2.325,12 FII 7,81% R$ 2.439,20

FGC: R$ 6.554,32 (20,98%) cobertos Vencimentos: curto R$ 5.484 ยท mรฉdio R$ 16.625 ยท longo R$ 1.070 ยท sem maturity R$ 8.038

Reconciliaรงรฃo: declarado R$ 31.250,00 vs computado R$ 31.236,66 โ†’ gap โˆ’R$ 13,34 (โˆ’0,04%, dentro de tolerรขncia)


Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Claude Desktop โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚ stdio (JSON-RPC 2.0)
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       PDF / CSV       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   portfolio-mcp     โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚   XP exports         โ”‚
โ”‚  TypeScript + MCP   โ”‚                       โ”‚   (your machine)     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚ SQL (better-sqlite3, WAL mode)
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚      SQLite         โ”‚
โ”‚   ~/.xp-mcp/        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

No network. No credentials. Read-only at XP.

Stack: TypeScript ยท @modelcontextprotocol/sdk ยท better-sqlite3 ยท pdf-parse ยท papaparse ยท zod


Tools

| Tool | Purpose | Status | | ----------------------------- | -------------------------------------------------------------------------------------- | :----: | | importxperformancepdf | Parse XP's official portfolio PDF (XPerformance). Idempotent on re-import. | โœ… | | importextractcsv | Parse a Posiรงรฃo Consolidada / Extrato CSV. Auto-detects delimiter and column aliases. | โœ… | | get_positions | List positions with quantity, market value, indexer, maturity. Optional class filter. | โœ… | | getportfoliosummary | Aggregate stats + declared-vs-computed reconciliation gap. Output now includes a cashflowsummary block (YTD + rolling 12m aporte/resgate aggregates) when cash flows have been imported. | โœ… | | get_transactions | History of buys/sells | โณ | | get_dividends | Income / proventos | โณ | | calculateallocationdrift | Compare current vs target allocation from ~/.xp-mcp/allocation.json. Returns drift %, BRL delta, and BUY/SELL suggestions per class. | โœ… | | setadvisorprofile | Save the advisor profile (risk, horizon, objective, exclusions, outbound gate, brapi token). | โœ… | | getadvisorprofile | Read the saved profile. Returns exists: false if not configured. | โœ… | | getmarketdata | Quotes / fundamentals from brapi.dev for 1-50 tickers, SQLite-cached. Opt-in. | โœ… | | screen_assets | Rank B3 FIIs / stocks / ETFs by DY, P/VP, P/L, ROE, market cap. Opt-in. | โœ… | | importnotacorretagem | Parse broker-note PDFs for transaction history | โณ | | importbankextract_pdf | Import a PDF exported from XP's Conta Digital Extrato. Filters for investment-account transfers only (APORTE/RESGATE). Idempotent. | โœ… | | getcashflows | List cash flows with optional date/kind filters; returns aggregate totals (aporte/resgate/net) over all matching rows. | โœ… | | suggestbuys | Suggest BUYs per underweight class using profile objective ร— asset class matrix (FII/ACAO/ETF). Non-screenable classes (TESOURO/RF/FUNDO) reported in skippedclasses. Requires outbound_enabled=true. | โœ… | | calculate_twr | Time-weighted return (TWR) over XPerformance imports. Modified Dietz chained โ€” GIPS-compliant for portfolios without daily NAV. Requires โ‰ฅ 2 imports. | โœ… | | calculate_mwr | Money-weighted return (MWR / IRR) via bisection over signed cash flows. Reports converged=false cleanly when no sign change. Requires โ‰ฅ 2 imports. | โœ… | | getcryptoquote | Spot crypto quotes in BRL via Mercado Bitcoin. Per-ticker partial failure, 15-min cache, outbound-gated. Quote-only (not yet a tracked asset_class). | โœ… | | setcryptoposition | Manually track a crypto holding (CRIPTO asset_class). Fetches a live quote, stores a snapshot market value (quantity ร— price). quantity: 0 removes it. No cost basis / P&L. Outbound-gated. | โœ… |


Quick Start

Add this to your claudedesktopconfig.json:

{
  "mcpServers": {
    "portfolio": {
      "command": "npx",
      "args": ["-y", "portfolio-mcp"]
    }
  }
}

Config file location:

  • macOS: ~/Library/Application Support/Claude/claudedesktopconfig.json
  • Windows: %APPDATA%\Claude\claudedesktopconfig.json
  • Linux: ~/.config/Claude/claudedesktopconfig.json
Restart Claude Desktop. Done.

See Development below for clone + build instructions if you want to hack on the server.


How to export from XP

XP has no single "export everything" button. Try in this order:

  • XPerformance PDF (recommended) โ€” Investimentos โ†’ XPerformance โ†’ โฌ‡ PDF. The richest single-file snapshot.
  • Portal XP web โ€” Investimentos โ†’ Posiรงรฃo Consolidada โ†’ Exportar CSV
  • Hub XP / Assessor Digital โ€” Meus Investimentos โ†’ Posiรงรฃo โ†’ Exportar
  • Notas de corretagem (PDF) โ€” Conta โ†’ Documentos โ†’ Notas de Corretagem (phase 2)
  • Extrato de movimentaรงรฃo โ€” Conta โ†’ Extrato โ†’ filtrar perรญodo โ†’ Exportar
The CSV parser auto-detects ;, ,, \t, | delimiters and fuzzy-matches common XP column names (Quantidade, Qtd, Preรงo mรฉdio, Valor aplicado, ...). If a column is missed, extend HEADER_ALIASES in src/parsers/csv-extract.ts.

Configuring your target allocation

calculateallocationdrift reads ~/.xp-mcp/allocation.json. A starter file is included at examples/allocation.example.json. Copy it once and edit the percentages:

mkdir -p ~/.xp-mcp
cp examples/allocation.example.json ~/.xp-mcp/allocation.json

The seven valid keys are TESOURO, RENDAFIXAPRIVADA, FII, ETF, ACAO, FUNDO, CRIPTO. Values must sum to 1.00 (ยฑ0.001). tolerance_pp is optional โ€” when set, drifts within the band are reported as "ok" with no action.


Try it without Claude

The server speaks JSON-RPC 2.0 over stdio. Smoke test from any terminal:

node dist/index.js <<'EOF'
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"smoke","version":"0.0.0"}}}
{"jsonrpc":"2.0","method":"notifications/initialized"}
{"jsonrpc":"2.0","id":2,"method":"tools/list"}
EOF

You should see the server announce itself and list the registered tools.


Advisor (opt-in)

v0.4 adds four MCP tools that turn portfolio-mcp into an investment-analysis advisor. These tools are opt-in: they only make outbound HTTP calls when the user has set outbound_enabled: true in their profile and accepted the disclaimer.

Configure your profile

The profile lives at ~/.xp-mcp/advisor-profile.json. Create or update it with setadvisorprofile:

{
  "risk_tolerance": 6,
  "horizon_years": 15,
  "objective": "balanced",
  "monthlyincometarget_brl": 3000,
  "excluded_classes": ["FUNDO"],
  "excluded_tickers": ["XYZW3"],
  "notes": "evitar tabaco, prefiro logรญstica e shoppings",
  "outbound_enabled": true,
  "brapi_token": "..."
}

When you flip outboundenabled to true, the tool requires acceptdisclaimer: true in the same call and stamps accepteddisclaimerat on the saved profile.

Disclaimer

Anรกlise educacional baseada em dados pรบblicos. Nรฃo constitui recomendaรงรฃo de investimento. Decisรตes financeiras sรฃo de sua responsabilidade.

The disclaimer is also returned in warnings[0] of every advisor tool that ranks or suggests assets.

Source: brapi.dev

v0.4 uses brapi.dev as the sole market-data source. Anonymous calls work for personal use; if you hit rate limits, set brapitoken in the profile. Quotes are cached for 60 minutes, fundamentals for 24 hours, universe lists for 7 days. Override per call via cachettlminutes.

Example flow

  • setadvisorprofile โ€” saves the profile, enables outbound
  • getmarketdata { tickers: ["BBAS3","MXRF11"] } โ€” quotes
  • screenassets { assetclass: "FII", criteria: { sortby: "dividendyield", order: "desc", filters: { mindividendyield_pct: 8 }, limit: 10 } }

Project layout

src/
โ”œโ”€โ”€ index.ts                       # MCP server entrypoint (stdio transport)
โ”œโ”€โ”€ tools/
โ”‚   โ”œโ”€โ”€ import-xperformance-pdf.ts # XPerformance PDF โ†’ positions
โ”‚   โ”œโ”€โ”€ import-extract-csv.ts      # XP CSV โ†’ positions
โ”‚   โ””โ”€โ”€ get-positions.ts           # SQL โ†’ positions list with P&L
โ”œโ”€โ”€ parsers/
โ”‚   โ”œโ”€โ”€ pdf-xperformance.ts        # PDF text โ†’ rows
โ”‚   โ”œโ”€โ”€ csv-extract.ts             # papaparse + fuzzy header matching
โ”‚   โ”œโ”€โ”€ classify.ts                # asset-class heuristics + name metadata
โ”‚   โ””โ”€โ”€ normalize.ts               # BRL / date / quantity normalizers
โ”œโ”€โ”€ storage/
โ”‚   โ”œโ”€โ”€ db.ts                      # better-sqlite3 singleton, WAL, env override
โ”‚   โ”œโ”€โ”€ schema.ts                  # CREATE TABLE + AssetClass enum
โ”‚   โ””โ”€โ”€ positions-repo.ts          # UPSERT, listPositions, import records
โ””โ”€โ”€ util/
    โ””โ”€โ”€ zod-to-json-schema.ts      # minimal zod โ†’ JSON Schema for MCP

Data model

imports        every parse attempt with row counts, timestamps, source path
positions      one row per (assetclass, externalid); upserted on re-import
transactions   buys/sells from broker notes (phase 2)
dividends      income / proventos (phase 2)

All monetary values are stored as INTEGER cents. Float math + currency is a well-known source of off-by-a-cent bugs; integers make every aggregation exact.

The UNIQUE (assetclass, externalid) constraint + ON CONFLICT DO UPDATE makes re-importing the same file idempotent โ€” no duplicates, no manual deduping.


Design decisions worth calling out

  • Wide positions table with nullable per-class columns. A table-per-asset-class would be cleaner in theory but adds JOINs for every read, and the column set is small. The wide table fits the access pattern (Claude almost always wants "all positions, maybe filtered by class").
  • Stdio over HTTP. Claude Desktop spawns the process directly. Zero ports listening, no auth surface, no CORS to misconfigure. Trade-off: no remote clients without a wrapper.
  • stderr-only logging. stdout is the JSON-RPC wire. One stray console.log silently corrupts every response. All logs go to stderr, where Claude Desktop captures them into ~/Library/Logs/Claude/mcp-server-xp.log.
  • No price fetching in MVP. Adding it means a network dependency and a rate-limit problem. When it lands (phase 2), it'll be behind an opt-in env var with a clearly-documented data source.

Privacy

  • The SQLite file (~/.xp-mcp/data.db) is the only place your position data lives. .gitignore blocks .db, .sqlite, and data/ from ever being committed.
  • The server makes no outbound HTTP calls for the core import/inspection tools (importxperformancepdf, importextractcsv, getpositions, calculateallocation_drift). No telemetry. No analytics.
  • The v0.4 advisor tools (getmarketdata, screenassets) call brapi.dev only when outboundenabled: true in ~/.xp-mcp/advisor-profile.json and the user has accepted the disclaimer. Disabled by default.

Roadmap

  • [x] PDF parser for XPerformance (XP's official portfolio report)
  • [x] CSV parser for Posiรงรฃo Consolidada / Extrato
  • [x] get_positions with class filter, P&L when invested-value is known
  • [ ] importnotacorretagem (broker-note PDF โ†’ transactions)
  • [ ] CSV parser for proventos export
  • [x] calculateallocationdrift against ~/.xp-mcp/allocation.json
  • [x] v0.3 โ€” npm publish + Smithery + awesome-mcp PR
  • [x] v0.4 โ€” Investment advisor foundations: setadvisorprofile, getadvisorprofile, getmarketdata, screen_assets (brapi.dev, SQLite cache)
  • [x] v0.5 โ€” Portfolio summary + reconciliation gap: getportfoliosummary (aggregate stats, declared-vs-computed gap)
  • [x] v0.6 โ€” Bank extract import + cash flows: importbankextractpdf (XP Conta Digital Extrato โ†’ cashflows table, schema v3), getcashflows (filterable query with aggregate totals)
  • [x] v0.7 โ€” Suggest Buys: suggestbuys (composes profile + drift + screening into deterministic BUY suggestions per underweight class; non-screenable classes surface in skippedclasses)
  • [x] v0.8 โ€” cashflowsummary in getportfoliosummary: YTD + rolling 12m aporte/resgate aggregates in the panorama output (no new tool, additive field).
  • [x] v0.9 โ€” calculatetwr + calculatemwr: time-weighted and money-weighted returns over XPerformance imports + cash_flows (Modified Dietz chained + bisection IRR; no schema change; tools MCP 12 โ†’ 14).
  • [x] v0.10 โ€” getcryptoquote: spot crypto quotes in BRL via Mercado Bitcoin (CryptoQuoteSource interface + MercadoBitcoinSource impl; per-ticker partial failure; 15-min cache; outbound-gated; quote-only; tools MCP 14 โ†’ 15).
  • [x] v0.11 โ€” multi-source crypto: getcryptoquote now falls back across Mercado Bitcoin โ†’ Foxbit โ†’ Binance (MultiSourceCryptoQuoteSource chain), with Binance USDT quotes converted to BRL via the MB USDT/BRL rate; widens altcoin coverage (internal only โ€” still 15 tools).
  • [x] v0.12 โ€” crypto as a tracked assetclass: setcryptoposition (manual entry, CRIPTO added to ASSETCLASSES, snapshot valuation via the v0.11 multi-source chain, no cost basis; flows into summary/drift/suggest_buys with no service change; tools MCP 15 โ†’ 16).
  • [ ] Adapters for other Brazilian brokers (Rico, NuInvest, Inter, Avenue)
  • [ ] Open Finance Brasil investment module when the standard matures

Changelog

v0.12.0 โ€” crypto as a tracked asset_class (2026-05-25)

  • New tool setcryptoposition: manual entry that makes crypto a
first-class tracked asset_class (CRIPTO). Fetches a live quote via the v0.11 multi-source chain (Mercado Bitcoin โ†’ Foxbit โ†’ Binance) and upserts a positions row with a snapshot market value (quantity ร— current price). Outbound-gated.
  • quantity: 0 removes the holding (idempotent single tool). Re-running
the tool refreshes the snapshot in place.
  • Snapshot valuation, no cost basis / P&L: manual entry records
quantity + current market value only (avgpricecents/ invested_cents stay null), so crypto shows market value but no profit/loss โ€” mirroring how XP positions are snapshots from the last import.
  • Crypto flows into getportfoliosummary and
calculateallocationdrift automatically โ€” both already aggregate by asset_class, so no service change was needed. A crypto holding with no target key shows as over-target vs 0% in drift; in suggest_buys it lands in skipped_classes (CRIPTO is non-screenable).
  • Additive: "CRIPTO" added to ASSET_CLASSES, no DDL change, no
SCHEMA_VERSION bump, no new dependency. Tools MCP: 15 โ†’ 16.

v0.11.0 โ€” multi-source crypto (2026-05-25)

  • getcryptoquote now defaults to a multi-source fallback chain
(MultiSourceCryptoQuoteSource): Mercado Bitcoin โ†’ Foxbit โ†’ Binance. Tries each in order, falling through on TickerNotFoundError or a recoverable error, returning the first successful quote.
  • New FoxbitSource (BRL-native) widens Brazilian coverage; new
BinanceSource (USDT-native) covers the altcoin long tail, converting every monetary field to BRL via a USDT/BRL rate from the already-integrated Mercado Bitcoin /USDT/ticker/ endpoint (MbUsdBrlRate) โ€” no new external FX dependency.
  • CryptoQuote gains additive optional fields price_usd and
fxratebrlperusd for conversion transparency (BRL-native sources leave them undefined).
  • The cache row records the source that actually answered (e.g.
binance), not the strategy name multi; top-level result source is "multi" while each quote.source keeps the real origin.
  • Internal only โ€” getcryptoquote is still one tool. Tools MCP: 15.

v0.10.0 โ€” getcryptoquote (2026-05-24)

  • New tool getcryptoquote: spot crypto quotes in BRL via Mercado
Bitcoin's public ticker API. 1-20 symbols per call, per-ticker partial failure, 15-minute cache, outbound-gated.
  • New CryptoQuoteSource interface + MercadoBitcoinSource impl โ€”
slim interface (no equity fundamentals/universe), leaves the door open for Binance/Foxbit later.
  • MarketDataCache.put gains an optional source param (default
brapi.dev โ€” no behaviour change).
  • Crypto is NOT yet a tracked asset_class โ€” quote-only foundation.
Scope B (positions, schema migration, summary/drift integration) deferred to a future TODO.
  • Tools MCP: 14 โ†’ 15.

v0.9.0 โ€” calculatetwr + calculatemwr (2026-05-24)

  • New tool calculate_twr: time-weighted return (Modified Dietz between consecutive XPerformance snapshots, geometric chain across sub-periods). GIPS-compliant for portfolios without daily NAV.
  • New tool calculate_mwr: money-weighted return (IRR via bisection on signed cash flows + synthetic initial/terminal NAV). Reports converged: false cleanly when no sign change in [-99%, 1000%].
  • New repo function listValuationSnapshots reads XPerformance imports as the NAV history โ€” no schema change.
  • New pure service services/returns.ts with hand-computable test references (CFA Modified Dietz example + 1Y 10% MWR case).
  • Quality warnings: sparse history, large cash flows, tiny period, MWR non-convergence, stale tail.
  • Tools MCP: 12 โ†’ 14.

v0.8.0 โ€” cashflowsummary in getportfoliosummary (2026-05-24)

  • Additive field on getportfoliosummary: cashflowsummary block with YTD + rolling 12-month aporte/resgate aggregates.
  • New repo function listCashFlowsSince (unbounded date-bounded query) in src/storage/cash-flows-repo.ts.
  • New pure service computeCashFlowSummary in src/services/cash-flow-summary.ts โ€” YTD + rolling 12m aggregates over CashFlowRow[], no DB access. Averages divide by monthswithdata (not 12) so short histories are not penalised.
  • getportfoliosummary warns when no cash flows have been imported yet (cashflowsummary: null).
  • 12 tools total (unchanged). No schema migration. No new MCP tool โ€” additive field on existing tool.

v0.7.0 โ€” Suggest Buys (2026-05-23)

  • New tool: suggest_buys โ€” composes advisor profile + allocation drift + asset screening into a deterministic list of BUY suggestions per underweight asset class.
  • Encodes a fixed objective ร— asset_class screening matrix (income/growth/balanced ร— FII/ACAO/ETF).
  • Non-screenable underweight classes (TESOURO, RENDAFIXAPRIVADA, FUNDO) surface in a dedicated skipped_classes field rather than being silently dropped.
  • Each suggestion includes amountbrl (= class gap / actualreturned), score, rationale, and already_owned.
  • 12 tools total (was 11). No schema migration.

Development

For contributors or anyone who wants to run a local checkout instead of the published npm package:

git clone https://github.com/Satsuj1n/portfolio-mcp
cd portfolio-mcp
npm install
npm run build
npm run test

Then point claudedesktopconfig.json at the local build:

{
  "mcpServers": {
    "portfolio": {
      "command": "node",
      "args": ["/absolute/path/to/portfolio-mcp/dist/index.js"]
    }
  }
}

Run the type checker with npm run typecheck. Smoke-test the MCP server end-to-end with:

node dist/index.js <<'EOF'
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"local","version":"0.0.0"}}}
{"jsonrpc":"2.0","method":"notifications/initialized"}
{"jsonrpc":"2.0","id":2,"method":"tools/list"}
EOF

Contributing

PRs welcome โ€” especially:

  • New parsers (other brokers, other export formats)
  • Heuristics for classifyAsset covering edge cases your portfolio exposes
  • Additional tools (calculateallocationdrift, get_dividends, ...)
  • Tests with anonymized fixtures (no real position values, no real account numbers)
Please never include real portfolio data, account numbers, or PDFs in your PR. Use the fixture pattern in tests/fixtures/ (synthetic data only).

License

MIT โ€” see LICENSE.

Built by Felipe Lima ยท Powered by Model Context Protocol.

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท Satsuj1n/portfolio-mcp ยท Updated daily from GitHub