crypto-mcp-server
An MCP server that exposes live cryptocurrency market data from CoinGecko as 12 typed read-only tools, including prices, market charts, OHLC candles, trending coins, and global market overview.
README
crypto-mcp-server
An MCP server exposing live cryptocurrency market data from the CoinGecko v3 API as 12 typed tools.
Built on the MCP Python SDK 2.x (MCPServer), fully asynchronous, with a
shared connection pool, client-side rate limiting, response caching, bounded
retries, and structured logging.
Tools
| Tool | Purpose |
|---|---|
check_api_status |
Upstream health plus this server's config and cache stats |
list_supported_currencies |
Every accepted vs_currency code |
search_coins |
Resolve a name or symbol to a CoinGecko coin id |
get_coin_price |
Spot prices for many coins in many currencies at once |
convert_crypto_amount |
Convert a quantity of a coin into another currency |
get_coin_details |
Full profile: supply, ATH, 24h/7d/30d changes |
list_top_coins |
Ranked market table by market cap, volume, or id |
get_market_chart |
Historical price / market cap / volume series |
get_ohlc_candles |
Candlestick data |
get_historical_price |
Market state on one past date (needs a paid plan) |
get_trending_coins |
Most-searched coins of the last 24 hours |
get_global_market_overview |
Total market cap, volume, BTC/ETH dominance |
Every tool is read-only, returns a typed model (so clients get an
outputSchema), and pairs raw numerics with preformatted *_display strings —
models quote the display string and compute on the raw value.
Install
uv sync
Run
# stdio (default) — how MCP clients launch it
uv run crypto-mcp-server
# HTTP, for remote clients or debugging
uv run crypto-mcp-server --transport streamable-http --port 8000
# verbose, machine-readable logs
uv run crypto-mcp-server --log-level DEBUG --log-format json
python -m crypto_mcp_server works identically.
Client configuration
{
"mcpServers": {
"crypto": {
"command": "uv",
"args": ["run", "--directory", "/path/to/crypto_mcp_server", "crypto-mcp-server"],
"env": { "CRYPTO_MCP_API_KEY": "CG-xxxxxxxxxxxx" }
}
}
}
Configuration
All settings come from CRYPTO_MCP_* environment variables and are resolved
once at startup by Settings.from_env(). Everything is optional — the server
runs anonymously against CoinGecko's public tier out of the box.
| Variable | Default | Meaning |
|---|---|---|
CRYPTO_MCP_API_KEY |
(unset) | CoinGecko Demo or Pro key |
CRYPTO_MCP_API_TIER |
inferred | public, demo, or pro |
CRYPTO_MCP_BASE_URL |
follows tier | API root; override for a proxy or mock |
CRYPTO_MCP_TIMEOUT_SECONDS |
15.0 |
Total request timeout |
CRYPTO_MCP_CONNECT_TIMEOUT_SECONDS |
5.0 |
Connect timeout |
CRYPTO_MCP_MAX_RETRIES |
3 |
Retries after the first attempt |
CRYPTO_MCP_BACKOFF_BASE_SECONDS |
0.5 |
First-retry backoff factor |
CRYPTO_MCP_BACKOFF_MAX_SECONDS |
8.0 |
Ceiling on any single sleep |
CRYPTO_MCP_MAX_CONNECTIONS |
10 |
Connection pool size |
CRYPTO_MCP_RATE_LIMIT_PER_MINUTE |
tier default | Client-side outbound ceiling |
CRYPTO_MCP_CACHE_TTL_SECONDS |
30.0 |
Response cache TTL; 0 disables |
CRYPTO_MCP_CACHE_MAX_ENTRIES |
512 |
Cache size before LRU eviction |
CRYPTO_MCP_LOG_LEVEL |
INFO |
DEBUG…CRITICAL |
CRYPTO_MCP_LOG_FORMAT |
text |
text or json |
The tier is inferred from the key's presence, and the base URL follows the
tier, so a Pro user only sets CRYPTO_MCP_API_KEY and
CRYPTO_MCP_API_TIER=pro.
A note on rate limits
The anonymous tier is throttled per source IP and shared with every other unauthenticated caller behind it. The default client-side budgets (5/min public, 25/min demo, 450/min pro) sit deliberately below CoinGecko's published ceilings — measured against the live API, even 10/min drew constant 429s without a key. For anything beyond casual use, set an API key.
Architecture
server.py MCP tools: argument validation, error translation, lifespan
↓
mappers.py raw CoinGecko JSON → typed models
↓
client.py the only module that knows HTTP
↓
utils.py retry, rate limiting, TTL cache, formatting, input hygiene
config.py, exceptions.py, logging_config.py, and models.py are shared
by every layer. A single request flows through:
get_json()
└─ TTLCache.get_or_load de-duplicates concurrent identical calls
└─ retry_async exponential backoff with full jitter
└─ AsyncRateLimiter
└─ httpx2 one attempt
Caching sits outside retries so a retried call is stored once; the limiter sits inside them so every physical attempt is metered.
Error handling
Failures are expressed as a shallow hierarchy under CryptoMCPError
(ToolInputError, RateLimitError, AuthenticationError,
ResourceNotFoundError, UpstreamTimeoutError, …). Each tool is wrapped by
@tool_handler, which guarantees three things:
- Argument mistakes fail before any network call, with a message naming a valid
value (
order must be one of market_cap_desc, …). - Known failures surface as
ToolErrorwith their message intact. - Anything unexpected is logged with a full traceback and returned as a generic message — no traceback ever reaches the client.
Retries cover timeouts, connection errors, and 5xx/429 responses. When
CoinGecko supplies a Retry-After longer than BACKOFF_MAX_SECONDS, the
server stops rather than retrying: sleeping less than the server demanded
only earns another rejection, and honouring a 60-second window inside a tool
call would stall the session.
Logging
Logs go to stderr, never stdout — under the stdio transport, stdout is the
JSON-RPC channel, and a stray write there corrupts the frame the client is
parsing and drops the session. configure_logging also detaches any stdout
handler it finds on the root logger.
Tests
uv run pytest
109 tests, no network access: upstream behaviour is simulated with
httpx2.MockTransport injected into the real client, and the tool layer is
driven through a genuine in-process MCP client session, so retries, caching,
rate limiting, error mapping, and the wire protocol all run as they do in
production.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。