# demosfen7/cryptomcp architecture

> Architecture diagram of the GitHub repository demosfen7/cryptomcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/demosfen7/cryptomcp
- Repository: https://github.com/demosfen7/cryptomcp

## Overview

cryptomcp provides Binance market context to AI through an MCP server, alongside a separate hourly collector that archives data and maintains scan lists. The main user workflow is to query the watchlist, then request market snapshots, squeeze metrics, raw candles, derivatives, levels, or order-book observations. Analytics and rendering turn market data into model-readable results. The README documents the collector’s SQLite handoff and Telegram notifications; source excerpts show server and collector modules, but not their complete runtime wiring.

Main entry points: [`cryptomcp/server.py`](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/server.py) (MCP server), [`cryptomcp/collector.py`](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/collector.py) (Hourly collector), [`cryptomcp/analysis.py`](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/analysis.py) (Squeeze analysis), [`cryptomcp/orderbook_watch.py`](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/orderbook_watch.py) (Book watch sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_serving["MCP market tools"]
  node_server["MCP server<br/>[server.py]"]
  node_assistant["Tool interface<br/>[assistant.py]"]
  node_render["Result rendering<br/>[render.py]"]
  node_reader["Market reader<br/>[reader.py]"]
  node_orderbook["Order book<br/>[orderbook.py]"]
  node_watch["Book watch sessions<br/>[orderbook_watch.py]"]
end

subgraph group_analysis["Market analysis"]
  node_fetcher["Candle fetcher<br/>[fetcher.py]"]
  node_analysis_core["Squeeze analysis<br/>[analysis.py]"]
  node_indicators["Indicators<br/>[indicators.py]"]
  node_volume["Volume metrics<br/>[volume.py]"]
  node_levels["Key levels<br/>[levels.py]"]
  node_derivatives["Derivatives<br/>[derivatives.py]"]
  node_flow["Flow metrics<br/>[flow.py]"]
  node_distribution["Accumulation detector<br/>[distribution.py]"]
end

subgraph group_collection["Hourly collection"]
  node_collector["Hourly collector<br/>[collector.py]"]
  node_symbols["Symbol registry<br/>[symbols.py]"]
  node_manual["Manual watchlist<br/>[manual.py]"]
  node_notify["Change notifications<br/>[notify.py]"]
end

subgraph group_state["Persistent state"]
  node_storage[("Market archive<br/>[storage.py]")]
  node_watch_store[("Book watch storage<br/>[orderbook_watch.py]")]
end

subgraph group_integrations["External services"]
  node_client["Binance client<br/>[client.py]"]
  node_binance{{"Binance API"}}
  node_telegram{{"Telegram"}}
end

node_user(("AI client"))

node_user -->|"queries tools"| node_server
node_server -->|"loads candles"| node_fetcher
node_fetcher -->|"requests market data"| node_client
node_client -->|"calls public API"| node_binance
node_server -->|"reads archived data"| node_reader
node_reader -->|"reads history"| node_storage
node_server -->|"builds metrics"| node_analysis_core
node_analysis_core -->|"computes indicators"| node_indicators
node_analysis_core -->|"computes volume context"| node_volume
node_analysis_core -->|"uses levels"| node_levels
node_server -->|"gets derivatives"| node_derivatives
node_server -->|"gets flow metrics"| node_flow
node_server -->|"gets accumulation"| node_distribution
node_server -->|"gets book snapshot"| node_orderbook
node_server -->|"manages sessions"| node_watch
node_watch -->|"records snapshots"| node_watch_store
node_server -->|"formats results"| node_render
node_collector -->|"collects market data"| node_client
node_collector -->|"selects symbols"| node_symbols
node_collector -->|"calculates scan index"| node_analysis_core
node_collector -->|"writes archive and scans"| node_storage
node_server -->|"reads scan history"| node_storage
node_collector -->|"maintains scan lists"| node_manual
node_server -->|"edits manual list"| node_manual
node_collector -->|"sends change delta"| node_notify
node_notify -->|"sends messages"| node_telegram
node_collector -.->|"updates book watches"| node_watch

click node_server "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/server.py"
click node_assistant "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/assistant.py"
click node_render "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/render.py"
click node_reader "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/reader.py"
click node_fetcher "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/fetcher.py"
click node_client "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/client.py"
click node_analysis_core "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/analysis.py"
click node_indicators "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/indicators.py"
click node_volume "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/volume.py"
click node_levels "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/levels.py"
click node_derivatives "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/derivatives.py"
click node_flow "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/flow.py"
click node_distribution "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/distribution.py"
click node_orderbook "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/orderbook.py"
click node_watch "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/orderbook_watch.py"
click node_collector "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/collector.py"
click node_symbols "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/symbols.py"
click node_manual "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/manual.py"
click node_notify "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/notify.py"
click node_storage "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/storage.py"
click node_watch_store "https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/orderbook_watch.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_assistant,node_render,node_reader,node_orderbook,node_watch,node_user toneBlue
class node_fetcher,node_analysis_core,node_indicators,node_volume,node_levels,node_derivatives,node_flow,node_distribution toneAmber
class node_collector,node_symbols,node_manual,node_notify toneMint
class node_storage,node_watch_store toneRose
class node_client,node_binance,node_telegram toneIndigo
```

## Components

### MCP market tools

- [MCP server](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/server.py): `cryptomcp/server.py`
- [Tool interface](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/assistant.py): `cryptomcp/assistant.py`
- [Result rendering](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/render.py): `cryptomcp/render.py`
- [Market reader](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/reader.py): `cryptomcp/reader.py`
- [Order book](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/orderbook.py): `cryptomcp/orderbook.py`
- [Book watch sessions](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/orderbook_watch.py): `cryptomcp/orderbook_watch.py`

### Market analysis

- [Candle fetcher](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/fetcher.py): `cryptomcp/fetcher.py`
- [Squeeze analysis](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/analysis.py): `cryptomcp/analysis.py`
- [Indicators](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/indicators.py): `cryptomcp/indicators.py`
- [Volume metrics](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/volume.py): `cryptomcp/volume.py`
- [Key levels](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/levels.py): `cryptomcp/levels.py`
- [Derivatives](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/derivatives.py): `cryptomcp/derivatives.py`
- [Flow metrics](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/flow.py): `cryptomcp/flow.py`
- [Accumulation detector](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/distribution.py): `cryptomcp/distribution.py`

### Hourly collection

- [Hourly collector](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/collector.py): `cryptomcp/collector.py`
- [Symbol registry](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/symbols.py): `cryptomcp/symbols.py`
- [Manual watchlist](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/manual.py): `cryptomcp/manual.py`
- [Change notifications](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/notify.py): `cryptomcp/notify.py`

### Persistent state

- [Market archive](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/storage.py): `cryptomcp/storage.py`
- [Book watch storage](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/orderbook_watch.py): `cryptomcp/orderbook_watch.py`

### External services

- [Binance client](https://github.com/demosfen7/cryptomcp/blob/main/cryptomcp/client.py): `cryptomcp/client.py`
- **Binance API**
- **Telegram**

### Other components

- **AI client**

## Connections

- AI client → MCP server: queries tools (evidence: `README.md`)
- MCP server → Candle fetcher: loads candles (evidence: `cryptomcp/server.py`)
- Candle fetcher → Binance client: requests market data (evidence: `cryptomcp/fetcher.py`)
- Binance client → Binance API: calls public API (evidence: `cryptomcp/client.py`)
- MCP server → Market reader: reads archived data (evidence: `cryptomcp/server.py`)
- Market reader → Market archive: reads history (evidence: `cryptomcp/reader.py`)
- MCP server → Squeeze analysis: builds metrics (evidence: `cryptomcp/server.py`)
- Squeeze analysis → Indicators: computes indicators (evidence: `cryptomcp/analysis.py`)
- Squeeze analysis → Volume metrics: computes volume context (evidence: `cryptomcp/analysis.py`)
- Squeeze analysis → Key levels: uses levels (evidence: `cryptomcp/analysis.py`)
- MCP server → Derivatives: gets derivatives (evidence: `cryptomcp/server.py`)
- MCP server → Flow metrics: gets flow metrics (evidence: `cryptomcp/server.py`)
- MCP server → Accumulation detector: gets accumulation (evidence: `README.md`)
- MCP server → Order book: gets book snapshot (evidence: `cryptomcp/server.py`)
- MCP server → Book watch sessions: manages sessions (evidence: `cryptomcp/server.py`)
- Book watch sessions → Book watch storage: records snapshots (evidence: `cryptomcp/orderbook_watch.py`)
- MCP server → Result rendering: formats results (evidence: `cryptomcp/server.py`)
- Hourly collector → Binance client: collects market data (evidence: `cryptomcp/collector.py`)
- Hourly collector → Symbol registry: selects symbols (evidence: `cryptomcp/collector.py`)
- Hourly collector → Squeeze analysis: calculates scan index (evidence: `cryptomcp/collector.py`)
- Hourly collector → Market archive: writes archive and scans (evidence: `README.md`)
- MCP server → Market archive: reads scan history (evidence: `README.md`)
- Hourly collector → Manual watchlist: maintains scan lists (evidence: `cryptomcp/collector.py`)
- MCP server → Manual watchlist: edits manual list (evidence: `cryptomcp/server.py`)
- Hourly collector → Change notifications: sends change delta (evidence: `README.md`)
- Change notifications → Telegram: sends messages (evidence: `README.md`)
- Hourly collector → Book watch sessions: updates book watches (evidence: `README.md`)
