Skip to main content

acb-tax-mcp

CI PyPI PyPI Downloads Python Glama 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

Tool What it does
calculate_acb Full calculation: current holdings (shares, total ACB, ACB per share), every disposition with proceeds/ACB/outlays/gain, per-year summaries, and warnings.
acb_summary Just current holdings and their book cost (handy for unrealized gains against a market price).
capital_gains_report A Schedule-3-style report for one tax year: each disposition plus totals, net capital gain, and taxable gain (50% inclusion).
schedule3_summary One 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_losses Flags losses caught by the 30-day rule, with the denied (deferred) amount per event.
unrealized_gains Current 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_csv Turns 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+.

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

Run from source without installing:

git clone https://github.com/haiiibin/acb-tax-mcp
cd acb-tax-mcp
uv run acb-tax-mcp

Configure your client

Claude Desktop

In claude_desktop_config.json:

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

Claude Code

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

Transactions

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

Field Required Notes
date yes YYYY-MM-DD
action yes buy or sell
security yes ticker / symbol (pooled by this key)
shares yes positive number
price yes price per share, in the trade currency
commission no trade commission (default 0)
currency no e.g. USD (default CAD)
fx_rate no trade currency to CAD, e.g. 1.35 for USD (default 1)
note no free 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.


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

// 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:

{ "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

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

License

MIT. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

acb_tax_mcp-0.4.0.tar.gz (174.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

acb_tax_mcp-0.4.0-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file acb_tax_mcp-0.4.0.tar.gz.

File metadata

  • Download URL: acb_tax_mcp-0.4.0.tar.gz
  • Upload date:
  • Size: 174.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for acb_tax_mcp-0.4.0.tar.gz
Algorithm Hash digest
SHA256 2b8b3fb972e8aa0efb87172567792ad5b6c6a6d50166549660b059c408b0cd6a
MD5 dc6c9371157700d771c7d4264b3fb2ce
BLAKE2b-256 458bd9dd35f0c2f884dc6c1fc1d5e182ce5c7f828a7083cc9bb4f80dff8ea75e

See more details on using hashes here.

Provenance

The following attestation bundles were made for acb_tax_mcp-0.4.0.tar.gz:

Publisher: publish.yml on haiiibin/acb-tax-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file acb_tax_mcp-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: acb_tax_mcp-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for acb_tax_mcp-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da964d0c964f425b2424b58c93531160173d153322db18083b5ef9fe72ddb03c
MD5 b925209d058d3c382432d83fb1602331
BLAKE2b-256 4c49c25cf6fc01c9e1d13db2bc6c10c4c057fe4c81573c7b9ecd4981bdb65f0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for acb_tax_mcp-0.4.0-py3-none-any.whl:

Publisher: publish.yml on haiiibin/acb-tax-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page