kite-mcp
Provides a comprehensive set of tools for trading Indian stocks through the Zerodha Kite API, including automated login via TOTP, order placement and modification, portfolio holding and position tracking, and access to live market quotes and historical candle data.
MCP server for Zerodha Kite -- trade Indian stocks through natural conversation with any MCP-compatible AI assistant.
Why an MCP server instead of a Python library?
Traditional Kite wrappers require you to write Python code to trade. With kite-mcp, you just talk:
You: "Buy 50 Reliance at market price"
Assistant: checks quote, verifies funds, asks for confirmation, places order
You: "How's my portfolio doing?"
Assistant: fetches holdings, calculates P&L, summarizes gainers and losers
You: "Set a stop-loss on my HAL position at 3400"
Assistant: places a GTT trigger for youNo code. No scripts. No terminal. Just conversation.
kite-mcp connects any MCP-compatible AI assistant directly to your Zerodha account with 14 trading tools, automated TOTP login, and auto-retry on expired tokens.
Related MCP server: Zerodha MCP Server
How it works
You (natural language) --> AI Assistant --> kite-mcp (MCP server) --> Zerodha Kite APIYour AI assistant interprets your intent, maps stock names to symbols (e.g., "Infosys" to NSE:INFY), checks your funds, and executes trades -- all through the MCP protocol. The server handles authentication automatically, including daily token refresh via TOTP.
Features
14 tools for complete trading control:
Tool | Description |
| Auto-authenticate with TOTP |
| Portfolio holdings with P&L |
| Today's intraday/delivery positions |
| Today's order history |
| Available funds and margins |
| Live market quotes |
| Open, high, low, close data |
| Historical candle data (minute to daily) |
| Search tradeable instruments across NSE, BSE, NFO, MCX |
| Place buy/sell orders (market, limit, stop-loss) |
| Modify pending orders |
| Cancel pending orders |
| View Good Till Triggered orders |
| Place GTT single or OCO (stoploss + target) triggers |
Key capabilities:
Fully automated login -- TOTP generated on the fly, no manual intervention
Auto-retry on stale tokens -- re-authenticates transparently if a token expires mid-session
Supports delivery (CNC), intraday (MIS), and F&O (NRML) orders
After-market orders (AMO) supported
Compatible with
Works with any MCP-compatible client, including:
Client | Platform |
macOS, Windows | |
Terminal (macOS, Linux, Windows) | |
macOS, Windows, Linux | |
macOS, Windows, Linux | |
VS Code, JetBrains | |
Any MCP-compatible client | See MCP clients list |
Quick Start
1. Install
pip install kite-mcp2. Get your credentials
You need a Kite Connect API app. From your app dashboard, note your API Key and API Secret.
You also need:
User ID -- your Zerodha client ID (e.g., AB1234)
Password -- your Zerodha login password
TOTP Secret (recommended) -- the base32 seed from setting up an external authenticator app for Zerodha 2FA. This enables fully automated login with no manual steps.
Log in to console.zerodha.com
Go to My Profile > Security > 2FA Settings
Switch to an external authenticator app (Google Authenticator, Authy, etc.)
When the QR code appears, look for a "Can't scan? Copy this key" link
That key is your TOTP secret -- save it before completing setup
Enter the 6-digit code from your authenticator to finish
3. Configure your MCP client
Add this to your MCP client configuration. The config location depends on your client -- refer to your client's documentation for the exact path.
{
"mcpServers": {
"kite": {
"command": "kite-mcp",
"env": {
"KITE_API_KEY": "your-api-key",
"KITE_API_SECRET": "your-api-secret",
"KITE_USER_ID": "your-user-id",
"KITE_PASSWORD": "your-password",
"KITE_TOTP_SECRET": "your-totp-secret"
}
}
}
}Restart your MCP client. You're ready to trade.
4. Try it out
Open a new chat and try:
"Show my portfolio holdings"
"What's Tata Motors trading at?"
"Buy 10 Infosys at market price"
"How much cash do I have available?"
"Cancel my last pending order"
"Show my top gainers and losers"
The AI assistant understands stock names in plain English -- no need to use trading symbols.
Environment Variables
Variable | Required | Description |
| Yes | Kite Connect API key |
| Yes | Kite Connect API secret |
| Yes | Zerodha client ID |
| Yes | Zerodha login password |
| No | TOTP base32 seed for auto-login. Without this, you must run |
Manual Login
If you don't have a TOTP secret, you can log in manually each day:
export KITE_API_KEY=your-api-key
export KITE_API_SECRET=your-api-secret
export KITE_USER_ID=your-user-id
export KITE_PASSWORD=your-password
kite-mcp-loginThis caches the access token for the rest of the day. The MCP server will use the cached token until it expires.
Use Cases
Daily portfolio monitoring -- "Give me a summary of my portfolio with top gainers and losers"
Quick trades -- "Buy 50 Reliance" / "Sell all my Yes Bank"
Research + action -- "What's the 52-week high of HDFC Bank? Should I add more at current levels?"
Risk management -- "Set a stop-loss GTT on my BDL position at 1100"
Scheduled reports -- Combine with MCP scheduled tasks to get a daily portfolio summary at 9am
Slack integration -- Pair with Slack MCP to receive portfolio alerts in your Slack channel
Roadmap
Option chain data for F&O traders
Basket orders -- place multiple orders in one command
Mutual fund tools -- buy, redeem, check SIPs
Watchlist management
Portfolio analytics -- sector allocation, diversification score
Webhook/streaming support for real-time price alerts
Support for multiple Zerodha accounts
Have an idea? Open a feature request.
Development
git clone https://github.com/aranjan/kite-mcp.git
cd kite-mcp
python -m venv venv
source venv/bin/activate
pip install -e .Security
Credentials are passed via environment variables -- never stored in code
Access tokens are cached locally at
~/.zerodha_kite_token.jsonand expire dailyThe server runs locally on your machine -- no data is sent to third-party servers
All communication with Zerodha uses HTTPS
License
MIT
Available Tools
14 toolscancel_orderCDestructive
Cancel a pending order.
Inputs: order_id (required), variety. Returns: result
get_gtt_triggersARead-only
Get all active GTT (Good Till Triggered) triggers.
Inputs: no named parameters. Returns: result
get_historical_dataBRead-only
Get historical candle data for an instrument. Interval can be: minute, day, 3minute, 5minute, 10minute, 15minute, 30minute, 60minute.
Inputs: instrument_token (required), from_date (required), to_date (required), interval (required). Returns: result
get_holdingsARead-only
Get all holdings in the portfolio with quantity, average price, last price, and P&L.
Inputs: no named parameters. Returns: result
get_instrumentsARead-only
Get list of tradeable instruments for an exchange. Use to find instrument_token for historical data. Exchange: NSE, BSE, NFO, BFO, CDS, MCX.
Inputs: exchange (required), search. Returns: result
get_marginsARead-only
Get account margins/funds available for trading (equity and commodity segments).
Inputs: no named parameters. Returns: result
get_ohlcARead-only
Get OHLC (open, high, low, close) and last price for instruments. Falls back to holdings/positions data if the market data API is not available.
Inputs: instruments (required). Returns: result
get_ordersARead-only
Get all orders placed today.
Inputs: no named parameters. Returns: result
get_positionsARead-only
Get current day's positions (both day and net).
Inputs: no named parameters. Returns: result
get_quoteARead-only
Get live market quote for one or more instruments. Use NSE: prefix for stocks (e.g., NSE:RELIANCE, NSE:INFY). Falls back to holdings/positions data if the market data API is not available.
Inputs: instruments (required). Returns: result
kite_loginA
Authenticate with Zerodha Kite. Auto-generates TOTP and logs in. Call this if other tools fail with auth errors.
Inputs: no named parameters. Returns: result
modify_orderC
Modify a pending order.
Inputs: order_id (required), quantity, price, order_type, +2 more. Returns: result
place_gttC
Place a GTT (Good Till Triggered) order. Supports single and two-leg (OCO) triggers.
Inputs: trigger_type (required), tradingsymbol (required), exchange (required), trigger_values (required), +2 more. Returns: result
place_orderB
Place a buy or sell order. Returns order ID on success. Use variety='regular' for normal orders, 'amo' for after-market orders.
Inputs: tradingsymbol (required), exchange (required), transaction_type (required), quantity (required), +5 more. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 14 tools
Each tool targets a distinct action or data type (orders, holdings, quotes, etc.). The few tools with overlapping data (get_quote vs get_ohlc) have clear differences in what they return and when to use them, preventing confusion.
All tools follow a consistent verb_noun pattern in snake_case (e.g., cancel_order, get_holdings, place_gtt). Even kite_login uses the same convention with a prefix, maintaining uniformity.
With 14 tools, the server covers the essential operations for a trading platform without being overwhelming. Each tool serves a clear purpose and contributes to a complete workflow.
Covers core trading lifecycle: authentication, order placement (regular, GTT, AMO), modification, cancellation, and retrieval of orders, positions, holdings, and market data. Minor gaps like missing bracket orders or trade history, but the surface is robust for typical use.
Maintenance
Related MCP Connectors
Indian broker accounts for AI agents: positions, holdings, orders, P&L, option chains, 10+ brokers.
Trade, monitor portfolios, and build Coinrule strategies by chat.
Connect brokerage accounts to AI assistants: holdings, orders, asset lookup, and approved trading.
Live stock quotes, a stock screener, crypto prices and FX rates as agent tools.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAn automated trading bot that interfaces with Zerodha to execute stock trades, manage positions, and access market information through natural language commands.1-
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with the Zerodha trading platform for placing stock orders, viewing portfolio holdings, and managing mutual fund investments. Provides secure OAuth authentication and real-time trading capabilities through Zerodha's official API.1-
- AlicenseNot gradedqualityDmaintenanceEnables trading operations on Zerodha platform through natural language, supporting account management, order placement/modification, portfolio holdings, positions, margins, and stock news retrieval.Apache 2.0
- AlicenseBqualityDmaintenanceEnables trading and portfolio management on Zerodha Kite Connect through natural language. Supports placing orders, viewing positions/holdings, accessing real-time market data, and managing GTT orders.24MIT