Ever wanted your AI assistant to check Bitcoin prices, place trades, or analyze market depth without you having to copy-paste data back and forth? That's exactly what the CoinEx MCP Server makes possible. It's a bridge that lets AI agents like Claude interact directly with the CoinEx cryptocurrency exchange through a standardized protocol.
Think of it as giving your AI a direct phone line to the crypto markets. No more "Hey Claude, BTC is at $43k, what should I do?" Instead, Claude can look up the price itself, check your balance, and even help you execute trades—all in real-time.
The CoinEx MCP Server isn't just another API wrapper. It's built on the Model Context Protocol, which means it speaks the same language as modern AI agents. Here's what you can do with it:
Market Intelligence: Pull live spot and futures data with unified parameters. Whether you're tracking BTCUSDT on spot markets or analyzing perpetual contracts, the syntax stays consistent. The server handles ticker snapshots, order book depth, K-line charts, and recent trade history.
Account Management: Query your balances across spot and futures accounts. The authentication happens securely through environment variables or HTTP headers—your API credentials never get hardcoded into conversations.
Active Trading: Place orders, check order history, and manage positions directly through AI conversations. The server supports both spot and futures trading operations.
Futures-Specific Tools: Access funding rates, premium index history, basis rates, margin tier information, and liquidation data. These are essential metrics for anyone trading perpetual contracts.
If you're building AI-powered trading tools or just want a smarter way to interact with crypto markets, 👉 explore how CoinEx's unified API architecture makes integration seamless. The exchange offers both spot and futures markets with consistent parameter conventions across endpoints.
The setup process is straightforward. You'll need Python installed, then it's just a matter of syncing dependencies:
uv sync
Next comes the API credentials. You have two configuration paths. For MCP clients like Claude Desktop or CherryStudio, you'll add credentials directly in their config files. For local development, copy the .env.example file to .env and fill in your CoinEx access ID and secret key.
To get those credentials, log into CoinEx, navigate to User Center, then API Management. Create a new API key and copy both the Access ID and Secret Key. Set appropriate permissions—only enable what you actually need. Trading bots gone rogue are nobody's idea of fun.
Security matters here. Never commit your .env file to Git. Never share API keys in public channels. And seriously consider IP whitelisting if CoinEx offers it for your account type.
The server supports three transport modes, each suited for different use cases.
Stdio Mode is the default. It's what most MCP clients expect—simple input/output communication over standard streams. This is perfect for desktop AI apps like Claude or CherryStudio where the server runs as a background process.
HTTP Mode turns the server into a web service. Start it with:
python -m coinex_mcp_server.main --transport http --host 0.0.0.0 --port 8000 --path /mcp
This mode is useful when you want multiple clients connecting to one server instance, or when you're building web-based AI applications. Note that if you try accessing the endpoint directly with a browser, you might get a 406 Not Acceptable response—that's expected, since the endpoint requires MCP protocol handshakes.
SSE Mode uses Server-Sent Events for streaming responses. It's less common but useful for real-time updates in browser-based applications.
For production HTTP deployments, enable authentication explicitly with --enable-http-auth. By default, HTTP mode only exposes public query tools—market data, tickers, order books. Trading operations require opt-in authentication since you'll be passing credentials via headers.
When running in HTTP mode with authentication enabled, the server expects credentials in request headers:
X-CoinEx-Access-Id: <your access ID>
X-CoinEx-Secret-Key: <your secret key>
This design means the server never stores third-party credentials. Each request carries its own authentication. But this also means never expose an authenticated HTTP endpoint publicly. Even with HTTPS, reverse proxies and logging systems might capture those headers. Deploy behind VPNs, use internal networks, or stick with stdio mode for personal use.
If you're serious about HTTP deployments, put Nginx or Caddy in front to handle TLS termination. Check that your logging setup doesn't record sensitive headers. And consider whether you even need trading operations exposed—sometimes read-only market data is all you really want.
When you're ready to implement secure trading infrastructure with proper API key management, 👉 CoinEx provides detailed documentation on authentication best practices and permission scoping.
Here's how you'd configure Claude Desktop to use the server. Edit your config file (location varies by OS—check the docs for the exact path) and add:
json
{
"mcpServers": {
"coinex": {
"command": "uvx",
"args": ["coinex-mcp-server"],
"env": {
"COINEX_ACCESS_ID": "your_access_id_here",
"COINEX_SECRET_KEY": "your_secret_key_here"
}
}
}
}
The uvx command is recommended because it handles package installation and environment isolation automatically—think of it like npx for Python. Restart Claude Desktop, and you should see the CoinEx tools available in the interface.
Now you can ask Claude things like "What's the current BTC funding rate?" or "Show me the order book depth for ETHUSDT" and get live data. Claude will call the appropriate server tools behind the scenes.
The server exposes around a dozen tools, divided into public market data and authenticated trading operations.
Market data tools work without authentication. list_markets shows you which trading pairs are active. get_tickers pulls current price snapshots—you can specify symbols or just grab the top gainers. get_orderbook returns bid/ask depth, useful for assessing liquidity before placing large orders. get_kline fetches candlestick data for technical analysis.
Futures tools add extra metrics. get_funding_rate shows what you'll pay (or earn) for holding perpetual positions overnight. get_position_tiers reveals margin requirements at different position sizes. get_liquidation_history lets you analyze where other traders got wrecked—morbid but educational.
Trading tools require authentication and the --enable-http-auth flag in HTTP mode. These include balance queries, order placement, and order history. The implementation details are in the code, but the point is you can build full trading workflows through AI conversations.
All tools use consistent parameter conventions. market_type defaults to "spot" but accepts "futures". Symbol names are flexible—BTCUSDT, BTC/USDT, even just BTC all work (defaulting to USDT pairs). Period strings like 1hour or 1day get validated against exchange limits.
If API calls return code != 0, check the error message first. Common issues include invalid period strings (futures and spot have different allowed values), malformed symbols, or exceeding rate limits.
Corporate networks sometimes block external API calls. If everything works on your home WiFi but fails at the office, that's probably firewall restrictions. Talk to IT or use a VPN.
For HTTP mode issues, verify the server actually started—check the console output for the listening address and port. If clients can't connect, it might be firewall rules on your machine blocking the port.
Missing dependencies usually show up as import errors. Run uv sync again to ensure everything's installed. If using system Python instead of uv, make sure you've got httpx, fastmcp, and python-dotenv.
The real value here isn't just convenience—it's about closing the loop between analysis and execution. Traditional trading workflows involve a lot of context switching: check prices in one app, analyze charts in another, execute trades in a third, then document everything in a spreadsheet.
With MCP servers like this, you can have conversations like "What's the 4-hour RSI for BTC, and based on that plus current funding rates, should I open a long position?" The AI can fetch the data, run the calculations, and even place the order—all while explaining its reasoning.
For developers, this is a template for building AI-powered trading systems. The code is open source under Apache 2.0, so you can fork it, extend it, or just learn from it. Add new exchanges, implement custom indicators, or build backtesting tools that can query historical data.
This project lives at github.com/coinexcom/coinex_mcp_server if you want to dig into the code. The structure is clean—main server logic in main.py, API client wrapper in coinex_client.py, and documentation in the doc/ folder.
Issues and pull requests are welcome. The crypto space moves fast, and community contributions help keep tools like this current with exchange API changes.
Just remember the disclaimer: this is educational software. Real trading involves real risk. Test thoroughly with small amounts before scaling up. And maybe don't let an AI manage your entire portfolio unsupervised—we're not quite there yet.
The intersection of AI and crypto trading is still early territory. Tools like the CoinEx MCP Server make it easier to experiment and build. Whether you're automating your own trading strategies or just exploring what's possible when AI agents can interact with financial markets, having solid infrastructure matters.