coinex-mcp-server
An MCP server for interacting with the CoinEx cryptocurrency exchange, enabling market data queries and authenticated trading operations via AI agents.
README
CoinEx MCP Server
中文版本 | English
A CoinEx MCP (Model Context Protocol) server that enables AI agents to interact with the CoinEx cryptocurrency exchange.
Features
- 🔍 Retrieve market data (spot/futures with unified parameters)
- 💰 Query account balances (authentication required)
- 📊 Get K-line data (spot/futures)
- 📈 View order book depth (spot/futures)
- 💹 Place orders (authentication required)
- 📋 Query order history (authentication required)
- 📜 Futures-specific: funding rates, premium/basis history, margin tiers, liquidation history, etc.
Quick Start
Choose one of the following installation methods based on your needs:
- Online HTTP Service (Recommended) - No local installation required, public market data only
- Local Installation via uvx/pip - Supports authenticated operations (balance queries, trading)
- From Source - For development or customization
Obtaining CoinEx API Credentials (Optional)
API credentials are only required for authenticated operations (account balance, trading). For market data queries only, you can skip this step.
- Log in to CoinEx Official Website
- Go to User Center -> API Management
- Create a new API Key
- Copy the Access ID and Secret Key for later use
⚠️ Security Notice:
- Keep your API credentials safe and do not share them with others
- Set appropriate permissions for your API Key, only enabling necessary functions
- Do not commit credentials to version control systems
Installation Method 1: Online HTTP Service (Recommended)
No local installation required. Use CoinEx's hosted MCP service at https://mcp.coinex.com/mcp.
⚠️ Note: The online service only provides public market data queries. For authenticated operations (balance, trading), use Method 2 or 3.
Claude Code
claude mcp add --transport http coinex-mcp-server https://mcp.coinex.com/mcp
Claude Desktop
Edit your Claude Desktop configuration file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"coinex": {
"command": "http",
"args": ["https://mcp.coinex.com/mcp"]
}
}
}
CherryStudio
In CherryStudio's MCP settings, GUI configuration:
<img src="images/CherryStudio_HTTP_en.png" alt="CherryStudio CoinEx MCP Configuration"/>
Installation Method 2: Local Installation via uvx/pip
Install the package locally to support authenticated operations with your API credentials.
Option A: Using uvx (Recommended)
No pre-installation needed. The package will be automatically downloaded and run.
Claude Desktop
Edit your Claude Desktop configuration file:
{
"mcpServers": {
"coinex": {
"command": "uvx",
"args": ["coinex-mcp-server"],
"env": {
"COINEX_ACCESS_ID": "your_access_id_here",
"COINEX_SECRET_KEY": "your_secret_key_here"
}
}
}
}
Claude Code
# Add the server
claude mcp add coinex-mcp-server uvx coinex-mcp-server
# Then manually edit the config file to add environment variables
# Config file location: ~/.config/claude/config.json
# Add env field to the coinex-mcp-server configuration:
# "env": {
# "COINEX_ACCESS_ID": "your_access_id",
# "COINEX_SECRET_KEY": "your_secret_key"
# }
CherryStudio
In CherryStudio's MCP settings, add:
<img src="images/CherryStudio_uvx_en.png" alt="CherryStudio CoinEx MCP Configuration"/>
Option B: Using pip install
First, install the package:
# Using pip
pip install coinex-mcp-server
# Or using uv
uv pip install coinex-mcp-server
Then configure your MCP client:
Claude Desktop
{
"mcpServers": {
"coinex": {
"command": "python",
"args": ["-m", "coinex_mcp_server.main"],
"env": {
"COINEX_ACCESS_ID": "your_access_id_here",
"COINEX_SECRET_KEY": "your_secret_key_here"
}
}
}
}
Claude Code
# Add the server
claude mcp add coinex-mcp-server python -m coinex_mcp_server.main
# Then manually edit the config file to add environment variables
# Config file location: ~/.config/claude/config.json
# Add env field to the coinex-mcp-server configuration:
# "env": {
# "COINEX_ACCESS_ID": "your_access_id",
# "COINEX_SECRET_KEY": "your_secret_key"
# }
CherryStudio
<img src="images/CherryStudio_python_en.png" alt="CherryStudio CoinEx MCP Configuration"/>
Installation Method 3: From Source
For development or customization purposes.
Step 1: Clone the Repository
git clone https://github.com/coinexcom/coinex_mcp_server
cd coinex_mcp_server
Step 2: Install Dependencies
uv sync
Step 3: Configure API Credentials
Copy the environment variable template file:
cp .env.example .env
Edit the .env file and fill in your CoinEx API credentials:
COINEX_ACCESS_ID=your_access_id_here
COINEX_SECRET_KEY=your_secret_key_here
Step 4: Configure MCP Client
Claude Desktop
{
"mcpServers": {
"coinex": {
"command": "python",
"args": ["-m", "coinex_mcp_server.main"],
"cwd": "/path/to/coinex_mcp_server/src"
}
}
}
Claude Code
# Run from the project directory
cd /path/to/coinex_mcp_server
python -m coinex_mcp_server.main
CherryStudio
<img src="images/CherryStudio_python_en.png" alt="CherryStudio CoinEx MCP Configuration"/>
Step 5: Run the Server (Optional)
For testing or running in HTTP mode:
# Default stdio mode
python -m coinex_mcp_server.main
# HTTP mode
python -m coinex_mcp_server.main --transport http --host 0.0.0.0 --port 8000
# View all available options
python -m coinex_mcp_server.main --help
Advanced Configuration
Command Line Arguments
The server supports the following command line arguments:
--transport: Transport protocol- Options:
stdio(default) |http|streamable-http|sse
- Options:
--host: HTTP service bind address (HTTP/SSE mode only)- Default:
127.0.0.1
- Default:
--port: HTTP service port (HTTP/SSE mode only)- Default:
8000
- Default:
--path: Endpoint path- HTTP mode: MCP endpoint path (default
/mcp) - SSE mode: SSE mount path
- HTTP mode: MCP endpoint path (default
--enable-http-auth: Enable HTTP-based authentication for trading tools- Default:
false(only public market data tools exposed)
- Default:
--workers: Number of worker processes (HTTP/SSE mode only)
Running as HTTP Service
# Basic HTTP service
python -m coinex_mcp_server.main --transport http --host 0.0.0.0 --port 8000
# HTTP service with authentication enabled
python -m coinex_mcp_server.main --transport http --host 0.0.0.0 --port 8000 --enable-http-auth
# HTTP service with multiple workers
python -m coinex_mcp_server.main --transport http --host 0.0.0.0 --port 8000 --workers 4
⚠️ Note: If you access the /mcp endpoint directly via HTTP GET, it may return 406 Not Acceptable. This is normal—Streamable HTTP endpoints require protocol-compliant interaction flows.
HTTP Authentication Mode
When running in HTTP mode with --enable-http-auth, you can pass CoinEx credentials via HTTP headers:
Request Headers:
X-CoinEx-Access-Id: Your CoinEx Access IDX-CoinEx-Secret-Key: Your CoinEx Secret Key
Security Considerations:
- Never enable HTTP authentication on publicly exposed services
- Always use HTTPS in production (use reverse proxy like Nginx/Caddy)
- Ensure reverse proxies/APM/logging systems don't record sensitive headers
- Only use in trusted internal network environments
- By default, HTTP mode only exposes public market data tools (no authentication required)
Tools Overview
Note: In HTTP mode, only public type tools are exposed by default; auth type tools require enabling --enable-http-auth or setting HTTP_AUTH_ENABLED=true to be available.
Standard Parameter Conventions:
market_type: Default"spot", use"futures"for contracts.symbol: SupportsBTCUSDT/BTC/USDT/btc/BTC(defaults toUSDTif no quote currency).interval(depth aggregation levels): Default"0".period: Default"1hour", validated against spot/futures whitelists.start_time/end_time: Millisecond timestamps.
Market Data (public)
list_markets(market_type="spot"|"futures", symbols: str|list[str]|None)- Get market status;
symbolscan be comma-separated or array, returns all if not provided.
- Get market status;
get_tickers(market_type="spot"|"futures", symbol: str|list[str]|None, top_n=5)- Get ticker snapshots; returns top
top_nwhensymbolnot provided.
- Get ticker snapshots; returns top
get_orderbook(symbol, limit=20, market_type="spot"|"futures", interval="0")- Get order book (depth); supports futures.
get_kline(symbol, period="1hour", limit=100, market_type="spot"|"futures")- Get K-line data; periods validated against respective spot/futures whitelists.
get_recent_trades(symbol, market_type="spot"|"futures", limit=100)- Get recent trades (deals).
get_index_price(market_type="spot"|"futures", symbol: str|list[str]|None, top_n=5)- Get market index (spot/futures).
Futures-Specific (public)
get_funding_rate(symbol)- Get current funding rate.
get_funding_rate_history(symbol, start_time?, end_time?, page=1, limit=100)- Get funding rate history.
get_premium_index_history(symbol, start_time?, end_time?, page=1, limit=100)- Get premium index history.
get_basis_history(symbol, start_time?, end_time?, page=1, limit=100)- Get basis rate history.
get_position_tiers(symbol)- Get position tiers/margin tier information.
get_liquidation_history(symbol?, side?, start_time?, end_time?, page=1, limit=100)- Get liquidation history.
Account & Trading (auth)
get_account_balance()- Get account balance information.
place_order(symbol, side, type, amount, price?)- Place trading order.
cancel_order(symbol, order_id)- Cancel order.
get_order_history(symbol?, limit=100)- Get order history (open orders + completed orders).
Environment Variables
| Variable | Description | Required |
|---|---|---|
COINEX_ACCESS_ID |
CoinEx API Access ID | No (optional with HTTP pass-through) |
COINEX_SECRET_KEY |
CoinEx API Secret Key | No (optional with HTTP pass-through) |
API_TOKEN |
Bearer token to protect MCP endpoint | No |
API_SCOPES |
Required scopes for endpoint | No |
HTTP_AUTH_ENABLED |
Enable HTTP authentication (default false) | No |
Development
Project Structure
coinex_mcp_server/
├── main.py # MCP server main file
├── coinex_client.py # CoinEx API client (unified spot/futures wrapper)
├── doc/
│ ├── coinex_api/
│ │ └── coinex_api.md # CoinEx API documentation
├── pyproject.toml # Project configuration
└── README.md # Project documentation
Dependencies
fastmcp- FastMCP framework (2.x)httpx- HTTP clientpython-dotenv- Environment variable loading
Troubleshooting
- If calls return
code != 0, record themessageand check parameters (period,limit,symbolnormalization). - In corporate network environments or with firewall restrictions, external APIs may be blocked; please verify network policies.
License
This project is open source under the Apache 2.0 license.
Contributing
Issues and Pull Requests are welcome!
Disclaimer
This tool is for educational and research purposes only. When using this tool for actual trading, please fully understand the risks and operate carefully. The developers are not responsible for any losses resulting from the use of this tool.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。