angleone-mcp-sever

angleone-mcp-sever

An MCP server that exposes Angel One's SmartAPI as tools for Claude Code, enabling login, portfolio data, market quotes, historical candles, and order placement/modification/cancellation.

Category
访问服务器

README

angleone-mcp-sever

An MCP (Model Context Protocol) server that exposes Angel One's SmartAPI as tools for Claude Code (or any MCP client) — login, portfolio data, market quotes, historical candles, and order placement/modification/cancellation.

⚠️ Order-related tools (place_order, modify_order, cancel_order) execute real trades on your Angel One account. Use with care.

Prerequisites

  • Python 3.10+
  • An Angel One trading account with SmartAPI access
    • An API key generated at https://smartapi.angelbroking.com/apps
    • TOTP enabled on your SmartAPI login (you'll need the base32 TOTP secret, not a 6-digit code)
  • Claude Code CLI, if you want to connect this as an MCP server

Setup

  1. Clone the repo and install dependencies:

    git clone https://github.com/bns218/angleone-mcp-sever.git
    cd angleone-mcp-sever
    pip install -r requirements.txt
    
  2. Copy the env template and fill in your credentials:

    cp .env.example .env
    

    Edit .env:

    SMARTAPI_API_KEY=your_api_key
    SMARTAPI_CLIENT_CODE=your_client_code
    SMARTAPI_PASSWORD=your_password
    SMARTAPI_TOTP_SECRET=your_totp_base32_secret
    

    .env is gitignored — never commit it.

  3. Sanity-check the server starts:

    cd mcp_server
    python -c "import server; print('tools loaded ok')"
    

Connecting to Claude Code

Register the server with the Claude Code CLI. Use --scope project to make it available only in this directory, or --scope user to make it available in every Claude Code session on your machine.

claude mcp add angleone-smartapi --scope user -- python "/absolute/path/to/angleone-mcp-sever/mcp_server/server.py"

Verify it connected:

claude mcp list

You should see angleone-smartapi ... ✓ Connected.

Available tools

Tool Description
login Authenticate with SmartAPI using .env credentials (TOTP-based). Call first.
logout Terminate the current session.
get_profile Get account profile details.
get_holdings Get current demat holdings.
get_positions Get today's open positions.
get_funds Get available margin/funds (RMS limits).
get_order_book Get today's orders and statuses.
get_trade_book Get today's executed trades.
get_ltp Get last traded price for an exchange/symbol/token triple.
get_price Get live LTP for a tracked stock/index by plain name (e.g. "SBIN", "NIFTY") — no token needed.
get_historical_candle Get historical OHLCV candles by exchange/token.
get_historical_by_symbol Get historical OHLCV candles by plain name. Supports daily (ONE_DAY) and intraday (ONE_MINUTE…ONE_HOUR) intervals.
list_option_expiries List available derivative expiry dates for a stock/index.
get_option_chain Get the CE/PE option chain (strikes + LTP) around spot for a stock/index.
place_order Place a real order. Executes a real trade.
modify_order Modify an existing open order. Affects a real order.
cancel_order Cancel an open order. Cancels a real order.

get_price, get_historical_by_symbol, list_option_expiries, and get_option_chain resolve symbols against a local lookup (mcp_server/instruments.json + derivatives.json) covering:

  • The tracked NSE F&O stock list (208 symbols)
  • Main tradable indices with F&O contracts: NIFTY, BANKNIFTY, FINNIFTY, MIDCPNIFTY (NSE), SENSEX (BSE)
  • NSE sectoral indices, spot quote only, no F&O: NIFTY AUTO, NIFTY FMCG, NIFTY IT, NIFTY MEDIA, NIFTY METAL, NIFTY PHARMA, NIFTY PSU BANK, NIFTY PVT BANK, NIFTY REALTY, NIFTY ENERGY, NIFTY INFRA, NIFTY COMMODITIES, NIFTY CONSUMPTION, NIFTY MNC, NIFTY SERV SECTOR, NIFTY CPSE, NIFTY PSE

No live scrip search needed for any of the above — use the exact multi-word name for sectoral indices (e.g. "NIFTY PSU BANK").

Claude Code Skill

A companion skill at ~/.claude/skills/nse-fo-quotes/SKILL.md (user scope) tells Claude to answer price/candle/option-chain questions for the tracked symbol list directly using these tools, without asking for exchange/token details first. It's independent of this repo — copy the skill file if you set the server up on another machine.

Project structure

mcp_server/
  server.py             # FastMCP server exposing SmartAPI operations as MCP tools
  smartapi_client.py    # Thin wrapper around the smartapi-python SDK
  instruments.json       # Local symbol -> {exchange, tradingsymbol, token} lookup
  derivatives.json       # Local option/future contract lookup per underlying
  build_instruments.py   # Regenerates the two files above from Angel One's instrument master
requirements.txt
.env.example              # Credential template (copy to .env)
.mcp.json                  # Claude Code project-scope MCP registration

Updating the tracked symbol list

instruments.json and derivatives.json are static snapshots. To refresh them (new F&O stocks added/removed, or the derivatives file goes stale near month-end rollovers):

  1. Edit FNO_STOCKS / INDEX_NAMES in mcp_server/build_instruments.py if the symbol list changed.

  2. Download the current instrument master and rebuild:

    cd mcp_server
    python -c "import requests; open('OpenAPIScripMaster.json','wb').write(requests.get('https://margincalculator.angelbroking.com/OpenAPI_File/files/OpenAPIScripMaster.json').content)"
    python build_instruments.py
    rm OpenAPIScripMaster.json
    

Notes

  • Login re-authenticates and replaces the session each time it's called; safe to call repeatedly — and every tool auto-logs in on first use if no session exists yet.
  • For symbols outside the tracked list, use SmartAPI's scrip search (or the Angel One instrument master) to look up tokens, then call get_ltp / get_historical_candle directly with exchange + token.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选