karthikrajask/Zerodha_MCP_Server
If you are the rightful owner of Zerodha_MCP_Server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
This is a Model Context Protocol (MCP) server in TypeScript that provides trading tools using the Zerodha Kite Connect JavaScript SDK.
Trading MCP Server (Kite Connect)
This is a Model Context Protocol (MCP) server in TypeScript that exposes trading tools using the official Zerodha Kite Connect JavaScript SDK. It enables programmatic trading, order management, and portfolio access via MCP tools.
Features
- Trading Tools: Authenticate, place orders, fetch orders, and view holdings using Kite Connect.
- Connect to Agent Builder: Integrate with the MCP Agent Builder for testing and debugging.
- Debug with MCP Inspector: Use MCP Inspector to interactively test and debug all trading tools.
Getting Started
Prerequisites:
- Node.js
- Zerodha Kite Connect API key and secret
Setup:
- Clone this repository and install dependencies:
npm install npm run build - Copy
.env.exampleto.envand fill in your Kite API credentials:KITE_API_KEY=your_api_key_here KITE_API_SECRET=your_api_secret_here KITE_REDIRECT_URI=http://localhost:3456/kite/callback - Start the MCP server:
npm run dev:http # HTTP transport (for Inspector) npm run dev:stdio # STDIO transport (for Agent Builder)
What's Included
| Folder / File | Contents |
|---|---|
.vscode | VSCode debug configs |
.aitk | AI Toolkit configs |
src | Source code for the trading MCP server |
.env.example | Example environment variable file |
Debugging and Testing
You can debug and test the server using:
- Agent Builder: Connects via STDIO for local tool testing.
- MCP Inspector: Connects via HTTP for interactive tool calls and debugging.
All debugging modes support breakpoints in your tool implementation code.
MCP Tools (Kite Connect)
The following tools are registered and available via MCP:
kite_get_login_url: Returns a login URL for user authentication. Input: optionalredirect_uri.kite_generate_session: Exchanges arequest_tokenfor an access token and session details. Input:request_token.kite_get_orders: Fetches all user orders. Input:access_token.kite_place_order: Places a new order. Inputs:access_token,exchange,tradingsymbol,transaction_type,quantity, optionalorder_type,product,price.kite_get_holdings: Fetches user holdings. Input:access_token.
Example Flow
- Call
kite_get_login_urland open the returned URL in your browser. After login, Zerodha redirects to yourredirect_uriwith arequest_token. - Call
kite_generate_sessionwith therequest_tokento get anaccess_token. - Use the
access_tokeninkite_get_orders,kite_place_order, andkite_get_holdings.
Security Note: Treat access tokens as secrets. For production, store tokens securely and never expose them in logs or client-side code.
Customization
You can change ports and parameters in .vscode/tasks.json, src/index.ts, .aitk/mcp.json, and .inspector.json as needed.
Feedback
If you have feedback or suggestions, please open an issue on the AI Toolkit GitHub repository