Skip to content

Commit 3dfb212

Browse files
committed
Updated MCP, CLI with skills
1 parent 09f04a8 commit 3dfb212

19 files changed

Lines changed: 3115 additions & 0 deletions

File tree

.claude/skills/polybot.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
name: polybot
3+
description: Interact with PolyBot trading system via CLI
4+
---
5+
6+
# PolyBot CLI Skill
7+
8+
Execute PolyBot CLI commands for trading system management.
9+
10+
## Available Commands
11+
12+
### Service Management
13+
- `polybot start` - Start all services
14+
- `polybot api` - Run API server only
15+
- `polybot mcp start` - Start MCP server
16+
17+
### Strategy Management
18+
- `polybot strategy list` - List all strategies with enabled/shadow status
19+
- `polybot strategy enable <name>` - Enable a strategy
20+
- `polybot strategy disable <name>` - Disable a strategy
21+
- `polybot strategy shadow <name> --enable` - Enable shadow mode (paper trading)
22+
- `polybot strategy shadow <name> --disable` - Disable shadow mode
23+
- `polybot strategy run <name>` - Run a single strategy
24+
25+
### AI Trading Management (MCP)
26+
- `polybot mcp status` - Show MCP server status, mode, and pending approvals
27+
- `polybot mcp mode <disabled|shadow|live>` - Set AI trading mode
28+
- `polybot mcp pending` - List pending AI trade approvals
29+
- `polybot mcp approve <id>` - Approve a pending AI trade
30+
- `polybot mcp reject <id> -r "reason"` - Reject a pending AI trade
31+
- `polybot mcp audit` - View AI action audit log
32+
33+
### Market Analysis
34+
- `polybot ai plugins` - List available AI prediction plugins
35+
- `polybot ai info <plugin>` - Show plugin details
36+
- `polybot ai predict <market_id>` - Test AI prediction for a market
37+
- `polybot ai scan` - Scan markets for AI-predicted opportunities
38+
39+
### Statistical Arbitrage
40+
- `polybot statarb correlations` - Show computed market correlations
41+
- `polybot statarb compute --hours 48` - Compute correlations
42+
- `polybot statarb opportunities` - Show current stat arb opportunities
43+
- `polybot statarb prices` - Show recent price snapshots
44+
45+
### Database & Configuration
46+
- `polybot db init` - Initialize databases
47+
- `polybot db stats` - Show 30-day trading statistics
48+
- `polybot config` - Show current configuration
49+
50+
### Authentication
51+
- `polybot auth --create` - Create new API credentials
52+
- `polybot auth --derive` - Derive existing credentials
53+
54+
## Usage
55+
56+
When using this skill, run commands via bash. For example:
57+
58+
```bash
59+
# List all strategies
60+
polybot strategy list
61+
62+
# Enable arbitrage in shadow mode
63+
polybot strategy enable arbitrage
64+
polybot strategy shadow arbitrage --enable
65+
66+
# Check MCP status
67+
polybot mcp status
68+
69+
# Approve an AI trade
70+
polybot mcp approve abc123
71+
```
72+
73+
## AI Trading Modes
74+
75+
| Mode | Description |
76+
|------|-------------|
77+
| `disabled` | AI can only read market data |
78+
| `shadow` | AI can paper trade (no real money) |
79+
| `live` | AI can submit real orders (with approval) |
80+
81+
## Safety Notes
82+
83+
- Shadow mode is recommended for testing AI strategies
84+
- Live trading requires explicit approval by default
85+
- All AI actions are logged in the audit log
86+
- Position limits apply to AI trades separately from manual limits

.env.example

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,38 @@ CORS_ALLOW_METHODS=GET,POST,PUT,DELETE,OPTIONS
130130

