Zerodha MCP Server
Zerodha MCP 服务器
通过 MCP(模型上下文协议)查询您的 Zerodha 交易账户。适用于 Claude Code、Claude Desktop、Cursor 以及其他兼容 MCP 的 AI 工具。
可用工具
工具 | 描述 |
| 可用余额和保证金 |
| 长期 demat 持仓 |
| 带有盈亏的日内/期货与期权 (F&O) 仓位 |
| 今日订单历史 |
| 综合盈亏摘要 |
| 任何金融工具的最新成交价 |
| 任何金融工具的 OHLC 数据 |
| 指定日期范围(最长 3 个月)的历史盈亏摘要 |
| 指定日期范围(最长 3 个月)的每日盈亏明细 |
Related MCP server: Trade-MCP
安装
git clone https://github.com/anish5256/zerodha-mcp.git
cd zerodha-mcp
pip install -e .配置
环境变量
服务器需要以下环境变量进行身份验证:
变量 | 描述 |
| 您的 Zerodha 客户 ID(例如 |
| 您的 Zerodha 登录密码 |
| 您的 TOTP 密钥(32 字符的 base32 字符串) |
获取您的 TOTP 密钥
您的 TOTP 密钥是您在 Google Authenticator/Authy 中设置双重验证 (2FA) 时使用的 32 位代码。它看起来像这样:ABCD1234EFGH5678IJKL9012MNOP3456
如果您没有保存它,请在 Zerodha Console 中重置 2FA 以获取新的密钥。
各平台设置
Claude Code (CLI)
添加到 ~/.mcp.json:
{
"mcpServers": {
"zerodha": {
"command": "python",
"args": ["/path/to/zerodha-mcp/server.py"],
"env": {
"ZERODHA_USER_ID": "YOUR_USER_ID",
"ZERODHA_PASSWORD": "YOUR_PASSWORD",
"ZERODHA_TOTP_KEY": "YOUR_TOTP_SECRET"
}
}
}
}然后重启 Claude Code。
Claude Desktop (macOS)
编辑 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"zerodha": {
"command": "python",
"args": ["/path/to/zerodha-mcp/server.py"],
"env": {
"ZERODHA_USER_ID": "YOUR_USER_ID",
"ZERODHA_PASSWORD": "YOUR_PASSWORD",
"ZERODHA_TOTP_KEY": "YOUR_TOTP_SECRET"
}
}
}
}然后重启 Claude Desktop。
Claude Desktop (Windows)
编辑 %APPDATA%\Claude\claude_desktop_config.json:
{
"mcpServers": {
"zerodha": {
"command": "python",
"args": ["C:\\path\\to\\zerodha-mcp\\server.py"],
"env": {
"ZERODHA_USER_ID": "YOUR_USER_ID",
"ZERODHA_PASSWORD": "YOUR_PASSWORD",
"ZERODHA_TOTP_KEY": "YOUR_TOTP_SECRET"
}
}
}
}然后重启 Claude Desktop。
Cursor
添加到 Cursor 的 MCP 设置中(Settings > MCP):
{
"zerodha": {
"command": "python",
"args": ["/path/to/zerodha-mcp/server.py"],
"env": {
"ZERODHA_USER_ID": "YOUR_USER_ID",
"ZERODHA_PASSWORD": "YOUR_PASSWORD",
"ZERODHA_TOTP_KEY": "YOUR_TOTP_SECRET"
}
}
}其他 MCP 客户端
对于任何兼容 MCP 的客户端,请配置:
命令:
python参数:
["/path/to/zerodha-mcp/server.py"]环境变量:
ZERODHA_USER_ID= 您的客户 IDZERODHA_PASSWORD= 您的密码ZERODHA_TOTP_KEY= 您的 TOTP 密钥
使用示例
配置完成后,您可以询问您的 AI 助手:
"What's my current portfolio value?" (我当前的投资组合价值是多少?)
"Show me my open positions" (显示我的未平仓位)
"What's my P&L for today?" (我今天的盈亏是多少?)
"How much funds do I have available?" (我有多少可用资金?)
"What's the LTP of RELIANCE?" (RELIANCE 的最新成交价是多少?)
"Get OHLC for NIFTY 50" (获取 NIFTY 50 的 OHLC 数据)
"What was my F&O profit in 2024?" (我 2024 年的期货与期权利润是多少?)
"Show me my daily P&L for last month" (显示我上个月的每日盈亏)
安全说明
您的凭据存储在本地的 MCP 配置文件中
凭据绝不会发送给 AI 模型,仅在服务器端使用
令牌会缓存在本地的
zerodha_enctoken.txt和zerodha_console_token.txt中(已在 gitignore 中忽略)每个用户必须在自己的机器上配置自己的凭据
许可证
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Trade across 22+ exchanges and brokers from any MCP-capable AI agent, no install required.
Open-source MCP server for Zerodha Kite Connect. Portfolio, market data, backtesting, alerts.
Brazilian Open Finance MCP — 30+ banks (Itaú, Nubank, etc.) to Claude/Cursor. Read-only.
Agentic brokerage access to a US brokerage account: quotes, orders, positions, cash and documents.
Related MCP Servers
- 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-
- FlicenseNot gradedqualityCmaintenanceEnables trading automation through Zerodha Kite Connect API, allowing users to place buy/sell orders and fetch holdings via MCP tools accessible to Claude Desktop and other MCP-compatible clients.-
- FlicenseNot gradedqualityDmaintenanceEnables AI models to interact with the Zerodha trading platform for portfolio management, trading, and account operations through natural language.3-
- AlicenseNot gradedqualityDmaintenanceEnables natural language management of Zerodha trading accounts, including placing orders, checking portfolio, and viewing positions through MCP integration.32Apache 2.0