Coinbase MCP Server

Coinbase MCP Server

Provides tools for interacting with the Coinbase Advanced Trading API, enabling autonomous crypto trading via a Claude skill.

Category
访问服务器

README

Coinbase MCP Server

A Model Context Protocol (MCP) server that provides tools for interacting with the Coinbase Advanced Trading API. This repository includes both the MCP server and a Claude Skill for fully autonomous crypto trading.

With this project, AI assistants like Claude can not only check account balances, place trades, and view market data, but also execute automated trading strategies end-to-end via the included autonomous trading agent (/trade Skill).


⚠️ WARNING: REAL MONEY TRADING ⚠️

This MCP server and the included Autonomous Trading Bot will execute real trades on your Coinbase account if you use them with valid API keys. Your actual funds can be bought, sold, or lost automatically.

Never use this software with funds you cannot afford to lose.

  • Always test with dry-run mode first.
  • Use read-only or test API keys for development.
  • Automated trading is risky and can result in significant financial loss.

Getting Started

Get from zero to running /trade 10 EUR from BTC in 5 minutes.

1. Get Coinbase API Credentials

  1. Go to Coinbase Developer Platform
  2. Create a new project or select an existing one
  3. Navigate to API KeysCreate API Key
  4. Select Trading permissions (read and trade)
  5. Download your credentials:
    • API Key Name: organizations/xxx/apiKeys/yyy
    • Private Key: PEM format (starts with -----BEGIN EC PRIVATE KEY-----)

Warning: Save your private key immediately. You won't be able to retrieve it again.

2. Clone and Setup

git clone https://github.com/visusnet/coinbase-mcp-server
cd coinbase-mcp-server
npm install

3. Create .env File

Copy the example and fill in your credentials:

cp .env.example .env

Edit .env:

COINBASE_API_KEY_NAME=organizations/your-org/apiKeys/your-key-id
COINBASE_PRIVATE_KEY="-----BEGIN EC PRIVATE KEY-----
MHcCAQEEI...your-key-here...
-----END EC PRIVATE KEY-----"

4. Start the Server

npm run build
npm start

You should see: Coinbase MCP Server running on http://localhost:3005/mcp

5. Open Claude Code

claude

The MCP server is automatically configured (via .claude/settings.json in this repo).

6. Start Trading

/trade 10 EUR from BTC dry-run

That's it! The trading agent will analyze the market and show you what trades it would make.

Remove dry-run to execute real trades.

Alternative: Use with npx (without cloning)

If you just want to use the MCP server without the /trade skill or development setup:

1. Install and Run

npx coinbase-mcp-server

2. Set Environment Variables

The server requires Coinbase API credentials. Create a .env file in your current directory:

COINBASE_API_KEY_NAME=organizations/your-org/apiKeys/your-key-id
COINBASE_PRIVATE_KEY="-----BEGIN EC PRIVATE KEY-----
...your-key...
-----END EC PRIVATE KEY-----"
PORT=3005

Or export them in your shell:

export COINBASE_API_KEY_NAME="organizations/your-org/apiKeys/your-key-id"
export COINBASE_PRIVATE_KEY="-----BEGIN EC PRIVATE KEY-----
...your-key...
-----END EC PRIVATE KEY-----"
export PORT=3005

Then start the server:

npx coinbase-mcp-server

3. Configure Claude

Add the MCP server to your Claude settings (e.g., ~/.claude/settings.json):

{
  "mcpServers": {
    "coinbase": {
      "url": "http://localhost:3005/mcp"
    }
  }
}

Now you can use all 74 tools (46 Coinbase API + 24 indicators + 2 analysis + 1 event + 1 market intelligence) and the /coinbase:assist prompt in Claude, but without the autonomous /trade skill.

Features

74 Tools: Trading, Indicators & Analysis

Full access to the Coinbase Advanced Trading API plus a fully autonomous trading skill for Claude:

  • Accounts: List accounts, get balances
  • Orders: Create, edit, cancel, preview orders
  • Products: List trading pairs, get candles (including batch for up to 10 products), order books, market trades, market snapshots
  • Portfolios: Create, manage, move funds between portfolios
  • Converts: Currency conversion quotes and execution
  • Futures & Perpetuals: Position management
  • Public Data: No-auth endpoints for market data
  • Autonomous Trading Agent (Skill): Automates technical/sentiment analysis and trading decisions via /trade command in Claude
  • TOON Output Format: All tools support optional compact format (~35% fewer tokens for list operations)

For a complete list of all trading skill features, see SKILL_FEATURES.md.

Trading Assistant Prompt (/coinbase:assist)

A built-in prompt that provides comprehensive guidance for trading on Coinbase:

/coinbase:assist

What it provides:

  • Complete overview of all available tools and capabilities
  • Trading best practices and safety guidelines
  • Fee considerations and market context
  • Recommended workflow for order creation (always preview first)

