Skip to main content

kite-connect-mcp

CI PyPI Licence: MIT

A self-hostable Model Context Protocol server for the Zerodha Kite Connect v3 API. Run it on your own machine or server with your own Kite Connect app, and let an AI assistant read your account, market data and orders. Every write is a dry run by default. Optionally, it also records every change to your orders and hands it to programs you choose (order events).

Status: beta (0.x). Every Kite Connect v3 capability is covered and tested offline against a fake Kite. The read tools, the margin and charge calculators and the ticker have also been checked against the live API; live writes (orders, GTTs, alerts, mutual funds) have not, so expect rough edges there and report them. Changes are listed in CHANGELOG.md. This project is not affiliated with or endorsed by Zerodha.

Why another Kite MCP server?

Zerodha publishes an official server (zerodha/kite-mcp-server) and hosts it at mcp.kite.trade. This project differs in three ways:

  • It covers the whole paid Kite Connect API. That includes alerts, GTTs, order and basket margins, charges, position conversion, holdings authorisation, auctions, mutual funds and the WebSocket ticker.
  • It's built for one person self-hosting. The daily token is persisted and shared by every client you connect.
  • It has a safety layer for orders: dry runs, two-step confirmation, value caps, allow-lists, a kill switch, an audit log and rate limiting.

The full evaluation and reasoning are in docs/DECISION.md.

What you need

  • A Zerodha account, and a Kite Connect app from the developer console.
    • Connect (paid, ₹500/month per API key) includes live quotes, the WebSocket and historical candles.
    • Personal (free) covers orders, GTTs, alerts, portfolio and margins, but no market data. Market-data tools return a clear "needs the paid plan" error.
  • Python 3.11+ (or Docker).
  • To place live orders: the order requests must come from a static IP registered in the developer console. This is a SEBI/NSE rule, in force since April 2026. Reads work from any IP.

The developer-console steps are in docs/KITE_SETUP.md: creating the app, the API key and secret, the redirect and postback URLs, the subscription, and the static IP.

Quick start (local, stdio)

# install
uv tool install kite-connect-mcp        # or: pipx install kite-connect-mcp  /  pip install kite-connect-mcp
# or run without installing:  uvx kite-connect-mcp --help
# or the image:               docker pull ghcr.io/techfreakworm/kite-connect-mcp

# configure: credentials from env vars or files (mode 600)
export KITE_API_KEY=your_api_key
export KITE_API_SECRET_FILE=~/.config/kite-connect-mcp/api_secret

kite-connect-mcp check-config   # validates settings, never prints credentials
kite-connect-mcp login --listen # prints the Kite login link and waits for the redirect (managed mode)
kite-connect-mcp status         # session and safety status

For login --listen, register http://127.0.0.1:8765/callback as your app's redirect URL. Every setting is listed in docs/CONFIGURATION.md.

Add it to an MCP client, e.g. Claude Desktop (claude_desktop_config.json) or any client that launches stdio servers:

{
  "mcpServers": {
    "kite": {
      "command": "kite-connect-mcp",
      "args": ["serve"],
      "env": { "KITE_API_KEY": "your_api_key", "KITE_API_SECRET_FILE": "/home/you/.config/kite-connect-mcp/api_secret" }
    }
  }
}

To run it on a server over HTTP, see docs/SELF_HOSTING.md. It covers systemd and Docker, a reverse proxy with TLS, bearer-token auth, and the login callback.

The safety model, in short

Guard Default
Every write tool takes dry_run true: validate, run the checks, preview the exact request and Kite's margin calculation; send nothing
Live trading switch off (KITE_MCP_TRADING_MODE=dry_run)
Confirmation a live write needs the single-use confirmation_token from a dry run of the identical call (or, if you opt in, an explicitly allow-listed instrument)
Value caps ₹10,000 per order, ₹50,000 per day, 20 live orders per day
Allow-lists instruments, exchanges, products, varieties, order types, sides (all optional)
Read-only mode KITE_MCP_READ_ONLY=true hides every write tool, and the HTTP client refuses write endpoints too
Kill switch a file; a tool can switch it on, only a person can switch it off
Audit log every dry run, refusal, live send and result, as JSON lines; the intent is fsynced before sending
Rate limits kept under Kite's 1/s (quotes), 3/s (historical), 10/s (orders and the rest), 400 orders/min
Retries reads back off and retry; writes are never retried. A timeout is reported as an unknown outcome: check the order book before trying again

Details: docs/SAFETY.md.

Sessions and the daily login

Kite access tokens expire every day at about 06:00 IST. A request token is single-use. Logging in again with the same API key invalidates the previous access token. So one app should have exactly one program that owns the daily login.

  • managed mode (default). This server owns the login. The login tool (or kite-connect-mcp login) gives you the link. Kite redirects to this server's /callback, which checks the one-time state, exchanges the request_token, and stores the token with mode 600.
  • external mode. Another program owns the login and writes a token file. This server only reads that file, picks up the new token every morning without a restart, and never writes, deletes or logs out that token.

