crypto-transactions-mcp
crypto-transactions-mcp
MCPサーバーで、暗号通貨市場で実行された取引と注文を追跡します。
LLMエージェント(Claude、agyなど)が、正確なDecimal精度でトレード、スワップ、転送を記録し、履歴を照会できるようにするMCPツールを公開します。永続化はローカルのJSONファイルまたはNotionデータベースに交換可能です。
クイックスタート
uv syncで依存関係をインストールします。バックエンドを選択します:
JSON (デフォルト、設定不要) — 手順3へ進みます。
Notion — 先に下の「Notionをゼロからセットアップ」セクションを参照してください。
MCPホストの設定にサーバーを追加します: 「Claude Desktopの設定」または「agyの設定」を参照してください。
ホストを再起動して、例えば次のように試してください: "Binanceで0.1 BTCを65000 USDTで購入、手数料0.0001 BTC、log_transactionで記録して。"
オニオンアーキテクチャ:
domain/— エンティティCryptoTransaction(Pydantic v2、金額フィールドはDecimal)。sideはBUY/SELL(トレード、crypto/cryptoスワップを含む) またはTRANSFER(同じアセットを2つの保管場所間で移動)。2つのケースはモデル自体で検証される異なる要件を持つ (BUY/SELLはprice/valueが必要、TRANSFERはto_exchangeが必要)interfaces/— ポートTransactionRepositoryとTransactionFiltersusecases/—LogTransactionUseCase(トレード、部分マージによるupsert)、LogTransferUseCase(トランスファー、upsertと同じセマンティクス)、GetTransactionHistoryUseCaseinfrastructure/— ポートTransactionRepositoryの具体的なアダプター:JsonTransactionRepository、ローカルJSONファイル、固定パスdata/crypto_transactions.jsonNotionTransactionRepository、Notionデータベース (下記参照)
delivery/— サーバーFastMCP、MCPツール (log_transaction,log_transfer,get_transaction_history)、factories.pyでの依存関係の配線
Related MCP server: Expense Tracker MCP Server
MCPツール
log_transaction— BUY/SELLトレード、2つのcrypto間のスワップ (例: ETH/BTC) を含む: 通常のトレードと同じ形式で、別のツールは不要。オプションのfiat_value/fiat_currencyをサポートし、交換時点のフィアット換算額を固定できる — crypto/cryptoスワップでは、price(2つのcrypto間の相対レート) だけでは後から実現損益や受け取った新しいアセットのフィアット原価を計算できないため、強く推奨される。log_transfer— 同じアセットを2つの保管場所間で移動 (exchange→to_exchange)、トレードではない:side/priceは不要だが、to_exchangeが必要。get_transaction_history— 両方の履歴、オプションのフィルター (symbol,exchange,sideは"TRANSFER"を含む,date_from/date_to)、日付降順 (新しい順) で並べ替え、ページネーション (limitデフォルト50,offset); レスポンスは{"transactions": [...], "has_more": bool}。get_portfolio_summary— 各アセット (vs_currency自体を除く) について: 保有量、総投資額、1単位あたりの平均投資額 (原価)、時価評価額、未実現損益。オプションのas_of_dateでライブではなく過去の日付の状況 (過去価格) を取得可能 — 税務申告用に設計。cost_basis_method(weighted_averageまたはfifo) は明示的な選択であり、自動ではない: 同じ履歴でも異なるキャピタルゲインを生む可能性があるため、どちらが必要か税理士に確認してください。get_asset_price— 単一アセットの現在または指定日の過去の価格を取得。ポートフォリオ全体を計算せずに。
セットアップ
uv sync.env.example を .env にコピーして値を設定します: 起動時に自動的に読み込まれます (main.py が load_dotenv() を呼び出します)。これはサーバーが外部ホスト (Claude Desktop、agy、...) から uv run --directory <path> main.py で起動される場合でも機能します。--directory がプロセスの作業ディレクトリをプロジェクトのルートに設定し、load_dotenv() がデフォルトで .env を探すためです — ホストの設定JSONにシークレットを複製する必要はありません。多くの場合、ローカルのgitignoreされた .env よりも保護が弱いためです。
永続化バックエンド
環境変数 TRANSACTION_REPOSITORY_BACKEND で選択できます:
json(デフォルト) — 追加設定は不要。notion—NOTION_TOKEN(Notionインテグレーションのトークン) とNOTION_DATABASE_IDが必要。
Notionをゼロからセットアップ
このプロジェクトに接続されたNotionインテグレーションがまだない場合は、次の手順を順に実行してください (ワークスペースでインテグレーションを作成する権限を持つNotionアカウントが必要です):
インテグレーションを作成 — notion.so/my-integrations にアクセス → "+ New integration" → 名前を付ける (例: "Crypto Transactions MCP") → ワークスペースを選択 → タイプ "Internal"。
ケイパビリティを有効化 — インテグレーションの設定ページで、"Capabilities" の下にある Read content、Update content、Insert content を有効にします。
トークンをコピー — "Secrets" タブ → "Internal Integration Secret" の値をコピー (先頭は
secret_またはntn_)。これがあなたのNOTION_TOKENです。データベースを作成 — Notionで新しいデータベース (フルページまたはインライン) を作成し、下の表にリストされているプロパティと正確に一致するように設定します。Notionがデフォルトで作成する "title" 列 (通常 "Name") は
Transaction IDに名前を変更する必要があります: 各Notionデータベースには必須で1つあり、これはデータベース名ではなく各行を識別する列です。データベースをインテグレーションと共有 — データベースのページを開く → 右上の "..." メニュー → "Connections" → 手順1で作成したインテグレーションを検索して接続。この手順を省略すると、有効なトークンでもAPIは404を返します。Notionの権限はワークスペース全体ではなくページ単位であるためです。
データベースIDを見つける — データベースページのURLにあります:
https://www.notion.so/<ID-senza-trattini>?v=...。例えば、https://www.notion.so/abcdef0123456789abcdef0123456789?v=...からIDはabcdef0123456789abcdef0123456789です。これがあなたのNOTION_DATABASE_IDです。変数を設定 — あなたの
.env(上記参照)、またはMCPホストのenvブロックで:
TRANSACTION_REPOSITORY_BACKEND=notion
NOTION_TOKEN=<il secret del punto 3>
NOTION_DATABASE_ID=<l'id del punto 6>Notionデータベースには次のプロパティが必要です (正確な名前とタイプ):
Property | タイプ |
| title |
| rich_text |
| select |
| select |
| select |
| select ( |
| date (時刻付き、UTC) |
| number |
| number |
| number |
| number |
| select |
| number |
| select |
| rich_text |
To Exchange、Price、Value、Fiat Value、Fiat Currency は空にできます (TRANSFER には適用されない、またはトレードではオプション)。
注: Notionの数値フィールドはネイティブの number (float64) であり、JSONバックエンドのような正確な Decimal ではありません — 実際の取引金額には十分ですが、倍精度浮動小数点の精度限界の影響を受けます。
テスト
uv run pytest手動実行
uv run main.pyClaude Desktopの設定
claude_desktop_config.json ファイルに追加します (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json)。プロジェクトのルートに .env が設定済みなら (上記参照) これだけで十分で、JSONにシークレットは不要です:
{
"mcpServers": {
"crypto-transactions": {
"command": "uv",
"args": [
"run",
"--directory",
"/path/to/crypto-transactions-mcp",
"main.py"
]
}
}
}あるいは、.env ファイルを使いたくない場合は、env ブロックで直接変数を渡すこともできます (両方存在する場合は .env の値を上書きします):
{
"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の設定
同じ mcpServers スキーマですが、agyを使用するプロジェクトのルートにある .agents/mcp_config.json ファイル内です (既存の他のサーバーを削除せずに、crypto-transactions エントリを追加します)。同じことが当てはまります: .env が設定されていれば env ブロックは不要です:
{
"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).
| Name | Required | Description | Default |
|---|---|---|---|
| side | No | ||
| symbol | No | ||
| date_to | No | ||
| exchange | No | ||
| date_from | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It states the action is read-only ('Restituisce') and specifies that date filters are inclusive and in UTC. However, it does not disclose other behavioral traits such as response format, pagination, or any side effects. The description is minimally adequate.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence that is front-loaded with the main action and then details parameters. It is concise but could be restructured for easier scanning (e.g., bullet points). However, it contains no unnecessary words and effectively communicates the tool's purpose and filters.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
An output schema exists (assumed but not shown), so explanation of return values is not required. The description covers filtering options and date inclusivity/UTC zone. However, it lacks information on default behavior (e.g., returns all history if no filters), pagination, or response limits. For a history retrieval tool, this is acceptable but not fully complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, but the description adds meaningful context: it explains the side parameter can use 'TRANSFER' to filter only transfers, and notes that date filters are inclusive and in UTC. This adds semantic value beyond the schema's property names and types. It could further describe parameter formats or constraints.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states it returns saved transaction history (trades and transfers) with optional filtering. The verb 'Restituisce' and resource 'storico delle transazioni' are specific. Sibling tools (log_transaction, log_transfer) are for creation, so the read purpose is distinguishable, though not explicitly contrasted.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Implied usage: use when you need to retrieve transaction history. The description lists available filters but does not provide explicit guidance on when to use this tool versus siblings or when not to use it. No alternatives or exclusions are mentioned.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | ||
| side | No | ||
| notes | No | ||
| price | No | ||
| value | No | ||
| amount | No | ||
| symbol | No | ||
| tx_hash | No | ||
| exchange | No | ||
| fee_asset | No | ||
| timestamp | No | ||
| fee_amount | No | ||
| fiat_value | No | ||
| fiat_currency | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Discloses key behavioral traits: upsert behavior (merge partial update when id matches), auto-generation of id for new transactions, recalculation of value based on amount*price, required fields for new transactions, and the optional use of tx_hash. No annotations are provided, so the description fully compensates.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is relatively long but well-structured with paragraphs separating normal trades, swaps, upsert behavior, and required fields. It is front-loaded with the main purpose. However, some content could be condensed, making it less concise than optimal.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity (14 parameters, upsert behavior, swap handling) and the absence of an output schema, the description covers most behavioral aspects thoroughly. It mentions sibling tools for disambiguation. It does not explain the return value of the tool, which is a minor gap.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 0% schema description coverage, the description explains the meanings of several key parameters (side, symbol, price, amount, fiat_value, fiat_currency, id, tx_hash, value). It does not explicitly cover all 14 parameters (e.g., notes, timestamp, exchange, fee_amount, fee_asset are mentioned as required but not detailed). The coverage is extensive enough to guide an agent, though not exhaustive.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly defines the tool as recording a trade (BUY/SELL, including swaps) and differentiates it from the sibling log_transfer tool, specifying which tool to use for asset transfers without exchange. The verb 'Registra' and the resource 'trade' are specific and unambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Provides explicit guidance on when to use this tool vs the sibling log_transfer: 'Per spostare lo stesso asset tra due exchange/wallet, senza scambiarlo con un altro asset, usa invece il tool log_transfer.' Also explains how to handle crypto/crypto swaps, including the recommendation to provide fiat_value and fiat_currency for better P&L calculation.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | ||
| notes | No | ||
| amount | No | ||
| symbol | No | ||
| tx_hash | No | ||
| exchange | No | ||
| fee_asset | No | ||
| timestamp | No | ||
| fee_amount | No | ||
| fiat_value | No | ||
| to_exchange | No | ||
| fiat_currency | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries full burden. It explains upsert behavior (auto-generated ID, partial merge for existing records), required fields for new transfers, and the nature of fees (network fee, not trading commission). However, it does not explicitly address side effects like idempotency or potential data loss, slightly reducing completeness.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is front-loaded with the core purpose and distinction, followed by parameter details and behavior. It is slightly verbose but every part adds value. No redundant sentences, but could be tightened slightly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given 12 parameters, upsert behavior, and no output schema, the description covers most essential aspects: both usage scenarios, parameter meanings, create vs. update behavior, and required fields. It doesn't describe the return value, but that's minor. Overall, it provides sufficient context for an agent to use the tool correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so description must compensate. It explains key parameters: exchange (origin), to_exchange (destination), symbol (single asset), fee_amount/fee_asset (network fee), tx_hash (recommended), fiat_value/fiat_currency (optional). However, the 'notes' parameter is not mentioned, and 'amount' is implied but not explicitly defined, leaving a minor gap.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description explicitly states the tool logs asset movement between two custodians, uses 'upsert per id', and distinguishes it from a trade by noting no side or price. It also names the sibling tool log_transaction for swaps between different assets, making the purpose unmistakable.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description clearly says when to use (same-asset transfer between custodians) and when not to (different-asset swap, directing to log_transaction). It also advises using tx_hash for on-chain transfers, providing practical guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
v0.1.0- First observed
get_transaction_history - First observed
log_transaction - First observed
log_transfer
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.
Maintenance
Related MCP Connectors
MCP server for Gainium — manage trading bots, deals, and balances via AI assistants
MCP server for Boson Protocol — on-chain agentic commerce for physical & digital goods.
An agent-native database over MCP: shared, validated, structured records in every AI chat.
API-first CRM for LLMs - contacts, companies, deals and activities over a native MCP server.
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.7Apache 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 gradedqualityBmaintenanceA lightweight MCP server that lets LLM clients track, query, and summarize personal expenses using a local SQLite database.-