Zerodha Kite MCP server

Integrates with Zerodha Kite trading platform to enable algorithmic trading and portfolio management for Indian stock markets.
Back to servers
Provider
Rohan Verma
Release date
Feb 25, 2025
Language
Python
Stats
72 stars

The Kite MCP Server implements the Model Context Protocol (MCP), allowing you to serve machine learning models through a standardized API. It provides a simple way to handle model communications, manage contexts, and deliver AI capabilities to client applications.

Installation

You can install the Kite MCP Server using pip:

pip install kite-mcp-server

Usage

Basic Server Setup

To start the MCP server with default settings:

from kite_mcp_server import MCPServer

server = MCPServer()
server.start()

Configuration Options

You can customize your server with various configuration options:

from kite_mcp_server import MCPServer

server = MCPServer(
    host="0.0.0.0",  # Listen on all network interfaces
    port=8080,       # Custom port
    models_path="/path/to/models",  # Custom models directory
    log_level="DEBUG"  # Set logging verbosity
)
server.start()

Loading Models

Load models into your server:

from kite_mcp_server import MCPServer, ModelConfig

server = MCPServer()

# Load a model with specific configuration
server.load_model(
    model_id="gpt-3.5-turbo",
    model_config=ModelConfig(
        path="/path/to/model",
        context_size=4096,
        parameters={
            "temperature": 0.7,
            "top_p": 0.9
        }
    )
)

server.start()

Using Environment Variables

The server also accepts configuration via environment variables:

# Set these before running your server
export MCP_HOST="0.0.0.0"
export MCP_PORT="8080"
export MCP_MODELS_PATH="/path/to/models"
export MCP_LOG_LEVEL="INFO"

Advanced Configuration

For more complex setups, you can use a configuration file:

from kite_mcp_server import MCPServer

server = MCPServer.from_config("/path/to/config.yaml")
server.start()

Example configuration file (config.yaml):

server:
  host: 0.0.0.0
  port: 8080
  models_path: /path/to/models
  log_level: INFO

models:
  - id: gpt-3.5-turbo
    path: /path/to/model1
    context_size: 4096
    parameters:
      temperature: 0.7
      top_p: 0.9
  
  - id: llama-7b
    path: /path/to/model2
    context_size: 2048
    parameters:
      temperature: 0.8

Connecting to the Server

Once your server is running, clients can connect using any MCP-compatible client:

curl -X POST http://localhost:8080/v1/models/gpt-3.5-turbo/generate \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Tell me about MCP",
    "max_tokens": 100
  }'

Managing Contexts

The MCP server supports context management for maintaining conversation history:

# Create a new context
context_id = server.create_context(model_id="gpt-3.5-turbo")

# Use the context for continued conversations
server.generate(
    model_id="gpt-3.5-turbo",
    context_id=context_id,
    prompt="Tell me more about that"
)

# Delete a context when finished
server.delete_context(context_id)

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later