Skip to main content
Glama
anish5256

Zerodha MCP Server

by anish5256

Zerodha MCPサーバー

MCP (Model Context Protocol) を介してZerodha取引口座を照会します。Claude Code、Claude Desktop、Cursor、およびその他のMCP互換AIツールで動作します。

利用可能なツール

ツール

説明

get_account_funds

利用可能な残高と証拠金

get_portfolio_holdings

長期デマット保有銘柄

get_open_positions

損益を含むデイトレード/F&Oポジション

get_todays_orders

今日の注文履歴

get_current_pnl

損益の合計サマリー

get_instrument_ltp

任意の銘柄の最終取引価格 (LTP)

get_instrument_ohlc

任意の銘柄のOHLCデータ

get_pnl_summary

指定期間(最大3ヶ月)の損益サマリー

get_pnl_heatmap

指定期間(最大3ヶ月)の日次損益内訳

Related MCP server: Trade-MCP

インストール

git clone https://github.com/anish5256/zerodha-mcp.git
cd zerodha-mcp
pip install -e .

設定

環境変数

サーバーの認証には以下の環境変数が必要です:

変数

説明

ZERODHA_USER_ID

ZerodhaクライアントID (例: AB1234)

ZERODHA_PASSWORD

Zerodhaログインパスワード

ZERODHA_TOTP_KEY

TOTPシークレットキー (32文字のbase32文字列)

TOTPキーの取得

TOTPシークレットキーは、Google AuthenticatorやAuthyで2要素認証を設定した際に使用した32文字のコードです。例: ABCD1234EFGH5678IJKL9012MNOP3456

保存していない場合は、Zerodha Consoleで2要素認証をリセットして新しいキーを取得してください。


プラットフォーム別のセットアップ

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 = クライアントID

    • ZERODHA_PASSWORD = パスワード

    • ZERODHA_TOTP_KEY = TOTPシークレット


使用例

設定が完了したら、AIアシスタントに以下のように尋ねてください:

  • "現在のポートフォリオの価値は?"

  • "オープンポジションを見せて"

  • "今日の損益は?"

  • "利用可能な資金はいくら?"

  • "RELIANCEのLTPは?"

  • "NIFTY 50のOHLCを取得して"

  • "2024年のF&Oの利益はいくらでしたか?"

  • "先月の日次損益を表示して"

セキュリティに関する注意点

  • 認証情報はMCP設定ファイル内にローカルで保存されます

  • 認証情報はAIモデルには送信されず、サーバー側でのみ使用されます

  • トークンはローカルの zerodha_enctoken.txt および zerodha_console_token.txt にキャッシュされます (gitignored)

  • 各ユーザーは自身のマシン上で個別に認証情報を設定する必要があります

ライセンス

MIT

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables 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
    -
  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables 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.
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables AI models to interact with the Zerodha trading platform for portfolio management, trading, and account operations through natural language.
    3
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables natural language management of Zerodha trading accounts, including placing orders, checking portfolio, and viewing positions through MCP integration.
    32
    Apache 2.0