stock_market_mcp
Provides decision journal persistence in MongoDB, allowing the server to log BUY/HOLD/SELL decisions with rationale and price, and to review those logged decisions against current prices for outcome verification.
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., "@stock_market_mcpAnalyze RELIANCE.NS and give a BUY/HOLD/SELL recommendation"
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.
π§ stock_market_mcp
FoodForBrains Β· Feeding your brain the data it needs to decide.
stock_market_mcp is a Model Context Protocol (MCP) server for stock research and screening. It exposes a verified-data layer that gives AI clients grounded market information for NSE/BSE and US equities, with a simple BUY/HOLD/SELL scoring model layered on top.
The server is designed for clients such as ZCode, Claude Desktop, and other MCP-compatible hosts. It keeps the LLM reasoning layer thin and pushes the data retrieval, calculations, and audit trail into the server.
π Full docs: the wiki
What it does
Covers Indian equities (NSE/BSE) and US tickers.
Exposes 20 MCP tools plus 1 prompt.
Uses Yahoo Finance as the default data source for quotes, history, fundamentals, and news.
Adds NSE/BSE market mover data from public exchange endpoints with 10-minute cache handling.
Supports a MongoDB-backed decision journal with a local JSON fallback.
Produces auditable
data_snapshotblocks so recommendation claims can be traced back to data.
Related MCP server: Rozkoduj MCP
Core facts
Area | Details |
Primary data source | Yahoo Finance ( |
Optional extra data | Alpha Vantage for company overview, only for US tickers |
Indian market sources | NSE public API + BSE public scraping ( |
Journal storage | MongoDB ( |
Protocol | MCP over stdio |
Python | 3.10+ |
Tool set
Market and quote tools
get_quoteβ current price, previous close, change %search_symbolβ resolve company names to symbols with India-first rankingtechnical_analysisβ SMA 20/50/200, RSI-14, MACD, 52-week range, daily volatilitymarket_moversβ NSE/BSE gainers/losers + index levelsstock_newsβ recent headlines for one symbolearnings_calendarβ earnings dates, EPS estimates, surprise history
Analysis tools
analyze_stockβ full technical + fundamental score (0β100), BUY/HOLD/SELL, reasons, data snapshotanalyze_watchlistβ rank a list of symbols by scorecompare_stocksβ side-by-side fundamentals for multiple symbolsstock_screenerβ filter by valuation, RSI, dividend yield, ROE, and scorecorrelation_analysisβ correlation, beta, r-squared against a benchmark
Fundamental and market context tools
currency_impactβ INR vs USD return comparisondividend_calendarβ yield, ex-dividend, historical payoutsoptions_dataβ options chain IV, put/call ratios, ATM detailssector_mappingβ sector, industry, peers, market cap, key metricsfii_dii_flowsβ institutional holders, mutual-fund holders, insider activity where available
Journal and workflow tools
log_decisionβ record a BUY/HOLD/SELL call with rationalereview_decisionsβ score open journal entries against current pricesanalyst_reportsβ generate fundamentals, technical, and sentiment reports for one symbol
Prompt
bull_bear_debateβ TradingAgents-style workflow: gather data β bull case β bear case β risk check β decision β journal it
Symbol formats
Market | Format | Example |
NSE (India) |
|
|
BSE (India) |
|
|
US | plain ticker |
|
Setup
Prerequisites
Python 3.10+
pip
An MCP client such as ZCode or Claude Desktop
Optional: Alpha Vantage API key for
alpha_vantage_overviewOptional: MongoDB for decision-journal persistence
Install
git clone https://github.com/AnupamSinha/stock_market_mcp.git
cd stock_market_mcp
pip install -r requirements.txtOptional environment config
Create a .env file in the project root (or export the same env vars):
ALPHA_VANTAGE_API_KEY=your_key_here
ALPHA_VANTAGE_BASE_URL=https://www.alphavantage.co/query
MONGODB_URI=mongodb://localhost:27017
MONGODB_DB_NAME=stock_dataIf ALPHA_VANTAGE_API_KEY is empty, alpha_vantage_overview simply reports that the feature is disabled.
macOS users sometimes hit SSL errors while installing packages. If that happens, run
pip install certifiand the server will pick it up automatically.
Run the server
This project runs as an MCP stdio server. The client starts it; you normally do not run it manually unless testing.
python3 server.pyMCP client configuration
ZCode
Add this to ~/.zcode/cli/config.json:
{
"mcp": {
"servers": {
"stock_market_mcp": {
"command": "python3",
"args": ["/absolute/path/to/stock_market_mcp/server.py"]
}
}
}
}Claude Desktop
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"stock_market_mcp": {
"command": "python3",
"args": ["/absolute/path/to/stock_market_mcp/server.py"]
}
}
}Use absolute paths. Start a new session after adding the server.
Verify the connection
python3 - <<'EOF'
import asyncio, json
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
async def main():
params = StdioServerParameters(command="python3", args=["server.py"])
async with stdio_client(params) as (r, w):
async with ClientSession(r, w) as s:
await s.initialize()
tools = await s.list_tools()
prompts = await s.list_prompts()
print("TOOLS:", [t.name for t in tools.tools])
print("PROMPTS:", [p.name for p in prompts.prompts])
asyncio.run(main())
EOFExpected result: 20 tool names plus bull_bear_debate.
Example prompts
"Analyze my watchlist and tell me which stocks to consider buying"
"Do a technical analysis of TCS.NS"
"Compare RELIANCE.NS, HDFCBANK.NS and INFY.NS"
"What is moving in the market today?"
"Screen for quality value stocks with P/E under 25 and RSI between 40 and 70"
"How does AAPL correlate with the S&P 500?"
Troubleshooting
Symptom | Fix |
Tools do not appear in the client | Start a new session; confirm the absolute path to |
|
|
SSL certificate errors |
|
Alpha Vantage returns an βInformationβ message | Free tier was hit or the symbol is not supported for that endpoint |
MongoDB journal not persisting | Confirm |
Empty or inconsistent market-movers data | NSE/BSE endpoints are rate-limited and cached; retry after a short pause |
Repository layout
stock_market_mcp/
βββ app.py # Shared FastMCP instance
βββ backtest.py # Backtest harness for the scoring model
βββ config.py # .env loading and runtime config
βββ e2e_test.py # MCP handshake validation
βββ prompts/
β βββ debate.py # bull_bear_debate prompt
βββ requirements.txt # Project dependencies
βββ server.py # Entrypoint: imports all modules and runs MCP stdio
βββ tools/
β βββ __init__.py
β βββ analysis.py # analyze_stock, analyze_watchlist, compare_stocks
β βββ classification.py # sector_mapping
β βββ core.py # quote, search, technicals, alpha vantage overview
β βββ derivatives.py # options_data
β βββ flows.py # fii_dii_flows
β βββ fundamentals.py # currency_impact, dividend_calendar
β βββ journal.py # log_decision, review_decisions, analyst_reports
β βββ market.py # market_movers, stock_news, earnings_calendar
β βββ screening.py # stock_screener, correlation_analysis
βββ utils/
β βββ __init__.py
β βββ helpers.py # _safe, RSI, MACD, Alpha Vantage helpers
βββ wiki/ # GitHub wiki pages
βββ .gitignore
βββ README.md
βββ SESSION_NOTES.mdBacktesting
backtest.py replays the scoring rules over recent market history and compares the signal against benchmark returns. The current findings are intentionally conservative: the technical score can have some short-horizon edge, but the rules are a screening aid rather than a proven predictive model.
Acknowledgements
This project borrows the βgrounded analyst reports β bull/bear debate β risk check β decision journalβ workflow from TradingAgents and adapts it to an MCP server for NSE/BSE and US markets. The key difference is that the server handles the data retrieval and the client does the higher-level reasoning.
Disclaimer
All output is educational analysis based on public market data and is not financial advice. BUY/HOLD/SELL recommendations are screening aids, not trade recommendations. Always do your own research and consult a qualified financial advisor before investing.
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
AI stock intelligence: prices, fundamentals, technicals, news, macro regime, and sector signals.
Analyze any Nifty 500 stock with AI β price action, demand zones, technicals & screener.
Portfolio analytics + US-equity market research for AI clients. ChatGPT deep-research compat.
Technical analysis (RSI, MA, signal score) for 9,400+ global stocks, by ticker or name.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceReal-time Indian stock market sentiment intelligence. Provides NSE/BSE news sentiment, aggregated stock & sector signals, and technical analysis.1-

Rozkoduj MCPofficial
AlicenseAqualityAmaintenanceProvides AI assistants with market screening, analysis, and scoring across stocks, crypto, and forex, enabling natural language queries for trading insights.4MIT- AlicenseNot gradedqualityDmaintenanceConnects AI assistants to real-time Indian stock market data with 34 tools for search, screening, analysis, portfolio tracking, and market insights across all NSE and BSE stocks.118 npm115MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to perform deep Indian stock research with fundamentals, forensic scores, DCF valuation, screening, and news for 6000+ NSE/BSE stocks.8 npm1MIT