shoonya-mcp
The shoonya-mcp server is a secure Node.js-based MCP interface for algorithmic trading via the Shoonya Broker API, designed for seamless integration with AI assistants like Claude, Cursor, or Gemini.
Secure Credential Management: Encrypts broker credentials using AES-256-GCM with PBKDF2 (310,000 iterations), storing them locally in an encrypted vault (~/.shoonya-mcp/vault.enc). The AI never directly sees sensitive credentials. Includes CLI commands for one-time setup, editing (e.g., for 90-day password resets), and securely deleting the vault.
Core Trading Capabilities:
Login — Authenticate using only a master password; credentials are decrypted locally and never exposed to the AI.
Place Standard Orders — Place market or limit orders via a simple command string (e.g.,
NIFTY 24500 CE 30 L 110).Place Manual Stop Loss Orders — Place SL orders using a command string (e.g.,
NIFTY 24500 CE 30 SL 100).Place Auto Stop Loss Orders — Automatically fetch the average buy price of a filled order and place an SL-LMT order based on index-specific offsets.
Modify Open Orders — Update price, quantity, or price type of an existing open order.
Modify Stop Loss Orders — Adjust price, trigger price, quantity, or price type of an existing SL order.
Cancel Orders — Cancel any open order, including stop loss orders.
Exit Positions — Exit an open position by placing an opposite market order.
View Order Book — Fetch and review your full order book.
Check Margin — Retrieve available trading margin (cash + payin + payout − margin used).
Check Order Status — Look up the current status of a specific order by order ID.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@shoonya-mcp Buy NIFTY 24500 CE 30"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Shoonya MCP Server (Node.js)
A lightweight, bank-level secure Model Context Protocol (MCP) server for algorithmic trading via the Shoonya Broker API.
This package is designed for effortless and secure distribution. It runs natively over stdio, meaning it can be plugged directly into AI assistants like Claude Desktop, Cursor, or Gemini without requiring a Python environment.
🔐 Security Architecture
Your trading credentials are protected using military-grade encryption. The AI assistant never sees, stores, or transmits your passwords.
How It Works
┌─────────────────────────────────────────────────────────┐
│ YOUR LOCAL MACHINE │
│ │
│ ┌──────────────┐ Master ┌──────────────────┐ │
│ │ AI (Claude, │ Password │ Shoonya MCP │ │
│ │ Cursor, etc) │ ──────────► │ Server (Node.js)│ │
│ │ │ │ │ │
│ │ Never sees │ │ Decrypts vault │ │
│ │ credentials │ │ locally only │ │
│ └──────────────┘ └────────┬─────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────┐ │
│ │ ~/.shoonya-mcp/ │ │
│ │ vault.enc │ │
│ │ │ │
│ │ AES-256-GCM │ │
│ │ encrypted file │ │
│ └──────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────┐ │
│ │ Shoonya Broker │ │
│ │ API (HTTPS) │ │
│ └──────────────────┘ │
└─────────────────────────────────────────────────────────┘Encryption Details
Feature | Specification |
Encryption Algorithm | AES-256-GCM (used by banks, governments, military) |
Key Derivation | PBKDF2 with SHA-256, 310,000 iterations (OWASP 2023) |
Salt | 32 bytes, cryptographically random, unique per vault |
IV (Nonce) | 16 bytes, cryptographically random, unique per save |
Authentication | GCM auth tag prevents tampering |
File Permissions |
|
Vault Location |
|
AI Exposure | ❌ Credentials never sent to or seen by the AI |
What the AI Can See vs Cannot See
Data | AI Can See? |
Master Password | ✅ Only to decrypt vault (not stored) |
User ID | ❌ Never |
Broker Password | ❌ Never |
TOTP Secret Key | ❌ Never |
Client ID (formerly Vendor Code) | ❌ Never |
Secret Code (formerly API Key) | ❌ Never |
IMEI | ❌ Never |
Order commands | ✅ (e.g., "NIFTY 24500 CE 30") |
Order results | ✅ (order ID, margin, status) |
Related MCP server: Phantom MCP
Quick Start
Step 1: Setup Credentials (One-Time)
Run the interactive setup wizard in your terminal:
npx github:benatcmathew/Shoonya_Trading_MCP-Server --setupThis will:
Ask for your Shoonya broker credentials
Ask you to set a master password
Encrypt everything with AES-256-GCM and save to
~/.shoonya-mcp/vault.enc
Editing Credentials (90-Day Password Reset)
Shoonya requires users to reset their broker password every 90 days. To update your vault with your new password (or edit any other API details), simply run the edit command:
npx github:benatcmathew/Shoonya_Trading_MCP-Server --editWhen prompted, type yes to overwrite your existing vault, and enter your new details.
Step 2: Connect to Claude Desktop
Add this to your claude_desktop_config.json:
{
"mcpServers": {
"shoonya-mcp": {
"command": "npx",
"args": [
"-y",
"github:benatcmathew/Shoonya_Trading_MCP-Server"
]
}
}
}Step 3: Start Trading!
In Claude Desktop, simply say:
"Login to Shoonya" → The AI will ask for your master password only. "Buy NIFTY 24500 CE 30" → Places a market order. "Place auto SL for order 12345 on NIFTY" → Auto stop-loss.
CLI Commands
Command | Description |
| First-time credential setup (interactive wizard) |
| Edit/update stored credentials |
| Securely wipe and delete the vault |
| Check if a vault exists |
| Start the MCP server (default, used by Claude) |
Available MCP Tools
Tool | Parameters | Description |
|
| Decrypt vault & login to Shoonya |
|
| Smart order ( |
|
| Manual SL (e.g., |
|
| Auto SL from filled order |
|
| Modify open order |
|
| Modify SL order |
|
| Cancel any order |
|
| Exit position |
| — | Fetch order book |
| — | Fetch available margin |
|
| Check specific order status |
Manual Build from Source
git clone https://github.com/benatcmathew/Shoonya_Trading_MCP-Server.git
cd Shoonya_Trading_MCP-Server
npm install
npm run build
npm startLicense
ISC
Available Tools
11 toolscancel_orderB
Cancel any open order (including SL).
Inputs: order_id (required).
check_marginA
Fetch the available margin (cash + payin + payout - marginused).
Inputs: no named parameters.
check_order_statusC
Fetch the status of a specific order from the order book.
Inputs: order_id (required).
exit_orderC
Exit an open position by placing an opposite market order.
Inputs: order_id (required), product_type (required).
get_order_bookB
Fetch the user's order book.
Inputs: no named parameters.
loginA
Securely login to Shoonya using encrypted credentials from the local vault. The AI never sees passwords. Requires the master_password to decrypt the vault.
Inputs: master_password (required).
modify_orderC
Modify an existing open order.
Inputs: exchange (required), order_id (required), tradingsymbol (required), price, +2 more.
modify_slC
Modify an existing Stop Loss order.
Inputs: exchange (required), order_id (required), tradingsymbol (required), price, +3 more.
place_auto_slA
Automatically fetch avg buy price of a filled order and place an auto SL-LMT order based on index specific offset.
Inputs: index (required), order_id (required).
place_manual_slB
Place a manual Stop Loss order using a string command like 'NIFTY 24500 CE 30 SL 100'
Inputs: command (required).
place_orderB
Place a standard order (Market/Limit) using a command string like 'NIFTY 24500 CE 30 L 110'
Inputs: command (required), buy_or_sell (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
Each tool has a distinct purpose: login, various order placement (standard, auto SL, manual SL), modifications, cancellation, exit, margin/status checks. No overlapping functions.
Most tools follow a verb_noun pattern (e.g., cancel_order, place_order, check_margin). 'login' is a single verb but is a clear exception.
11 tools cover the core trading lifecycle from authentication to order management and status checks, without being excessive.
Covers login, order placement (3 types), modification (2 types), cancellation, exit, margin, and order book. Missing a position book view and trade history, but core operations are well-covered.
Maintenance
Related MCP Connectors
AI agents backtest, paper trade and live trade via your broker. Free to connect; OAuth.
Build, backtest and diagnose algo trading strategies in your own Tradetron account in plain English.
Connect brokerage accounts to AI assistants: holdings, orders, asset lookup, and approved trading.
Automate trading on your own Alpaca account - build, backtest and run strategies via your AI.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables natural language analysis of AWS costs, automated FinOps waste audits, and budget monitoring across multiple profiles and regions while keeping credentials secure locally.25 PyPI184MIT
- FlicenseNot gradedqualityDmaintenanceEnables authorized compliance verification and security auditing through natural language, bridging AI assistants with industry-standard security tools for enterprise audits.24-
- AlicenseAqualityBmaintenanceEnables natural language control of SSH servers, allowing users to execute commands, manage files, view logs, deploy applications, and more through AI-driven conversations.973 PyPI4MIT
- FlicenseNot gradedqualityAmaintenanceEnables AI assistants to analyze AWS cloud costs, audit for waste, monitor budgets, and generate FinOps reports using natural language across multiple AWS profiles and regions, while keeping credentials on the local machine.-