crypto-transactions-mcp
MCP server per registrare e interrogare transazioni crypto (trade, swap e trasferimenti) con persistenza su JSON locale o Notion.
log_transaction: registra trade BUY/SELL, inclusi swap crypto/crypto, con prezzi/importi in Decimal, fee, note, hash on-chain e controvalore fiat opzionale; supporta upsert con merge parziale.
log_transfer: registra spostamenti dello stesso asset tra exchange/wallet (origine → destinazione), con fee di rete e hash opzionali; upsert per id.
get_transaction_history: recupera lo storico di trade e transfer con filtri per symbol, exchange, side (BUY/SELL/TRANSFER) e intervallo di date, ordinato per data decrescente e paginato.
get_portfolio_summary: calcola per ogni asset posseduto: quantità, totale investito, cost-basis medio, valore di mercato e plus/minusvalenza non realizzata; supporta data passata e metodi weighted_average o fifo.
get_asset_price: ottiene la quotazione di un singolo asset, corrente o storica.
Persistenza intercambiabile: backend JSON locale (default) o database Notion, selezionabile via variabile d'ambiente.
Facile integrazione: configurabile come server MCP per Claude Desktop o agy, con segreti gestiti tramite file
.env.
Uses a Notion database as a backend for persisting crypto transactions, trades, and transfers, with configurable properties and support for querying history.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@crypto-transactions-mcp Log a trade: bought 0.1 BTC at 65000 USDT on Binance."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
crypto-transactions-mcp
MCP server for tracking transactions and orders executed in the crypto market.
It exposes MCP tools that let an LLM agent (Claude, agy, etc.) record trades,
swaps, and transfers with exact Decimal precision, and query the history —
with swappable persistence on a local JSON file or a Notion database.
Quick Start
uv syncto install dependencies.Choose a backend:
JSON (default, zero config) — skip to step 3.
Notion — first follow the "Set up Notion from scratch" section below.
Add the server to your MCP host configuration: see "Claude Desktop configuration" or "agy configuration".
Restart the host and try, for example: "I bought 0.1 BTC on Binance at 65000 USDT, fee 0.0001 BTC, record it with log_transaction."
Onion architecture:
domain/— theCryptoTransactionentity (Pydantic v2, monetary fields inDecimal).sideisBUY/SELL(trade, including a crypto/crypto swap) orTRANSFER(moving the same asset between two custodial accounts); the two cases have different requirements validated in the model itself (BUY/SELL requireprice/value, TRANSFER requiresto_exchange)interfaces/— theTransactionRepositoryandTransactionFiltersportsusecases/—LogTransactionUseCase(trade, upsert with partial merge),LogTransferUseCase(transfer, same upsert semantics),GetTransactionHistoryUseCaseinfrastructure/— concrete adapters of theTransactionRepositoryport:JsonTransactionRepository, local JSON file, fixed pathdata/crypto_transactions.jsonNotionTransactionRepository, Notion database (see below)
delivery/— theFastMCPserver, MCP tools (log_transaction,log_transfer,get_transaction_history), dependency wiring infactories.py
Related MCP server: Expense Tracker MCP Server
MCP tools
log_transaction— BUY/SELL trade, including a swap between two cryptos (e.g. ETH/BTC): same shape as a normal trade, no separate tool needed. Supports optionalfiat_value/fiat_currencyto lock in the fiat equivalent at the time of the exchange — strongly recommended for crypto/crypto swaps, wherepricealone (the relative exchange rate between the two cryptos) does not allow you to calculate the realized P&L afterwards, nor the fiat cost basis of the new asset received.log_transfer— moving the same asset between two custodial accounts (exchange→to_exchange), not a trade: noside/price, but requiresto_exchange.get_transaction_history— history of both, with optional filters (symbol,exchange,sideincluding"TRANSFER",date_from/date_to), sorted by date descending (most recent first) and paginated (limitdefault 50,offset); the response is{"transactions": [...], "has_more": bool}.get_portfolio_summary— for each asset (excludingvs_currencyitself): how much you own, how much you invested in total and on average per unit (cost basis), market value, unrealized gain/loss. Optionalas_of_datefor a position as of a past date (historical price) instead of live — designed for tax reporting.cost_basis_method(weighted_averageorfifo) is an explicit choice, not automatic: they can produce different capital gains on the same history, check with an accountant which one you need.get_asset_price— quote for a single asset, current or historical as of a date, without computing the whole portfolio.
Setup
uv syncCopy .env.example to .env and fill it in: it is loaded automatically
at startup (main.py calls load_dotenv()). This works even when the
server is launched by an external host (Claude Desktop, agy, ...) with
uv run --directory <path> main.py, because --directory sets the process
working directory to the project root, where load_dotenv() looks for
.env by default — there is no need to duplicate secrets in the host config
JSON, which is often less protected than a local gitignored .env.
Persistence backend
Selectable with the TRANSACTION_REPOSITORY_BACKEND environment variable:
json(default) — no additional configuration required.notion— requiresNOTION_TOKEN(Notion integration token) andNOTION_DATABASE_ID.
Set up Notion from scratch
If you don't already have a Notion integration connected to this project, follow these steps in order (requires a Notion account with permission to create integrations in the workspace):
Create the integration — go to notion.so/my-integrations → "+ New integration" → give it a name (e.g. "Crypto Transactions MCP") → choose the workspace → type "Internal".
Enable the capabilities — on the integration configuration page, under "Capabilities", enable: Read content, Update content, Insert content.
Copy the token — "Secrets" tab → copy the value of "Internal Integration Secret" (starts with
secret_orntn_). This is yourNOTION_TOKEN.Create the database — in Notion, create a new database (full-page or inline) and configure it with exactly the properties listed in the table below. The "title" column that Notion creates by default (usually "Name") must be renamed to
Transaction ID: every Notion database is required to have one; it is not the database name but the column that identifies each row.Share the database with the integration — open the database page → "..." menu at the top right → "Connections" → search for and connect the integration created in step 1. Without this step the API returns 404 even with a valid token, because Notion permissions are per-page, not workspace-wide.
Find the database ID — it is in the database page URL:
https://www.notion.so/<ID-senza-trattini>?v=.... For example, fromhttps://www.notion.so/abcdef0123456789abcdef0123456789?v=...the ID isabcdef0123456789abcdef0123456789. This is yourNOTION_DATABASE_ID.Configure the variables — in your
.env(see above), or in the host MCPenvblock:TRANSACTION_REPOSITORY_BACKEND=notion NOTION_TOKEN=<il secret del punto 3> NOTION_DATABASE_ID=<l'id del punto 6>
The Notion database must have these properties (exact name and type):
Property | Type |
| title |
| rich_text |
| select |
| select |
| select |
| select ( |
| date (with time, UTC) |
| number |
| number |
| number |
| number |
| select |
| number |
| select |
| rich_text |
To Exchange, Price, Value, Fiat Value, Fiat Currency can be
empty (they don't apply to a TRANSFER, or they are optional on a trade).
Note: numeric fields on Notion are native number (float64), not exact
Decimal like in the JSON backend — sufficient for real trading amounts, but
subject to the precision limits of a double-precision float.
Tests
uv run pytestManual execution
uv run main.pyClaude Desktop configuration
Add to the claude_desktop_config.json file (on macOS:
~/Library/Application Support/Claude/claude_desktop_config.json). With an
.env already configured at the project root (see above), that's all you need,
no secrets in the JSON:
{
"mcpServers": {
"crypto-transactions": {
"command": "uv",
"args": [
"run",
"--directory",
"/path/to/crypto-transactions-mcp",
"main.py"
]
}
}
}Alternatively, if you prefer not to use a .env file, you can pass the
variables directly in the env block (they override those in .env if both
are present):
{
"mcpServers": {
"crypto-transactions": {
"command": "uv",
"args": [
"run",
"--directory",
"/path/to/crypto-transactions-mcp",
"main.py"
],
"env": {
"TRANSACTION_REPOSITORY_BACKEND": "notion",
"NOTION_TOKEN": "secret_...",
"NOTION_DATABASE_ID": "abcdef0123456789abcdef0123456789"
}
}
}
}agy configuration
Same mcpServers schema, but in the .agents/mcp_config.json file at the
project root where you use agy (add the crypto-transactions entry next to the
other servers already present, without removing them). The same applies: with
.env configured you don't need the env block:
{
"mcpServers": {
"crypto-transactions": {
"command": "uv",
"args": [
"run",
"--directory",
"/path/to/crypto-transactions-mcp",
"main.py"
]
}
}
}Available Tools
3 toolsget_transaction_historyA
Restituisce lo storico delle transazioni salvate (trade e transfer), filtrato opzionalmente per symbol, exchange, side (usa "TRANSFER" per i soli transfer) e/o intervallo di date (date_from/date_to, inclusivi, in UTC).
Inputs: side, symbol, date_to, exchange, +1 more. Returns: result
log_transactionA
Registra un trade (BUY/SELL, incluso uno swap tra due crypto), upsert per id.
Trade normale (es. BTC/USDT): symbol è la coppia BASE/QUOTE,
side=BUY se acquisti il base, side=SELL se lo cedi; price è il
prezzo unitario del base in quote.
Swap crypto/crypto (es. scambio ETH -> BTC su un DEX o un exchange):
si usa questo stesso tool, non ce n'è uno dedicato. Metti come base
l'asset ceduto e come quote quello ricevuto, es. symbol="ETH/BTC",
side="SELL", amount=1 (ETH ceduti), price=0.05 (BTC ricevuti per
ETH). Attenzione: in questo caso price ti dice solo il cambio tra
le due crypto, non il loro controvalore in una valuta fiat — senza
quel dato non potrai più calcolare a posteriori né il P&L realizzato
sull'asset ceduto né il cost-basis fiat del nuovo asset ricevuto.
Per questo, quando disponibile, valorizza sempre fiat_value (il
controvalore totale dello scambio, es. in EUR al momento
dell'esecuzione) e fiat_currency: è fortemente consigliato per gli
swap crypto/crypto, utile anche per i trade con quote fiat/stablecoin.
Se `id` è omesso viene generata una nuova transazione con un id
generato automaticamente. Se `id` corrisponde a una transazione già
salvata, solo i campi passati vengono aggiornati (merge parziale);
`value` viene ricalcolato come amount * price se non fornito
esplicitamente e uno tra amount/price cambia. Per una nuova
transazione sono richiesti tutti i campi obbligatori dello schema
(exchange, symbol, side, timestamp, amount, price, fee_amount,
fee_asset). `tx_hash` è opzionale, usalo per l'hash on-chain quando
disponibile (tipico per gli swap su DEX).
Per spostare lo stesso asset tra due exchange/wallet, senza
scambiarlo con un altro asset, usa invece il tool log_transfer.
Inputs: id, side, notes, price, +10 more.
log_transferA
Registra il movimento dello stesso asset tra due custodie (exchange o wallet), upsert per id. Non è un trade: non c'è side né un prezzo di scambio, quindi non usare questo tool per uno swap tra due asset diversi (per quello usa log_transaction).
`exchange` è l'origine, `to_exchange` la destinazione. `symbol` è
il solo asset spostato (es. "BTC"), non una coppia. `fee_amount`/
`fee_asset` rappresentano la fee di rete del trasferimento, non una
commissione di trading. `tx_hash` è fortemente consigliato quando
disponibile (tipico per i prelievi/depositi on-chain). `fiat_value`/
`fiat_currency` sono opzionali, per tracciare il controvalore fiat
dell'importo spostato al momento del trasferimento.
Se `id` è omesso viene generato automaticamente. Se `id`
corrisponde a un transfer già salvato, solo i campi passati vengono
aggiornati (merge parziale). Per un nuovo transfer sono richiesti
exchange, to_exchange, symbol, timestamp, amount, fee_amount,
fee_asset.
Inputs: id, notes, amount, symbol, +8 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a distinct and clear purpose: one for querying history, one for logging trades/swaps, and one for logging asset transfers. There is no overlap in functionality.
All tool names follow a consistent verb_noun pattern with lowercase and underscores: get_transaction_history, log_transaction, log_transfer. This is predictable and easy to understand.
With only 3 tools, the set is minimal but covers the core actions of reading and writing transactions and transfers. It feels slightly thin but is still well-scoped for a focused server.
The server covers basic CRUD operations for transactions and transfers, including upsert and filtering. Missing a dedicated tool for single transaction retrieval or deletion, but the existing tools can accommodate those needs.
Related MCP Connectors
Ledger of record for AI spend: verifiable receipts, waste auditor & model arbitrage MCP.
Hosted Notion MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
MCP server for the Z1N Protocol - on-chain identity for AI agents on Polygon
MCP server for Gainium — manage trading bots, deals, and balances via AI assistants
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAgent-native, self-hosted MCP server for crypto trading and DeFi management. Enables agents to query balances, execute trades, and manage positions with a policy engine and secure key storage.8Apache 2.0
- FlicenseBqualityDmaintenanceA powerful SQLite-backed expense tracking server built with the Model Context Protocol (MCP). This server allows AI agents (like Claude) to manage your personal finances by adding, deleting, and listing expenses directly from your chat interface.3-
- AlicenseNot gradedqualityDmaintenanceMCP server for cryptocurrency trading across multiple exchanges (Bybit, Binance, KuCoin, etc.) with real-time price data, comparison, and natural language query support. Integrates with AI assistants via the Model Context Protocol.MIT
- FlicenseNot gradedqualityDmaintenanceA lightweight MCP server that lets LLM clients track, query, and summarize personal expenses using a local SQLite database.-