zerodha-mcp-server-aks
v1.0.3
Published
Zerodha Kite Connect MCP Server for AI Assistants
Downloads
766
Readme
Zerodha Kite Connect MCP Server (zerodha-mcp-server-aks)
An Model Context Protocol (MCP) server that connects your AI Assistant (Claude Desktop, Cursor, etc.) directly to the Zerodha Kite Connect API. This enables your AI agent to fetch portfolio details, look up instruments, check funds, and safely place stock orders on your behalf.
[!CAUTION] Trading Safety: Running trading operations via AI assistants carries inherent risks. Always verify your holdings and available margins, and review orders before execution.
Features & Tools
- Profile & Funds: Get account profile info (
get_zerodha_profile) and check margins/available cash (get_zerodha_margins). - Portfolio Tracking: Retrieve current stock holdings (
get_zerodha_hodings) and intraday/derivatives positions (get_zerodha_positions). - Market Data: Look up trading symbols for companies (
get_trading_symbols) and retrieve stock quotes (get_stock_details). - Trading: Place stock orders (BUY/SELL) securely with automated pre-checks for quantity, margins, and ownership (
trade_stocks_on_zerodha).
How It Works
Zerodha's Kite Connect API requires a daily session authentication token which expires every morning.
- You use a web assistant (e.g. hosted on a Cloudflare Worker) to log in to Zerodha and generate your daily
access_token. - You provide the
ZERODHA_API_KEYand the generatedZERODHA_ACCESS_TOKENas environment variables to your AI client. - The AI client runs the MCP server locally in the background using
npx.
Setup Guide
1. Zerodha Developer App
- Go to the Zerodha Developer Console and create an account.
- Create an App (requires a Kite Connect subscription).
- Set the Redirect URL of your app to your hosted token generator URL (e.g.,
https://your-token-generator.workers.dev/).
2. Generate Daily Access Token
- Open your hosted token generator URL in your browser.
- Enter your Zerodha API Key and API Secret (these are saved only in your browser's local storage).
- Click Connect to Zerodha and complete the login.
- When redirected back to your page, click Generate Access Token.
- Copy the generated Access Token.
3. Configure Your AI Client
Claude Desktop
Open your Claude Desktop configuration file:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Add the following block to the mcpServers section:
{
"mcpServers": {
"zerodha-mcp": {
"command": "npx",
"args": ["-y", "zerodha-mcp-server-aks"],
"env": {
"ZERODHA_API_KEY": "YOUR_ZERODHA_API_KEY",
"ZERODHA_ACCESS_TOKEN": "YOUR_GENERATED_DAILY_ACCESS_TOKEN"
}
}
}
}Cursor IDE
- Open Cursor Settings > Features > MCP.
- Click + Add New MCP Server.
- Configure the following fields:
- Name:
zerodha - Type:
command - Command:
npx -y zerodha-mcp-server-aks
- Name:
- Add Environment Variables:
ZERODHA_API_KEY=YOUR_ZERODHA_API_KEYZERODHA_ACCESS_TOKEN=YOUR_GENERATED_DAILY_ACCESS_TOKEN
- Click Save.
License
MIT License. Feel free to fork, customize, and build your own trading agents!
