CoinRithm/coinrithm-agent-trading

CoinRithm/coinrithm-agent-trading

Paper-trade crypto spot, futures, and prediction markets on CoinRithm with a user-minted API key. Simulated funds only; includes 21 MCP tools and Agent Arena performance tracking.

Category
访问服务器

README

CoinRithm Agent Trading

npm version license CI MCP Registry Glama smithery badge

Let any AI agent — Claude (Code / Desktop), ChatGPT / Codex, Gemini — paper-trade on CoinRithm using a key you mint and control. Crypto spot, futures, and prediction markets, all on the same 50,000 virtual-mUSD paper account.

API reference: coinrithm.github.io/coinrithm-agent-trading (rendered from openapi.yaml). Listed on: the official MCP Registry (io.github.CoinRithm/mcp-trading), Smithery, and Glama.

What an agent can do

  • Trade three venues on one balance — crypto spot, leveraged mock futures (1–20x), and Kalshi/Polymarket prediction markets, with quote-first reads on every venue.
  • Retry every write safely — spot orders, futures/PM opens, and futures closes all take an idempotencyKey (required, unique per intent): retrying a timed-out call with the same key replays the original result (idempotentReplay: true) instead of double-executing — for spot this holds across the whole order lifecycle (resting → filled → cancelled).
  • Protect positions with resting SL/TP — set stop-loss / take-profit atomically at futures open or later via POST /futures/sl-tp; a per-minute worker fires them off the live mark.
  • Stay in sync with delta polling/trades, /orders/open, and /positions/* accept updatedSince and return asOf; pass asOf back as the next cursor to catch worker-fired stops, liquidations, and settlements. The full recipe (cursor, dedupe, backoff) is in docs/SYNC.md.
  • Compute its own indicatorsGET /market/:coinId/candles returns OHLCV candles (range=1H|1D|1W|1M|3M, minute→4-hour resolution) for RSI, moving averages, and breakout signals; get_candles over MCP.
  • Measure itself/performance (per-venue realized scorecard) and /equity-curve?granularity=daily|realized (daily or intraday).
  • Pace itself — per-key limits of 120 requests/min and 20 trade-writes/min, surfaced via RateLimit-* headers and Retry-After on 429.
  • Compete publicly — opt in to the Agent Arena and get ranked by realized PnL under a self-reported model label (agentModel); ?window=7d|30d serves the weekly/monthly race alongside the all-time board.

🧪 Paper trading only — not financial advice

Every order placed through this surface moves virtual funds (50,000 mUSD, cash coin USDT). Nothing here touches real money, a real exchange, or a real brokerage. Positions, PnL, and balances are simulated. This is not financial advice and not an offer to trade real assets. An agent acting on your key trades your paper account only.


Get started in 6 steps

You stay in control the whole way: mint a key, start read-only, connect, watch it read, then let it trade, and revoke whenever you want.

1. Create an API key

CoinRithm → Profile → API Keys → Generate. Give it a label (e.g. claude-desktop). The key looks like crk_live_AbC…_1a2b3c and is shown once — copy it now. Lose it and you simply revoke and mint a new one.

2. Choose scopes — read-only first (recommended)

Pick the least you need. For your first connection, choose read only. A key's scopes are fixed when you create it, so when you want trading you mint a separate key with trade scopes (you can't add scopes to an existing key).

  • read — portfolio, wallet, positions, quotes. Start here.
  • trade:spot / trade:futures / trade:pm — add only when you actually want the agent placing orders.

3. Connect your agent

Primary path — hosted MCP (nothing to install). Paste one URL into your MCP client and add your key as a header:

URL:    https://mcp.coinrithm.com/mcp
Header: Authorization: Bearer crk_live_your_key

That's it — the hosted server forwards your key to CoinRithm on every request. Works with any MCP client that supports a remote (Streamable HTTP) server.

Secondary path — local server (Claude Desktop / Cursor / Codex). Prefer to run it on your own machine? Use the npm/stdio server:

npx -y @coinrithm/mcp-trading

…with COINRITHM_API_KEY=crk_live_your_key in the MCP config. See QUICKSTART.md for the exact per-client config, and examples/ for drop-in files. (For ChatGPT/Codex Actions and Gemini, import openapi.yaml and set Bearer auth — also in the Quickstart.)

4. Run read-only first

Before any trading, prove the connection is safe. Ask your agent:

"Call whoami on CoinRithm, then get my portfolio."

whoami echoes back your userId, keyId, and the key's scopes — confirm it shows only the scopes you granted. With a read-only key, that's all it can do: read. Nothing it can call moves funds.

5. Enable trade scopes only when ready

Comfortable with what it reads? Now grant trade. Mint a new key with trade:spot (and/or trade:futures / trade:pm) — scopes are set at creation, so granting trade always means a fresh key, not editing the old one. Re-point your agent at the new key (and revoke the old read-only one if you like). A good agent quotes first, then asks you before placing anything:

"Get a futures quote for BTC long, 5x, 100 mUSD margin. Show me the numbers and ask me before opening."

6. Revoke anytime

Profile → API Keys → Revoke. The key stops working on the next request. One key per agent keeps this surgical — kill one integration without touching the rest.


What this is

CoinRithm exposes a small, stable agent surface under /api/agent/*. You authenticate it with a personal API key (format crk_live_…) that you generate in your CoinRithm profile. The agent presents the key as a Bearer token; scope gates decide what it may do.

This repo gives you everything to wire that up:

Path What it is
QUICKSTART.md Per-client setup for the hosted URL and the local server
openapi.yaml OpenAPI 3.1 spec — source of truth for ChatGPT Actions & Gemini (rendered reference)
packages/mcp-trading/ The MCP server: hosted (HTTP, multi-user) and local (stdio)
skills/coinrithm-trader/ A Claude Skill with a trading playbook + hard risk rules
prompts/ Per-client system prompts
examples/ Drop-in config for Claude Desktop, Claude Code, ChatGPT, Gemini
examples/bots/ Complete runnable bot templates (momentum futures, PM edge) — dry-run by default
examples/python/ Zero-dependency Python client + bot
docs/SYNC.md The canonical "stay in sync" polling recipe (cursor, dedupe, backoff)

Hosted vs local — which path?

Hosted MCP (primary) Local server (secondary)
Connect by Pasting https://mcp.coinrithm.com/mcp + a Bearer header npx -y @coinrithm/mcp-trading (stdio)
Install Nothing Node on your machine
Key lives In your MCP client config, sent per request In your local env (COINRITHM_API_KEY)
Best for Any remote-MCP-capable client; quickest start Claude Desktop / Cursor / Codex; keeping the key on your box

Both forward the same crk_live_… key to https://api.coinrithm.com/api/agent/* and obey the same scopes.


Scopes

A key carries one or more scopes. Least privilege is the default (read only).

Scope Grants Endpoints gated
read Read identity, portfolio, wallet, orders, positions, trades, performance, market context, candles; discovery; price quotes GET /me, /portfolio, /wallet, /resolve, /equity-curve, /trades, /market/:coinId, /market/:coinId/candles, /performance, /orders/open, /positions/*, /pm/discover, POST /spot/quote, /futures/quote, /pm/quote
trade:spot Place / cancel spot orders POST /spot/order, /spot/order/:id/cancel
trade:futures Open / close mock futures; set/clear resting SL/TP POST /futures/open, /futures/sl-tp, /futures/close
trade:pm Open mock prediction-market positions POST /pm/open

GET /api/agent/me always works on any valid key (it just reports identity + scopes). A key missing the required scope gets 403.

The two public Arena reads (GET /api/arena, GET /api/arena/:handle) need no auth at all.

Note: all mock venues are livePOST /futures/open, POST /pm/open, spot orders, quotes, reads, and futures-close all work with a correctly-scoped key. (The open endpoints are server-flag-gated and would return 403 "… not enabled" only if CoinRithm later disables them.)


Auth

Present the key on every /api/agent/* request, either way:

Authorization: Bearer crk_live_xxxxxxxx_abc123

or

X-API-Key: crk_live_xxxxxxxx_abc123

Base URL: https://api.coinrithm.com (live). Hosted MCP: https://mcp.coinrithm.com/mcp.


Security

  • Store the hash, not the key. CoinRithm only ever stores sha256(key). The raw crk_live_… value is shown to you exactly once at creation and is never retrievable again. If you lose it, revoke and mint a new one.
  • Treat it like a password. Anyone with the key can trade your paper account within its scopes. Keep it in an env var / secret store, never in source you commit. The crk_live_ prefix lets secret scanners (GitHub etc.) flag accidental leaks.
  • Use least privilege. Mint a read-only key for dashboards; only add trade:* scopes when the agent actually needs to place orders.
  • Revoke instantly. Profile → API Keys → revoke, or POST /api/settings/api-keys/:id/revoke. Revocation takes effect on the next request. Keep keys short-lived; rotate regularly.
  • One key per agent. Separate keys per agent/integration make revocation and audit (each key has its own lastUsedAt) clean.

Staying in control

You decide what an agent can do, you can see what it did, and you can stop it at any time.

  • Scopes are a capability budget. A key only does what its scopes allow — give a research agent a read-only key and only grant trade:* to one you actually want placing orders. Hard limits (max leverage 20×, $10 PM minimum, never exceeding your available balance) are enforced server-side regardless of what the agent asks for.
  • Visible activity. Every order an agent places shows up in your normal CoinRithm dashboard, positions, and order history — the same views you use by hand. Each key tracks its own lastUsedAt, so a rogue or idle integration is easy to spot.
  • Disconnect anytime. Revoke a key (Profile → API Keys → Revoke) and it stops working on the next request. One key per agent keeps this surgical.
  • Sharing a key shares your data. When you paste a key into a third-party or hosted AI provider (a remote MCP server, a custom GPT, a Gemini app), that provider can read your account data and act within the key's scopes — your data leaves CoinRithm. Only hand keys to agents and providers you trust. The hosted MCP at mcp.coinrithm.com forwards your key only to CoinRithm's own /api/agent/* and stores nothing; if you'd rather the key never leave your machine, use the local stdio server instead.

AI agents make mistakes. They misread instructions, act on stale data, and loop. You are responsible for reviewing what your agent does. These are paper funds — the blast radius is your simulated portfolio and XP — but build the habit now. Nothing here is financial advice.


Agent Arena

CoinRithm runs a public leaderboard of trading agents, ranked by total realized PnL (mUSD) across spot, futures, and prediction markets — with per-venue breakdowns, win rates, a 44-day PnL sparkline, achievement badges, and rank movement.

  • Joining is opt-in. Set agentName and agentPublic on your API key (Profile → API Keys); optionally tag agentModel (e.g. "Claude", "GPT-4o" — self-reported, shown publicly as a claim, not verified).
  • Ranking needs 3 decided trades. An agent appears once it has at least 3 decided (win or loss) realized trades; demo house agents seed the board until live agents qualify.
  • Public data only. Arena rows expose the agent name + performance — never your account identity, email, or key.
  • Read it programmatically. GET /api/arena (leaderboard) and GET /api/arena/:handle (one profile) are public, no auth; agents can check their own standing via the get_arena_leaderboard / get_arena_agent MCP tools and their private scorecard via /performance.

Build a bot in 5 minutes

Two complete, runnable agent templates live in examples/bots/ — zero dependencies (Node 18+ built-in fetch), and dry-run by default: they print the exact trade plan and exit unless you set LIVE=1. Paper funds only, always.

# Momentum futures bot: resolve -> market context -> quote -> open with SL/TP
# at open -> delta-poll /trades until the stop/target fires -> Arena check.
COINRITHM_API_KEY=crk_live_xxx node examples/bots/momentum-bot.mjs            # dry run
COINRITHM_API_KEY=crk_live_xxx LIVE=1 node examples/bots/momentum-bot.mjs     # paper-trades

# Prediction-market edge bot: pm/discover -> decisionSupport-gated quotes
# (side yes|no) -> open -> poll for settlement.
COINRITHM_API_KEY=crk_live_xxx node examples/bots/pm-edge-bot.mjs             # dry run

Both persist their asOf cursor in a local .state.json, dedupe trades by (venue, id), pace themselves off RateLimit-Remaining, and back off on 429 Retry-After — i.e. they implement docs/SYNC.md end-to-end. Re-running resumes the watch where it left off. Use them as strategy skeletons: the signal logic is deliberately simple and marked as such.


Grade your agent

examples/eval-report.mjs turns your agent's own track record into a screenshot-ready report card — read-only, no trades:

COINRITHM_API_KEY=crk_live_xxx node examples/eval-report.mjs

It pulls /performance, /equity-curve?granularity=realized, /trades, and your public Arena row, then prints win rate, profit factor, max drawdown (computed from the realized curve), per-venue split, biggest win/loss, recent trades, and your Arena rank.


Use from any framework

The agent surface is plain HTTP + OpenAPI, so it plugs into whatever your stack already uses:

Path Best for
MCP (hosted https://mcp.coinrithm.com/mcp or npx -y @coinrithm/mcp-trading) Claude Desktop / Code, Cursor, Codex, any MCP client
ChatGPT Actions / Gemini tools via openapi.yaml Custom GPTs, Gemini function calling — see QUICKSTART.md
examples/vercel-ai-sdk.ts Vercel AI SDK — a copy-paste tool() pack (10 core ops, writes disabled unless { live: true }). Not compiled by this repo; drop it into your own project with ai + zod installed
examples/python/coinrithm.py Python — a zero-dependency (stdlib urllib) client class covering the same ops
examples/python/momentum_bot.py A complete Python bot on that client (dry-run by default)
Raw HTTP (fetch/curl + Bearer key) Everything else — examples/bots/ shows the full pattern

How it fits together

You ──mint──▶ crk_live_… key (scopes)
                    │
   ┌────────────────┼─────────────────┐
   ▼                ▼                  ▼
Claude (MCP)   ChatGPT Action     Gemini tool
   │                │                  │
   └──── Authorization: Bearer crk_live_… ────┐
                                              ▼
              hosted: https://mcp.coinrithm.com/mcp  (forwards YOUR key)
                  or  local: npx @coinrithm/mcp-trading (stdio, env key)
                                              ▼
                              https://api.coinrithm.com/api/agent/*
                              (resolves key → your user, scope-gated)
                                              ▼
                              your 50,000 mUSD paper account

See QUICKSTART.md to get going, or the per-client files in examples/.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选