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 分