{
  "markdown": "# MCP Server Kalshi\n\n<!-- mcp-name: io.github.9crusher/mcp-server-kalshi -->\n\nAn MCP server that gives Claude Code and other agent harnesses a first-class interface to\n[Kalshi](https://kalshi.com). It is built for end-to-end trading: browse markets, research them, read the *exact* settlement\nrules (including pulling the contract-terms PDFs), and execute trades — all through MCP tools.\n\n## Highlights\n\n- **Discovery** — `list_markets`, `get_market`, `list_events`, `get_event`, `list_series`,\n  `get_series`. (Kalshi has no free-text search; `list_markets` filters are the search.)\n- **Research** — `get_market_orderbook`, `get_market_candlesticks`, `get_market_trades`.\n- **Deep rules** — `get_market_rules` consolidates a market's `rules_primary`/`rules_secondary`,\n  early-close conditions, settlement sources, and series prohibitions; `fetch_rules_pdf`\n  downloads and extracts the text of the actual legal contract PDF so the agent can read it.\n- **Exchange** — `get_exchange_status`, `get_exchange_schedule` (is the market open, and its hours).\n- **Portfolio** — `get_balance`, `get_positions`, `get_fills`, `get_settlements`.\n- **Trading** — `create_order`, `cancel_order`, `amend_order`, `decrease_order`,\n  plus `list_orders` / `get_order`.\n\n### Safety by default\n\n- The server targets Kalshi's **demo (sandbox)** environment unless you explicitly set\n  `KALSHI_ENV=prod`.\n- Order-placing tools (`create_order`, `amend_order`) require `confirm=true`. Without it they\n  return a **preview** — a human-readable summary and the exact payload — and place nothing.\n- Credentials are **optional**: all market/rules tools work unauthenticated. Only portfolio\n  and order tools need an API key + RSA private key.\n\n### Intuitive order model\n\nKalshi's V2 order API quotes everything from the YES leg (`bid`/`ask` in fixed-point dollars).\nThis server exposes the natural model instead — `action` (buy/sell) + `side` (yes/no) + a whole\n**cents** limit price — and translates it (including the buy-NO ⇄ sell-YES price inversion).\n\n## Configuration\n\n| Variable | Default | Purpose |\n|----------|---------|---------|\n| `KALSHI_ENV` | `demo` | `demo` (sandbox) or `prod` (real money). Derives the base URL. |\n| `KALSHI_API_KEY` | _(none)_ | Kalshi API key ID. Required only for authenticated tools. |\n| `KALSHI_PRIVATE_KEY_PATH` | _(none)_ | Path to your RSA private key `.pem`. Required for authenticated tools. |\n| `BASE_URL` | _(derived)_ | Optional explicit REST base override (must include `/trade-api/v2`). |\n\nSee `.env-example`. Get API credentials at\n[docs.kalshi.com/getting_started/api_keys](https://docs.kalshi.com/getting_started/api_keys)\nand a demo account via the\n[demo environment guide](https://docs.kalshi.com/getting_started/test_in_demo).\n\n### Claude Desktop (uvx)\n\n```json\n\"mcpServers\": {\n  \"kalshi\": {\n    \"command\": \"uvx\",\n    \"args\": [\"mcp-server-kalshi\"],\n    \"env\": {\n      \"KALSHI_ENV\": \"demo\",\n      \"KALSHI_API_KEY\": \"<YOUR KALSHI API KEY>\",\n      \"KALSHI_PRIVATE_KEY_PATH\": \"PATH TO YOUR RSA KEY FILE\"\n    }\n  }\n}\n```\n\n### Claude Desktop (Docker)\n\n```json\n\"mcpServers\": {\n  \"kalshi\": {\n    \"command\": \"docker\",\n    \"args\": [\"run\", \"--rm\", \"-i\",\n      \"--mount\", \"type=bind,src=/Users/username,dst=/Users/username\",\n      \"-e\", \"KALSHI_ENV\", \"-e\", \"KALSHI_API_KEY\", \"-e\", \"KALSHI_PRIVATE_KEY_PATH\",\n      \"mcp-server-kalshi\"],\n    \"env\": {\n      \"KALSHI_ENV\": \"demo\",\n      \"KALSHI_API_KEY\": \"<YOUR KALSHI API KEY>\",\n      \"KALSHI_PRIVATE_KEY_PATH\": \"PATH TO YOUR RSA KEY FILE\"\n    }\n  }\n}\n```\n\n## Local Development\n\n1. Create a `.env` file (see `.env-example`).\n2. Install deps: `uv sync` (add `--extra dev` for dev tools). Requires Python 3.10+.\n3. Run: `uv run start`.\n4. Test: `uv run pytest`.\n\n### MCP Inspector\n\n```bash\nnpx @modelcontextprotocol/inspector uv --directory /path/to/mcp-server-kalshi run start\n```\n\n## Testing & code quality\n\n```bash\nuv sync --extra dev              # install dev tools (ruff, mypy, pytest, ...)\nuv run pytest                    # run the test suite\nuv run pytest --cov              # tests with a coverage report\nuv run ruff check src tests      # lint\nuv run black src tests           # format (add --check to verify only)\nuv run mypy                      # type check\nuv run pre-commit install        # (once) run ruff + black on every commit\n```\n\nTests are pure/offline — they exercise the order translation and confirm-gate, the HTTP client\n(via an injected `httpx.MockTransport`), the MCP tool registry, config, and PDF extraction, all\nwithout touching the live Kalshi API. CI (`.github/workflows/ci.yml`) runs ruff + black + mypy +\npytest across Python 3.10–3.13 on every push/PR, and releases are gated on that same suite.\n\n## Authentication\n\nRequests are signed with RSA-PSS (MGF1-SHA256, max salt). Each authenticated request sends\n`KALSHI-ACCESS-KEY`, `KALSHI-ACCESS-TIMESTAMP`, and `KALSHI-ACCESS-SIGNATURE`, where the signed\nmessage is `timestamp_ms + METHOD + path` (path includes `/trade-api/v2`, excludes the query\nstring).\n",
  "bytes": 5001,
  "sha": "7542d5810792a9512b97170f5fcc31b9fe6dc2de5b8e5585be3580cb3aa33e7d",
  "repo_slug": "9crusher/mcp-server-kalshi",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_9crusher_mcp_server_kalshi_287cd1e5/readme"
}