Order events

Optional, and off by default. With KITE_MCP_EVENTS=true on an HTTP server, kite-connect-mcp records each change to your orders (placed, partly filled, modified, filled, cancelled, rejected) and hands it to commands you choose: a notification on your phone, a trading journal, an automation.

  • Postbacks are a doorbell. A verified postback makes the server read the order back from Kite, and it records Kite's answer, never the postback.
  • A poll of the order book, every minute from 09:00 to 16:00 IST on weekdays by default, catches a lost postback and the orders placed outside your API key (on Kite's web site or app, or by another program; a GTT's order too, if Kite sends no postback for it).
  • Each event is stored in SQLite, then delivered to your commands as JSON on standard input, with retries. get_order_events and get_event_status read the store; kite-connect-mcp events status shows its health.
  • It only reads. Nothing in it can place, modify or cancel an order.

Example consumers (Telegram, a JSON-lines log, a webhook) are in examples/; the whole story is in docs/EVENTS.md.

Tools

60 tools in 12 toolsets (53 by default: the mutual-fund writes are opt-in, and the two events tools need an event store). Tool names follow the official server where one exists, so prompts carry over. Pick toolsets with KITE_MCP_TOOLSETS and hide single tools with KITE_MCP_EXCLUDED_TOOLS; kite-connect-mcp tools lists what your configuration exposes.

Toolset Tools
session session_status, login, complete_login, logout
account get_profile, get_margins
orders place_order, modify_order, cancel_order, get_orders, get_order_history, get_trades, get_order_trades
gtt get_gtts, get_gtt, place_gtt_order, modify_gtt_order, delete_gtt_order
alerts get_alerts, get_alert, get_alert_history, create_alert (simple and ATO), modify_alert, delete_alerts
portfolio get_holdings, get_positions, get_auctions, convert_position, authorise_holdings
market get_quotes, get_ohlc, get_ltp, get_historical_data, search_instruments, get_instrument, get_instruments_status, refresh_instruments
margins get_order_margins, get_basket_margins, get_order_charges
mf get_mf_holdings, get_mf_orders, get_mf_sips, search_mf_instruments; opt-in: place_mf_order, cancel_mf_order, place_mf_sip, modify_mf_sip, cancel_mf_sip
ticker ticker_subscribe, ticker_unsubscribe, ticker_get_ticks, ticker_status, ticker_order_updates, ticker_stop
events get_order_events, get_event_status (with an event store: KITE_MCP_EVENTS=true, or KITE_MCP_EVENTS_DB)
safety get_safety_status, get_audit_log, engage_kill_switch

Every argument of every tool is in docs/TOOLS.md.

Development

git clone https://github.com/techfreakworm/kite-connect-mcp && cd kite-connect-mcp
python -m venv .venv && .venv/bin/pip install -e ".[dev]"
.venv/bin/pytest            # never touches the network: Kite is faked in-process
.venv/bin/ruff check . && .venv/bin/ruff format --check .

See CONTRIBUTING.md. Security reports: SECURITY.md.

Disclaimer

Trading involves risk. This software can place real orders on a real brokerage account when you configure it to. AI systems are unpredictable: keep the caps low, use dry runs, and review what you confirm. The software is provided "as is", without warranty of any kind (see LICENSE). You are responsible for complying with Zerodha's terms, SEBI's rules (including the static-IP and algo rules) and exchange data policies. Kite Connect data may not be redistributed.

Licence

MIT © 2026 Mayank Gupta

Metadata

Release files for kite-connect-mcp 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kite-connect-mcp 0.2.0
File Size Uploaded Provenance Actions
kite_connect_mcp-0.2.0.tar.gz 453.9 kB With provenance Details for kite_connect_mcp-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kite-connect-mcp 0.2.0
File Interpreter ABI Platform Actions
kite_connect_mcp-0.2.0-py3-none-any.whl Python 3 none any Details for kite_connect_mcp-0.2.0-py3-none-any.whl

Total release size: 679.6 kB

Release files / kite_connect_mcp-0.2.0.tar.gz

Download URL kite_connect_mcp-0.2.0.tar.gz
Size 453.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b0e46e2dbe0ac99b47c84fc289ae4ef0342525fe1d5ceeac4ff073e3c16410d7
BLAKE2b-256 checksum
How to use checksums
b40db6b57e07be715916cd6f477d25b151557a1d59d8d6de418d8d0c6482abef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Release files / kite_connect_mcp-0.2.0-py3-none-any.whl

Download URL kite_connect_mcp-0.2.0-py3-none-any.whl
Size 225.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4afdccf906c642299456b90cfab66591d74478f4b4fa5ef125071ef21ef4118b
BLAKE2b-256 checksum
How to use checksums
d0af44c1432410ed93c9ae45e0b559f137778e314a750ddbd9f51b8e0ebd23d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Security for kite-connect-mcp 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for kite_connect_mcp-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page