Skip to main content
Glama
bolesk

crypto-transactions-mcp

by bolesk

crypto-transactions-mcp

MCP 서버로, 암호화폐 시장에서 실행된 거래 및 주문을 추적합니다. LLM 에이전트(Claude, agy 등)가 Decimal 정밀도로 트레이드, 스왑, 전송을 기록하고, 내역을 조회할 수 있도록 하는 MCP 도구를 노출합니다. — 로컬 JSON 파일 또는 Notion 데이터베이스에 교체 가능한 영속성을 제공합니다.

빠른 시작

  1. uv sync로 의존성을 설치합니다.

  2. 백엔드를 선택합니다:

    • JSON (기본값, 설정 불필요) — 3단계로 건너뜁니다.

    • Notion — 먼저 아래 "Notion 처음부터 설정" 섹션을 따릅니다.

  3. MCP 호스트 구성에 서버를 추가합니다: "Claude Desktop 구성" 또는 "agy 구성"을 참조하세요.

  4. 호스트를 다시 시작하고 예를 들어 시도해 보세요: "바이낸스에서 0.1 BTC를 65000 USDT에 샀어, 수수료 0.0001 BTC, log_transaction으로 기록해 줘."

Onion 아키텍처:

  • domain/CryptoTransaction 엔티티 (Pydantic v2, 금액 필드는 Decimal). sideBUY/SELL (트레이드, crypto/crypto 스왑 포함) 또는 TRANSFER (동일 자산을 두 보관소 간 이동)이며, 두 경우는 모델 자체에서 검증되는 서로 다른 요구사항을 가집니다 (BUY/SELL는 price/value 필요, TRANSFER는 to_exchange 필요)

  • interfaces/ — 포트 TransactionRepositoryTransactionFilters

  • usecases/LogTransactionUseCase (트레이드, 부분 병합을 통한 upsert), LogTransferUseCase (전송, 동일한 upsert 의미론), GetTransactionHistoryUseCase

  • infrastructure/ — 포트 TransactionRepository의 구체적인 어댑터:

    • JsonTransactionRepository, 로컬 JSON 파일, 고정 경로 data/crypto_transactions.json

    • NotionTransactionRepository, 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 트레이드, 두 암호화폐 간 스왑(예: ETH/BTC) 포함: 일반 트레이드와 동일한 형태이므로 별도 도구가 필요하지 않습니다. 교환 시점의 명목 가치를 고정하기 위해 선택적 fiat_value/fiat_currency를 지원합니다 — crypto/crypto 스왑의 경우 강력히 권장됩니다. price(두 암호화폐 간 상대 환율)만으로는 사후에 실현 손익이나 새로 받은 자산의 명목 비용 기준을 계산할 수 없기 때문입니다.

  • log_transfer — 동일 자산을 두 보관소 간 이동(exchangeto_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 자체 제외)에 대해: 보유 수량, 총 투자 금액 및 단위당 평균(비용 기준), 시장 가치, 미실현 손익. as_of_date 선택 사항으로 실시간이 아닌 과거 날짜의 상황(과거 가격)을 볼 수 있습니다 — 세금 신고용으로 설계되었습니다. cost_basis_method(weighted_average 또는 fifo)는 자동이 아닌 명시적 선택입니다: 동일한 내역에서 서로 다른 양도차익이 나올 수 있으므로, 세무사와 확인하세요.

  • get_asset_price — 단일 자산의 현재 또는 특정 날짜의 과거 시세, 전체 포트폴리오를 계산하지 않고 조회합니다.

설정

uv sync

.env.example.env로 복사하고 값을 채우세요: 시작 시 자동으로 로드됩니다 (main.pyload_dotenv()를 호출). 이는 서버가 외부 호스트(Claude Desktop, agy 등)에서 uv run --directory <path> main.py로 실행될 때도 작동합니다. --directory가 프로세스의 작업 디렉터리를 프로젝트 루트로 설정하고, load_dotenv()가 기본적으로 .env를 찾기 때문입니다 — 호스트의 JSON 구성에 비밀번호를 중복할 필요가 없습니다. 호스트 구성은 종종 gitignore된 로컬 .env보다 보호 수준이 낮습니다.

영속성 백엔드

환경 변수 TRANSACTION_REPOSITORY_BACKEND로 선택합니다:

  • json (기본값) — 추가 구성 불필요.

  • notionNOTION_TOKEN(Notion integration 토큰) 및 NOTION_DATABASE_ID 필요.

Notion 처음부터 설정

