@quantish/kalshi-server
v0.2.0
Published
Self-hosted Kalshi MCP server for trading via DFlow on Solana
Downloads
90
Maintainers
Readme
@quantish/kalshi-server
Self-hosted Kalshi MCP server for trading on Kalshi markets via DFlow on Solana.
Overview
This package provides an MCP (Model Context Protocol) server that enables AI agents to trade on Kalshi prediction markets through the DFlow protocol on Solana.
Features
- Full Kalshi Trading - Buy/sell on any Kalshi market
- Solana Wallet Management - Generate and manage Solana wallets
- DFlow Integration - Trade via DFlow's Solana infrastructure
- MCP Compatible - Works with Claude, Quantish Agent, and any MCP client
- Self-Hostable - Run on Railway, Fly.io, or any Node.js host
Quick Start
Option 1: Deploy to Railway (Recommended)
Option 2: Self-Host
npm install @quantish/kalshi-serverEnvironment Variables
| Variable | Required | Description |
|----------|----------|-------------|
| DATABASE_URL | Yes | PostgreSQL connection string |
| ENCRYPTION_KEY | Yes | 64-character hex string for wallet encryption |
| JWT_SECRET | Yes | Secret for API key generation |
| DFLOW_API_KEY | Yes | DFlow API key (see below) |
| SOLANA_RPC_URL | No | Solana RPC endpoint (defaults to mainnet) |
| PORT | No | Server port (defaults to 3000) |
Obtaining a DFlow API Key
Important: DFlow access is not permissionless. To self-host this server, you must obtain an API key directly from the DFlow team.
- Visit dflow.net and contact their team
- Request API access for your organization/project
- Once approved, you'll receive a
DFLOW_API_KEY - Add this key to your environment variables
Using Quantish's public servers? You don't need your own DFlow key - we handle this for you. Just use the default MCP endpoints provided by the Quantish Agent.
Generate Encryption Key
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"Available Tools
Account Management
kalshi_signup- Create account with Solana walletkalshi_get_wallet_info- Get wallet address and balanceskalshi_export_private_key- Export wallet private key
Market Discovery
kalshi_search_markets- Search Kalshi marketskalshi_get_market- Get market details by tickerkalshi_get_events- Browse market categorieskalshi_get_live_data- Get live market data
Trading
kalshi_get_quote- Get quote for tradekalshi_place_order- Execute trade on Solanakalshi_get_positions- View current positions
Market Operations
kalshi_check_market_initialization- Check if market is tokenizedkalshi_initialize_market- Initialize market on-chainkalshi_check_redemption_status- Check if market can be redeemed
API Format
The server exposes a JSON-RPC 2.0 endpoint at /mcp:
curl -X POST https://your-server.com/mcp \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "kalshi_get_positions",
"arguments": {}
},
"id": 1
}'Connecting to Quantish Agent
Configure the CLI to use your server:
export KALSHI_MCP_URL=https://your-server.com/mcp
export KALSHI_API_KEY=your-api-key
quantishOr add to ~/.quantish/config.json:
{
"kalshiMcpUrl": "https://your-server.com/mcp",
"kalshiApiKey": "your-api-key"
}Development
# Install dependencies
npm install
# Generate Prisma client
npm run db:generate
# Run migrations
npm run db:push
# Start development server
npm run devResources
- NPM: @quantish/kalshi-server
- GitHub: joinQuantish/kalshi-mcp
- Quantish Agent: @quantish/agent
- DFlow Docs: docs.dflow.net
License
This project is licensed under the PolyForm Noncommercial License 1.0.0.
Free for personal use, research, and non-commercial purposes. Commercial use requires explicit permission from Quantish Inc. Contact [email protected] for commercial licensing.
Built by Quantish Inc.
