Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ˆ Kalshi MCP Server

npm version License: MIT

πŸ“– Overview

The Kalshi MCP Server enables AI agents to interact with Kalshi, a regulated prediction market exchange in the US. This server provides comprehensive access to market data, real-time pricing, order books, portfolio management, and trading capabilities.

By implementing the Model Context Protocol (MCP), this server allows Large Language Models (LLMs) to discover prediction markets, analyze odds (probabilities), execute trades, and track portfolio performance directly through their context window, bridging the gap between AI and regulated prediction markets.

✨ Features

  • Market Discovery: Search and filter prediction markets by status, series, or event keywords.
  • Real-time Pricing: Access live price data, implied probabilities, and depth-of-market (order books) for any market.
  • Portfolio Tracking: Monitor account balance, positions, trade history, fills, and settlements.
  • Trading Operations: Place limit or market orders, cancel orders, and manage positions.

πŸ“¦ Installation

πŸš€ Using npx (Recommended)

To use this server without installing it globally:

npx @iqai/mcp-kalshi

πŸ”§ Build from Source

git clone https://github.com/IQAIcom/mcp-kalshi.git
cd mcp-kalshi
pnpm install
pnpm run build

⚑ Running with an MCP Client

Add the following configuration to your MCP client settings (e.g., claude_desktop_config.json).

πŸ“‹ Minimal Configuration

{
  "mcpServers": {
    "kalshi": {
      "command": "npx",
      "args": ["-y", "@iqai/mcp-kalshi"],
      "env": {
        "KALSHI_API_KEY": "your_api_key_here",
        "KALSHI_PRIVATE_KEY_PATH": "./path/to/your/private-key.pem"
      }
    }
  }
}

βš™οΈ Advanced Configuration (Local Build)

{
  "mcpServers": {
    "kalshi": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-kalshi/dist/index.js"],
      "env": {
        "KALSHI_API_KEY": "your_api_key_here",
        "KALSHI_PRIVATE_KEY_PATH": "/absolute/path/to/private-key.pem"
      }
    }
  }
}

πŸ” Configuration (Environment Variables)

Variable Required Description Default
KALSHI_API_KEY Yes Your Kalshi API key ID -
KALSHI_PRIVATE_KEY_PATH Yes* Path to your RSA private key PEM file -
KALSHI_PRIVATE_KEY_PEM Yes* RSA private key as PEM string (alternative to path) -

*Either KALSHI_PRIVATE_KEY_PATH or KALSHI_PRIVATE_KEY_PEM is required.

πŸ”‘ Getting API Credentials

  1. Log in to your Kalshi account
  2. Go to Settings > API Keys
  3. Create a new API key pair
  4. Download and save your private key securely
  5. Note your API Key ID

πŸ’‘ Usage Examples

πŸ” Market Discovery

  • "What prediction markets are currently open on Kalshi?"
  • "Show me markets related to cryptocurrency"
  • "Find markets about the S&P 500"

πŸ“Š Analytics & Pricing

  • "Get the order book for INXD-25JAN20"
  • "What is the current implied probability for this market?"
  • "Show me recent trades on this market"

πŸ’Ό Portfolio Management

  • "What's my current account balance?"
  • "Show me my open positions"
  • "What trades have I made today?"
  • "List my recent settlements"

πŸ“ Trading

  • "Place a limit buy order for 10 Yes contracts at 45 cents on [market]"
  • "Cancel my order with ID [order_id]"
  • "Show me all my resting orders"

πŸ› οΈ MCP Tools

BATCH_CANCEL_ORDERS

Cancel multiple orders at once (up to 20 orders per batch).

Parameter Type Required Description
ids array βœ… Array of order IDs to cancel (max 20)

GET_BALANCE

Get the current account balance and portfolio value. Values are returned in dollars.

No parameters

GET_MARKET_ORDERBOOK

Get the current orderbook for a market showing bid prices and quantities for both Yes and No sides.

Parameter Type Required Description
ticker string βœ… The market ticker
depth number Depth of orderbook to retrieve (1-100, default 10)

πŸ‘¨β€πŸ’» Development

πŸ—οΈ Build Project

pnpm run build

πŸ‘οΈ Development Mode (Watch)

pnpm run watch

βœ… Linting & Formatting

pnpm run lint
pnpm run format

πŸ“ Project Structure

  • src/tools/: Individual tool definitions
  • src/services/: API client and business logic
  • src/lib/: Shared utilities (config, http)
  • src/index.ts: Server entry point

πŸ”’ Security & Privacy

Your RSA private key is used to sign API requests. Here's what you need to know:

Your Key Stays Safe:

  • The MCP server runs entirely on your local machine
  • Your private key never leaves your computer
  • No data is sent to any third-party servers except Kalshi's official API

Important Security Practices:

  • Never commit your private key to version control
  • Never share your configuration file containing the key path
  • Only use this on trusted, secure machines

πŸ“š Resources

⚠️ Disclaimer

This project is an unofficial tool and is not directly affiliated with Kalshi. It interacts with financial and prediction market data. Users should exercise caution and verify all data independently. Trading in prediction markets involves risk.

πŸ“„ License

MIT

About

MCP server for Kalshi prediction markets, portfolios, and trading.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages