Skip to main content

OpenAlgo MCP Server stub

Project description

OpenAlgo MCP Server

This is a Model Context Protocol (MCP) server that provides trading and market data functionality through the OpenAlgo platform. It enables AI assistants to execute trades, manage positions, and retrieve market data directly from supported brokers.

Quick Start: Use Without Cloning

You can use this MCP server directly from GitHub—no need to clone the repository manually.

1. Install Directly from GitHub

If you have uv (recommended) or pip:

uv pip install "git+https://github.com/yourusername/openalgo-mcp.git"
# or, with pip:
pip install "git+https://github.com/yourusername/openalgo-mcp.git"
  • This will install the server and all dependencies into your current environment.
  • Requires Python 3.12+

2. Run the MCP Server

After installation, you can start the server with:

uvx -m openalgo_mcp.mcpserver YOUR_API_KEY_HERE http://127.0.0.1:5000

or, if using pip:

python -m openalgo_mcp.mcpserver YOUR_API_KEY_HERE http://127.0.0.1:5000
  • Replace YOUR_API_KEY_HERE and the URL as needed.
  • Or, use the CLI entry point:
    openalgo-mcp-server YOUR_API_KEY_HERE http://127.0.0.1:5000
    

3. (Alternative) Use pipx

You can use pipx to run the MCP server directly from GitHub, without cloning or installing globally.
pipx will create a temporary isolated environment, install the package, and run its CLI entry point in a single step.

Requirements:

  • The repository must provide a CLI entry point (e.g., openalgo-mcp-server) in its pyproject.toml or setup.py.

How it works:

  • pipx run fetches the repo, installs it in an isolated environment, and runs the CLI tool.
  • The -- separates pipx arguments from arguments passed to the CLI.

Example:

pipx run "git+https://github.com/yourusername/openalgo-mcp.git" -- YOUR_API_KEY_HERE http://127.0.0.1:5000
  • Replace YOUR_API_KEY_HERE and the URL as needed.
  • If the CLI entry point is named differently, use that name.

This is the fastest way to try the server from GitHub with zero setup or cleanup.


Prerequisites

1. Python Version

  • Python 3.12 or higher is required.
    This MCP server is only supported on Python 3.12+ due to dependency and language feature requirements.

2. OpenAlgo Server Setup