Autonomous Trading Agent (/trade)

A built-in Claude command that runs an autonomous trading bot:

/trade 10 EUR from BTC
/trade 5 EUR dry-run

What it does:

  • Technical analysis: 24 indicators across 6 weighted categories (Momentum 25%, Trend 30%, Volatility 15%, Volume 15%, S/R 10%, Patterns 5%)
  • Sentiment analysis (Fear & Greed Index with 7 regions, news search)
  • Automatic order execution with preview
  • Dynamic ATR-based stop-loss/take-profit
  • Attached bracket orders (crash-proof TP/SL via Coinbase API)
  • Trailing stop (locks in profits)
  • Liquidity check before altcoin entries (spread >0.5%: skip, 0.2-0.5%: reduce to 50%)
  • HODL Safe portfolio isolation (protects user holdings via separate portfolio)
  • Profit protection (configurable % of gains auto-moved to HODL Safe)
  • Event-driven market monitoring (price, volume & indicator conditions)
  • Opportunity rebalancing (exit stagnant positions)
  • Continuous loop until you stop it

For a complete list of all trading features, see SKILL_FEATURES.md.

Configuration:

Setting Default Customizable
Strategy Aggressive No
Take-Profit ATR-based (min 2.5%) Via ATR
Stop-Loss ATR-based (2.5-10%) Via ATR
Trailing Stop 1.5% trail after +3%, min lock-in 1.0% No
Check Interval 15 minutes Yes (interval=5m)
Profit Protection 50% of profits moved to HODL Safe Yes (choose at session start: 0%, 50%, 100%, or custom)
Rebalancing After 12h if <3% move, delta >40, max loss -2%, cooldown 4h, max 3/day Yes (no-rebalance, rebalance-delta=50, rebalance-max=2)
Pairs All SPOT pairs (USD, EUR, USDT) No

Stop the agent: Press Ctrl+C


Usage Examples

Natural Language

Just ask Claude:

"What are my account balances?"
"Show me the current BTC-EUR price"
"Buy 0.001 BTC at market price"
"Get the last 24 hours of ETH-EUR candles"

Trading Agent

# Dry run (no real trades)
/trade 10 EUR from BTC dry-run

# Real trading with 10 EUR from your BTC
/trade 10 EUR from BTC

# Trade with EUR balance directly
/trade 5 EUR

# Custom interval (check every 5 minutes)
/trade 10 EUR from BTC interval=5m

# Fast trading (every 60 seconds, dry-run)
/trade 5 EUR interval=60s dry-run

# Continue previous session
/trade continue where you left off

Development

Project Structure

coinbase-mcp-server/
├── src/
│   ├── index.ts                 # HTTP server entry point
│   └── server/
│       └── CoinbaseMcpServer.ts # MCP server with 74 tools
├── .claude/
│   ├── settings.json            # MCP server config (auto-loaded)
│   └── commands/
│       └── trade.md             # /trade command definition
├── .env.example                 # Environment template
└── package.json

Scripts

npm start          # Start production server
npm run start:dev  # Start with hot-reload
npm test           # Run tests
npm run lint       # Check code style
npm run build      # Build for production
npm run inspect    # Open MCP Inspector for debugging

Testing with MCP Inspector

Interactive UI

  1. Start the server: npm run start:dev
  2. In another terminal: npm run inspect
  3. Connect to http://localhost:3005/mcp
  4. Test any of the 74 tools interactively

CLI

Use the MCP Inspector CLI to call tools directly without the browser UI:

# List all accounts
npx @modelcontextprotocol/inspector --cli node dist/index.js --stdio \
  --method tools/call \
  --tool-name list_accounts

# Get a specific product
npx @modelcontextprotocol/inspector --cli node dist/index.js --stdio \
  --method tools/call \
  --tool-name get_product \
  --tool-arg productId=BTC-EUR

The --stdio flag tells the server to use stdio transport instead of HTTP, which the inspector CLI requires.


Security

  1. Never commit .env - It's in .gitignore
  2. Use read-only keys for testing - Create separate keys with minimal permissions
  3. Rotate keys regularly
  4. Monitor API usage - Check your Coinbase account for unexpected activity

API Rate Limits

  • Public endpoints: 10 requests/second
  • Private endpoints: 15 requests/second

Troubleshooting

Problem Solution
"Authentication failed" Check API key and private key format (PEM with newlines)
"Server not responding" Ensure npm start is running, check .env
"/trade not found" Restart Claude Code to reload commands
Tools not showing Verify .claude/settings.json exists, restart Claude

Resources

Disclaimer

This software is for educational purposes. Cryptocurrency trading involves significant risk. The autonomous trading agent can and will lose money.

  • Start with small amounts
  • Use dry-run mode first
  • Monitor the agent's decisions
  • Never invest more than you can afford to lose

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选