아직 이 프로젝트에 연결된 Notion integration이 없다면, 다음 단계를 순서대로 따르세요 (워크스페이스에 integration을 만들 수 있는 권한이 있는 Notion 계정 필요):

  1. Integration 생성notion.so/my-integrations로 이동 → "+ New integration" → 이름 지정(예: "Crypto Transactions MCP") → 워크스페이스 선택 → 유형 "Internal".

  2. Capabilities 활성화 — integration 설정 페이지의 "Capabilities"에서 다음을 활성화: Read content, Update content, Insert content.

  3. 토큰 복사 — "Secrets" 탭 → "Internal Integration Secret" 값 복사(secret_ 또는 ntn_로 시작). 이것이 NOTION_TOKEN입니다.

  4. 데이터베이스 생성 — Notion에서 새 데이터베이스(전체 페이지 또는 인라인)를 만들고 아래 표에 나열된 property로 정확히 구성하세요. Notion이 기본으로 만드는 "title" 열(보통 "Name")은 Transaction ID로 이름을 바꿔야 합니다: 모든 Notion 데이터베이스에는 필수로 하나가 있으며, 데이터베이스 이름이 아니라 각 행을 식별하는 열입니다.

  5. 데이터베이스를 integration과 공유 — 데이터베이스 페이지 열기 → 오른쪽 상단 "..." 메뉴 → "Connections" → 1단계에서 만든 integration을 검색하여 연결. 이 단계를 건너뛰면 유효한 토큰으로도 API가 404를 반환합니다. Notion 권한은 페이지별이지 워크스페이스 전체가 아니기 때문입니다.

  6. 데이터베이스 ID 찾기 — 데이터베이스 페이지 URL에 있습니다: https://www.notion.so/<하이픈-없는-ID>?v=.... 예를 들어, https://www.notion.so/abcdef0123456789abcdef0123456789?v=...에서 ID는 abcdef0123456789abcdef0123456789입니다. 이것이 NOTION_DATABASE_ID입니다.

  7. 변수 구성.env(위 참조) 또는 MCP 호스트의 env 블록에서:

    TRANSACTION_REPOSITORY_BACKEND=notion
    NOTION_TOKEN=<il secret del punto 3>
    NOTION_DATABASE_ID=<l'id del punto 6>

Notion 데이터베이스에는 다음 property(정확한 이름 및 유형)가 있어야 합니다:

Property

유형

Transaction ID

title

Tx Hash

rich_text

Exchange

select

To Exchange

select

Symbol

select

Side

select (BUY, SELL, TRANSFER)

Timestamp

date (시간 포함, UTC)

Amount

number

Price

number

Value

number

Fee Amount

number

Fee Asset

select

Fiat Value

number

Fiat Currency

select

Notes

rich_text

To Exchange, Price, Value, Fiat Value, Fiat Currency는 비어 있을 수 있습니다 (TRANSFER에는 적용되지 않거나 트레이드에서 선택 사항).

참고: Notion의 숫자 필드는 기본 number(float64)이며 JSON 백엔드의 정확한 Decimal이 아닙니다 — 실제 거래 금액에는 충분하지만, 배정밀도 부동소수점의 정밀도 한계가 있습니다.

테스트

uv run pytest

수동 실행

uv run main.py

Claude 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 tools
get_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).

ParametersJSON Schema
NameRequiredDescriptionDefault
sideNo
symbolNo
date_toNo
exchangeNo
date_fromNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.5/5.0
Behavior3/5

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.

Conciseness4/5

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.

Completeness3/5

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.

Parameters4/5

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.

Purpose4/5

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.

Usage Guidelines3/5

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.
    
ParametersJSON Schema
NameRequiredDescriptionDefault
idNo
sideNo
notesNo
priceNo
valueNo
amountNo
symbolNo
tx_hashNo
exchangeNo
fee_assetNo
timestampNo
fee_amountNo
fiat_valueNo
fiat_currencyNo

TDQS

A4.6/5.0
Behavior5/5

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.

Conciseness3/5

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.

Completeness4/5

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.

Parameters4/5

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.

Purpose5/5

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.

Usage Guidelines5/5

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.
    
ParametersJSON Schema
NameRequiredDescriptionDefault
idNo
notesNo
amountNo
symbolNo
tx_hashNo
exchangeNo
fee_assetNo
timestampNo
fee_amountNo
fiat_valueNo
to_exchangeNo
fiat_currencyNo

TDQS

A4.5/5.0
Behavior4/5

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.

Conciseness4/5

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.

Completeness4/5

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.

Parameters4/5

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.

Purpose5/5

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.

Usage Guidelines5/5

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.

  1. 3 tool updatesv0.1.0
    • First observedget_transaction_history
    • First observedlog_transaction
    • First observedlog_transfer

TDQS

A4.1/5.0

Scored across 3 tools

Disambiguation5/5

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.

Naming Consistency5/5

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.

Tool Count4/5

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.

Completeness4/5

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

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Agent-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.
    7
    Apache 2.0
  • F
    license
    B
    quality
    D
    maintenance
    A 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
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    MCP 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
  • F
    license
    Not graded
    quality
    B
    maintenance
    A lightweight MCP server that lets LLM clients track, query, and summarize personal expenses using a local SQLite database.
    -