> For the complete documentation index, see [llms.txt](https://docs.openalgo.in/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.openalgo.in/mcp/tool-references.md).

# Tool References

## OpenAlgo MCP: Tool Reference & Prompt Examples

Companion reference to the main MCP setup guide. Once the MCP server is wired into Claude Desktop, Cursor, Windsurf, Antigravity, or any other MCP-capable client, you can ask for these operations in plain English; the client decides which tool to call.

The supported tools are grouped below. The live MCP `tools/list` response is authoritative for the exact registry and schemas exposed by a running version. Each entry includes:

* What the tool does
* Key parameters (required / optional)
* Example prompts you can paste directly into Claude / Cursor / Antigravity / Windsurf

### Conventions

* **Default strategy tag**: `python mcp`. Every MCP-triggered order is tagged so you can filter MCP activity in OpenAlgo logs and the Analyzer. Override by saying *"use strategy 'my scalper'"* in the prompt.
* **Product type defaults**: `MIS` for equity. Use `NRML` for F\&O carry; `CNC` for delivery.
* **Exchange codes**: `NSE`, `BSE`, `NFO`, `BFO`, `CDS`, `BCD`, `MCX`, `NCDEX` + `NSE_INDEX` / `BSE_INDEX` for index values.
* **Toolsets**: every tool belongs to exactly one of `orders`, `account`, `marketdata`, `research`, or `utility`. Those five names are the only values `OPENALGO_MCP_TOOLSETS` accepts. The section headings below group tools by task, which does not always match the toolset: `close_all_positions` and `analyzer_toggle` are in `orders`, `calculate_margin` and `analyzer_status` are in `account`, and the calendar and instrument tools are in `marketdata`.
* **Lot size**: never hardcoded. The model will call `get_option_symbol` / `get_option_chain` / `get_symbol_info` to read the live `lotsize` from the broker master contract, then compute `quantity = lots × lotsize` for you.

***

### Order Management

#### `place_order`

Place a single market / limit / stop-loss order.

| Param                                          | Required | Notes                                             |
| ---------------------------------------------- | -------- | ------------------------------------------------- |
| `symbol`, `quantity`, `action`                 | Yes      | none                                              |
| `exchange`                                     | No       | Default `NSE`                                     |
| `price_type`                                   | No       | `MARKET`, `LIMIT`, `SL`, `SL-M`. Default `MARKET` |
| `product`                                      | No       | `CNC`, `NRML`, `MIS`. Default `MIS`               |
| `strategy`                                     | No       | Default `python mcp`                              |
| `price`, `trigger_price`, `disclosed_quantity` | No       | Use as applicable                                 |

**Prompts:**

* *"Place a market buy for 100 shares of RELIANCE on NSE, intraday"*
* *"Buy 50 INFY at limit 1550, delivery product"*
* *"Sell 25 SBIN with a stop-loss at 765 and trigger 766"*

***

#### `place_smart_order`

Auto-calculates the delta between your current position and the target `position_size`, then sends only the incremental order.

| Param                                           | Required | Notes                                 |
| ----------------------------------------------- | -------- | ------------------------------------- |
| `symbol`, `quantity`, `action`, `position_size` | Yes      | `position_size` = your target net qty |
| Rest                                            | No       | Same defaults as `place_order`        |

**Prompts:**

* *"Square off my TATAMOTORS intraday position to zero"*
* *"Scale my YESBANK position to 100 shares long"*

***

#### `place_basket_order`

Fire multiple orders in one call. Each basket entry carries its own `symbol`, `exchange`, `action`, `quantity`, `pricetype`, `product`.

**Prompts:**

* *"Place a basket: buy 1 BHEL and sell 1 ZOMATO, both market MIS on NSE"*
* *"Build a basket of SBIN, HDFCBANK and ICICIBANK buys, 10 shares each, CNC"*

***

#### `place_split_order`

Break a large order into equal chunks (helpful for low-liquidity names or to avoid freeze limits).

| Param                                                         | Required | Notes                                  |
| ------------------------------------------------------------- | -------- | -------------------------------------- |
| `symbol`, `exchange`, `action`, `quantity`, `split_size`      | Yes      | `split_size` is the size of each slice |
| `price_type`, `product`, `price`, `trigger_price`, `strategy` | No       | Same as `place_order`                  |

**Prompts:**

* *"Sell 500 YESBANK in slices of 50, market orders"*
* *"Split 1200 NIFTY lots across 100-lot chunks"*

***

#### `place_options_order`

Single-leg option order using offset-based strike selection (ATM / ITM1-ITM50 / OTM1-OTM50). The server resolves the strike against the live option chain.

| Param                                                                               | Required | Notes                                                            |
| ----------------------------------------------------------------------------------- | -------- | ---------------------------------------------------------------- |
| `underlying`, `exchange`, `offset`, `option_type`, `action`, `quantity`             | Yes      | none                                                             |
| `expiry_date`                                                                       | No       | Optional if underlying includes expiry (e.g., `NIFTY28OCT25FUT`) |
| `price_type`, `product`, `price`, `trigger_price`, `disclosed_quantity`, `strategy` | No       | Same as `place_order`                                            |

> **Lot size note**: if you don't know it, just ask: the assistant will pull `lotsize` from `get_option_symbol` first, then size the quantity correctly.

**Prompts:**

* *"Buy 1 lot NIFTY ATM CE expiring 28NOV25"*
* *"Short 2 lots BANKNIFTY OTM3 PE for next weekly expiry"*

***

#### `place_options_multi_order`

Multi-leg option strategies (up to 20 legs). BUY legs are fired first for margin efficiency, then SELL legs. Supports per-leg overrides for `expiry_date`, `pricetype`, `price`, `product`, etc., perfect for calendar / diagonal spreads.

**Prompts:**

* *"Place an iron condor on NIFTY 28NOV25 at OTM5 and OTM10 strikes, 1 lot each, NRML"*
* *"Build a long straddle on BANKNIFTY ATM for 25NOV25 expiry with limit orders at 250"*
* *"Diagonal NIFTY spread: buy ITM2 CE 30DEC25, sell OTM2 CE 25NOV25, 1 lot"*

***

#### `modify_order`

Change price / quantity / type / trigger on a working order.

| Param                                                                      | Required | Notes                                                                                                                                                                                                                                        |
| -------------------------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `order_id`, `symbol`, `action`, `exchange`, `product`, `quantity`, `price` | Yes      | `price` is mandatory per the REST spec, use current price if unchanged                                                                                                                                                                       |
| `price_type`, `trigger_price`, `disclosed_quantity`                        | No       | `price_type` defaults to **`LIMIT`**, unlike every other order tool, which defaults to `MARKET`. Modifying a working `SL-M` order without passing `price_type` converts it to `LIMIT`. `trigger_price` and `disclosed_quantity` default to 0 |

**Prompts:**

* *"Modify order 250408001002736, change limit price to 16.5"*
* *"Increase quantity of my open NIFTY CE buy order to 2 lots"*

***

#### `cancel_order`

**Prompt:** *"Cancel order 250408001002736"*

***

#### `cancel_all_orders`

**Prompts:**

* *"Cancel every pending order I have"*
* *"Kill all open orders for strategy 'nifty scalper'"*

***

### Positions & Holdings

#### `close_all_positions`

Square off everything for a strategy.

**Prompt:** *"Close all my open positions now"*

***

#### `get_open_position`

Query the current net quantity for a specific instrument.

**Prompts:**

* *"What's my current position in NHPC NSE MIS?"*
* *"How many NIFTY futures am I long?"*

***

#### `get_position_book`

Every open position across instruments.

**Prompt:** *"Show me all open positions with unrealized P\&L"*

***

#### `get_holdings`

Delivery/CNC holdings with today's P\&L, % move, and aggregate statistics.

**Prompts:**

* *"Show my demat holdings sorted by today's % change"*
* *"What's the total unrealized P\&L on my long-term portfolio?"*

***

#### `get_funds`

Cash, collateral, realized/unrealized M2M, utilized margin.

**Prompt:** *"How much free cash do I have for trading today?"*

***

### Order Tracking

#### `get_order_status`

**Prompt:** *"Check status of order 250828000185002, did it fill?"*

***

#### `get_order_book`

Every order today with statistics (open / complete / cancelled / rejected counts).

**Prompts:**

* *"Show today's order book"*
* *"How many of my orders got rejected today and why?"*

***

#### `get_trade_book`

Only executed fills.

**Prompt:** *"List all my executed trades today with average price"*

***

### Market Data

#### `get_quote`

LTP, bid, ask, OHLC, volume for one symbol.

**Prompts:**

* *"Get the latest quote for RELIANCE"*
* *"What's NIFTY trading at right now?"*

***

#### `get_multi_quotes`

Quotes for many symbols in one round-trip.

**Prompt:** *"Get quotes for RELIANCE, TCS, INFY, HDFCBANK and ICICIBANK"*

***

#### `get_market_depth`

Full 5-level bid/ask book plus total buy/sell qty and OI.

**Prompt:** *"Show the order book depth for SBIN"*

***

#### `get_historical_data`

OHLCV history. Two sources:

* `source="api"` (default) → live fetch from broker API
* `source="db"` → local Historify DuckDB store (1m and D stored physically; other intervals, including custom ones like 2m/3m/W/M/Q/Y, computed on-the-fly via SQL)

> **`bars` defaults to 20.** However wide a date range you ask for, the tool returns only the last 20 rows and sets `truncated: true`. Say how many bars you want ("the last 200 daily bars") or the model will silently work from 20. The same default applies to `calculate_indicator`.

**Prompts:**

* *"Get 5-minute SBIN candles from 1 Apr to 8 Apr 2025"*
* *"Pull NIFTY daily data for the last 6 months from the local Historify DB"*
* *"Give me weekly aggregates of BANKNIFTY for the past year using source=db"*

***

#### `get_option_chain`

Real-time chain with CE/PE data per strike, LTP, bid/ask, OHLC, volume, OI, `lotsize`, moneyness labels. `strike_count=N` returns N strikes **above and** N below ATM, so roughly 2N+1 rows. Valid range is 1 to 100.

**Prompts:**

* *"Show me NIFTY option chain for 30DEC25, 10 strikes around ATM"*
* *"Full BANKNIFTY option chain for this week's expiry"*

***

### Instrument Search & Symbols

#### `search_instruments`

Fuzzy search across exchanges by name or symbol.

**Prompts:**

* *"Search for NIFTY 26000 Dec CE"*
* *"Find all TATA stocks on NSE"*

***

#### `get_symbol_info`

Full metadata for one symbol: `brsymbol`, `lotsize`, `expiry`, `strike`, `tick_size`, `token`.

**Prompts:**

* *"Get symbol info for NIFTY30DEC25FUT on NFO"*
* *"What's the lot size for BANKNIFTY futures?"*

***

#### `get_option_symbol`

Resolve ATM/ITM/OTM offset to the exact option symbol plus `lotsize`, `tick_size`, `underlying_ltp`. Expiry optional if the underlying includes one.

**Prompts:**

* *"Get the ATM CE symbol for NIFTY expiring 28OCT25"*
* *"What's the OTM4 PE for BANKNIFTY next weekly?"*

***

#### `get_option_greeks`

Delta, Gamma, Theta, Vega, Rho + Implied Volatility using Black-76. Underlying is auto-detected, override with `underlying_symbol` / `underlying_exchange`, supply `forward_price` for custom / illiquid underlyings, and `expiry_time` for non-standard MCX contracts. `interest_rate` is the annualized risk-free rate in percent and **defaults to 0**, which materially shifts rho and theta: pass it when those matter.

**Prompts:**

* *"Calculate greeks for NIFTY25NOV2526000CE with 6.5% interest rate"*
* *"What's the delta and IV of the ATM NIFTY CE for 28NOV25?"*

***

#### `get_synthetic_future`

Put-call parity synthetic future price, useful for illiquid futures or weekly expiries that lack a traded future.

**Prompt:** *"What's the NIFTY synthetic future price for 25NOV25?"*

***

#### `get_expiry_dates`

All tradeable expiries for an underlying.

**Prompt:** *"List all NIFTY options expiries available on NFO"*

***

#### `get_available_intervals`

Supported timeframes for `get_historical_data`.

**Prompt:** *"What intraday intervals are supported?"*

***

#### `get_instruments`

Bulk instrument master download for an exchange (or all exchanges when `exchange` is omitted). Output is paginated, default limit 500, with a `truncated` flag.

**Prompts:**

* *"Download the NFO instrument master, first 500 rows"*
* *"Get all MCX instruments available for trading"*

***

#### `get_index_symbols`

Returns the full standardized OpenAlgo index symbol list (57 NSE + 40 BSE), rolled out uniformly across every supported broker.

**Prompts:**

* *"List all NSE index symbols I can subscribe to"*
* *"Show me the BSE index list, I want to stream SENSEX50"*

***

### Margin

#### `calculate_margin`

SPAN + exposure margin for a hypothetical position set. Accepts an array of legs with `symbol`, `exchange`, `action`, `product`, `pricetype`, `quantity`.

**Prompts:**

* *"Calculate margin for 1 lot NIFTY 25000 CE buy + 1 lot 25500 CE sell, 25NOV25 expiry"*
* *"How much margin do I need for a BANKNIFTY short straddle at ATM for next week?"*

***

### Analyzer

#### `analyzer_status`

Am I in simulated (analyzer) or live mode?

**Prompt:** *"Am I in live or analyzer mode right now?"*

***

#### `analyzer_toggle`

Flip between simulated and live trading. Analyzer mode returns sandbox order IDs in the same `YYMMDD` + sequence shape as a real one, and the response carries `mode: "analyze"`, without touching the broker. Read the `mode` field, not the order ID, to tell simulated from live.

**Prompts:**

* *"Switch to analyzer mode before I test this strategy"*
* *"Turn off analyzer, I want to go live"*

***

### Market Calendar

#### `get_holidays`

Full holiday list for a year (year optional → defaults to current year).

**Prompts:**

* *"What are the trading holidays in 2026?"*
* *"List this year's market holidays"*

***

#### `get_timings`

Exchange open/close epoch timestamps for a given date (date optional → defaults to today).

**Prompt:** *"What are today's market timings across NSE, BFO and MCX?"*

***

#### `check_holiday`

This tool is registered and appears in MCP clients, but it is currently **unavailable**: it calls `/api/v1/checkholiday`, which is not a registered OpenAlgo REST endpoint. Calls return an endpoint error instead of a holiday result. Use `get_timings` for one date or `get_holidays` for the yearly list.

***

### Utilities

#### `get_openalgo_version`

**Prompt:** *"What version of the openalgo library is running?"*

***

#### `validate_order_constants`

Quick cheat-sheet of valid exchanges, product types, price types, actions, and intervals, useful when the model wants to double-check a parameter before sending an order.

**Prompt:** *"Remind me of the valid product types and price types"*

***

#### `send_telegram_alert`

Push a Telegram notification via the OpenAlgo Telegram bot (must be configured in OpenAlgo settings first).

| Param      | Required | Notes                                                                 |
| ---------- | -------- | --------------------------------------------------------------------- |
| `username` | Yes      | Your OpenAlgo login ID. There is no default, so name it in the prompt |
| `message`  | Yes      | Body text                                                             |
| `priority` | No       | 1 to 10, defaults to 5                                                |

This is the one tool annotated as a write that is gated on `read:account`, so a read-only remote session can still send Telegram messages.

**Prompts:**

* *"Send me a Telegram alert: NIFTY crossed 26000, priority 8"*
* *"Ping me on Telegram if my NIFTY CE fills"*

***

### Technical Research

Research tools fetch broker or Historify history and calculate compact results on the OpenAlgo server. Common optional controls are `interval`, `start_date`, `end_date`, `lookback_bars`, `lookback_days`, and `source` (`api` or `db`). `multi_timeframe_analysis` is the exception: it takes a list called `intervals`, not a single `interval`.

#### `calculate_indicator`

Run an `openalgo.ta` indicator by name. Supply `symbol`, `exchange`, and `indicator`; use `params` for indicator arguments, `inputs` when automatic OHLCV input detection is insufficient, and `bars` to limit returned rows.

**Prompt:** *"Calculate RSI(14) and the latest 20 values for RELIANCE daily candles"*

#### `get_trend_snapshot`

Return a one-call trend bundle containing SMA, EMA, Supertrend, ADX/DMI, and Ichimoku values.

**Prompt:** *"Give me a daily trend snapshot for NIFTY"*

#### `get_momentum_snapshot`

Return RSI, MACD, Stochastic, CCI, and Williams %R values for one symbol and interval.

**Prompt:** *"Show a 15-minute momentum snapshot for SBIN"*

#### `get_volatility_snapshot`

Return ATR, NATR, Bollinger, Keltner, Donchian, and historical-volatility values.

**Prompt:** *"Compare the current volatility measures for INFY on daily candles"*

#### `get_support_resistance`

Calculate pivot points, Donchian levels, and rolling highest-high and lowest-low values. `period` defaults to 20.

**Prompt:** *"Find 20-day support and resistance levels for RELIANCE"*

#### `detect_signals`

Find recent bullish and bearish events. `signal_type` selects the rule and defaults to `ema_cross`; valid values are `ema_cross`, `sma_cross`, `macd_cross`, `supertrend_flip`, and `rsi_threshold`. `fast` (20) and `slow` (50) set the crossover lengths, `period` (14) the RSI length, `upper` (70) and `lower` (30) the RSI thresholds, and `limit` (20) bounds the returned events.

**Prompt:** *"Find the latest EMA 20/50 cross signals for TCS"*

#### `screen_instruments`

Evaluate a modest list of `{symbol, exchange}` pairs. `condition` defaults to `rsi_below`; valid values are `rsi_below`, `rsi_above`, `price_above_sma`, `price_below_sma`, `supertrend_bullish`, and `supertrend_bearish`. `value` (30.0) is the threshold and `period` (14) the indicator length. History is fetched per symbol, so keep broker-backed lists small.

**Prompt:** *"Screen RELIANCE, INFY, TCS, and SBIN for RSI below 35"*

#### `multi_timeframe_analysis`

Compute one indicator across several timeframes. The default timeframes are `5m`, `15m`, `1h`, and `D`.

**Prompt:** *"Check RSI confluence for NIFTY across 5m, 15m, 1h, and daily"*

#### `correlation_beta`

Align two symbols on common timestamps and return rolling correlation, rolling beta, linear-regression slope, and full-sample Pearson correlation.

**Prompt:** *"Calculate 60-day correlation and beta for RELIANCE versus NIFTY"*

***

### Worked Multi-Tool Workflows

Real strength shows when the assistant chains tools on its own. Example prompts:

**1. End-to-end iron condor (analyzer mode):**

> *"Set up a NIFTY iron condor for next week's expiry. Find the expiry, pull the option chain, use OTM5 strikes on both sides, calculate the margin required, and, only if margin is under ₹1L, place it in analyzer mode using 1 lot per leg."*

The assistant will chain: `get_expiry_dates` → `get_option_chain` → `get_option_symbol` (for lot size) → `calculate_margin` → `analyzer_status` / `analyzer_toggle` → `place_options_multi_order`.

**2. Pre-market checklist:**

> *"Before I start trading: is the market open today on NSE and MCX, what's my free cash, what's my current position book, and what's NIFTY spot right now?"*

Chains: `get_timings` → `get_funds` → `get_position_book` → `get_quote`.

**3. Options greeks scan:**

> *"Pull the NIFTY option chain for 25NOV25 within 5 strikes of ATM, then compute greeks for the ATM CE and PE with 6.5% interest rate, tell me which has higher vega."*

Chains: `get_option_chain` → `get_option_symbol` (ATM) × 2 → `get_option_greeks` × 2.

**4. Square-off with Telegram confirmation:**

> *"Square off everything, cancel all pending orders, then send me a Telegram alert summarizing what got closed with the realized P\&L."*

Chains: `cancel_all_orders` → `close_all_positions` → `get_trade_book` → `send_telegram_alert`.

***

### Quick Prompt Patterns

| Intent        | Prompt pattern                                                 |
| ------------- | -------------------------------------------------------------- |
| Status check  | *"What's my {thing}?"*                                         |
| Single action | *"{Buy/Sell} {qty} {symbol} at {price}"*                       |
| Multi-leg     | *"Build a {strategy} on {underlying} {expiry} with {offsets}"* |
| Safety-first  | *"In analyzer mode, {do the thing}"*                           |
| Conditional   | *"Only if {condition}, then {action}"*                         |
| Research      | *"Show me {chain/greeks/history} and recommend {levels}"*      |

***

### Safety Tips

* Start in **analyzer mode** (`analyzer_toggle True`) while you get comfortable. Orders look real but never leave OpenAlgo.
* Use phrases like *"only if margin is under X"* or *"ask me to confirm before placing"* and the assistant will pause for your OK.
* Use a unique `strategy` name per use-case (e.g., *"use strategy 'nifty scalper'"*) so MCP-driven activity is cleanly separable from manual orders in logs.
* For live trading, set up the OpenAlgo Telegram bot and ask the assistant to *"send a Telegram alert after every order fill"*. You get a realtime feed without staring at the screen.

***

### Related

* MCP Server Setup Guide: install, configure Claude / Cursor / Windsurf, broker prerequisites
* OpenAlgo Symbol Format: how equity / future / option symbols are constructed
* API Documentation: underlying REST endpoints each MCP tool wraps
