
Company News
Andrew Becherer Joins Socket as Chief Information Security Officer
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.
Unofficial Model Context Protocol (MCP) server for the Kalshi trading API — lets an AI agent fully interface with Kalshi (market data, portfolio, trading, WebSocket snapshots) over stdio. Not affiliated with Kalshi.
A TypeScript Model Context Protocol (MCP) server that lets an AI agent fully interface with Kalshi — the regulated events/prediction exchange. It exposes Kalshi's Trade API v2 as MCP tools over stdio: market data, portfolio, full order management, structural data, RFQ/quotes, and live WebSocket snapshots.
ℹ️ Unofficial. Community project, not affiliated with or endorsed by Kalshi. "Kalshi" is a trademark of its owner.
⚠️ Real money. Kalshi production is a real-money exchange. This server defaults to the demo (paper) environment and gates all trading behind explicit, layered safety rails (see Safety). You are responsible for any orders an agent places once you enable trading and point it at production.
No clone or build needed — your MCP client runs it via npx:
{
"mcpServers": {
"kalshi": {
"command": "npx",
"args": ["-y", "kalshi-mcp"],
"env": {
"KALSHI_ENV": "demo",
"KALSHI_API_KEY_ID": "your-key-id",
"KALSHI_PRIVATE_KEY_PATH": "/absolute/path/to/kalshi_key.pem"
}
}
}
}
Public market-data tools work with no credentials. See Configuration for the full env list and Safety before enabling trading.
| Toolset | Tools | Auth |
|---|---|---|
market_data | get_exchange_status, get_exchange_schedule, get_exchange_announcements, get_series_list, get_series, get_events, get_event, get_markets, get_market, get_market_orderbook, get_trades, get_market_candlesticks, get_series_fee_changes | public |
portfolio | get_balance, get_positions, get_fills, get_settlements, get_user_data_timestamp | required |
orders | get_orders, get_order, create_order, cancel_order, amend_order, decrease_order, batch_create_orders, batch_cancel_orders, get_order_queue_position, get_queue_positions, get_total_resting_order_value | required |
structural | get_multivariate_event_collections, get_multivariate_event_collection, create_market_in_multivariate_event_collection, get_milestones, get_milestone, get_structured_targets, get_structured_target | mostly public |
communications (opt-in) | RFQ + quotes: get_rfqs, get_rfq, create_rfq, delete_rfq, get_quotes, get_quote, create_quote, accept_quote, confirm_quote, delete_quote, get_communications_id | required (members-only) |
streaming | ws_orderbook_snapshot, ws_ticker_snapshot, ws_await_fill, ws_collect_trades | required (signed WS) |
Default toolsets: market_data, portfolio, orders, structural, streaming (~40 tools). communications is opt-in.
fetch).npm install
npm run build # compiles src → dist
npm test # unit tests (auth signing, client, safety)
npm run smoke # live DEMO public-endpoint check (no credentials needed)
demo.kalshi.co).Copy .env.example → .env and fill in. All variables:
| Variable | Default | Purpose |
|---|---|---|
KALSHI_ENV | demo | demo (paper) or prod (real money). |
KALSHI_ALLOW_PRODUCTION | false | Must be true and KALSHI_ENV=prod to use production, else the server refuses to start. |
KALSHI_API_KEY_ID | — | Your Kalshi Key ID. |
KALSHI_PRIVATE_KEY_PATH | — | Path to the RSA private-key PEM. |
KALSHI_PRIVATE_KEY_PEM | — | Inline PEM alternative (supports \n escapes). |
KALSHI_TRADING_ENABLED | false | Master switch — order-mutating tools are blocked until true. |
KALSHI_MAX_ORDER_CONTRACTS | 100 | Reject orders exceeding this contract count (batches summed). |
KALSHI_MAX_ORDER_COST_CENTS | 10000 | Reject orders whose estimated cost exceeds this (¢). |
KALSHI_TOOLSETS | market_data,portfolio,orders,structural,streaming | Comma list, or all. Trims the tool surface. |
KALSHI_WS_TIMEOUT_MS | 5000 | WebSocket snapshot timeout (hard-capped at 15000). |
KALSHI_MAX_RETRIES | 4 | Retries on 429 / transient 5xx (exponential backoff + jitter). |
claude_desktop_config.json or .mcp.json){
"mcpServers": {
"kalshi": {
"command": "node",
"args": ["/absolute/path/to/bot-trader/dist/index.js"],
"env": {
"KALSHI_ENV": "demo",
"KALSHI_API_KEY_ID": "your-key-id",
"KALSHI_PRIVATE_KEY_PATH": "/absolute/path/to/kalshi_private_key.pem",
"KALSHI_TRADING_ENABLED": "false"
}
}
}
}
Run npm run build first so dist/index.js exists. For local development without building, use "command": "npx", "args": ["tsx", "/absolute/path/to/bot-trader/src/index.ts"].
npm run inspect # builds, then launches the MCP Inspector against dist/index.js
Trading is protected by five independent layers:
prod requires both KALSHI_ENV=prod and KALSHI_ALLOW_PRODUCTION=true, or startup fails. Default is demo.KALSHI_TRADING_ENABLED=false blocks every order-mutating tool with a clear message; reads/market-data still work.create_order and batch_create_orders accept dry_run: true to validate + preview the exact payload without sending.destructiveHint, so a host like Claude can prompt for confirmation.Prices are integer cents (1–99); quantities are whole contracts; query/body timestamps are Unix seconds.
src/
index.ts # stdio entrypoint
config.ts # env parsing + demo/prod gate
server.ts # McpServer assembly
safety.ts # trading guards
kalshi/ # auth (RSA-PSS signing), HTTP client, WebSocket snapshot helper, errors, types
tools/ # one module per toolset (market-data is the exemplar)
util/ # shared zod fragments + result helpers + formatting
test/ # node:test unit tests
scripts/smoke.ts # no-credential live demo check
npm run typecheck — tsc --noEmit.npm test — unit tests via the Node test runner (tsx loader).This software is provided as-is, with no warranty. It is not financial advice. Trading on Kalshi involves risk of loss. Verify every order before enabling live trading.
FAQs
Unofficial Model Context Protocol (MCP) server for the Kalshi trading API — lets an AI agent fully interface with Kalshi (market data, portfolio, trading, WebSocket snapshots) over stdio. Not affiliated with Kalshi.
We found that kalshi-mcp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.

Company News
Replit is integrating Socket Firewall into its AI-powered development experience to help protect builders from malicious open source packages.

Security News
npm confirmed a tooling bug incorrectly marked several one-character packages as security holders and said it was working on a rollback.