kite-mcp-server

kite-mcp-server

Indian stock market trading via Zerodha Kite Connect. 78 tools for order execution, portfolio analytics, options Greeks, paper trading, backtesting, technical indicators, price alerts with Telegram, and SEBI compliance. Multi-user OAuth with remote Streamable HTTP transport.

Category
Visit Server

README

Kite MCP Server (Self-Hosted Fork)

This is a private fork of zerodha/kite-mcp-server with significant additions for self-hosted multi-user deployment on Fly.io.

Fork Additions (v1.0.0)

40 MCP Tools

Category Tools
Orders place_order, modify_order, cancel_order, convert_position, place/modify/delete_gtt_order
Portfolio get_profile, get_margins, get_holdings, get_positions, get_trades, get_orders, get_order_history, get_order_trades, get_gtts, get_mf_holdings
Market Data get_quotes, search_instruments, get_historical_data, get_ltp, get_ohlc
Analytics portfolio_summary, portfolio_concentration, position_analysis, trading_context
Margins get_order_margins, get_basket_margins, get_order_charges
Alerts setup_telegram, set_alert (above/below/drop_pct/rise_pct), list_alerts, delete_alert
Ticker start/stop_ticker, ticker_status, subscribe/unsubscribe_instruments
Setup login, open_dashboard

Infrastructure

  • Per-user OAuth 2.1 + PKCE — each user brings their own Kite developer app
  • Full SQLite persistence — credentials, tokens, OAuth clients, MCP sessions (all AES-256-GCM encrypted)
  • AI Activity Audit Trail — every tool call logged with summaries, filterable timeline at /dashboard/activity
  • Telegram daily briefings — morning 9 AM (alerts, token status) + P&L summary 3:35 PM IST
  • SSO — dashboard cookie set during MCP OAuth callback (Callback Session Establishment pattern)
  • Rate limiting — per-IP on all endpoints (auth 2/sec, token 5/sec, MCP 20/sec)
  • SEBI compliant — static egress IP 209.71.68.157, market_protection parameter, gokiteconnect v4.4.0
  • 270+ tests, security score ~8.5/10

Deployment

# Fly.io (production)
flyctl deploy -a kite-mcp-server

# Required secrets
flyctl secrets set OAUTH_JWT_SECRET=<random-32-bytes>
flyctl secrets set EXTERNAL_URL=https://kite-mcp-server.fly.dev
flyctl secrets set ADMIN_EMAILS=your@email.com
flyctl secrets set TELEGRAM_BOT_TOKEN=<bot-token>  # optional
flyctl secrets set ALERT_DB_PATH=/data/alerts.db

Dashboards

  • /dashboard — user portfolio (holdings, P&L, alerts, credentials)
  • /dashboard/activity — AI activity audit trail with filters and export
  • /admin/ops — admin monitoring (all users, sessions, logs)

Trading Skill Plugin

# Load the plugin
claude --plugin-dir ~/.claude/plugins/local/kite-trading

# Commands
/morning          # Morning briefing
/trade RELIANCE 10  # Pre-flight check
/eod              # End-of-day review
/price RELIANCE   # Quick price check

Below is the original upstream README.


Kite MCP Server (Upstream)

A Model Context Protocol (MCP) server that provides AI assistants with secure access to the Kite Connect trading API. This server enables AI agents to retrieve market data, manage portfolios, and execute trades through a standardized interface.

TL;DR for Traders

Want to use AI with your Kite trading account? Just add https://mcp.kite.trade/mcp to your AI client configuration. No installation or API keys required - it's hosted and ready to use.

Features

  • Portfolio Management: View holdings, positions, margins, and mutual fund investments
  • Order Management: Place, modify, and cancel orders with full order history
  • GTT Orders: Good Till Triggered order management
  • Market Data Access: Real-time quotes, historical data, OHLC data
  • Pagination Support: Automatic pagination for large datasets (holdings, orders, trades)
  • Comprehensive Coverage: Implements most Kite Connect API endpoints
  • Multiple Deployment Modes: stdio, HTTP, SSE, and hybrid mode (production)
  • Built-in Documentation: Auto-served documentation at runtime

Quick Start

Hosted Version (Recommended)

The easiest way to get started is with our hosted version at mcp.kite.trade. Both /mcp and /sse endpoints are available - no installation or API keys required on your end.

Quick Setup: Add the following to your MCP configuration:

https://mcp.kite.trade/mcp

Recommended: Use the new HTTP mode (/mcp endpoint) for better performance and reliability. You can use mcp-remote to connect to the hosted server.

For self-hosting with your own API keys, follow the installation steps below.

Prerequisites

  • For hosted version (recommended): Nothing! Just use https://mcp.kite.trade/mcp
  • For self-hosting: Go 1.21 or later
  • For self-hosting: Valid Kite Connect API credentials

Getting started

git clone https://github.com/zerodha/kite-mcp-server
cd kite-mcp-server

Configuration

Create a .env file with your Kite Connect credentials:

KITE_API_KEY=your_api_key
KITE_API_SECRET=your_api_secret
APP_MODE=http
APP_PORT=8080
APP_HOST=localhost

You can also use the provided justfile to initialize the config.

just init-env

Running the Server

# Build and run
go build -o kite-mcp-server
./kite-mcp-server

# Or run directly
go run main.go

