Zerodha MCP Integration

by aptro
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Enables interaction with Zerodha's trading platform, allowing users to check account margins, view portfolio holdings, manage positions, get quotes, place orders, access historical data, and handle mutual fund operations including holdings, orders, SIPs, and browsing available funds.

Zerodha MCP 集成

该项目使用多云插件 (MCP) 框架将 Zerodha 的交易平台与 Claude AI 集成,使您能够直接通过 Claude 与您的 Zerodha 交易账户进行交互。

设置说明

1.创建 Zerodha 开发者账户

  1. 前往Kite Connect并注册开发者账户
  2. 登录developers.kite.trade上的帐户

2. 创建新应用

  1. 导航到 Kite 开发者信息中心中的“应用程序”部分
  2. 点击“创建新应用”
  3. 填写所需的详细信息:
    • 应用程序名称:选择一个描述性名称(例如,“Claude Zerodha Integration”)
    • 应用类别:选择“个人”或合适的类别
    • 重定向 URL:设置为http://127.0.0.1:5000/zerodha/auth/redirect
    • 描述:简要描述您的应用程序的用途
  4. 提交表单以创建您的应用

3.获取 API 凭证

创建应用程序后,您将收到:

  • API 密钥(也称为消费者密钥)
  • API Secret(也称为消费者机密)

这些凭证将显示在您的应用程序的详细信息页面上。

4.配置环境变量

  1. 在该项目的根目录中创建一个.env文件
  2. 将您的 API 凭据添加到文件中:
KITE_API_KEY=your_api_key_here KITE_API_SECRET=your_api_secret_here

your_api_key_hereyour_api_secret_here替换为步骤 3 中的实际凭证。

5.安装依赖项

确保已安装所有必需的依赖项:

uv pip install kiteconnect fastapi uvicorn python-dotenv httpx

6. 在 Claude 桌面应用上安装 MCP 配置

在您的 Claude 桌面应用程序上安装 MCP 配置:

mcp install main.py

此命令向 Claude 注册 Zerodha 插件,使 AI 可以使用所有交易功能。

用法

设置完成后,您可以使用以下功能通过 Claude 与您的 Zerodha 帐户进行交互:

验证

Can you please check if I'm logged into my Zerodha account and authenticate if needed?

股票和一般交易

  • 检查账户保证金: What are my current margins on Zerodha?
  • 查看投资组合持股: Show me my current holdings on Zerodha
  • 查看当前职位: What positions do I currently have open on Zerodha?
  • 获取符号报价: What's the current price of RELIANCE and INFY on NSE?
  • 下单: Place a buy order for 10 shares of INFY at market price on NSE
  • 获取历史数据: Can you show me the historical price data for SBIN for the last 30 days?

共同基金

  • 查看共同基金持有量: Show me my mutual fund holdings on Zerodha
  • 获取共同基金订单: List all my mutual fund orders on Zerodha
  • 下达共同基金订单: Place a buy order for ₹5000 in the mutual fund with symbol INF090I01239
  • 取消共同基金订单: Cancel my mutual fund order with order ID 123456789
  • 查看 SIP 详细信息: Show all my active SIPs on Zerodha
  • 创建新的 SIP: Set up a monthly SIP of ₹2000 for the fund with symbol INF090I01239 for 12 installments
  • 修改现有 SIP: Change my SIP with ID 987654321 to ₹3000 per month
  • 取消 SIP: Cancel my SIP with ID 987654321
  • 浏览可用的共同基金: Show me a list of available mutual funds on Zerodha

身份验证流程

第一次使用任何 Zerodha 功能时,Claude 将:

  1. 在端口 5000 上启动本地服务器
  2. 打开浏览器窗口进行 Zerodha 登录
  3. 成功登录后,存储访问令牌以供将来会话使用

您的会话将保持活动状态,直到令牌过期(通常为 24 小时)。令牌过期后,Claude 将自动重新启动登录流程。

可用的 MCP 工具

该插件提供了 Claude 可以使用的以下 MCP 工具:

验证

  • check_and_authenticate - 验证身份验证状态并在需要时启动登录
  • initiate_login - 启动 Zerodha 登录流程
  • get_request_token - 登录后检索请求令牌

股票/一般交易

  • get_holdings - 检索投资组合持股
  • get_positions - 获取当前位置
  • get_margins - 检索账户保证金
  • place_order - 下达交易订单
  • get_quote - 获取指定符号的报价
  • get_historical_data - 检索历史价格数据

共同基金

  • get_mf_orders - 检索共同基金订单
  • place_mf_order - 下达共同基金订单
  • cancel_mf_order - 取消共同基金订单
  • get_mf_instruments - 获取可用的共同基金工具
  • get_mf_holdings - 检索共同基金持有量
  • get_mf_sips - 获取活动的 SIP
  • place_mf_sip - 创建一个新的 SIP
  • modify_mf_sip - 修改现有的 SIP
  • cancel_mf_sip - 取消 SIP

故障排除

  • 如果遇到身份验证问题,请尝试删除.tokens文件并重新启动身份验证过程
  • 确保.env文件中的 Zerodha 凭据正确
  • 确保端口 5000 未被其他应用程序使用
  • 对于持续存在的问题,请访问status.zerodha.com检查 Zerodha 的 API 状态

安全说明

  • 您的 Zerodha API 凭据仅存储在本地.env文件中
  • 访问令牌存储在项目目录中的.tokens文件中
  • 不会向 Claude 或任何第三方传输任何凭证
  • 所有身份验证都直接在您和 Zerodha 的服务器之间进行
-
security - not tested
A
license - permissive license
-
quality - not tested

使用多云插件框架将 Zerodha 的交易平台与 Claude AI 集成,允许用户直接通过 Claude 与他们的 Zerodha 交易账户进行股票交易和共同基金操作。

  1. Setup Instructions
    1. 1. Create a Zerodha Developer Account
    2. 2. Create a New App
    3. 3. Get API Credentials
    4. 4. Configure Environment Variables
    5. 5. Install Dependencies
    6. 6. Install MCP config on your Claude desktop app
  2. Usage
    1. Authentication
    2. Stocks and General Trading
    3. Mutual Funds
  3. Authentication Flow
    1. Available MCP Tools
      1. Authentication
      2. Stock/General Trading
      3. Mutual Funds
    2. Troubleshooting
      1. Security Notes
        ID: v1iomvkl4i