# Kite MCP Server > **Kite MCP Server** is a hosted, multitenant Model Context Protocol (MCP) server run by **MewCP** (https://mewcp.com), giving AI agents managed access to Kite. > > MewCP takes care of all MCP infrastructure for you — credential storage, OAuth flows, > token refresh, and production-grade auto-scaling — so your AI agents can connect to > third-party services and run freely without you managing any MCP server yourself. > > To connect your agent to this server you need a MewCP account and your API key: > - MEWCP_KEY — your personal API key (dashboard → Developer) > > Server page: https://mewcp.com/mcp/kite > MewCP docs: https://docs.mewcp.com > Full catalog: https://mewcp.com/llms.txt ## About Trade and manage investments through Zerodha Kite. Access market data, place orders, monitor positions and automate trading-related workflows. ## How to connect Server Page URL: https://mewcp.com/mcp/kite Gateway URL: https://gateway.mewcp.com/personal/mcp Every request to this server requires one header: Authorization: Bearer — your MewCP API key (dashboard → Developer) All connection snippets and ready-to-use code examples are available on the server page and in this document below. --- ## Server documentation **Trade smarter with Zerodha Kite — orders, positions, holdings, and live market data via MCP.** A Model Context Protocol (MCP) server that exposes Zerodha Kite Connect's API for trading, portfolio management, and market data retrieval. ## Overview The Kite Connect MCP Server provides full access to Zerodha's trading platform: - Place, modify, and cancel equity and derivatives orders - Fetch real-time quotes, historical candlestick data, and instrument lists - Monitor positions, holdings, margins, and user profile Perfect for: - Automating trading workflows through an AI assistant - Building portfolio monitoring and analysis pipelines - Querying live and historical market data programmatically ## Tools
kite_place_order — Place an order on Zerodha Kite Place a market, limit, SL, or SL-M order for any NSE/BSE/NFO/MCX instrument. **Inputs:** ``` - `tradingsymbol` (string, required) — Trading symbol (e.g., 'INFY', 'RELIANCE') - `exchange` (string, required) — Exchange: NSE, BSE, NFO, MCX - `transaction_type` (string, required) — BUY or SELL - `quantity` (integer, required) — Number of shares/units (min 1) - `order_type` (string, optional) — MARKET, LIMIT, SL, SL-M (default: MARKET) - `product` (string, optional) — MIS (intraday), CNC (delivery), NRML (overnight) (default: MIS) - `price` (float, optional) — Price for LIMIT orders - `validity` (string, optional) — DAY or IOC (default: DAY) - `disclosed_quantity` (integer, optional) — Disclosed quantity - `trigger_price` (float, optional) — Trigger price for SL/SL-M orders - `tag` (string, optional) — Tag for order tracking ``` **Output:** ```json { "success": true, "order_id": "230914000012345", "status": "placed", "message": "Order placed successfully. Order ID: 230914000012345" } ```
kite_get_orders — Get all orders for the user Returns all orders for the session including status, quantity, price, and timestamps. **Inputs:** ``` (none) ``` **Output:** ```json { "success": true, "count": 2, "orders": [ { "order_id": "230914000012345", "tradingsymbol": "INFY", "status": "COMPLETE", "transaction_type": "BUY", "quantity": 10, "filled_quantity": 10, "average_price": 1452.5, "order_timestamp": "2023-09-14 10:32:00" } ] } ```
kite_cancel_order — Cancel an existing order Cancel a pending order by its order ID. **Inputs:** ``` - `order_id` (string, required) — Order ID to cancel - `variety` (string, optional) — Order variety: regular, co, amo, iceberg (default: regular) ``` **Output:** ```json { "success": true, "order_id": "230914000012345", "status": "cancelled", "message": "Order 230914000012345 cancelled successfully" } ```
kite_get_positions — Get all open positions Returns day and net positions with P&L, buy/sell prices, and M2M values. **Inputs:** ``` (none) ``` **Output:** ```json { "success": true, "day_positions": [ { "tradingsymbol": "INFY", "quantity": 10, "pnl": 250.0, "buy_price": 1450.0, "sell_price": 0.0 } ], "net_positions": [ { "tradingsymbol": "INFY", "quantity": 10, "pnl": 250.0, "unrealised": 250.0, "m2m": 250.0 } ] } ```
kite_get_holdings — Get delivery portfolio holdings Returns all long-term holdings with average price, last price, and P&L. **Inputs:** ``` (none) ``` **Output:** ```json { "success": true, "count": 3, "holdings": [ { "tradingsymbol": "RELIANCE", "quantity": 5, "average_price": 2400.0, "last_price": 2520.0, "pnl": 600.0, "day_change_percentage": 0.85 } ] } ```
kite_get_quote — Get real-time market quotes Fetch live quotes for one or more instruments including last price, volume, and circuit limits. **Inputs:** ``` - `instruments` (string, required) — Comma-separated instrument symbols (e.g., 'NSE:INFY,NSE:RELIANCE') ``` **Output:** ```json { "success": true, "count": 1, "quotes": { "NSE:INFY": { "last_price": 1452.5, "volume": 1234567, "change": 12.5, "upper_circuit": 1597.75, "lower_circuit": 1307.25, "timestamp": "2023-09-14 15:29:59" } } } ```
kite_get_historical_data — Get historical candlestick data Fetch OHLCV candlestick data for any instrument over a date range and interval. Returns up to 100 candles. **Inputs:** ``` - `instrument_token` (string, required) — Instrument token (use kite_get_instruments to find tokens) - `from_date` (string, required) — Start date (YYYY-MM-DD) - `to_date` (string, required) — End date (YYYY-MM-DD) - `interval` (string, optional) — minute, day, 5minute, 15minute, 30minute, 60minute (default: day) ``` **Output:** ```json { "success": true, "count": 5, "interval": "day", "data": [ { "date": "2023-09-14", "open": 1440.0, "high": 1460.0, "low": 1435.0, "close": 1452.5, "volume": 1234567 } ] } ```
kite_get_instruments — Get tradable instrument list Returns instruments available for trading, optionally filtered by exchange. Returns up to 1000 results. **Inputs:** ``` - `exchange` (string, optional) — Filter by exchange: NSE, BSE, NFO, MCX, CDS - `limit` (integer, optional) — Maximum results to return, 1–1000 (default: 100) ``` **Output:** ```json { "success": true, "count": 100, "exchange": "NSE", "instruments": [ { "tradingsymbol": "INFY", "instrument_token": "408065", "exchange": "NSE", "segment": "NSE", "name": "INFOSYS" } ] } ```
kite_get_profile — Get user profile Returns the authenticated user's profile including name, email, phone, and enabled exchanges and products. **Inputs:** ``` (none) ``` **Output:** ```json { "success": true, "user_id": "AB1234", "user_name": "John Doe", "user_type": "individual", "email": "john@example.com", "phone": "9876543210", "exchanges": ["NSE", "BSE", "NFO"], "products": ["CNC", "MIS", "NRML"], "order_types": ["MARKET", "LIMIT", "SL", "SL-M"] } ```
kite_get_margins — Get account margins Returns available, utilized, and total margins for equity and commodity segments. **Inputs:** ``` (none) ``` **Output:** ```json { "success": true, "equity": { "available": { "cash": 50000.0 }, "utilised": { "debits": 12000.0 } }, "commodity": { "available": { "cash": 10000.0 }, "utilised": { "debits": 0.0 } } } ```
kite_health_check — Check server readiness Returns server status and supported capability list. Does not require credentials. **Inputs:** ``` (none) ``` **Output:** ```json { "status": "ok", "server": "CL Kite Connect MCP Server", "type": "third-party-integration", "auth_required": true, "supports": ["orders", "positions", "holdings", "quotes", "historical_data"] } ```
## API Parameters Reference
Order Types - `MARKET` — Execute immediately at the best available price - `LIMIT` — Execute at a specified price or better; requires `price` - `SL` — Stop-loss limit order; requires both `trigger_price` and `price` - `SL-M` — Stop-loss market order; requires `trigger_price` only
Product Codes - `MIS` — Margin Intraday Square-off; must be closed before market end - `CNC` — Cash and Carry; for delivery/long-term holding - `NRML` — Normal; for overnight F&O positions
Instrument Token **Finding a token:** ``` Use kite_get_instruments with the exchange filter, then read the instrument_token field. Example: { "tradingsymbol": "INFY", "instrument_token": "408065", "exchange": "NSE" } ``` **Quote symbol format:** ``` {EXCHANGE}:{TRADINGSYMBOL} Example: NSE:INFY ```
## Getting Your Kite Connect Credentials
Steps 1. Go to [Kite Connect Developer Console](https://developers.kite.trade/) 2. Create an app to get your **API Key** and **API Secret** 3. Complete the login flow to obtain an **Access Token** (valid for one trading day) 4. Both `api_key` and `access_token` are required — provide them as static credential fields
## Troubleshooting
Missing or Invalid Headers - **Cause:** Credentials not provided in request headers or incorrect format - **Solution:** 1. Verify `Authorization: Bearer YOUR_API_KEY` and `X-Mewcp-Credential-Id: CREDENTIAL-ID` headers are present 2. Check that the credential is active in your MewCP account
Insufficient Credits - **Cause:** API calls have exceeded your request limits - **Solution:** 1. Check credit usage in your Curious Layer dashboard 2. Upgrade to a paid plan or add credits for higher limits 3. Contact support for credit adjustments
Credential Not Connected - **Cause:** No Kite Connect credential linked to your account - **Solution:** 1. Go to **Credentials** in your MewCP dashboard 2. Add your Kite Connect `api_key` and `access_token` as a static credential 3. Retry the request with the correct `X-Mewcp-Credential-Id` header
Malformed Request Payload - **Cause:** JSON payload is invalid or missing required fields - **Solution:** 1. Validate JSON syntax before sending 2. Ensure all required tool parameters are included 3. Check parameter types match expected values
Server Not Found - **Cause:** Incorrect server name in the API endpoint - **Solution:** 1. Verify endpoint format: `{server-name}/mcp/{tool-name}` 2. Use correct server name from documentation 3. Check available servers in your Curious Layer account
Kite Connect API Error - **Cause:** Upstream Kite Connect API returned an error - **Solution:** 1. Check Kite Connect service status at [Kite Status Page](https://status.zerodha.com/) 2. Verify your access token is valid and not expired (tokens expire at end of trading day) 3. Review the error message for specific details
---
Resources - **[Kite Connect API Documentation](https://kite.trade/docs/connect/v3/)** — Official API reference - **[Kite Connect API Reference](https://kite.trade/docs/connect/v3/user/)** — Complete endpoint reference - **[FastMCP Docs](https://gofastmcp.com/v2/getting-started/welcome)** — FastMCP specification - **[FastMCP Credentials](https://pypi.org/project/fastmcp-credentials/)** — FastMCP Credentials package for credential handling
--- ## Connection snippets ### Python (fastmcp) ```python import asyncio from fastmcp import Client from fastmcp.client.transports import StreamableHttpTransport SERVER_URL = "https://gateway.mewcp.com/personal/mcp" MEWCP_KEY = "YOUR_MEWCP_KEY" transport = StreamableHttpTransport( url=SERVER_URL, headers={ "Authorization": f"Bearer {MEWCP_KEY}", } ) async def main(): client = Client(transport) async with client: await client.ping() tools = await client.list_tools() resources = await client.list_resources() prompts = await client.list_prompts() # Change the tool name and arguments with actual tool and arguments available in server result = await client.call_tool("example_tool", {"param": "value"}) print(result) asyncio.run(main()) ``` ### TypeScript (MCP SDK) ```typescript import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"; const SERVER_URL = "https://gateway.mewcp.com/personal/mcp"; const MEWCP_KEY = "YOUR_MEWCP_KEY"; const transport = new StreamableHTTPClientTransport(new URL(SERVER_URL), { requestInit: { headers: { Authorization: `Bearer ${MEWCP_KEY}`, }, }, }); const client = new Client({ name: "mewcp-client", version: "1.0.0", }); await client.connect(transport); const tools = await client.listTools(); console.log("Available tools:", tools.tools.map(t => t.name)); // Change the tool name and arguments to a tool available on your server const result = await client.callTool({ name: "example_tool", arguments: { param: "value" }, }); console.log("Tool result:", result); ``` ### VS Code (settings.json) ```json { "servers": { "mewcp": { "type": "http", "url": "https://gateway.mewcp.com/personal/mcp", "headers": { "Authorization": "Bearer YOUR_MEWCP_KEY" } } } } ``` ### Cursor (mcp.json) ```json { "mcpServers": { "mewcp": { "url": "https://gateway.mewcp.com/personal/mcp", "headers": { "Authorization": "Bearer YOUR_MEWCP_KEY" } } } } ``` ### Claude Desktop (claude_desktop_config.json) ```json "mcpServers": { "mewcp": { "command": "npx", "args": [ "-y", "mcp-remote@latest", "https://gateway.mewcp.com/personal/mcp", "--transport", "http-only", "--header", "Authorization: Bearer YOUR_MEWCP_KEY" ] } } ```