Self-Hosting
Run your own Trading MCP server for full control over your wallet keys and infrastructure.
- Full Control - Own your private keys completely
- Custom Logic - Add your own trading strategies
- Privacy - No third-party access to your trades
- Compliance - Meet regulatory requirements
Configure Custom Server URL
Before deploying your own server, you can configure the CLI to point to any Trading MCP endpoint:
Option 1: CLI Command
Option 2: Environment Variable
Set the MCP_SERVER_URL environment variable (takes precedence over config):
# In your shell profile (~/.zshrc, ~/.bashrc)
export MCP_SERVER_URL=https://your-server.com/mcp
# Or in a .env file for your project
MCP_SERVER_URL=https://your-server.com/mcp
Option 3: Config File
Edit ~/.quantish/config.json directly:
{
"anthropicApiKey": "sk-ant-...",
"quantishApiKey": "your-custom-key",
"mcpServerUrl": "https://your-server.com/mcp",
"model": "claude-sonnet-4-5-20250929"
}
Server Requirements
Your self-hosted Trading MCP server must implement the following:
Endpoint
POST /mcp/execute
Content-Type: application/json
X-API-Key: <user-api-key>
Request Format (JSON-RPC 2.0)
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "get_balances",
"arguments": {}
},
"id": 1
}
Response Format
{
"jsonrpc": "2.0",
"result": {
"content": [
{
"type": "text",
"text": "{\"success\": true, \"data\": {...}}"
}
]
},
"id": 1
}
Required Tools
Your server should implement at minimum:
| Tool | Description |
|---|---|
get_balances |
Return wallet USDC and collateral balances |
get_positions |
Return current market positions |
place_order |
Submit buy/sell orders to Polymarket |
cancel_order |
Cancel an open order |
get_orders |
List open/filled orders |
Using @quantish/server
We provide an official self-hosting package on NPM:
Source code: github.com/joinQuantish/quantish-server
Quick Start
import { createServer, PostgresAdapter } from '@quantish/server';
const server = await createServer({
database: new PostgresAdapter({
connectionString: process.env.DATABASE_URL
}),
encryption: {
masterKey: process.env.QUANTISH_MASTER_KEY
}
});
server.listen(3000);
console.log('Quantish server running on http://localhost:3000');
Generate Master Key
Packages Included
| Package | Description |
|---|---|
@quantish/server |
Express server with trading endpoints |
@quantish/core |
Encryption, signing, wallet utilities |
@quantish/types |
TypeScript type definitions |
Manual Implementation
If you prefer to build from scratch, your server must implement a JSON-RPC 2.0 compatible endpoint:
// server.js - Minimal Trading MCP Server
import express from 'express';
const app = express();
app.use(express.json());
app.post('/mcp/execute', async (req, res) => {
const { method, params, id } = req.body;
const apiKey = req.headers['x-api-key'];
// Validate API key
if (!validateApiKey(apiKey)) {
return res.status(401).json({ error: 'Unauthorized' });
}
try {
let result;
switch (params.name) {
case 'get_balances':
result = await getBalances(apiKey);
break;
case 'place_order':
result = await placeOrder(apiKey, params.arguments);
break;
// ... implement other tools
}
res.json({
jsonrpc: '2.0',
result: { content: [{ type: 'text', text: JSON.stringify(result) }] },
id
});
} catch (error) {
res.json({
jsonrpc: '2.0',
error: { code: -32000, message: error.message },
id
});
}
});
app.listen(3000);
Required Environment Variables
| Variable | Description |
|---|---|
DATABASE_URL |
PostgreSQL connection string |
POLYMARKET_API_KEY |
Your Polymarket Builder API key |
POLYMARKET_API_SECRET |
Your Polymarket Builder API secret |
POLYMARKET_PASSPHRASE |
Your Polymarket Builder passphrase |
ENCRYPTION_KEY |
32-byte hex key for wallet encryption |
Getting Polymarket Builder Credentials
To run your own Trading MCP server, you need Polymarket Builder API credentials:
- Apply via the Polymarket Developer Docs
- Complete the application process (typically 1-2 weeks)
- Once approved, you'll receive API key, secret, and passphrase
Never commit your Polymarket credentials or encryption keys to version control. Always use environment variables or a secrets manager.
Architecture Overview
┌─────────────────────────────────────────────────────────┐
│ Your Infrastructure │
├─────────────────────────────────────────────────────────┤
│ │
│ quantish (CLI) │
│ │ │
│ ├── Local Tools (filesystem, shell, git) │
│ │ │
│ └── Trading MCP ──► Your Server │
│ │ │
│ ├── PostgreSQL (users/keys) │
│ │ │
│ └── Polymarket API │
│ │
└─────────────────────────────────────────────────────────┘
Discovery MCP is always provided by quantish.live (public, read-only)
Testing Your Server
Test that your server is working correctly:
Expected response:
{
"jsonrpc": "2.0",
"result": {
"content": [
{
"type": "text",
"text": "{\"success\":true,\"data\":{\"usdc\":\"100.00\",\"collateral\":\"0.00\"}}"
}
]
},
"id": 1
}