Skip to main content
Glama
Kite MCP Server

Kite MCP Server

Kite MCP Server + OneApp Portfolio Manager

This repository contains two integrated systems:

  1. Kite MCP Server: A Model Context Protocol (MCP) server for Zerodha Kite Connect trading APIs

  2. OneApp Portfolio Manager: A multi-account portfolio management web application with XIRR tracking

๐Ÿš€ Quick Start - MCP | ๐Ÿ“– MCP Usage Examples | ๐ŸŽฏ Portfolio App Guide | ๐Ÿ“Š Project Status


๐ŸŽ‰ NEW: OneApp Portfolio Manager

A comprehensive portfolio management system for tracking multiple Zerodha accounts with historical data import and XIRR calculations.

Features

  • ๐Ÿ“Š Multi-Account Support: Manage 3+ Zerodha accounts in one place

  • ๐Ÿ“ฅ CSV Import: Upload Tradebook and Ledger data (5+ years)

  • ๐Ÿ’ฐ XIRR Tracking: Calculate annualized returns at portfolio and stock level

  • ๐Ÿ”„ Consolidated & Individual Views: Toggle between all accounts or specific ones

  • ๐Ÿ“ˆ Holdings Analysis: Detailed P&L and performance metrics per stock

  • ๐ŸŽจ Modern UI: Clean, responsive interface with data privacy toggle

Quick Start (Portfolio App)

# Start DDEV environment
ddev start

# Access the application
open https://oneapp.ddev.site

For detailed setup instructions: See GETTING_STARTED.md

Complete implementation details: See PROJECT_STATUS.md


Related MCP server: kite-mcp

Kite MCP Server

Features

  • ๐Ÿ” Authentication: Secure login flow with API key and access token management

  • ๐Ÿ“Š Market Data: Real-time quotes, OHLC, LTP, and historical data

  • ๐Ÿ“ˆ Trading: Place, modify, and cancel orders (Regular, AMO, CO, Iceberg, Auction)

  • ๐Ÿ’ผ Portfolio: View holdings, positions, and mutual fund holdings

  • ๐ŸŽฏ GTT Orders: Place and manage Good Till Triggered orders

  • ๐Ÿ” Instrument Search: Search and filter trading instruments

  • ๐Ÿ“‰ Order Management: Track order history and trades

Installation

Prerequisites

Setup

  1. Clone this repository:

git clone <repository-url>
cd oneapp
  1. Install dependencies:

npm install
  1. Build the project:

npm run build
  1. Test the installation:

npm test

You should see: "โœ… SUCCESS! MCP Server started correctly."

Configuration

For Claude Desktop

Add the following to your Claude Desktop configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "kite": {
      "command": "node",
      "args": ["/absolute/path/to/oneapp/dist/index.js"]
    }
  }
}

For Other MCP Clients

Configure your MCP client to run:

node /path/to/oneapp/dist/index.js

Usage

1. Authentication

First, authenticate with Kite Connect:

Use the login tool with your API key and API secret

The server will return a login URL. Click on it to authorize the application. After authorization, you'll be redirected to a URL containing a request_token parameter.

Use the generate_session tool with the request_token

This will complete the authentication process and store your access token locally in ~/.kite-mcp-credentials.json.

2. Available Tools

Once authenticated, you can use any of the following tools:

Profile & Account

  • get_profile: Get user profile information

  • get_margins: Get account margin details

Trading

  • place_order: Place a new order

  • modify_order: Modify an existing order

  • cancel_order: Cancel an order

  • get_orders: Get all orders

  • get_order_history: Get order history for a specific order

  • get_order_trades: Get trades for a specific order

Portfolio

  • get_positions: Get current positions

  • get_holdings: Get holdings

  • get_mf_holdings: Get mutual fund holdings

  • get_trades: Get trade history

Market Data

  • search_instruments: Search for trading instruments

  • get_quotes: Get detailed quotes for instruments

  • get_ohlc: Get OHLC data

  • get_ltp: Get last traded price

  • get_historical_data: Get historical candle data

