cairn
A local-first MCP server that connects Claude Code to your Robinhood account, enabling read-only portfolio insights, tax analysis, and natural language queries, with optional human-in-the-loop trading actions.
README
Cairn
An insights engine for your Robinhood account that runs on your machine. It unifies everything Robinhood scatters — live positions, trade & options history, and monthly statements — into one report you can actually read and ask questions of: concentration, cost basis, holding period, realized long/short-term gains, premium income, wash-sale flags, and opportunities.
Robinhood keeps your data on three surfaces that never talk to each other — the UI (now), history (the past), statements (the record) — and none of them synthesize. So the insights you actually need are impossible to get without exporting CSVs and hand-stitching spreadsheets. Cairn does the stitching, on your machine.
Built in the open. Runs local-first — your credentials live only on your device, the connection is strictly read-only, and every line is auditable. MIT licensed.
⭐ If Cairn shows you something Robinhood couldn't, give it a star — it's the only way I know it's useful to someone.
Quick start
git clone https://github.com/arunash/cairn.git && cd cairn
cp .env.example .env # add your Robinhood login — stays on this machine
pip install -r requirements.txt
python -m cairn report # builds web/report.html from your live account
open web/report.html # your insights, on one page
Then open the folder in Claude Code and just ask: "what should I do about my concentration?", "what's my tax situation?", "how much premium did I collect?"
You need nothing but a Robinhood login for the report. For the chat you need Claude Code (it's the brain). Everything runs locally.
Where does it open?
web/report.htmlis a plain file on your machine —openit (file://), or runpython -m cairn serveto build it and open it athttp://localhost:8787(bound to localhost only; add--port Nto change). There is no hosted portal — your data never leaves your machine.
Status — built in the open. The report spans all your accounts and is a full read: value, cash, every position with cost basis / unrealized P&L / holding period (LT vs ST), concentration (Herfindahl index), realized long- and short-term gains, options premium, dividends, and wash-sale candidates. Cost basis comes straight from Robinhood (already split- and transfer-adjusted); realized gains use a small bundled, local split table — no network.
python -m cairn taxesprints the tax view, and--account <id>limits any command to one account. Read-only throughout. Issues and PRs welcome.
The three layers — all free, all local
| Layer | What it does | Runs on |
|---|---|---|
| 1 · Insights | The report — deterministic compute + render | Python, no LLM |
| 2 · Ask Cairn | Chat & advice, in the context of your whole account | Claude Code, read-only |
| 3 · Act & Steward | Places trades, runs the wheel, rolls, trims, watches | Claude Code + write tools, human-in-loop |
The safety line is structural: layers 1–2 only ever have read tools, so they physically cannot trade. Layer 3 unlocks the write tools and still approves every single order with you.
How it works
CLAUDE CODE (the brain, local) YOUR ROBINHOOD (your account)
┌───────────────────────────┐ read ┌────────────────────────────┐
│ CLAUDE.md = rules+guards │ ───────────► │ positions · quotes │
│ config/ledger.json = YOU │ ◄─────────── │ trade & options history │
│ broker/mcp.py = the gate │ write* │ monthly statements (PDF) │
└───────────────────────────┘ *Act only └────────────────────────────┘
│ runs
▼
cairn/ report ──► web/report.html python -m cairn report
compute/* · act/* · watch/* gains · premium · wheel · roll · trim · alerts
- Report (
python -m cairn report) pulls your live holdings read-only and renders the page — account value, unrealized P&L, concentration, and per-position cost basis & weight. - Compute holds the deterministic engines in
cairn/compute/: a FIFO lot engine (realized LT/ST gains, holding periods, wash-sale flags), positions & concentration, premium, cashflow (deposits + dividends), and the intent ledger (pool split, day-over-day). - Claude Code reads the report, answers questions in plain language, and — only in Act mode — executes with your approval.
Security
- Local-first. Your Robinhood login sits in
.envon your machine. There is no Cairn server. - Read-only by default. Insights & chat never have trading permission.
- No outbound calls except to your Robinhood account and (for chat) your Claude.
- Disconnect anytime — delete the local session token and it's cut off instantly.
- Auditable — it's all here, MIT, nothing obfuscated.
Repo structure
cairn/
├── CLAUDE.md # the agent's behavior, YOUR rules, the hard guardrails
├── SECURITY.md # read-only-by-default model + secret handling
├── .mcp.json # Robinhood MCP wiring (read tools always; write gated to Act)
├── config/
│ └── ledger.example.json # intent-based pools + your rules (copy → ledger.json)
├── cairn/
│ ├── broker/mcp.py # the MCP gate — write tools registered only when CAIRN_ACT_ENABLED=1
│ ├── report/build.py # builds web/report.html (the insights page)
│ ├── compute/ # lots · realized · washsale · positions · premium · cashflow · ledger
│ ├── ingest/statements.py # monthly statement PDF → ACH cash-flow parse
│ ├── act/ # wheel · roll · reinvest · trim (human-in-loop)
│ └── watch/ # trim watcher · reminders (email alerts)
└── web/report.html # generated locally — your insights page (git-ignored)
Keeping your fork clean
Your personal data never belongs in the repo. Account IDs, cost basis, credentials, and generated output all live in git-ignored files only:
| File | What | Where it comes from |
|---|---|---|
.env |
your Robinhood login | copy .env.example |
config/ledger.json |
your accounts & pools | copy config/ledger.example.json |
web/report.html, config/daily-ledger.* |
generated output | created at runtime |
The tracked cairn/ modules ship with placeholders only — MARGIN_ACCT, IRA_ACCT,
<ticker>, BASIS = 0.0. Put your real values into config/ledger.json, never into the code.
Before you push, confirm git status shows none of the files above. See SECURITY.md.
License
MIT — do anything, no warranty. This is software, not financial advice. You run it, you own the decisions.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。