Gainium
Read and manage Gainium DCA/Combo/Grid bots, deals, balances, backtests, the crypto screener, and curated strategy presets via MCP.
README
gainium-mcp
An MCP (Model Context Protocol) server for Gainium — the crypto trading bot platform. Lets AI assistants manage your bots, deals, balances, and more through a standard MCP interface.
Detailed setup and connection documentation is available in docs/using-gainium-mcp.md.
Quick Start
1. Get your API keys
Go to Gainium API Settings and create an API key pair.
2. Add to your MCP client
Add this to your MCP configuration (VS Code, Claude Desktop, etc.):
{
"gainium-mcp": {
"command": "npx",
"args": ["-y", "gainium-mcp"],
"env": {
"GAINIUM_API_KEY": "<your-api-key>",
"GAINIUM_API_SECRET": "<your-api-secret>"
}
}
}
That's it. The server starts automatically when your AI assistant needs it.
This local stdio mode uses GAINIUM_API_KEY and GAINIUM_API_SECRET from the server process environment.
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
GAINIUM_API_KEY |
Yes | — | Your Gainium API public key |
GAINIUM_API_SECRET |
Yes | — | Your Gainium API secret |
GAINIUM_API_BASE_URL |
No | https://api.gainium.io |
API base URL |
GAINIUM_MCP_TRANSPORT |
No | stdio |
Transport mode: stdio, http, streamable-http, sse, or http-sse |
GAINIUM_MCP_HOST |
No | 127.0.0.1 |
Bind host for HTTP mode |
GAINIUM_MCP_PORT |
No | 3000 |
Bind port for HTTP mode |
GAINIUM_MCP_HTTP_PATH |
No | /mcp |
Streamable HTTP endpoint path |
GAINIUM_MCP_SSE_PATH |
No | /sse |
Deprecated SSE GET endpoint path |
GAINIUM_MCP_MESSAGES_PATH |
No | /messages |
Deprecated SSE POST endpoint path |
GAINIUM_OAUTH_ISSUER |
No | — | Authorization-server base URL. Setting this (with MCP_INTROSPECTION_SECRET, in HTTP mode) enables OAuth protected-resource mode |
GAINIUM_INTROSPECTION_URL |
No | <issuer>/oauth/introspect |
Token introspection endpoint |
MCP_INTROSPECTION_SECRET |
No | — | Shared secret presented to the introspection endpoint (must match the auth server) |
GAINIUM_MCP_PUBLIC_URL |
No | derived from request | Public base URL used in the protected-resource metadata |
OPENAI_APPS_CHALLENGE_TOKEN |
No | — | When set, served as plain text at /.well-known/openai-apps-challenge for OpenAI Apps domain verification |
Authentication Modes
gainium-mcp supports three deployment models:
- Local stdio mode: the MCP server reads
GAINIUM_API_KEYandGAINIUM_API_SECRETfrom env vars. - OAuth 2.1 hosted mode (recommended for hosted/public): the server acts as an OAuth protected resource. Clients (e.g. the Claude connector) obtain an access token from the Gainium authorization server and send it as
Authorization: Bearer <token>. See OAuth 2.1 hosted mode below. - Header hosted mode (legacy/self-hosted): each request sends
X-API-KeyandX-API-Secretheaders so one shared server can serve many users.
In header/stdio mode, request headers take priority, falling back to GAINIUM_API_KEY / GAINIUM_API_SECRET. When OAuth mode is enabled, the Bearer token is required and the X-API-Key/X-API-Secret headers are ignored.
OAuth 2.1 hosted mode
This is the mode used for the public https://mcp.gainium.io/mcp endpoint and the Anthropic Claude connector directory (which requires OAuth and forbids API-key headers).
Enable it by setting, in HTTP mode:
export GAINIUM_MCP_TRANSPORT=http
export GAINIUM_OAUTH_ISSUER=https://app.gainium.io # Gainium authorization server
export MCP_INTROSPECTION_SECRET=<shared-secret> # must match the auth server
export GAINIUM_MCP_PUBLIC_URL=https://mcp.gainium.io # this server's public URL
# optional, defaults to <issuer>/oauth/introspect:
# export GAINIUM_INTROSPECTION_URL=https://app.gainium.io/oauth/introspect
node dist/server.js
When enabled, the server:
- Serves OAuth Protected Resource Metadata (RFC 9728) at
/.well-known/oauth-protected-resourceand/.well-known/oauth-protected-resource/mcp, advertising the authorization server. - Rejects unauthenticated MCP requests with
401 Unauthorizedand aWWW-Authenticate: Bearer resource_metadata="…"header, so clients can discover the auth server and run the OAuth flow (Dynamic Client Registration + PKCE). - Validates the Bearer access token on each request via the auth server's
token introspection endpoint, resolving it to the user's Gainium
(apiKey, apiSecret)and per-key restrictions (read/write, paper-only, single-bot), which are still enforced server-side. Introspection results are cached briefly.
The local stdio path is unaffected by these variables.
HTTP and SSE Mode
By default, gainium-mcp runs over stdio for MCP clients that spawn local processes. To run it as an HTTP server instead:
export GAINIUM_MCP_TRANSPORT=http
export GAINIUM_MCP_HOST=127.0.0.1
export GAINIUM_MCP_PORT=3000
node dist/server.js
When HTTP mode is enabled, the server exposes both transport styles:
GET|POST|DELETE /mcpfor the current Streamable HTTP transportGET /sseplusPOST /messages?sessionId=...for deprecated HTTP+SSE clients
This makes one server process compatible with both modern MCP HTTP clients and older SSE-based integrations. In hosted mode, authenticate with OAuth (see OAuth 2.1 hosted mode) or, for self-hosted/legacy setups, send X-API-Key and X-API-Secret on each request.
Available Tools (17)
As of v3.0.0 the toolset is consolidated: a single tool per operation, with a
botType / dealType / action discriminator instead of one tool per variant.
Every tool carries an MCP safety annotation — read-only tools set readOnlyHint,
write tools set destructiveHint.
Bots
| Tool | Access | Description |
|---|---|---|
list_bots |
read | List bots by type (dca, combo, grid) with filters and field selection |
get_bot |
read | Get a single bot by id and type |
create_bot |
write | Create a bot (dca, combo, or grid) |
update_bot |
write | Update bot settings |
clone_bot |
write | Clone a bot with optional overrides |
manage_bot |
write | Lifecycle action: start, stop, archive, restore, changePairs |
Deals
| Tool | Access | Description |
|---|---|---|
list_deals |
read | List deals by type (dca, combo, terminal) with filters |
get_deal |
read | Get a single deal by id and type |
create_deal |
write | Create a deal |
update_deal |
write | Update an active deal |
manage_deal |
write | Deal action: close, addFunds, reduceFunds |
Backtest
| Tool | Access | Description |
|---|---|---|
run_backtest |
write | Run a backtest: validate, estimate, async, or sync (request/requestSync submit a job — not read-only) |
backtest_info |
read | List backtest requests or get one by ID |
Discovery, Account & Market
| Tool | Access | Description |
|---|---|---|
discover |
read | Schema discovery for bot types and indicators |
get_account |
read | Balances, connected exchanges, supported exchanges, and global variables |
get_screener |
read | Cryptocurrency screener with market metrics |
manage_global_variable |
write | Global variable action: create, update, delete |
Field Selection
All GET endpoints support the fields parameter for efficient payloads:
- Presets:
minimal,standard(default),extended,full - Custom: comma-separated dot-notation fields (e.g.
_id,uuid,settings.name,profit.total)
Using minimal reduces payload size by ~85%.
API Permissions
- Read-only key: read tools only (
list_*,get_*,discover,backtest_info,get_screener,list_presets) - Write key: all tools, including
create_*,update_*,clone_bot,manage_bot,manage_deal,manage_global_variable,apply_preset, andrun_backtest - Read-only directory connector (
/mcpwithGAINIUM_READONLY=true, served atmcp.gainium.io/read): exposes and allows only the 9readOnlyHinttools —run_backtestand all write tools are excluded - Token audience binding (OAuth mode): when
GAINIUM_MCP_PUBLIC_URLis set, the server treats<public-url><http-path>as its RFC 8707 resource. An access token whose introspectedaudis a different resource is rejected — a token minted formcp.gainium.io/readcan't be replayed againstmcp.gainium.io/mcp, and vice versa. Tokens with noaud(legacy grants) are still accepted.
Development
# Clone and install
git clone https://github.com/gainium/gainium-mcp.git
cd gainium-mcp
npm install
# Build
npm run build
# Run locally (for testing)
export GAINIUM_API_KEY=your_key
export GAINIUM_API_SECRET=your_secret
node dist/server.js
# Run in HTTP/SSE mode
export GAINIUM_MCP_TRANSPORT=http
export GAINIUM_MCP_PORT=3000
node dist/server.js
Architecture
gainium-mcp/
├── src/
│ ├── server.ts # MCP server + tool definitions (stdio + HTTP/SSE transports)
│ └── gainium-client.ts # HMAC-authenticated HTTP client for Gainium API v2
├── dist/ # Compiled output (published to npm)
├── package.json
├── tsconfig.json
└── README.md
License
MIT
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。