Acb Tax Mcp

io.github.haiiibin由 GitHub 帳號 haiiibin 發布v0.5.0更新於 Oct 24, 2026

Canadian ACB and capital gains: average-cost, per-disposition gains, superficial-loss detection.

已驗證STDIO僅桌面金融資料與分析

概覽

AI 產生的概覽

本機 MCP 伺服器,依交易紀錄計算加拿大調整後成本基礎(ACB)與資本利得,包含逐筆處分損益與表面虧損偵測。

可以做什麼
  • 依交易清單或 CSV/JSON 檔計算 ACB 與資本利得,回傳持倉、逐筆處分與按年度彙總
  • 報告目前持倉與帳面成本,並以你提供的市價計算未實現損益
  • 產生某一課稅年度的 Schedule 3 式資本利得報告,以及依證券彙總的 Schedule 3 摘要
  • 依 30 天規則標示表面虧損,並列出每次事件被否認的金額
  • 把券商原始活動匯出整理成乾淨的交易紀錄,並說明略過列的原因
適用情境
適合在加拿大非註冊(應稅)帳戶持有證券、希望讓助理依 CRA 平均成本法與表面虧損規則處理交易紀錄、而不想手動操作試算表的情境,例如查詢某年度資本利得或準備 Schedule 3 申報。
執行需求
以 stdio 在本機執行;需要 Python 3.10+ 與 MCP Python SDK 2.x,可用 uv tool install 或 pip install 安裝(套件 acb-tax-mcp)。未宣告任何帳號、API 金鑰或環境變數。交易需以清單或 CSV/JSON 檔案路徑提供,且須自行提供每筆交易的匯率,因為它不會取得匯率。
安裝前請注意
它只是計算輔助工具,不構成稅務建議,申報前請逐一核對數字。證券依 security 鍵合併,因此同一證券在各帳戶的所有交易須一併提供。不處理資本返還、再投資分配、股票分割、選擇權等公司行為,註冊帳戶也不在適用範圍。它會讀取你指定的本機交易檔案。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Acb Tax Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

acb-tax-mcp

[CI] [PyPI] [PyPI Downloads] [Python] [Glama] [MCP Registry] [Listed in awesome-mcp-servers] [License: MIT]

An MCP server that computes Canadian adjusted cost base (ACB) and capital gains from your trade history: average-cost tracking, per-disposition gains, and superficial-loss detection, returned as structured JSON.

Ask your assistant "what are my capital gains for 2024?" or "did I trigger any superficial losses?" and it runs the CRA rules over your transactions instead of you wrestling a spreadsheet.

⚠️ This is a calculation aid, not tax advice. Verify every number before you file, and consult a professional for anything non-trivial. See Limitations.

[acb-tax-mcp demo: one prompt cleans a broker export, reports 2025 capital gains and flags a superficial loss]

Works with Claude Desktop, Claude Code, Cursor, or any MCP-compatible client.


Features

ToolWhat it does
calculate_acbFull calculation: current holdings (shares, total ACB, ACB per share), every disposition with proceeds/ACB/outlays/gain, per-year summaries, and warnings.
acb_summaryJust current holdings and their book cost (handy for unrealized gains against a market price).
capital_gains_reportA Schedule-3-style report for one tax year: each disposition plus totals, net capital gain, and taxable gain (50% inclusion).
schedule3_summaryOne aggregated row per security in the exact Schedule 3 column shape: shares, gross proceeds, ACB, outlays (commissions), gain/loss after the superficial-loss rule, acquisition years, and totals -- the lines you actually transcribe when filing.
check_superficial_lossesFlags losses caught by the 30-day rule, with the denied (deferred) amount per event.
unrealized_gainsCurrent holdings' ACB against market prices you supply: per-position and total unrealized gain in dollars and percent (foreign-quoted securities take a price + fx_rate pair).
normalize_broker_csvTurns a raw broker activity export into clean transactions: maps common column aliases ("Trade Date", "Activity Type", "Quantity"...), keeps buy/sell rows (DRIP counts as a buy), cleans "$1,200"/"(9.95)" formats, and reports every skipped row with a reason.

Implements the CRA average-cost method (all shares of a security pool into one ACB; gains are against the average, not FIFO) and the superficial-loss rule (loss denied and deferred into the ACB of substitute shares bought within 30 days before or after the sale). Commissions and per-trade CAD FX conversion are handled.