Ensure your OpenAlgo server is running and properly configured:

  1. Start OpenAlgo Server: Your OpenAlgo server should be running (e.g., on http://127.0.0.1:5000)
  2. Verify Connection: Test that the server is accessible by visiting the web interface.
  3. Broker Authentication: Ensure your broker credentials are properly configured in OpenAlgo.

3. API Key

To get your OpenAlgo API key:

  1. Open your OpenAlgo web interface (e.g., http://127.0.0.1:5000)
  2. Navigate to Settings → API Keys.
  3. Generate or copy your existing API key.

4. (Recommended) Install uv

  • uv is a fast Python package manager and runner that provides the uvx command, a drop-in replacement for python/python3 for running scripts in virtual environments.
  • Using uvx simplifies configuration and ensures the correct Python version/environment is used.
  • Install with:
    pip install uv
    
    or see the uv installation guide.

MCP Client Configuration

You can configure your MCP client to use either the traditional Python executable path or the modern uvx runner.
uvx is recommended for simplicity and reliability, and works cross-platform.

Using uvx (Recommended, All Platforms)

Example Configuration:

{
  "mcpServers": {
    "openalgo": {
      "command": "uvx",
      "args": [
        "-m",
        "openalgo_mcp.mcpserver",
        "YOUR_API_KEY_HERE",
        "http://127.0.0.1:5000"
      ]
    }
  }
}
  • This will run the server using the Python interpreter from your current virtual environment (must be Python 3.12+).
  • You can also use the CLI entry point:
    {
      "mcpServers": {
        "openalgo": {
          "command": "openalgo-mcp-server",
          "args": [
            "YOUR_API_KEY_HERE",
            "http://127.0.0.1:5000"
          ]
        }
      }
    }
    

Using Python Executable Path (Legacy/Alternative)

If you prefer to specify the Python executable directly, use the following examples for your OS:

Windows

{
  "mcpServers": {
    "openalgo": {
      "command": "D:\\openalgo-mcp\\openalgo\\.venv\\Scripts\\python.exe",
      "args": [
        "-m",
        "openalgo_mcp.mcpserver",
        "YOUR_API_KEY_HERE",
        "http://127.0.0.1:5000"
      ]
    }
  }
}

macOS

{
  "mcpServers": {
    "openalgo": {
      "command": "/Users/your_username/openalgo/.venv/bin/python3",
      "args": [
        "-m",
        "openalgo_mcp.mcpserver",
        "YOUR_API_KEY_HERE",
        "http://127.0.0.1:5000"
      ]
    }
  }
}

Linux

{
  "mcpServers": {
    "openalgo": {
      "command": "/home/your_username/openalgo/.venv/bin/python3",
      "args": [
        "-m",
        "openalgo_mcp.mcpserver",
        "YOUR_API_KEY_HERE",
        "http://127.0.0.1:5000"
      ]
    }
  }
}

Configuration File Locations

  • Claude Desktop:
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Linux: ~/.config/Claude/claude_desktop_config.json
  • Windsurf:
    • Windows: %APPDATA%\Windsurf\mcp_config.json
    • macOS: ~/.config/windsurf/mcp_config.json
    • Linux: ~/.config/windsurf/mcp_config.json
  • Cursor:
    • Windows: %APPDATA%\Cursor\User\settings.json
    • macOS: ~/Library/Application Support/Cursor/User/settings.json
    • Linux: ~/.config/Cursor/User/settings.json

Path Configuration Notes

  • Important: Replace the paths in the examples above with your actual installation paths.
  • If using uvx, ensure you are in the correct project directory or adjust the script path accordingly.
  • If using the Python executable path, ensure it points to a Python 3.12+ interpreter in your virtual environment.

ChatGPT Configuration (Platform Independent)

If your ChatGPT client supports MCP, use the appropriate path format for your operating system from the examples above.

Available Tools

The MCP server provides the following categories of tools:

Order Management

  • place_order - Place market or limit orders
  • place_smart_order - Place orders considering position size
  • place_basket_order - Place multiple orders at once
  • place_split_order - Split large orders into smaller chunks
  • modify_order - Modify existing orders
  • cancel_order - Cancel specific orders
  • cancel_all_orders - Cancel all orders for a strategy

Position Management

  • close_all_positions - Close all positions for a strategy
  • get_open_position - Get current position for an instrument

Order Status & Tracking

  • get_order_status - Check status of specific orders
  • get_order_book - View all orders
  • get_trade_book - View executed trades
  • get_position_book - View current positions
  • get_holdings - View long-term holdings
  • get_funds - Check account funds and margins

Market Data

  • get_quote - Get current price quotes
  • get_market_depth - Get order book depth
  • get_historical_data - Retrieve historical price data

Instrument Search

  • search_instruments - Search for trading instruments
  • get_symbol_info - Get detailed symbol information
  • get_expiry_dates - Get derivative expiry dates
  • get_available_intervals - List available time intervals

Utilities

  • get_openalgo_version - Check OpenAlgo version
  • validate_order_constants - Display valid order parameters

Usage Examples

Once configured, you can ask your AI assistant to:

  • "Place a buy order for 100 shares of RELIANCE at market price"
  • "Show me my current positions"
  • "Get the latest quote for NIFTY"
  • "Cancel all my pending orders"
  • "What are my account funds?"

Supported Exchanges

  • NSE - National Stock Exchange (Equity)
  • NFO - NSE Futures & Options
  • CDS - NSE Currency Derivatives
  • BSE - Bombay Stock Exchange
  • BFO - BSE Futures & Options
  • BCD - BSE Currency Derivatives
  • MCX - Multi Commodity Exchange
  • NCDEX - National Commodity & Derivatives Exchange

Security Note

⚠️ Important: This server is designed for local use. For production environments, consider implementing additional security measures such as environment variables for sensitive data and restricting network access.

Troubleshooting

  1. Connection Issues: Verify OpenAlgo server is running on http://127.0.0.1:5000
  2. Authentication Errors: Check your API key is correct and valid
  3. Permission Errors: Ensure the Python virtual environment has proper permissions
  4. Order Failures: Verify your broker connection and trading permissions
  5. Order Failures: Verify broker credentials in OpenAlgo are valid and active

Support

For issues related to:

  • OpenAlgo Platform: Visit the OpenAlgo documentation
  • MCP Protocol: Check the Model Context Protocol specifications
  • Trading Errors: Verify your broker connection and trading permissions

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openalgo_mcp-0.1.1.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openalgo_mcp-0.1.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file openalgo_mcp-0.1.1.tar.gz.

File metadata

  • Download URL: openalgo_mcp-0.1.1.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for openalgo_mcp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0b058b8b775bc63d20c769c6b8a5b79ed7f64dae9a2de03f231bf89382012ac4
MD5 a7a9ce157dbc24cea2bdf8779931fa8a
BLAKE2b-256 3be38ff2ace9fbaf1161e660bfe5d108c7fcebbf0d9782748e70c72e226bd934

See more details on using hashes here.

File details

Details for the file openalgo_mcp-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: openalgo_mcp-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for openalgo_mcp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 04b33950375f42cb83ca6c0e5e64ad9ec9f8771cbfaaa8b16be3e4a812c92e62
MD5 044cc5121c579e4d83ac05e7525da814
BLAKE2b-256 34cd7b06d54a91adc53c45ef601e490e7ecdd0dd1e92f16f332826be9aaa6e22

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page