truemarkets-mcp-server
Enables AI agents to perform native trading on True Markets by providing tools for price lookups, balance management, and secure trade execution with quote caching. It replaces fragile CLI-based workflows with structured JSON responses and persistent authentication for more reliable financial operations.
README
truemarkets-mcp-server
MCP (Model Context Protocol) server for True Markets. Gives AI agents native trading capabilities without shelling out to bash.
Why this exists
The True Markets CLI (tm) works with agents through bash skills — the agent runs tm buy SOL 50 -o json --force and parses stdout. This works, but has fundamental problems:
- Two-quote problem:
--dry-runand--forcefetch separate quotes. The agent decides based on quote A but executes at quote B's price. - No slippage protection: No mechanism to reject execution if price moves.
- Process overhead: Every command spawns a new process, re-reads credentials, re-establishes HTTP connections.
- Fragile parsing: Agent must parse JSON from stdout mixed with stderr warnings.
The MCP server solves all of these:
- Quote caching:
tm_get_quotereturns aquote_idcached for 60 seconds.tm_execute_tradeuses the same quote — no price surprise. - Structured responses: Tools return typed JSON via MCP's
structuredContent, no stdout parsing. - Persistent auth: Credentials loaded once on startup, tokens refreshed automatically.
- Native tool calls: Agents call tools directly instead of composing bash strings.
Tools
Read-only
| Tool | Description |
|---|---|
tm_get_price |
Get token price in USDC (no API key needed) |
tm_get_balances |
Get token balances across chains |
tm_list_assets |
List available tokens |
tm_get_profile |
Get account email and wallet addresses |
Trading
| Tool | Description | Destructive |
|---|---|---|
tm_get_quote |
Get a trade quote (cached 60s) | No |
tm_execute_trade |
Execute a cached quote | Yes |
tm_prepare_transfer |
Prepare outbound transfer | No |
tm_execute_transfer |
Execute a prepared transfer | Yes |
Agent workflow
1. tm_get_balances → check available funds
2. tm_get_quote(buy, SOL, 50) → inspect price, fee, issues
3. [agent decides: price acceptable? issues empty?]
4. tm_execute_trade(quote_id) → execute the SAME quote
Compare to the CLI flow where step 4 fetches a new quote silently.
Setup
Prerequisites
- Node.js 18+
- Existing True Markets account (
tm signup/tm loginvia the CLI) - API key configured (
tm config set api_key <key>)
The MCP server reads credentials from ~/.config/truemarkets/ — the same location the CLI uses. No separate auth setup needed.
Install
npm install -g truemarkets-mcp-server
Configure your agent
Claude Code / claude.ai
Add to your MCP config (.claude/mcp.json or via settings):
{
"mcpServers": {
"truemarkets": {
"command": "truemarkets-mcp-server",
"args": []
}
}
}
Cursor
Add to .cursor/mcp.json:
{
"mcpServers": {
"truemarkets": {
"command": "npx",
"args": ["truemarkets-mcp-server"]
}
}
}
Environment variables
| Variable | Description |
|---|---|
TM_AUTH_TOKEN |
Override stored auth token |
TM_API_KEY |
Override stored API key |
Development
git clone https://github.com/true-markets/mcp-server.git
cd mcp-server
npm install
npm run build
npm start
Test with the MCP inspector:
npx @modelcontextprotocol/inspector node dist/index.js
Architecture
src/
├── index.ts # Entry point, stdio transport
├── constants.ts # API host, paths, version
├── types.ts # Shared types and helpers
├── services/
│ ├── auth.ts # Token/key management (reads ~/.config/truemarkets/)
│ ├── api-client.ts # DeFi Gateway HTTP client
│ └── signer.ts # Turnkey P256 payload signing
└── tools/
├── read.ts # Read-only tools (price, balances, assets, profile)
└── trade.ts # Trading tools (quote, execute, transfer)
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 模型以安全和受控的方式获取实时的网络信息。