The most comprehensive MCP server for Bybit β 246 tools covering the entire Bybit V5 API
Quick Start β’ Features β’ Configuration β’ Tools Reference β’ Troubleshooting β’ Contributing
Bybit MCP Server enables AI assistants like Claude, Cursor, ChatGPT, and other MCP-compatible clients to interact directly with the Bybit cryptocurrency exchange. Execute trades, manage portfolios, analyze markets, and automate strategies β all through natural language.
- π₯ Complete Coverage β 246 tools spanning every Bybit V5 API endpoint
- π Secure by Design β API credentials never leave your machine
- ποΈ Read-Only Mode β Use all market tools without any API key
- π‘ Triple Transport β STDIO, SSE, and Streamable HTTP
- π Universal Compatibility β Works with Claude Desktop, Cursor, ChatGPT, and any MCP client
- β‘ Zero Config Start β Just
uv run bybit.pyand go
|
|
|
|
Simply tell your AI assistant:
"Help me install the Bybit MCP server from https://github.com/JohnnyWic/bybit-mcp"
Your AI will clone the repo, install dependencies, and configure everything automatically. Works with Claude Code, Cursor, and other MCP-compatible clients.
git clone https://github.com/JohnnyWic/bybit-mcp.git
cd bybit-mcp
uv syncRequires Python β₯ 3.13 and uv.
Add the following to your MCP config file:
| Client | Config File |
|---|---|
| Claude Desktop | claude_desktop_config.json |
| Cursor | ~/.cursor/mcp.json |
| Claude Code | Run claude mcp add (see below) |
JSON config (Claude Desktop / Cursor):
{
"mcpServers": {
"bybit-mcp": {
"command": "uv",
"args": ["--directory", "/path/to/bybit-mcp", "run", "bybit.py"]
}
}
}Claude Code CLI:
claude mcp add bybit-mcp -- uv --directory /path/to/bybit-mcp run bybit.pyCreate a .env file in the project root:
cp .env.example .envBYBIT_API_KEY=your_api_key_here
BYBIT_SECRET_KEY=your_secret_key_here
BYBIT_TESTNET=falseOr pass credentials inline in the MCP config:
{
"mcpServers": {
"bybit-mcp": {
"command": "uv",
"args": [
"--directory", "/path/to/bybit-mcp", "run", "bybit.py",
"--bybit-api-key", "YOUR_API_KEY",
"--bybit-secret-key", "YOUR_SECRET_KEY"
]
}
}
}π‘ No API key? No problem! All 23 market data tools work without authentication.
π Security Note: Never commit your
.envfile. It's already in.gitignore.
uv run bybit.py # STDIO (default)
uv run bybit.py --transport sse --port 8000 # SSE
uv run bybit.py --transport streamable-http --port 8000 # Streamable HTTP"What's the current price of BTC?"
"Buy 0.01 BTC at market price on spot"
"Show me the funding rate history for ETHUSDT over the last 24 hours"
"What are my open positions? Set a stop loss at 95000 for my BTCUSDT long"
"Show my unified account balance and all open orders"
| Module | Tools | Description |
|---|---|---|
| Market | 23 | Prices, klines, orderbook, funding rates, open interest, tickers (no API key needed) |
| Trade | 15 | Market/limit orders, amend, cancel, batch operations, DCP |
| Account | 25 | Balance, fee rates, margin mode, collateral, MMP, transaction log |
| Position | 11 | Positions, leverage, TP/SL, auto-margin, move positions |
| Asset | 41 | Deposits, withdrawals, transfers, convert, fiat, address management |
| Lending | 39 | Crypto loans β legacy + new (fixed & flexible) |
| User | 15 | Sub-accounts, API key management, affiliate |
| RFQ | 15 | Block trading β create/cancel RFQ, quotes, executions |
| Spot Margin | 12 | Spot margin trading, borrow, repay, collateral |
| Spread | 11 | Spread instruments, orderbook, trading |
| Broker | 10 | Broker earnings, rate limits, vouchers |
| OTC | 7 | Institutional OTC lending |
| Pre-Upgrade | 6 | Pre-upgrade historical data queries |
| Earn | 6 | Staking, redemption, yield tracking |
| Leveraged Token | 5 | Leveraged token subscribe/redeem |
| Announcement | 2 | Exchange announcements, system status |
| Strategy | 2 | Built-in arbitrage pair detection |
Total: 246 tools
π View all tool names
uv run python -c "
import src.tools
from src import mcp
for name in sorted(mcp._tool_manager._tools):
print(name)
"bybit-mcp/
βββ bybit.py # Entry point (backward compatible)
βββ src/
β βββ __init__.py # Shared FastMCP instance
β βββ main.py # CLI: dotenv + argparse + logging + mcp.run()
β βββ client.py # Config singleton + HMAC signing + HTTP methods
β βββ tools/
β βββ __init__.py # Auto-imports all tool modules
β βββ market.py # 23 tools β public market data
β βββ trade.py # 15 tools β order management
β βββ account.py # 25 tools β account operations
β βββ position.py # 11 tools β position management
β βββ asset.py # 41 tools β wallet & transfers
β βββ lending.py # 39 tools β crypto loans
β βββ earn.py # 6 tools β staking & yield
β βββ leveraged_token.py # 5 tools β leveraged tokens
β βββ spot_margin.py # 12 tools β spot margin
β βββ user.py # 15 tools β sub-accounts & API keys
β βββ broker.py # 10 tools β broker services
β βββ otc.py # 7 tools β OTC lending
β βββ spread.py # 11 tools β spread trading
β βββ rfq.py # 15 tools β block trading RFQ
β βββ pre_upgrade.py # 6 tools β pre-upgrade data
β βββ announcement.py # 2 tools β announcements
β βββ strategy.py # 2 tools β arbitrage strategies
βββ .env.example # Environment variable template
βββ pyproject.toml # Project config & dependencies
βββ LICENSE # MIT License
If you've configured the server but /mcp shows no tools or "No MCP servers configured":
Claude Code reads MCP server config from ~/.claude.json (per-project), not from ~/.claude/settings.json. The recommended way to add the server is via CLI:
claude mcp add bybit-mcp -- uv --directory /path/to/bybit-mcp run bybit.pyThis writes the config to the correct location. If you manually edited ~/.claude/settings.json, the server won't be found.
Claude Code spawns MCP server subprocesses without loading your shell profile (.zshrc / .zprofile), so PATH may not include ~/.local/bin. Use the absolute path:
# Find your uv path
which uv
# Example output: /Users/yourname/.local/bin/uv
# Add with full path
claude mcp add bybit-mcp -- /Users/yourname/.local/bin/uv --directory /path/to/bybit-mcp run bybit.pyMCP servers connect at session startup. After adding or changing config, you must exit and restart Claude Code for changes to take effect.
Test that the server can start and respond to MCP protocol:
# Test import
uv run python -c "from src.main import main; print('Import OK')"
# Test MCP initialize handshake
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"0.1"}}}' | uv run bybit.pyIf the import fails, run uv sync to install dependencies.
Claude Code manages the MCP server process itself via stdio. A manually started server instance is completely separate β Claude Code won't connect to it. Let Claude Code handle the lifecycle automatically.
| Symptom | Cause | Fix |
|---|---|---|
/mcp shows "No MCP servers configured" |
Config in wrong file (settings.json instead of .claude.json) |
Use claude mcp add CLI command |
| Config exists but tools don't load | uv not found (PATH issue) |
Use absolute path to uv |
| Tools loaded before but not now | Session not restarted after config change | Restart Claude Code |
| Server works manually but not in Claude Code | Manual server is a separate process | Don't start manually; let Claude Code manage it |
| Import errors on startup | Dependencies not installed | Run uv sync |
This software is provided for educational and informational purposes only.
- Not Financial Advice β This tool does not provide financial, investment, or trading advice
- Use at Your Own Risk β Cryptocurrency trading involves substantial risk of loss
- API Security β Protect your API credentials; use IP restrictions and disable withdrawal permissions
- Test First β Always test on Bybit Testnet before using real funds (
--testnetflag) - No Warranty β The software is provided "as is" without warranty of any kind
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Add your tool function in the appropriate
src/tools/*.pymodule - Decorate with
@mcp.tool() - Use
_public_getfor unauthenticated or_signed_get/_signed_postfor authenticated endpoints - That's it β tools are auto-registered on import
| Resource | Description |
|---|---|
| Bybit V5 API Docs | Official Bybit API documentation |
| Bybit Testnet | Practice trading with test funds |
| MCP Specification | Model Context Protocol spec |
| uv Package Manager | Fast Python package manager |
This project is licensed under the MIT License β see the LICENSE file for details.
Built with β€οΈ for the Bybit trading community