loading…
Search for a command to run...
loading…
Enables AI models to interact with the Zerodha trading platform for portfolio management, trading, and account operations through natural language.
Enables AI models to interact with the Zerodha trading platform for portfolio management, trading, and account operations through natural language.
A powerful Model Context Protocol (MCP) server that enables AI models to interact seamlessly with the Zerodha trading platform
| Feature | Description |
|---|---|
| 🔐 Secure Authentication | Robust authentication with Zerodha API using official KiteConnect SDK |
| 📊 Portfolio Management | Real-time access to your complete portfolio holdings and valuations |
| 📈 Position Tracking | Monitor open positions with live P&L calculations |
| 💹 Order Execution | Place buy/sell orders with market/limit options |
| 👤 Profile Access | Retrieve comprehensive user profile and account information |
| 🔄 Real-time Data | Live market data and portfolio updates |
| 🛡️ Type Safety | Built with TypeScript and Zod validation for reliability |
The Model Context Protocol (MCP) is a standardized way for AI models to interact with external systems and APIs. This server acts as a bridge between AI assistants (like Claude) and the Zerodha trading platform, enabling natural language trading operations.
Before you begin, ensure you have:
# Clone the repository
git clone https://github.com/gamandeepsingh/zerodha-claude-mcp.git
# Navigate to the project directory
cd zerodha-claude-mcp
Choose your preferred package manager:
# Using npm
npm install
# Using bun (recommended for better performance)
bun install
# Using yarn
yarn install
Create a .env file in the root directory:
# Copy the example environment file
cp .env.example .env
Add your Zerodha credentials to the .env file:
# Zerodha API Configuration
KITE_API_KEY=your_api_key_here
KITE_SECRET_KEY=your_secret_key_here
REQUEST_TOKEN=your_request_token_here
ACCESS_TOKEN=your_access_token_here
# Optional: Debug mode
DEBUG=false
💡 Pro Tip: You can get your API credentials from the Kite Connect Developer Console
For a containerized setup, you can use Docker to run the MCP server:
Clone the repository:
git clone https://github.com/gamandeepsingh/zerodha-claude-mcp.git
cd zerodha-claude-mcp
Create environment file:
# Create .env file with your credentials
cp .env.example .env
Edit the .env file with your Zerodha credentials:
KITE_API_KEY=your_api_key_here
KITE_SECRET_KEY=your_secret_key_here
REQUEST_TOKEN=your_request_token_here
ACCESS_TOKEN=your_access_token_here
DEBUG=false
Build and run with Docker Compose:
# Build and start the container
docker-compose up --build
# Run in detached mode (background)
docker-compose up -d --build
Stop the container:
docker-compose down
Build the Docker image:
docker build -t zerodha-claude-mcp .
Run the container:
docker run -d \
--name zerodha-mcp \
-e KITE_API_KEY=your_api_key \
-e KITE_SECRET_KEY=your_secret_key \
-e REQUEST_TOKEN=your_request_token \
-e ACCESS_TOKEN=your_access_token \
zerodha-claude-mcp
# View running containers
docker ps
# View logs
docker logs zerodha-mcp
# Stop the container
docker stop zerodha-mcp
# Remove the container
docker rm zerodha-mcp
# Remove the image
docker rmi zerodha-claude-mcp
When using Docker, update your claude_desktop_config.json to point to the containerized version:
{
"mcpServers": {
"zerodha-trading": {
"command": "docker",
"args": ["exec", "-i", "zerodha-mcp", "bun", "run", "index.ts"],
"env": {
"KITE_API_KEY": "your_actual_api_key",
"KITE_SECRET_KEY": "your_actual_secret_key",
"REQUEST_TOKEN": "your_actual_request_token",
"ACCESS_TOKEN": "your_actual_access_token"
}
}
}
}
⚠️ Note: Make sure your Docker container is running before starting Claude Desktop when using this configuration.
api_key and api_secret.env file# Step 1: Get the login URL
curl "https://kite.trade/connect/login?api_key=your_api_key&v=3"
# Step 2: After login, extract request_token from redirect URL
# Step 3: Generate access_token using the request_token
To integrate this MCP server with Claude Desktop, follow these steps:
Find your claude_desktop_config.json file:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.jsonAdd the following to your claude_desktop_config.json:
{
"mcpServers": {
"zerodha-trading": {
"command": "bun",
"args": ["run", "/absolute/path/to/your/index.ts"],
"env": {
"KITE_API_KEY": "your_actual_api_key",
"KITE_SECRET_KEY": "your_actual_secret_key",
"REQUEST_TOKEN": "your_actual_request_token",
"ACCESS_TOKEN": "your_actual_access_token"
}
}
}
}
After saving the configuration, restart Claude Desktop to load the MCP server.
If you prefer Node.js over Bun:
{
"mcpServers": {
"zerodha-trading": {
"command": "node",
"args": ["--loader", "ts-node/esm", "/absolute/path/to/your/index.ts"],
"env": {
"KITE_API_KEY": "your_actual_api_key",
"KITE_SECRET_KEY": "your_actual_secret_key",
"REQUEST_TOKEN": "your_actual_request_token",
"ACCESS_TOKEN": "your_actual_access_token"
}
}
}
}
⚠️ Important:
- Replace
/absolute/path/to/your/index.tswith the actual path to your project- Use your real Zerodha API credentials
- Ensure the path uses forward slashes even on Windows
The MCP server exposes the following tools for AI interaction:
get-profileRetrieves comprehensive user profile information.
// Usage in Claude
"Can you show me my Zerodha profile?"
// Returns
{
user_id: string,
user_name: string,
email: string,
user_type: string,
broker: string,
// ... additional profile data
}
show-portfolioDisplays complete portfolio holdings with current valuations.
// Usage in Claude
"What's in my portfolio right now?"
// Returns detailed holdings with:
// - Stock symbols and quantities
// - Current market prices
// - P&L calculations
// - Total portfolio value
show-positionsShows all open positions with live P&L.
// Usage in Claude
"Show me my current trading positions"
// Returns active positions with:
// - Entry prices and quantities
// - Current market prices
// - Unrealized P&L
// - Position status
buy-stockPlaces a buy order for specified stock and quantity.
// Parameters
{
stock: string, // Stock symbol (e.g., "RELIANCE", "TCS")
quantity: number // Number of shares to buy
}
// Usage in Claude
"Buy 10 shares of RELIANCE"
"Purchase 50 TCS stocks"
sell-stockPlaces a sell order for specified stock and quantity.
// Parameters
{
stock: string, // Stock symbol (e.g., "RELIANCE", "TCS")
quantity: number // Number of shares to sell
}
// Usage in Claude
"Sell 5 shares of HDFC Bank"
"Exit my position in Infosys"
Here are some natural language examples you can use with Claude:
🗣️ "What's my current portfolio value?"
🗣️ "Buy 25 shares of ITC"
🗣️ "Show me all my losing positions"
🗣️ "What's my profile information?"
🗣️ "Sell half of my Wipro holdings"
| Technology | Purpose | Version |
|---|---|---|
| TypeScript | Type-safe development | ^5.0.0 |
| KiteConnect | Zerodha API integration | Latest |
| MCP SDK | Model Context Protocol | Latest |
| Zod | Runtime type validation | ^3.0.0 |
| Bun | Fast runtime & package manager | ^1.0.0 |
zerodha-claude-mcp/
├── 📄 index.ts # MCP server entry point
├── 📄 trade.ts # Trading logic and API calls
├── 📄 package.json # Dependencies and scripts
├── 📄 tsconfig.json # TypeScript configuration
├── 📄 .env # Environment variables
├── 📄 README.md # Documentation
├── 📄 bun.lock # Lock file
├── 🐳 Dockerfile # Docker image configuration
├── 🐳 docker-compose.yml # Docker Compose setup
└── 📄 .dockerignore # Docker ignore rules
Clone and setup (if not already done):
git clone https://github.com/gamandeepsingh/zerodha-claude-mcp.git
cd zerodha-claude-mcp
bun install
Start development server:
# Development mode with auto-reload
bun run dev
# Production mode
bun run start
Run tests (if available):
bun test
To add new trading tools:
Enable debug mode by setting DEBUG=true in your .env file:
DEBUG=true
This will provide detailed logging of API calls and responses.
We welcome contributions! Here's how you can help:
git checkout -b feature/amazing-featuregit commit -m 'Add amazing feature'git push origin feature/amazing-featureThis project is licensed under the MIT License - see the LICENSE file for full details.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software...
IMPORTANT: This project is for educational and development purposes only.
Made with ❤️ for the trading community
⭐ Star this repo if you find it useful! | 🍴 Fork it to customize for your needs
Выполни в терминале:
claude mcp add zerodha-claude-mcp -- npx Web content fetching and conversion for efficient LLM usage.
Retrieval from AWS Knowledge Base using Bedrock Agent Runtime.
автор: modelcontextprotocolProvides auto-configuration for setting up an MCP server in Spring Boot applications.
A very streamlined mcp client that supports calling and monitoring stdio/sse/streamableHttp, and can also view request responses through the /logs page. It also
автор: xuzexin-hzНе уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории ai