KiteMCP is a command-based Zerodha trading system built using the KiteConnect API, Bun, and the Model Context Protocol (MCP). It allows real-time stock buy/sell operations through MCP command calls from a local server, currently integrated with Claude or any compatible tool interface.
- 🔄 Buy and sell stocks programmatically via commands
- 🛠 Modular MCP tool structure (
buy-stock,sell-stock) - 🔐 Secure API key handling via
.env - ✅ Schema validation using Zod
- ⚙️ Fast runtime with Bun and TypeScript
- 🧪 Local test environment with log outputs
git clone https://github.com/your-username/zerodha-trade
cd zerodha-tradebun installCreate a .env file in the root:
KITE_API_KEY=your_api_key
KITE_API_SECRET=your_api_secret
ACCESS_TOKEN=your_access_tokenbun index.tsSend the following JSON to the server via terminal or Claude:
{
"id": "1",
"action": "call_tool",
"tool": "buy-stock",
"arguments": {
"symbol": "RELIANCE",
"exchange": "NSE",
"quantity": 10,
"price": 2800
}
}All tool inputs are validated using Zod for:
- Required fields:
symbol,exchange,quantity - Type and range checks
- Custom error messages on invalid input
{
"status": "success",
"message": "Buy order placed for RELIANCE at ₹2800"
}- Do not expose your
.envfile in production - Add rate limiting and request authentication if going public
- Store order logs securely
- 🌐 Deploy on cloud with webhook interface
- 📊 Add portfolio view and PnL tracking
- 🔔 Telegram/email alerts for order confirmations
- 🧠 Auto-trading with strategy modules
Utkarsh Agarwal
GitHub • LinkedIn
MIT License © 2025 Utkarsh Agarwal

