flash-trade-mcp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +185 -0
- package/dist/index.js +29499 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# flash-trade-mcp
|
|
2
|
+
|
|
3
|
+
MCP server for [Flash Trade](https://flash.trade) perpetual DEX on Solana. Gives AI agents (Claude, GPT, etc.) tools to read market data, preview trades, and build unsigned transactions.
|
|
4
|
+
|
|
5
|
+
## Quick Start — Just Paste and Use
|
|
6
|
+
|
|
7
|
+
No cloning, no building. Add this config and restart your editor.
|
|
8
|
+
|
|
9
|
+
### Claude Code (`.mcp.json`)
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"mcpServers": {
|
|
14
|
+
"flash-trade": {
|
|
15
|
+
"command": "npx",
|
|
16
|
+
"args": ["-y", "flash-trade-mcp"],
|
|
17
|
+
"env": {
|
|
18
|
+
"FLASH_API_URL": "https://flashapi.trade"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Claude Desktop (`claude_desktop_config.json`)
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"mcpServers": {
|
|
30
|
+
"flash-trade": {
|
|
31
|
+
"command": "npx",
|
|
32
|
+
"args": ["-y", "flash-trade-mcp"],
|
|
33
|
+
"env": {
|
|
34
|
+
"FLASH_API_URL": "https://flashapi.trade"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Cursor / Windsurf
|
|
42
|
+
|
|
43
|
+
Add the same JSON block to your MCP settings. Use `npx` as the command.
|
|
44
|
+
|
|
45
|
+
### Using Bun instead of Node
|
|
46
|
+
|
|
47
|
+
If you prefer Bun, replace `npx` with `bunx`:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"mcpServers": {
|
|
52
|
+
"flash-trade": {
|
|
53
|
+
"command": "bunx",
|
|
54
|
+
"args": ["flash-trade-mcp"],
|
|
55
|
+
"env": {
|
|
56
|
+
"FLASH_API_URL": "https://flashapi.trade"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Environment Variables
|
|
64
|
+
|
|
65
|
+
| Variable | Required | Default | Description |
|
|
66
|
+
|----------|----------|---------|-------------|
|
|
67
|
+
| `FLASH_API_URL` | Yes | — | Flash Trade API base URL (`https://flashapi.trade` for production) |
|
|
68
|
+
| `FLASH_API_TIMEOUT` | No | `30000` | HTTP timeout in milliseconds |
|
|
69
|
+
| `WALLET_PUBKEY` | No | — | Default wallet pubkey for transaction building |
|
|
70
|
+
|
|
71
|
+
## Available Tools
|
|
72
|
+
|
|
73
|
+
### Read Tools (no transactions)
|
|
74
|
+
|
|
75
|
+
| Tool | Description |
|
|
76
|
+
|------|-------------|
|
|
77
|
+
| `health_check` | Verify API connectivity |
|
|
78
|
+
| `get_markets` | List all perpetual futures markets |
|
|
79
|
+
| `get_market` | Market details by pubkey |
|
|
80
|
+
| `get_pools` | List liquidity pools |
|
|
81
|
+
| `get_pool` | Pool details by pubkey |
|
|
82
|
+
| `get_custodies` | List custody accounts |
|
|
83
|
+
| `get_custody` | Custody details by pubkey |
|
|
84
|
+
| `get_prices` | Current oracle prices for all assets |
|
|
85
|
+
| `get_price` | Price for a single symbol (SOL, BTC, ETH) |
|
|
86
|
+
| `get_positions` | List positions, optionally by owner wallet |
|
|
87
|
+
| `get_position` | Single position by pubkey |
|
|
88
|
+
| `get_orders` | List orders (limit, TP, SL), optionally by owner |
|
|
89
|
+
| `get_order` | Single order by pubkey |
|
|
90
|
+
| `get_pool_data` | Pool AUM, LP stats, utilization |
|
|
91
|
+
|
|
92
|
+
### Preview Tools (calculations only)
|
|
93
|
+
|
|
94
|
+
| Tool | Description |
|
|
95
|
+
|------|-------------|
|
|
96
|
+
| `preview_limit_order_fees` | Estimate fees, entry price, liquidation price |
|
|
97
|
+
| `preview_exit_fee` | Estimate exit fee for closing a position |
|
|
98
|
+
| `preview_tp_sl` | Calculate TP/SL prices and projected PnL |
|
|
99
|
+
| `preview_margin` | Preview effect of adding/removing collateral |
|
|
100
|
+
|
|
101
|
+
### Transaction Tools (return unsigned base64)
|
|
102
|
+
|
|
103
|
+
| Tool | Description |
|
|
104
|
+
|------|-------------|
|
|
105
|
+
| `open_position` | Open a new perpetual position (market or limit) |
|
|
106
|
+
| `close_position` | Close or partially close a position |
|
|
107
|
+
| `add_collateral` | Add collateral to reduce leverage |
|
|
108
|
+
| `remove_collateral` | Remove collateral to increase leverage |
|
|
109
|
+
| `reverse_position` | Close + open opposite direction |
|
|
110
|
+
|
|
111
|
+
### Trigger Order Tools (TP/SL management)
|
|
112
|
+
|
|
113
|
+
| Tool | Description |
|
|
114
|
+
|------|-------------|
|
|
115
|
+
| `place_trigger_order` | Place TP or SL on an existing position |
|
|
116
|
+
| `edit_trigger_order` | Edit an existing TP/SL order |
|
|
117
|
+
| `cancel_trigger_order` | Cancel a single TP/SL order |
|
|
118
|
+
| `cancel_all_trigger_orders` | Cancel all TP/SL for a market+side |
|
|
119
|
+
|
|
120
|
+
## Platform Compatibility
|
|
121
|
+
|
|
122
|
+
This server uses **stdio transport** — it runs as a local process on the user's machine and communicates over stdin/stdout.
|
|
123
|
+
|
|
124
|
+
| Platform | Supported | Notes |
|
|
125
|
+
|----------|-----------|-------|
|
|
126
|
+
| Claude Code (CLI) | Yes | Add to `.mcp.json` in your project |
|
|
127
|
+
| Claude Desktop (app) | Yes | Add to `claude_desktop_config.json` |
|
|
128
|
+
| Cursor | Yes | Add via Cursor MCP settings |
|
|
129
|
+
| Windsurf | Yes | Add via MCP configuration |
|
|
130
|
+
| **Claude.ai (website)** | **No** | Requires remote HTTP transport (see below) |
|
|
131
|
+
| **Any cloud-hosted MCP** | **No** | Requires remote HTTP transport (see below) |
|
|
132
|
+
|
|
133
|
+
### Why Claude.ai doesn't work
|
|
134
|
+
|
|
135
|
+
Claude.ai's remote MCP feature needs a publicly accessible URL. It cannot spawn a local process on your machine. Supporting Claude.ai would require:
|
|
136
|
+
|
|
137
|
+
1. Migrating from `StdioServerTransport` to [Streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http)
|
|
138
|
+
2. Deploying to a hosting platform (Cloudflare Workers, Fly.io, Railway, etc.)
|
|
139
|
+
3. Adding authentication (the server would be publicly accessible)
|
|
140
|
+
|
|
141
|
+
This is on the roadmap but not yet implemented.
|
|
142
|
+
|
|
143
|
+
## Important Notes
|
|
144
|
+
|
|
145
|
+
- **Non-custodial**: Transaction tools return unsigned base64 transactions. The user's wallet signs and submits.
|
|
146
|
+
- **Minimum collateral >$10**: Limit orders, TP, and SL require more than $10 collateral after fees. Use at least $11-12 for positions needing TP/SL.
|
|
147
|
+
- **Mainnet only**: Pyth oracle prices are mainnet only. Devnet returns stale/zero.
|
|
148
|
+
- **Rate limit**: 10 requests per second.
|
|
149
|
+
|
|
150
|
+
## Development
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
bun run dev # Start MCP server (stdio transport)
|
|
154
|
+
bun run test # Run tests (26 pass, 9 skip for integration)
|
|
155
|
+
bun run typecheck # Type check
|
|
156
|
+
bun run build # Bundle for npm (dist/index.js, node-compatible)
|
|
157
|
+
bun run build:binary # Compile to standalone binary
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Architecture
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
src/
|
|
164
|
+
index.ts # Entry point — registers tools, resources, starts stdio transport
|
|
165
|
+
config.ts # Env var loading (FLASH_API_URL, timeout, wallet)
|
|
166
|
+
client/
|
|
167
|
+
flash-api.ts # Typed HTTP client for Flash Trade REST API
|
|
168
|
+
types.ts # Request/response type definitions
|
|
169
|
+
tools/
|
|
170
|
+
index.ts # Tool registration barrel
|
|
171
|
+
read.ts # Read-only tools (markets, positions, prices)
|
|
172
|
+
transactions.ts # Transaction-building tools (open, close, collateral)
|
|
173
|
+
previews.ts # Preview/calculation tools
|
|
174
|
+
trigger-orders.ts # TP/SL trigger order tools
|
|
175
|
+
pool-data.ts # Pool metrics tool
|
|
176
|
+
...
|
|
177
|
+
resources/
|
|
178
|
+
index.ts # MCP resources (accounts snapshot, positions, orders)
|
|
179
|
+
tests/
|
|
180
|
+
mocks/ # MSW handlers for unit tests
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### API Documentation
|
|
184
|
+
|
|
185
|
+
Interactive Swagger docs are available at `{FLASH_API_URL}/docs/`.
|