GTT Orders

  • place_gtt_order: Place a GTT order

  • modify_gtt_order: Modify a GTT order

  • delete_gtt_order: Delete a GTT order

  • get_gtts: Get all active GTT orders

Example Conversations

Example 1: Check Profile and Margins

User: What's my profile information?
Assistant: [Uses get_profile tool]

User: How much margin do I have?
Assistant: [Uses get_margins tool]

Example 2: Place a Market Order

User: Buy 10 shares of INFY at market price
Assistant: [Uses place_order tool with parameters:
  - variety: "regular"
  - exchange: "NSE"
  - tradingsymbol: "INFY"
  - transaction_type: "BUY"
  - quantity: 10
  - product: "CNC"
  - order_type: "MARKET"
]

Example 3: Get Market Data

User: What's the current price of Reliance?
Assistant: [Uses search_instruments to find the instrument, then get_ltp]

User: Show me the OHLC data for TCS
Assistant: [Uses get_ohlc tool with instruments: ["NSE:TCS"]]

Example 4: View Positions

User: What positions do I have open?
Assistant: [Uses get_positions tool]

User: Show me my holdings
Assistant: [Uses get_holdings tool]

Security

  • Credentials Storage: API keys and access tokens are stored locally in ~/.kite-mcp-credentials.json

  • Never commit credentials: The .gitignore file is configured to exclude credentials

  • API Security: Follow Zerodha's security best practices for API usage

Development

Build

npm run build

Watch Mode

npm run dev

Project Structure

oneapp/                   # Root project directory
โ”œโ”€โ”€ equity/               # Next.js portfolio management app
โ”‚   โ”œโ”€โ”€ app/              # Next.js app directory
โ”‚   โ”œโ”€โ”€ lib/              # Library files
โ”‚   โ”œโ”€โ”€ components/       # React components
โ”‚   โ””โ”€โ”€ package.json      # Next.js app dependencies
โ”œโ”€โ”€ src/                  # MCP server source code
โ”‚   โ”œโ”€โ”€ index.ts          # Main MCP server implementation
โ”‚   โ””โ”€โ”€ config.ts         # Configuration helpers
โ”œโ”€โ”€ dist/                 # Compiled JavaScript (generated, gitignored)
โ”œโ”€โ”€ .ddev/                # DDEV configuration
โ”œโ”€โ”€ docs/                 # Documentation
โ”œโ”€โ”€ documentation/        # Additional documentation
โ”œโ”€โ”€ package.json          # MCP server dependencies
โ”œโ”€โ”€ tsconfig.json         # TypeScript configuration
โ””โ”€โ”€ README.md

API Reference

This server wraps the official kiteconnectjs library. For detailed API documentation, refer to:

Troubleshooting

"Not authenticated" Error

If you see this error, you need to authenticate:

  1. Call the login tool with your API key and secret

  2. Follow the login URL

  3. Call generate_session with the request token

Session Expired

Kite Connect access tokens are valid for the entire trading day. If your session expires:

  1. Get a new request token by visiting the login URL

  2. Call generate_session with the new request token

API Rate Limits

Kite Connect has rate limits:

  • 3 requests per second

  • Some endpoints have specific limits

The server does not implement rate limiting, so be mindful of your request frequency.

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Disclaimer

This is an unofficial MCP server for Kite Connect. Use at your own risk. Always test with small amounts and paper trading before using real money. The authors are not responsible for any trading losses.

Support

For Kite Connect API issues, contact Zerodha Support

For MCP server issues, please open an issue on this repository.

Available Tools

24 tools
cancel_orderC

Cancel an existing order

Inputs: variety (required), order_id (required).

delete_gtt_orderC

Delete an existing GTT (Good Till Triggered) order

Inputs: trigger_id (required).

generate_sessionB

Generate session using request token. After user authorizes, call this with the request_token from the redirect URL to complete authentication.

Inputs: client_id (required), request_token (required).

get_gttsA

Get all active GTT orders. Supports pagination for large datasets.

Inputs: limit, from.

