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
Note:
If you seeModuleNotFoundError: No module named 'openalgo_mcp', you are using asrc/layout.
Either:
- Set the
PYTHONPATHenvironment variable tosrcwhen running as a module:PYTHONPATH=src python -m openalgo_mcp.mcpserver YOUR_API_KEY_HERE http://127.0.0.1:5000(On Windows:set PYTHONPATH=src && python -m openalgo_mcp.mcpserver ...)- Or, install the package in development mode:
pip install -e .After this, you can run the module from anywhere in the project.
- Replace
YOUR_API_KEY_HEREand 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 itspyproject.tomlorsetup.py.
How it works:
pipx runfetches 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_HEREand 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:
- Start OpenAlgo Server: Your OpenAlgo server should be running (e.g., on
http://127.0.0.1:5000) - Verify Connection: Test that the server is accessible by visiting the web interface.
- Broker Authentication: Ensure your broker credentials are properly configured in OpenAlgo.
3. API Key
To get your OpenAlgo API key:
- Open your OpenAlgo web interface (e.g.,
http://127.0.0.1:5000) - Navigate to Settings → API Keys.
- Generate or copy your existing API key.
4. (Recommended) Install uv
- uv is a fast Python package manager and runner that provides the
uvxcommand, a drop-in replacement forpython/python3for running scripts in virtual environments. - Using
uvxsimplifies 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
- Windows:
- Windsurf:
- Windows:
%APPDATA%\Windsurf\mcp_config.json - macOS:
~/.config/windsurf/mcp_config.json - Linux:
~/.config/windsurf/mcp_config.json
- Windows:
- Cursor:
- Windows:
%APPDATA%\Cursor\User\settings.json - macOS:
~/Library/Application Support/Cursor/User/settings.json - Linux:
~/.config/Cursor/User/settings.json
- Windows:
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 ordersplace_smart_order- Place orders considering position sizeplace_basket_order- Place multiple orders at onceplace_split_order- Split large orders into smaller chunksmodify_order- Modify existing orderscancel_order- Cancel specific orderscancel_all_orders- Cancel all orders for a strategy
Position Management
close_all_positions- Close all positions for a strategyget_open_position- Get current position for an instrument
Order Status & Tracking
get_order_status- Check status of specific ordersget_order_book- View all ordersget_trade_book- View executed tradesget_position_book- View current positionsget_holdings- View long-term holdingsget_funds- Check account funds and margins
Market Data
get_quote- Get current price quotesget_market_depth- Get order book depthget_historical_data- Retrieve historical price data
Instrument Search
search_instruments- Search for trading instrumentsget_symbol_info- Get detailed symbol informationget_expiry_dates- Get derivative expiry datesget_available_intervals- List available time intervals
Utilities
get_openalgo_version- Check OpenAlgo versionvalidate_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
- Connection Issues: Verify OpenAlgo server is running on
http://127.0.0.1:5000 - Authentication Errors: Check your API key is correct and valid
- Permission Errors: Ensure the Python virtual environment has proper permissions
- Order Failures: Verify your broker connection and trading permissions
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openalgo_mcp-0.1.3.tar.gz.
File metadata
- Download URL: openalgo_mcp-0.1.3.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3d166e66b3c1fbc10eb358f655a318615a82f471ef8b9bf9890e28b8ade4465
|
|
| MD5 |
faf5003ef9f1e103e5a9ad7061d6afd3
|
|
| BLAKE2b-256 |
aca3657e4541b23a454c4c588d878f0f9c9c95138a3f6b114ca9813a0594de6d
|
File details
Details for the file openalgo_mcp-0.1.3-py3-none-any.whl.
File metadata
- Download URL: openalgo_mcp-0.1.3-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6884c01ac5faf5bea7cf602d4053f415bb03896075b002f0ac75a540e71abd7
|
|
| MD5 |
7593bbc3a0bec14786b36046907a7908
|
|
| BLAKE2b-256 |
66d2746a29ef63d61ed85ae2f2f97723f3515086446c4658238ad8c5bad7f425
|