131131
# Allowed headers
132132
CORS_ALLOW_HEADERS=Authorization,X-API-Key,Content-Type,Accept
133+
134+
# =============================================================================
135+
# MCP SERVER (AI Agent Integration)
136+
# =============================================================================
137+
138+
# Enable MCP server for AI agent integration
139+
MCP_ENABLED=false
140+
141+
# MCP server host and port
142+
MCP_HOST=127.0.0.1
143+
MCP_PORT=3001
144+
145+
# AI trading mode:
146+
# disabled - AI can only read market data
147+
# shadow - AI can paper trade (no real money)
148+
# live - AI can submit real orders (with approval)
149+
MCP_AI_TRADING_MODE=shadow
150+
151+
# AI-specific risk limits (separate from main limits)
152+
MCP_MAX_POSITION_USD=100
153+
MCP_MAX_DAILY_TRADES=50
154+
MCP_DAILY_LOSS_LIMIT_USD=200
155+
156+
# Approval settings for live trading
157+
MCP_REQUIRE_APPROVAL=true
158+
MCP_APPROVAL_TIMEOUT_SEC=300
159+
160+
# Rate limiting and audit
161+
MCP_RATE_LIMIT_PER_MIN=30
162+
MCP_AUDIT_LOG_ENABLED=true
163+
164+
# Strategy assessment settings
165+
MCP_ALLOW_CODE_READ=true
166+
MCP_ALLOW_CLI_EXECUTION=true
167+
MCP_ASSESSMENT_LOOKBACK_DAYS=30

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,67 @@ class MyAIPlugin(AIModelPlugin):
167167

168168
[Developer Guide](https://docs.cryptuon.com/polybot/developer-guide/)
169169

170+
## AI Agent Integration
171+
172+
PolyBot includes comprehensive AI agent integration via MCP (Model Context Protocol):
173+
174+
- **MCP Server** for AI agents (Claude, etc.) to interact with trading
175+
- **Strategy Assessment** for AI to analyze and improve strategies
176+
- **Claude Code Skill** for direct CLI interaction
177+
178+
### Quick Start
179+
180+
```bash
181+
# Enable MCP server
182+
export MCP_ENABLED=true
183+
export MCP_AI_TRADING_MODE=shadow # Start with paper trading
184+
185+
# Start MCP server
186+
polybot mcp start
187+
```
188+
189+
### Claude Code Skill
190+
191+
Install the skill for direct CLI access in Claude Code:
192+
193+
```bash
194+
cp -r .claude/skills ~/.claude/skills/
195+
```
196+
197+
Then use `/polybot` in Claude Code:
198+
```
199+
/polybot strategy list
200+
/polybot mcp status
201+
```
202+
203+
### AI Capabilities
204+
205+
| Feature | Description |
206+
|---------|-------------|
207+
| **Market Analysis** | Query markets, prices, positions |
208+
| **Shadow Trading** | Paper trade without real money |
209+
| **Live Trading** | Real orders with approval workflow |
210+
| **Strategy Assessment** | Analyze performance, suggest improvements |
211+
| **CLI Execution** | Run polybot commands programmatically |
212+
213+
### Trading Modes
214+
215+
| Mode | Description |
216+
|------|-------------|
217+
| `disabled` | AI can only read market data |
218+
| `shadow` | AI can paper trade (no real money) |
219+
| `live` | AI can submit real orders (with approval) |
220+
221+
### Safety Controls
222+
223+
- **Position Limits**: AI trades limited to `MCP_MAX_POSITION_USD`
224+
- **Daily Loss Limit**: Auto-disable if `MCP_DAILY_LOSS_LIMIT_USD` exceeded
225+
- **Approval Queue**: Live trades require human approval by default
226+
- **Audit Logging**: All AI actions logged for review
227+
- **CLI Whitelist**: Only safe commands allowed via MCP
228+
229+
[AI Integration Guide](https://docs.cryptuon.com/polybot/user-guide/ai-agents/)
230+
170231
## Architecture
171232

172233
```
@@ -215,6 +276,15 @@ polybot ai plugins # List AI plugins
215276
polybot ai predict <market_id> # Test prediction
216277
polybot ai scan # Scan for opportunities
217278

279+
# MCP (AI Agent) management
280+
polybot mcp start # Start MCP server
281+
polybot mcp status # Show status and pending approvals
282+
polybot mcp mode <mode> # Set AI trading mode
283+
polybot mcp pending # List pending approvals
284+
polybot mcp approve <id> # Approve AI trade
285+
polybot mcp reject <id> # Reject AI trade
286+
polybot mcp audit # View AI action audit log
287+
218288
# Database
219289
polybot db init # Initialize databases
220290
polybot db stats # Show performance stats

0 commit comments

Comments
 (0)