Mcp Server Kalshi

io.github.9crusher由 GitHub 帳號 9crusher 發布v0.2.2更新於 Oct 24, 2026

MCP server for end-to-end trading on Kalshi prediction markets: discover, research, trade.

已驗證STDIO僅桌面金融資料與分析

概覽

AI 產生的概覽

讓助理瀏覽 Kalshi 預測市場、閱讀結算規則與合約 PDF,並下單或管理交易。

可以做什麼
提供 MCP 工具來探索 Kalshi 的市場、事件與系列,研究訂單簿、K 線圖與成交紀錄,並閱讀結算規則,包括擷取合約條款 PDF 的文字。投資組合工具可讀取餘額、持倉、成交與結算,交易工具可建立、修改、減少、取消與列出訂單。下單工具採用買入/賣出加上是/否的模型,限價為整數美分,且下單需要明確的確認旗標,否則只回傳預覽。
適用情境
適合讓助理研究預測市場,並可能完成端到端交易,從市場探索、規則閱讀到訂單執行。適用於需要 Kalshi 市場資料或投資組合狀態的代理工作流程,也可在無憑證情況下以唯讀方式使用。
執行需求
透過 stdio 在本機執行,通常使用 uvx 或 Docker,本機開發需要 Python 3.10+。市場與規則工具不需要憑證;投資組合與訂單工具需要 KALSHI_API_KEY,以及指向 RSA 私鑰 .pem 的 KALSHI_PRIVATE_KEY_PATH。KALSHI_ENV 選擇 demo 或 prod,BASE_URL 可覆寫 REST 基礎位址。需要連線至 Kalshi 的網路存取。
安裝前請注意
KALSHI_ENV 預設為 demo,但設為 prod 會進行真實資金交易。訂單工具可建立、修改、減少與取消訂單;create_order 與 amend_order 需要 confirm=true,否則只回傳預覽。伺服器要求 KALSHI_API_KEY 與 RSA 私鑰檔案路徑,請妥善保護這些憑證。已驗證請求會被簽章並傳送至 Kalshi,市場資料與規則 PDF 從第三方端點取得。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Mcp Server Kalshi,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

MCP Server Kalshi

An MCP server that gives Claude Code and other agent harnesses a first-class interface to Kalshi. It is built for end-to-end trading: browse markets, research them, read the exact settlement rules (including pulling the contract-terms PDFs), and execute trades — all through MCP tools.

Highlights

  • Discovery — list_markets, get_market, list_events, get_event, list_series, get_series. (Kalshi has no free-text search; list_markets filters are the search.)
  • Research — get_market_orderbook, get_market_candlesticks, get_market_trades.
  • Deep rules — get_market_rules consolidates a market's rules_primary/rules_secondary, early-close conditions, settlement sources, and series prohibitions; fetch_rules_pdf downloads and extracts the text of the actual legal contract PDF so the agent can read it.
  • Exchange — get_exchange_status, get_exchange_schedule (is the market open, and its hours).
  • Portfolio — get_balance, get_positions, get_fills, get_settlements.
  • Trading — create_order, cancel_order, amend_order, decrease_order, plus list_orders / get_order.

Safety by default

  • The server targets Kalshi's demo (sandbox) environment unless you explicitly set KALSHI_ENV=prod.
  • Order-placing tools (create_order, amend_order) require confirm=true. Without it they return a preview — a human-readable summary and the exact payload — and place nothing.
  • Credentials are optional: all market/rules tools work unauthenticated. Only portfolio and order tools need an API key + RSA private key.

Intuitive order model

Kalshi's V2 order API quotes everything from the YES leg (bid/ask in fixed-point dollars). This server exposes the natural model instead — action (buy/sell) + side (yes/no) + a whole cents limit price — and translates it (including the buy-NO ⇄ sell-YES price inversion).

Configuration

VariableDefaultPurpose
KALSHI_ENVdemodemo (sandbox) or prod (real money). Derives the base URL.
KALSHI_API_KEY(none)Kalshi API key ID. Required only for authenticated tools.
KALSHI_PRIVATE_KEY_PATH(none)Path to your RSA private key .pem. Required for authenticated tools.
BASE_URL(derived)Optional explicit REST base override (must include /trade-api/v2).

See .env-example. Get API credentials at docs.kalshi.com/getting_started/api_keys and a demo account via the demo environment guide.

Claude Desktop (uvx)

json
"mcpServers": {  "kalshi": {    "command": "uvx",    "args": ["mcp-server-kalshi"],    "env": {      "KALSHI_ENV": "demo",      "KALSHI_API_KEY": "<YOUR KALSHI API KEY>",      "KALSHI_PRIVATE_KEY_PATH": "PATH TO YOUR RSA KEY FILE"    }  }}

Claude Desktop (Docker)

json
"mcpServers": {  "kalshi": {    "command": "docker",    "args": ["run", "--rm", "-i",      "--mount", "type=bind,src=/Users/username,dst=/Users/username",      "-e", "KALSHI_ENV", "-e", "KALSHI_API_KEY", "-e", "KALSHI_PRIVATE_KEY_PATH",      "mcp-server-kalshi"],    "env": {      "KALSHI_ENV": "demo",      "KALSHI_API_KEY": "<YOUR KALSHI API KEY>",      "KALSHI_PRIVATE_KEY_PATH": "PATH TO YOUR RSA KEY FILE"    }  }}

Local Development

  1. Create a .env file (see .env-example).
  2. Install deps: uv sync (add --extra dev for dev tools). Requires Python 3.10+.
  3. Run: uv run start.
  4. Test: uv run pytest.

MCP Inspector

bash
npx @modelcontextprotocol/inspector uv --directory /path/to/mcp-server-kalshi run start

Testing & code quality

bash
uv sync --extra dev              # install dev tools (ruff, mypy, pytest, ...)uv run pytest                    # run the test suiteuv run pytest --cov              # tests with a coverage reportuv run ruff check src tests      # lintuv run black src tests           # format (add --check to verify only)uv run mypy                      # type checkuv run pre-commit install        # (once) run ruff + black on every commit

Tests are pure/offline — they exercise the order translation and confirm-gate, the HTTP client (via an injected httpx.MockTransport), the MCP tool registry, config, and PDF extraction, all without touching the live Kalshi API. CI (.github/workflows/ci.yml) runs ruff + black + mypy + pytest across Python 3.10–3.13 on every push/PR, and releases are gated on that same suite.

Authentication

Requests are signed with RSA-PSS (MGF1-SHA256, max salt). Each authenticated request sends KALSHI-ACCESS-KEY, KALSHI-ACCESS-TIMESTAMP, and KALSHI-ACCESS-SIGNATURE, where the signed message is timestamp_ms + METHOD + path (path includes /trade-api/v2, excludes the query string).

來源:README.md,提交 0cadb81

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.2.2最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分