get_historical_dataC

Get historical price data for an instrument

Inputs: instrument_token (required), from_date (required), to_date (required), interval (required), +2 more.

get_holdingsA

Get holdings for the current user. Supports pagination for large datasets.

Inputs: client_id, limit, from.

get_ltpC

Get latest trading prices for a list of instruments

Inputs: instruments (required).

get_marginsD

Get margins

Inputs: client_id.

get_mf_holdingsB

Get all mutual fund holdings. Supports pagination for large datasets.

Inputs: client_id, limit, from.

get_ohlcC

Get OHLC (Open, High, Low, Close) data for a list of instruments

Inputs: instruments (required).

get_order_historyC

Get order history for a specific order

Inputs: order_id (required).

get_ordersC

Get all orders. Supports pagination for large datasets.

Inputs: limit, from.

get_order_tradesC

Get trades for a specific order

Inputs: order_id (required).

get_positionsC

Get current positions. Supports pagination for large datasets.

Inputs: client_id, limit, from.

get_profileB

Retrieve the user's profile information, including user ID, name, email, and account details like products orders, and exchanges available to the user. Use this to get basic user details.

Inputs: client_id.

get_quotesB

Get market data quotes for a list of instruments

Inputs: instruments (required).

get_tradesB

Get trading history. Supports pagination for large datasets.

Inputs: limit, from.

list_accountsA

List all available Kite accounts configured in the system. Returns account IDs and display names. Use this to show available accounts to the user.

Inputs: no named parameters.

loginA

Login to Kite API for a specific account. This tool helps you log in to the Kite API. If you are starting off a new conversation call this tool before hand. Call this if you get a session error. Returns a link that the user should click to authorize access, present as markdown if your client supports so that they can click it easily when rendered.

Inputs: client_id (required), api_key, api_secret.

modify_gtt_orderC

Modify an existing GTT (Good Till Triggered) order

Inputs: trigger_id (required), trigger_type (required), exchange (required), tradingsymbol (required), +11 more.

modify_orderC

Modify an existing order

Inputs: variety (required), order_id (required), order_type (required), quantity, +4 more.

place_gtt_orderC

Place a GTT (Good Till Triggered) order

Inputs: trigger_type (required), exchange (required), tradingsymbol (required), last_price (required), +11 more.

place_orderC

Place an order

Inputs: variety (required), exchange (required), tradingsymbol (required), transaction_type (required), +11 more.

search_instrumentsC

Search instruments. Supports pagination for large result sets.

Inputs: query (required), filter_on, limit, from.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelogโ€ฆ

    TDQS

    B3/5.0

    Scored across 24 tools

    Disambiguation4/5

    Most tools have distinct purposes, but there is some overlap between get_orders, get_order_history, and get_order_trades, which could cause confusion in selecting the right one for order-related queries. Additionally, get_ltp and get_quotes both provide price data, though they differ in scope (latest trading prices vs. market data quotes).

    Naming Consistency5/5

    Tool names follow a consistent verb_noun pattern throughout, such as cancel_order, get_holdings, and place_gtt_order. There are no deviations in naming conventions, making the set predictable and easy to parse.

    Tool Count3/5

    With 24 tools, the count is borderline high for a trading API server, potentially overwhelming for agents. While it covers many functionalities, it might benefit from consolidation or better scoping to reduce complexity.

    Completeness5/5

    The tool set provides comprehensive coverage for a trading domain, including authentication (generate_session, login), account management (list_accounts, get_profile), order handling (place, modify, cancel), market data (get_historical_data, get_quotes), and holdings/positions. No obvious gaps are present for core trading workflows.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables trading operations on Zerodha platform through natural language, supporting account management, order placement/modification, portfolio holdings, positions, margins, and stock news retrieval.
      Apache 2.0
    • A
      license
      A
      quality
      D
      maintenance
      Trade Indian stocks on Zerodha Kite via natural conversation. 14 tools for holdings, orders, quotes, GTT triggers with automated TOTP login.
      14
      6
      MIT
    • 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