safetrade-mcp
Docs-driven MCP server for SafeTrade REST API with a generic client that reads OpenAPI specs, validates requests, signs private calls, and blocks dangerous operations like withdrawals by default.
README
safetrade-mcp
Docs-driven Model Context Protocol server for the SafeTrade REST API.
This MCP is intentionally not a one-tool-per-endpoint wrapper. It gives agents a small generic client that reads SafeTrade's OpenAPI docs, validates requests against those docs by default, signs private calls internally, and keeps API secrets out of prompts and command lines.
Tools
safetrade_openapi
Inspect the SafeTrade OpenAPI spec cached by the MCP.
Arguments:
pathoptional API path, such as/trade/public/tickersor/trade/account/members/memethodoptional HTTP method whenpathis supplied
Use this first to discover paths, methods, query parameters, body schemas, and response shapes.
safetrade_request
Execute a generic SafeTrade REST request.
Arguments:
method:GET,POST,PUT,PATCH, orDELETE; defaultGETpath: relative SafeTrade API path starting with/query: object of query parametersbody: JSON body for non-GET requestsauth:auto,none, orrequired; defaultautovalidate: validate method/path against OpenAPI before sending; defaulttruetimeoutMs: request timeout; default15000, max60000confirmDangerous: must beALLOW_WITHDRAWfor withdraw mutations when withdraws are enabled
Safety model
- Credentials are read from environment variables or a local key file.
- Credentials are never returned in tool output.
- Key files must not be group/world readable. Mode
600is required. - Withdraw mutation endpoints are blocked by default.
- To allow withdraw mutations, both conditions are required:
- environment variable
SAFETRADE_ALLOW_WITHDRAW=true - request argument
confirmDangerous: "ALLOW_WITHDRAW"
- environment variable
For normal agent use, create a SafeTrade API key without withdraw permission and IP-lock it at SafeTrade.
Secrets
Preferred key file:
{
"apiKey": "...",
"apiSecret": "..."
}
Default path:
~/.config/opencode/keys/safetrade.json
Permissions:
chmod 600 ~/.config/opencode/keys/safetrade.json
Environment variables are also supported:
SAFETRADE_API_KEY=...
SAFETRADE_API_SECRET=...
Install
bun install
Run
bun run index.ts
Self-test:
bun run index.ts --self-test
The self-test checks:
- OpenAPI lookup works
- live public
/trade/public/tickersrequest returns HTTP 200 - withdraw mutation guard blocks before request
If credentials are configured, MCP clients can also call private endpoints such as /trade/account/members/me through safetrade_request.
OMP MCP config example
{
"mcpServers": {
"safetrade": {
"type": "stdio",
"command": "/home/cachybtw/.bun/bin/bun",
"args": [
"run",
"/home/cachybtw/.config/opencode/mcp/safetrade-mcp/index.ts"
],
"env": {
"PATH": "/home/cachybtw/.local/bin:/home/cachybtw/.bun/bin:/usr/local/bin:/usr/bin:/bin",
"SAFETRADE_KEYS_FILE": "/home/cachybtw/.config/opencode/keys/safetrade.json"
},
"enabled": true
}
}
}
Auth details
The signing implementation follows SafeTrade's official example client:
- header
X-Auth-Apikey: API key - header
X-Auth-Nonce: millisecond timestamp - header
X-Auth-Signature:HMAC_SHA256(apiSecret, nonce + apiKey)as lowercase hex
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.