Zerodha Kite Connect MCP
Provides tools for interacting with the Zerodha Kite Connect trading platform via its Python SDK, enabling login/session lifecycle management, order placement/modification/cancellation, portfolio and positions, holdings, market quotes, OHLC/LTP, historical data, margin calculations, GTT, mutual fund orders and SIPs, auction operations, and KiteTicker WebSocket management including connect, subscribe, unsubscribe, mode changes, and tick retrieval.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Zerodha Kite Connect MCPshow my current positions and holdings"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Zerodha Kite Connect MCP
An MCP server that exposes Kite Connect's Python SDK operations as tools. REST methods run in worker threads so synchronous SDK requests do not block the MCP event loop. KiteTicker is controlled through dedicated WebSocket tools.
Setup
Requires Python 3.10 or newer.
cd D:\PRO\Zerodha_MCP
py -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -r requirements.txt
Copy-Item .env.example .envSet KITE_API_KEY and KITE_API_SECRET in .env. The default callback is
http://127.0.0.1:5000/login; set KITE_REDIRECT_URL if the redirect URL
registered in the Kite developer console is different. The URL must match
exactly, including host, port, and path. Keep .env private; it is ignored by
Git.
The MCP starts a Flask loopback callback listener on that URL using the flow in
login.py. Call kite_login to get a Zerodha login link. After sign-in, Kite redirects to /login with a
short-lived request_token; the MCP exchanges it for an access token, updates
the running client, and persists the token to .env. The browser page reports
success without displaying the token. If any authenticated SDK tool gets a Kite
TokenException, it returns an authentication_required result with a fresh
login link. Complete login, then retry the original tool. The direct
generate_session and set_access_token tools also persist refreshed tokens.
Start using stdio:
python server.pyExample MCP client configuration:
{
"mcpServers": {
"zerodha-kite-connect": {
"command": "D:\\PRO\\Zerodha_MCP\\.venv\\Scripts\\python.exe",
"args": ["D:\\PRO\\Zerodha_MCP\\server.py"],
"env": {
"KITE_API_KEY": "your-api-key",
"KITE_API_SECRET": "your-api-secret",
"KITE_REDIRECT_URL": "http://127.0.0.1:5000/login"
}
}
}
}Related MCP server: Trade-MCP
Tools
Every REST SDK method has its own tool name. Its SDK keyword parameters are
passed inside an arguments JSON object. Examples include place_order,
orders, order_history, order_trades, positions, holdings, quote,
ohlc, ltp, instruments, historical_data, margin calculations, GTT,
mutual fund orders and SIPs, session login/token lifecycle, and auction tools.
The exact accepted parameters and values are those of the installed
kiteconnect SDK; Kite Connect's own validation and errors are returned.
The ticker_* tools manage the KiteTicker WebSocket: connect, subscribe,
unsubscribe, set mode, check connection, read recent ticks, resubscribe, stop
retries, stop, and close. Call ticker_connect before subscribing. Recent ticks
are kept in a bounded in-memory buffer (up to 5,000) and retrieved with
ticker_read_ticks.
SQLite audit batching
Every tool invocation is queued in memory, then written with SQLite
executemany from a background worker. The worker flushes at the configured
batch size, after the flush interval for partial batches, and on clean shutdown.
Defaults are 25 calls or 2 seconds, whichever comes first.
Environment variable | Default | Purpose |
|
| SQLite audit database path |
|
| Calls per batch flush |
|
| Max delay for partial batches |
The tool_calls table stores UTC time, tool name, JSON arguments and result,
error text, and duration in milliseconds. Credential fields such as access,
refresh, request, and API secret tokens are redacted. Large JSON values are
truncated to keep the audit database bounded per call. Since batching is
in-memory, an abrupt process termination can lose the pending batch.
Notes
This server sends real requests to the authenticated Kite account. Order placement, modification, cancellation, GTT, and mutual fund tools can cause financial transactions.
The registered redirect URL must be reachable on the same machine running this MCP process. Port 5000 must be free when using the default URL.
Kite redirects with a
request_token, not an access code. The callback exchanges it server-side; the API secret and access token are not shown in the browser response.Ticker and REST methods require an active Kite session. The daily session lifecycle and API permissions are controlled by Zerodha.
This server cannot be deployed
Maintenance
Related MCP Connectors
Open-source MCP server for Zerodha Kite Connect. Portfolio, market data, backtesting, alerts.
MCP server exposing the Backtest360 engine API as tools for AI agents.
- FensoryOAuthcom.fensory
Trading MCP server for AI agents, with live market data, account reads and controlled execution.
Create and manage trading strategies, bots, webhooks and signals from any MCP client.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that integrates with Zerodha APIs for automated trading, providing tools for authentication, market data retrieval, order placement, and portfolio management.MIT
- FlicenseNot gradedqualityDmaintenanceEnables trading automation through Zerodha Kite Connect API, allowing users to place buy/sell orders and fetch holdings via MCP tools accessible to Claude Desktop and other MCP-compatible clients.-
- FlicenseNot gradedqualityDmaintenanceEnables natural language access to Zerodha trading accounts for retrieving portfolio holdings, positions, orders, funds, and real-time market prices. Supports secure authentication for Indian stock market trading operations via Claude, Cursor, and other MCP-compatible AI tools.1-
- AlicenseNot gradedqualityDmaintenanceEnables natural language management of Zerodha trading accounts, including placing orders, checking portfolio, and viewing positions through MCP integration.32Apache 2.0