gainium-mcp
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
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.):
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 | /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_KEY and GAINIUM_API_SECRET from 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 . See OAuth 2.1 hosted mode below.
- **Header hosted mode (legacy/self-hosted):** each request sends X-API-Key and X-API-Secret headers 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:
When enabled, the server:
1. Serves **OAuth Protected Resource Metadata** (RFC 9728) at
/.well-known/oauth-protected-resource and /.well-known/oauth-protected-resource/mcp,
advertising the authorization server.
2. Rejects unauthenticated MCP requests with **401 Unauthorized** and a
WWW-Authenticate: Bearer resource_metadata="…" header, so clients can discover