Install

No install needed to try it: open the Glama server page and use Try in Browser to call the tools against a sandbox with a couple of sample transactions.

Requires Python 3.10+.

Requires MCP Python SDK 2.x (mcp>=2,<3). SDK 1.x is feature-frozen upstream and no longer supported here; 0.4.0 is the last release that ran on it.

bash
uv tool install acb-tax-mcp      # or:  pip install acb-tax-mcp

Run from source without installing:

bash
git clone https://github.com/haiiibin/acb-tax-mcpcd acb-tax-mcpuv run acb-tax-mcp

Configure your client

Claude Desktop

In claude_desktop_config.json:

json
{  "mcpServers": {    "acb-tax": {      "command": "acb-tax-mcp"    }  }}

Claude Code

bash
claude mcp add acb-tax -- acb-tax-mcp

Transactions

Give the tools a list of transactions (or a path to a .csv / .json file).

FieldRequiredNotes
dateyesYYYY-MM-DD
actionyesbuy or sell
securityyesticker / symbol (pooled by this key)
sharesyespositive number
priceyesprice per share, in the trade currency
commissionnotrade commission (default 0)
currencynoe.g. USD (default CAD)
fx_ratenotrade currency to CAD, e.g. 1.35 for USD (default 1)
notenofree text

CSV uses the same column names as a header row. If your broker's export uses different headers ("Trade Date", "Activity Type", "Symbol", "Quantity"...), run it through normalize_broker_csv first.

Want something to try immediately? examples/sample_trades.csv is a ready-made broker-style export with aliased headers, $-formatted numbers, a DRIP row, a dividend row (skipped with a reason), a USD trade with FX, and a superficial-loss scenario. Ask your assistant to clean it with normalize_broker_csv and run calculate_acb on the result.


Usage

  • "Calculate the ACB and capital gains for the trades in ~/trades.csv."
  • "What's my capital-gains report for 2024?"
  • "Did any of these sales trigger a superficial loss?"
  • "What's my current book cost for XEQT?"
  • "Here's my RBC activity export -- clean it up and compute my ACB."
  • "XEQT is at $35.20 and VTI at $305.40 USD (1.37 CAD): what are my unrealized gains?"

Example

jsonc
// calculate_acb with:// buy 100 XYZ @ $10, buy 100 XYZ @ $20, sell 100 XYZ @ $25{  "holdings": [    { "security": "XYZ", "shares": 100.0, "total_acb": 1500.0, "acb_per_share": 15.0 }  ],  "dispositions": [    { "date": "2024-03-01", "security": "XYZ", "shares_sold": 100.0,      "proceeds": 2500.0, "acb": 1500.0, "capital_gain": 1000.0,      "is_superficial_loss": false }  ],  "summary": {    "by_tax_year": [      { "tax_year": 2024, "net_capital_gain": 1000.0, "taxable_capital_gain": 500.0 }    ],    "inclusion_rate": 0.5  }}

Superficial loss example

Buy 100 @ $10, sell 100 @ $8 (a $200 loss), then rebuy 100 @ $8 nine days later:

jsonc
{ "gain_before_superficial": -200.0, "superficial_loss_denied": 200.0,  "capital_gain": 0.0, "is_superficial_loss": true }

The $200 loss is denied and added to the ACB of the repurchased shares (new ACB per share becomes $10), so it is recovered on a future sale.


Limitations

Read these before relying on the output.

  • Average-cost, per identical property. Feed all trades of the same security across your accounts together, since the CRA rule pools identical property at the taxpayer level. The tool pools by the security key you provide.
  • Superficial losses use the standard least-of-three test with a single forward pass. Deeply chained or overlapping superficial losses can need case-by-case professional judgment.
  • Not yet handled: return of capital, reinvested/notional distributions (ETF phantom distributions), stock splits, options, and other corporate actions. These affect ACB and are on the roadmap.
  • FX must be supplied per transaction (use the transaction-date rate). The tool does not fetch exchange rates.
  • Registered accounts (TFSA/RRSP) do not have capital gains; this tool is for non-registered (taxable) accounts.
  • Not tax advice.

Development

bash
uv venvuv pip install -e ".[dev]"uv run pytest

License

MIT. See LICENSE.

來源:README.md,提交 3408d12

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

2
  1. v0.5.0最新Oct 9, 2026
  2. v0.4.0Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分