Nubra MCP server for Codex and other MCP clients
Project description
Nubra MCP Server
A Python MCP server for Nubra built on FastMCP.
This repo is designed to let MCP clients such as Codex connect to Nubra for:
- authentication
- instrument lookup and ref-id resolution
- quotes and historical data
- option-chain and derivatives analysis
- holdings, funds, positions, and portfolio reporting
- TA/indicator scans via
nubra-talib - backtesting via
vectorbt - local report and CSV export workflows
- UAT-only trading actions with strict environment guardrails
What This MCP Supports
Read-only workflows
- auth state and session checks
- cash, futures, and options instrument discovery
- quotes, current price, and previous-close change
- historical OHLCV fetch and CSV export
- options analytics and chain summaries
- portfolio summary, holdings, positions, and funds
- HTML and image-based portfolio reports
- watchlist scanning and strategy helper tools
- trade journal summaries
- backtest reports and equity curve exports
Trading workflows
Trading is intentionally limited:
- order placement is allowed only in
UAT - order modification is allowed only in
UAT - order cancellation is allowed only in
UAT - square-off is allowed only in
UAT - options strategy execution is allowed only in
UAT - all trading actions are blocked in
PROD
The guardrail exists in both the MCP tool layer and the service layer.
Safety Model
This repo is meant to be public-safe if used correctly.
What should be committed:
- source code
.env.example.mcp.json- docs
- tests
What should never be committed:
.envauth_state.json- personal phone numbers
- MPIN values
- OTPs
- generated reports and exports
Each user of this MCP should create their own local .env and log in with their own Nubra account.
Project Structure
- [server.py](C:\Users\suboth sundar\Desktop\Nubra_API_Full_context\nubra-mcp-server\server.py): MCP entrypoint and tool registration
- [config.py](C:\Users\suboth sundar\Desktop\Nubra_API_Full_context\nubra-mcp-server\config.py): environment-driven settings
- [nubra_client.py](C:\Users\suboth sundar\Desktop\Nubra_API_Full_context\nubra-mcp-server\nubra_client.py): Nubra client and high-level service layer
- [tools](C:\Users\suboth sundar\Desktop\Nubra_API_Full_context\nubra-mcp-server\tools): MCP tool modules
- [tests](C:\Users\suboth sundar\Desktop\Nubra_API_Full_context\nubra-mcp-server\tests): local unit tests
- [bootstrap.ps1](C:\Users\suboth sundar\Desktop\Nubra_API_Full_context\nubra-mcp-server\bootstrap.ps1): local environment setup
- [run_stdio.ps1](C:\Users\suboth sundar\Desktop\Nubra_API_Full_context\nubra-mcp-server\run_stdio.ps1): stdio launcher for MCP clients
- [run_http.ps1](C:\Users\suboth sundar\Desktop\Nubra_API_Full_context\nubra-mcp-server\run_http.ps1): HTTP launcher for manual testing
Requirements
- Windows with PowerShell
- Python 3.12 recommended
- Nubra account access
- internet access for Nubra APIs
Installed dependencies include:
nubra-sdknubra-talibTA-LibpandasmatplotlibvectorbtFastMCPstack
Setup
1. Clone the repo
git clone https://github.com/socials-zanskar/nubra-mcp-server.git
cd nubra-mcp-server
2. Bootstrap the local environment
powershell -ExecutionPolicy Bypass -File .\bootstrap.ps1
This script:
- creates
.venv - installs dependencies
- creates
.envfrom.env.exampleif missing
Alternative: install from pip
This repo also supports package-based install so users can run:
pip install nubra-mcp
After install, the user gets a nubra-mcp command.
Important caveat:
nubra-sdkinstalls from PyPInubra-talibis not included in the base published package yetvectorbtis not included in the base published package yet- indicator tools that depend on
nubra-talibare optional in package mode for now - backtest tools that depend on
vectorbtare optional in package mode for now - the repo/bootstrap flow still installs the full indicator and backtest stack for local development
Optional package installs:
pip install "nubra-mcp[indicators]"
pip install "nubra-mcp[backtest]"
pip install "nubra-mcp[full]"
3. Fill in your local .env
Use [.env.example](C:\Users\suboth sundar\Desktop\Nubra_API_Full_context\nubra-mcp-server.env.example) as the template.
Example:
PHONE=
MPIN=
NUBRA_ENV=UAT
NUBRA_DEFAULT_EXCHANGE=NSE
LOG_LEVEL=INFO
HOST=127.0.0.1
PORT=8000
MCP_PATH=/mcp
AUTH_STATE_FILE=auth_state.json
Important:
- keep
NUBRA_ENV=UATwhile testing trading features - do not commit your real
.env - do not share
auth_state.json
Running the MCP
Packaged command
If installed as a package, the command is:
nubra-mcp
That defaults to stdio mode so Codex can launch it directly as an MCP server.
Optional helper:
nubra-mcp init
init is not required. It only creates a local user config template under the user's home folder for convenience.
Recommended for MCP clients
powershell -ExecutionPolicy Bypass -File .\run_stdio.ps1
Recommended for HTTP testing
powershell -ExecutionPolicy Bypass -File .\run_http.ps1
Direct Python entrypoints
stdio:
.\.venv\Scripts\python.exe .\server.py --transport stdio
streamable HTTP:
.\.venv\Scripts\python.exe .\server.py --transport streamable-http
SSE:
.\.venv\Scripts\python.exe .\server.py --transport sse
Default local endpoints for HTTP mode:
- health:
http://127.0.0.1:8000/health - mcp:
http://127.0.0.1:8000/mcp
Codex / MCP Client Integration
This repo includes [.mcp.json](C:\Users\suboth sundar\Desktop\Nubra_API_Full_context\nubra-mcp-server.mcp.json), so repo-aware MCP clients can discover it automatically.
Typical local flow:
- Open the repo folder in the MCP client.
- Run bootstrap once.
- Fill
.env. - Reload or reopen the workspace.
- Let the client launch [run_stdio.ps1](C:\Users\suboth sundar\Desktop\Nubra_API_Full_context\nubra-mcp-server\run_stdio.ps1).
If the client does not detect the server immediately, reload the workspace or restart the app.
Codex desktop app flow for GitHub/repo users
- Clone the repo.
- Run bootstrap.
- Fill
.env. - Open the repo folder in Codex desktop.
- Reload the workspace so Codex reads
.mcp.json. - Start chatting with:
Use nubra mcp and check auth status
Codex desktop app flow for pip users
- Install the package:
pip install nubra-mcp
- Optionally create a user-home config template:
nubra-mcp init
- In Codex desktop, add a global MCP server entry using:
- name:
nubra-mcp - type:
stdio - command:
nubra-mcp
- name:
- Reload or restart Codex desktop.
- In a new chat, start with:
Use nubra mcp and check auth status
Codex CLI flow for pip users
- Install the package:
pip install nubra-mcp
- Register it with Codex CLI:
codex mcp add nubra-mcp --command nubra-mcp
- Verify registration:
codex mcp list
- Start Codex:
codex
- In chat, start with:
Use nubra mcp and check auth status
Where pip users put credentials
nubra-mcp init is optional, not mandatory.
If the user does not run init, they can still connect and log in interactively through chat:
- call
auth_status - enter phone number when asked
- enter OTP when asked
- enter MPIN when asked
If the user does run nubra-mcp init, it creates a local config file under:
C:\Users\<username>\.nubra-mcp\.env
That file is local only and should not be shared.
Authentication Flow
The intended auth flow is:
- call
auth_status - if login is required, ask for phone number
- call
begin_auth_floworsend_otp - ask for OTP
- call
verify_otp - ask for MPIN
- call
verify_mpin
The authenticated session is stored locally in auth_state.json and reused until Nubra expires it or the user logs out.
UAT Trading Guardrails
Trading tools are UAT-only.
Allowed only in UAT:
preview_uat_orderplace_uat_ordermodify_uat_ordercancel_uat_ordersquare_off_uat_positionplace_uat_options_strategyplace_uat_named_option_strategy
Blocked in PROD:
- all order placement
- all modify/cancel actions
- all square-off actions
- all strategy execution actions
Recommended trading flow:
- use
preview_uat_order - show the clean preview table to the user
- confirm the order details
- place the order with
place_uat_order
The preview includes:
- environment
- symbol
- ref id
- side
- quantity
- order type
- price type
- order price
- product
- validity
- current price
- warnings if the limit is marketable
Export and Report Features
This MCP can save artifacts locally on the user’s machine.
Examples:
- historical CSV exports
- HTML portfolio reports
- PNG portfolio dashboards
- HTML backtest reports
- PNG backtest equity curves
Exports are written under:
- [artifacts](C:\Users\suboth sundar\Desktop\Nubra_API_Full_context\nubra-mcp-server\artifacts)
For small outputs, tools can also return:
preview_rowspreview_columnspreview_mode
That lets the chat render a small table inline while still providing a full downloadable file path.
Indicator and Backtest Features
nubra-talib
Indicator tools use nubra-talib.
In repo mode, it is installed through [requirements.txt](C:\Users\suboth sundar\Desktop\Nubra_API_Full_context\nubra-mcp-server\requirements.txt).
In package mode, nubra-talib is currently optional and not bundled into the base pip install nubra-mcp path yet.
Example uses:
- summarize indicators for one symbol
- scan multiple symbols for RSI thresholds
- scan EMA/SMA crossovers
vectorbt
Backtesting tools use vectorbt.
In package mode, vectorbt is currently optional and not bundled into the base pip install nubra-mcp path yet.
Currently supported examples:
- moving average crossover backtest
- RSI backtest
- HTML backtest export
- equity curve image export
Example Prompts
Auth
Check auth statusStart authentication for phone 9965514793Verify OTP 123456Verify MPIN 2004
Quotes and history
Get quote for RELIANCEExport historical data as CSV for RELIANCE on 1d candles from 2026-02-01 to 2026-03-01Give me a historical chart summary for RELIANCE on 1d candles
Portfolio
Generate a portfolio reportExport my portfolio report as HTMLExport my portfolio report as an image dashboard
Indicators
Summarize symbol indicators for RELIANCE on 1d candles with RSI 14 and EMA 20Scan indicator threshold for RELIANCE, TCS, INFY with RSI >= 60
Backtesting
Run a moving average crossover backtest for RELIANCE on 1d candles with fast_window 20 and slow_window 50Export a backtest report as HTML for RELIANCE using strategy_type ma_crossover
UAT trading
Preview a UAT order for RELIANCE with quantity 1, limit price 1500, and CNCPlace a UAT order for RELIANCE with quantity 1, limit price 1500, and CNCModify UAT order 12345 with a new priceCancel UAT order 12345
Local Validation
Import smoke test
.\.venv\Scripts\python.exe -c "import server; print('server-import-ok')"
Run tests
.\.venv\Scripts\python.exe -m unittest discover -s tests -v
Public Release Checklist
Before pushing this repo publicly:
- make sure
.envis not committed - make sure
auth_state.jsonis not committed - make sure
artifacts/is ignored - make sure your real credentials are removed from local screenshots, logs, and examples
- verify
NUBRA_ENVdefaults toUATin examples - test
preview_uat_orderandplace_uat_order - verify
PRODtrading is still blocked
Notes
- Start with
UATwhile validating the tool surface. - If a client says trading is disabled, it may be reading an older workspace or worktree copy of the repo.
- The main intended repo path should be used, not a stale Codex worktree, when testing the latest changes.
- This repo is designed to be extended; the tool surface is intentionally modular.
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 nubra_mcp-0.1.1.tar.gz.
File metadata
- Download URL: nubra_mcp-0.1.1.tar.gz
- Upload date:
- Size: 62.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff59cbaaf7e0b189e9be42e2113783c68daccda9e070217aa9a925494ef35481
|
|
| MD5 |
c68bfe1216f0efe730eb8616f8fad913
|
|
| BLAKE2b-256 |
663a99282e2119e01d6726424975926084ad8d91159aafe1dd68276a5b382b3c
|
File details
Details for the file nubra_mcp-0.1.1-py3-none-any.whl.
File metadata
- Download URL: nubra_mcp-0.1.1-py3-none-any.whl
- Upload date:
- Size: 61.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
304a45e5ae52ffbaf82f022163b326540c2db86c7c66746c91634bdd5e039b6e
|
|
| MD5 |
3169618af5f26309a02627786640ea0d
|
|
| BLAKE2b-256 |
1080f3f862fcafe395c66b1178532aa9bc1ed5d5eaac4f80da6da9b9b0a8011d
|