MCP Kalshi
Access and trade on prediction markets via the Kalshi platform API.
- Package:
@iqai/mcp-kalshi - Provider: Kalshi
Overview
The Kalshi MCP server connects your agent to Kalshi's regulated prediction markets. It can fetch active markets, retrieve market prices and probabilities, place trades, and query your open positions — enabling agents to reason about real-world outcomes using financial prediction data.
API Credentials Required
Trading on Kalshi requires a funded account and valid API credentials. Paper trading is not available via the API.
Getting Started
Install the package:
pnpm add @iqai/mcp-kalshiUse the server in your agent:
import { McpKalshi } from "@iqai/adk";
const toolset = McpKalshi({
env: {
KALSHI_API_KEY: process.env.KALSHI_API_KEY,
KALSHI_PRIVATE_KEY_PATH: process.env.KALSHI_PRIVATE_KEY_PATH,
},
});
const tools = await toolset.getTools();import { McpToolset } from "@iqai/adk";
const toolset = new McpToolset({
name: "Kalshi MCP Client",
description: "Client for Kalshi prediction markets",
transport: {
mode: "stdio",
command: "npx",
args: ["-y", "@iqai/mcp-kalshi"],
env: {
KALSHI_API_KEY: process.env.KALSHI_API_KEY,
KALSHI_PRIVATE_KEY_PATH: process.env.KALSHI_PRIVATE_KEY_PATH,
PATH: process.env.PATH || "",
},
},
});
const tools = await toolset.getTools();{
"mcpServers": {
"kalshi-mcp-server": {
"command": "npx",
"args": ["-y", "@iqai/mcp-kalshi"],
"env": {
"KALSHI_API_KEY": "your_kalshi_api_key",
"KALSHI_PRIVATE_KEY_PATH": "/path/to/your/private_key.pem"
}
}
}
}Environment Variables
| Variable | Required | Description |
|---|---|---|
KALSHI_API_KEY | Yes | Your Kalshi API key ID |
KALSHI_PRIVATE_KEY_PATH | One of the two key options required | Path to your RSA private key .pem file for request signing |
KALSHI_PRIVATE_KEY_PEM | One of the two key options required | RSA private key as a PEM string (alternative to the path option) |
Credentials
To get your Kalshi API credentials:
- Create an account at kalshi.com and complete identity verification
- Go to Account Settings → API
- Generate a new API key and note your API Key ID
- Generate an RSA key pair (Kalshi uses RSA-PS256 for request signing):
openssl genrsa -out kalshi_private.pem 2048 openssl rsa -in kalshi_private.pem -pubout -out kalshi_public.pem - Upload
kalshi_public.pemin your Kalshi API settings - Set
KALSHI_PRIVATE_KEY_PATHto the path of yourkalshi_private.pem
Available Tools
GET_MARKETSlimit:numbercursor:stringeventTicker:stringseriesTicker:stringstatus:stringtickers:string
GET_MARKETSDescription
List and discover prediction markets on Kalshi. Markets represent binary outcomes users can trade on. Returns paginated results with market details including ticker, title, prices, and volume.
GET_MARKETticker:string
GET_MARKETDescription
Get detailed information about a specific prediction market by its ticker, including current prices, volume, open interest, and settlement rules.
GET_MARKET_ORDERBOOKticker:stringdepth:number
GET_MARKET_ORDERBOOKDescription
Get the current orderbook for a market showing bid prices and quantities for both Yes and No sides.
GET_TRADESticker:stringlimit:numbercursor:stringminTs:numbermaxTs:number
GET_TRADESDescription
Get recent public trades across all markets or for a specific market. Each trade shows price, quantity, and timestamp.
GET_SERIESseriesTicker:string
GET_SERIESDescription
Get information about a series, which is a template for recurring events (e.g., monthly jobs reports, daily weather).
GET_BALANCENo parameters
GET_BALANCENo parameters
Description
Get the current account balance and portfolio value. Values are returned in dollars.
GET_POSITIONSticker:stringeventTicker:stringlimit:numbercursor:stringcountFilter:string
GET_POSITIONSDescription
Get your current portfolio positions showing market exposure, cost basis, and P&L for each position.
GET_FILLSticker:stringorderId:stringlimit:numbercursor:stringminTs:numbermaxTs:number
GET_FILLSDescription
Get your trade fill history. A fill occurs when your order is matched with another trader.
GET_SETTLEMENTSticker:stringeventTicker:stringlimit:numbercursor:stringminTs:numbermaxTs:number
GET_SETTLEMENTSDescription
Get your settlement history showing resolved markets and their payouts.
GET_ORDERSticker:stringeventTicker:stringstatus:stringlimit:numbercursor:string
GET_ORDERSDescription
Get your orders with optional filtering by market, status, or time range.
GET_ORDERorderId:string
GET_ORDERDescription
Get detailed information about a specific order by its ID.
CREATE_ORDERticker:stringside:stringaction:stringcount:numbertype:stringyesPrice:numbernoPrice:numbertimeInForce:stringpostOnly:booleanreduceOnly:boolean
CREATE_ORDERDescription
Create a new order to buy or sell contracts in a prediction market. Use limit orders with a price, or market orders for immediate execution.
CANCEL_ORDERorderId:string
CANCEL_ORDERDescription
Cancel an existing open order by its ID.
BATCH_CANCEL_ORDERSids:array
BATCH_CANCEL_ORDERSDescription
Cancel multiple orders at once (up to 20 orders per batch).
DECREASE_ORDERorderId:stringreduceBy:number
DECREASE_ORDERDescription
Decrease the quantity of an existing order. This is the only way to reduce order size without fully canceling.
Integration Example
import { AgentBuilder, McpKalshi } from "@iqai/adk";
import * as dotenv from "dotenv";
dotenv.config();
async function main() {
// Initialize McpKalshi toolset
const toolset = McpKalshi({
env: {
KALSHI_API_KEY: process.env.KALSHI_API_KEY,
KALSHI_PRIVATE_KEY_PATH: process.env.KALSHI_PRIVATE_KEY_PATH,
},
});
// Get available McpKalshi tools
const kalshiTools = await toolset.getTools();
// Create agent with McpKalshi tools
const { runner } = await AgentBuilder.create("kalshi_agent")
.withModel("gemini-2.5-flash")
.withDescription(
"A prediction market agent that monitors and trades on Kalshi",
)
.withTools(...kalshiTools)
.build();
const response = await runner.ask(
"What are the most active prediction markets on Kalshi right now, and what are their current odds",
);
console.log(response);
}
main().catch(console.error);