Cost Basis Lots MCP: FIFO, LIFO, HIFO, Average avatar

Cost Basis Lots MCP: FIFO, LIFO, HIFO, Average

Pricing

from $10.00 / 1,000 ledger calculations

Go to Apify Store
Cost Basis Lots MCP: FIFO, LIFO, HIFO, Average

Cost Basis Lots MCP: FIFO, LIFO, HIFO, Average

MCP server and Actor for cost-basis lot accounting: realised gain per lot under FIFO, LIFO, HIFO or average cost, short or long term, open lots and a method comparison. Exact decimals. Not tax advice.

Pricing

from $10.00 / 1,000 ledger calculations

Rating

0.0

(0)

Developer

Agustín Recoba

Agustín Recoba

Maintained by Community

Actor stats

0

Bookmarked

1

Total users

0

Monthly active users

an hour ago

Last modified

Features

Limited permissionsMulti-tenantServer interface

Share

Cost basis lots: MCP server for FIFO, LIFO, HIFO and average cost

Give it a ledger of buys, sells and splits in one currency. For every sale it returns which lots were used and the proceeds, cost basis, gain and short or long term, under FIFO, LIFO, HIFO or average cost. Arithmetic is exact decimal: no floating point and no language model.

It is a calculator, not tax, legal or accounting advice. It applies no tax rule other than a holding period you choose: no wash-sale, like-kind or jurisdiction rules and no tax forms. Check results with a qualified person before filing.

Connect an AI agent (MCP)

The server speaks MCP over Streamable HTTP. Every request needs your own Apify API token.

{
"mcpServers": {
"cost-basis-lots": {
"url": "https://agustin-recoba--cost-basis-lots-mcp.apify.actor/mcp",
"headers": { "Authorization": "Bearer <YOUR_APIFY_TOKEN>" }
}
}
}
ToolWhat it doesCharged
validate_ledgerEvery problem that would stop a calculationno
compute_gainsGain per lot used, totals and open lots. method: fifo (default), lifo, hifo, average; optional tax_year, decimals, holding_daysyes
compare_methodsThe same ledger and year under all four methodsyes
open_lotsQuantity and remaining basis of each lot held, optionally as_of a dateyes

Ask your agent, for example: "Which method gives the smallest gain for 2024 on this ledger?"

Ledger format

{"events": [
{"type": "buy", "asset": "BTC", "date": "2023-01-10", "quantity": "1", "price": "10000", "fee": "10", "id": "jan"},
{"type": "buy", "asset": "BTC", "date": "2023-06-01", "quantity": "1", "price": "30000", "id": "jun"},
{"type": "sell", "asset": "BTC", "date": "2024-02-01", "quantity": "1.5", "price": "40000", "fee": "15"}
]}
  • type: buy, receive (units that arrive without a purchase, price is their fair value per unit), sell or split (ratio 2 turns one unit into two).
  • Give exactly one of price (per unit) or amount (total). Numbers or numeric strings.
  • fee is added to the basis of a buy and taken off the proceeds of a sell.
  • id names a lot. A sell may choose lots with "lots": [{"id": "jan", "quantity": "1"}].
  • Dates are YYYY-MM-DD. Events are replayed in date order.

Run it without MCP

Pick an operation on the Input tab and start a run. The run stores one dataset item. The prefilled ledger is the made-up one above.

{ "operation": "open_lots", "events": [
{"type": "buy", "asset": "ABC", "date": "2024-01-02", "quantity": 10, "price": 5}
] }

The output item has operation and result; result is what the MCP tool returns.

How results are computed

  • FIFO takes the oldest lot first, LIFO the newest, HIFO the highest unit basis. average pools each asset at its moving average cost and reports the term as n/a.
  • Long term means sold after the first anniversary of acquisition, or held more than holding_days.
  • Each row is rounded half up to decimals (default 2). Totals add the rounded rows, so they can differ from the exact total by a few cents.

Pricing

Pay per event. One successful compute_gains, compare_methods or open_lots call costs USD 0.01, through the MCP server or a run. validate_ledger, tools/list and a ledger that is refused are not charged. A run started on the Input tab also has the Actor start event (USD 0.00005).

What it does not do

No CSV or exchange import, no transfers between accounts, no currency conversion, no income tax on received units, no wash-sale or other jurisdiction rules, no Form 8949 or 1099-DA.

Privacy

The ledger is processed in memory. The server writes no part of it to disk or to the log and calls no other service with it. The one outbound call is the charge to the Apify API, which carries a request id and an event name. A run started on the Input tab stores your input and the result in your own Apify storage. Requests pass through Apify's platform. Try it with anonymised or made-up data.

Limits

  • Up to 5,000 events and 200 assets per call.
  • The server accepts 600 tool calls a minute, shared by all callers of one instance. Over the limit it answers with the seconds to wait.
  • The first call after a quiet period waits for an instance to start.
  • MCP revisions: 2026-07-28 and the initialize based ones from 2024-11-05 to 2025-11-25.

Support and authorship

Open an issue on the Issues tab. It was written with AI assistance and tested with hand-computed examples.