The server will start and serve a status page at http://localhost:8080/

Client Integration

Setup Guide

Claude Desktop (Hosted Mode)

For the hosted version, add to your Claude Desktop configuration (~/.config/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "kite": {
      "command": "npx",
      "args": ["mcp-remote", "https://mcp.kite.trade/mcp"]
    }
  }
}

Claude Desktop (HTTP Mode)

Add to your Claude Desktop configuration (~/.config/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "kite": {
      "command": "npx",
      "args": ["mcp-remote", "http://localhost:8080/mcp", "--allow-http"],
      "env": {
        "APP_MODE": "http",
        "KITE_API_KEY": "your_api_key",
        "KITE_API_SECRET": "your_api_secret"
      }
    }
  }
}

Claude Desktop (SSE Mode)

Add to your Claude Desktop configuration (~/.config/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "kite": {
      "command": "npx",
      "args": ["mcp-remote", "http://localhost:8080/sse", "--allow-http"],
      "env": {
        "APP_MODE": "sse",
        "KITE_API_KEY": "your_api_key",
        "KITE_API_SECRET": "your_api_secret"
      }
    }
  }
}

Claude Desktop (stdio Mode)

For self-hosted installations, you must first build the binary:

go build -o kite-mcp-server

Then add to your Claude Desktop configuration (~/.config/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "kite": {
      "command": "/full/path/to/your/kite-mcp-server",
      "env": {
        "APP_MODE": "stdio",
        "KITE_API_KEY": "your_api_key",
        "KITE_API_SECRET": "your_api_secret"
      }
    }
  }
}

Important: Use the full absolute path to your built binary. For example:

  • /home/username/kite-mcp-server/kite-mcp-server (Linux)
  • /Users/username/kite-mcp-server/kite-mcp-server (macOS)
  • C:\Users\username\kite-mcp-server\kite-mcp-server.exe (Windows)

Other MCP Clients

For other MCP-compatible clients, use the hosted endpoint https://mcp.kite.trade/mcp with mcp-remote or configure your client to connect directly to the HTTP endpoint.

Available Tools

Setup & Authentication

  • login - Login to Kite API and generate authorization link

Market Data

  • get_quotes - Get real-time market quotes
  • get_ltp - Get last traded price
  • get_ohlc - Get OHLC data
  • get_historical_data - Historical price data
  • search_instruments - Search trading instruments

Portfolio & Account

  • get_profile - User profile information
  • get_margins - Account margins
  • get_holdings - Portfolio holdings
  • get_positions - Current positions
  • get_mf_holdings - Mutual fund holdings

Orders & Trading

  • place_order - Place new orders
  • modify_order - Modify existing orders
  • cancel_order - Cancel orders
  • get_orders - List all orders
  • get_trades - Trading history
  • get_order_history - Order execution history
  • get_order_trades - Get trades for a specific order

GTT Orders

  • get_gtts - List GTT orders
  • place_gtt_order - Create GTT orders
  • modify_gtt_order - Modify GTT orders
  • delete_gtt_order - Delete GTT orders

API Coverage

This server implements the majority of Kite Connect API endpoints and also provides additional tools.

Development

Development Environment

This project includes a Nix flake for consistent development environments:

# Enter development shell
nix develop

# Or with direnv
direnv allow

Using Just Commands

Install Just for convenient development commands:

just build      # Build the project
just run        # Run the server
just test       # Run tests
just lint       # Format and lint code
just coverage   # Generate coverage report

Running Tests

Requirements:

  • Go 1.23+ with GOEXPERIMENT=synctest (required for timing-dependent tests)
# Run all tests
just test

# With coverage
just coverage

# With race detector
just test-race

# Direct go command (if you prefer)
CGO_ENABLED=0 GOEXPERIMENT=synctest go test -v ./...

Synctest Integration

This project requires Go's synctest package for time-dependent tests (session expiry, clock skew tolerance). All timing tests use synctest.Run() for:

  • Fast execution: Time-dependent tests complete in milliseconds instead of minutes
  • Deterministic timing: No flaky timing-based test failures
  • Controlled time: Tests can advance time without actual delays

The justfile automatically includes GOEXPERIMENT=synctest in all test commands.

Configuration Options

Environment Variable Default Description
KITE_API_KEY Required Your Kite Connect API key
KITE_API_SECRET Required Your Kite Connect API secret
APP_MODE http Server mode: stdio, http, sse, or hybrid
APP_PORT 8080 Server port (HTTP/SSE/hybrid modes)
APP_HOST localhost Server host (HTTP/SSE/hybrid modes)
EXCLUDED_TOOLS (empty) Comma-separated list of tools to exclude from registration

Note: In production, we use hybrid mode which supports both /sse and /mcp endpoints, making both HTTP and SSE protocols available for different client needs.

Tool Exclusion

You can exclude specific tools by setting the EXCLUDED_TOOLS environment variable with a comma-separated list of tool names. This is useful for creating read-only instances.

Example:

EXCLUDED_TOOLS=place_order,modify_order,cancel_order

The hosted version at mcp.kite.trade excludes potentially destructive trading operations for security. For accessing the other operations you can generate your own API keys and run the server locally.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Run just lint and just test
  6. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For bugs and general suggestions, please use GitHub Discussions.

For Kite Connect API documentation, visit: https://kite.trade/docs/connect/

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured