Indian Stock Analyst MCP

เซิร์ฟเวอร์ MCP สำหรับการวิเคราะห์ตลาดหุ้นอินเดีย — ปัจจัยพื้นฐาน เทคนิค การประเมินมูลค่า DCF การเปรียบเทียบกลุ่มบริษัท และอื่นๆ อีกมากมาย

GitHubลองใช้ MCP นี้ผู้สนับสนุน

เอกสาร

stock-analyst-mcp

MCP server for global stock market analysis — fundamentals, technicals, DCF valuation, peer comparison, multi-asset support, and more. Works for 50+ regions worldwide.

What's New in v0.5.7

Python 3.13+ Requirement

  • Requires Python >=3.13: Fixes uvx picking stale Python 3.12 which caused pandas C extension crashes (ModuleNotFoundError: pandas._libs.pandas_parser)
  • uvx stock-analyst-mcp now works without --python: uv/uvx auto-selects 3.13+

What's New in v0.5.6

MCP Framework Migration — FastMCP standalone

  • Replaced mcp SDK with standalone fastmcp: Eliminates v2.0.0 breaking changes, no more mcp.server.fastmcp import errors
  • Cleaner dependency: fastmcp>=3.4.0,<4.0.0 (Prefect-maintained, actively developed)
  • Port configuration: Now passed as kwarg to mcp.run(transport=..., port=...)
  • Future-proof: No SDK version conflicts, fastmcp handles all MCP protocol versions

What's New in v0.5.5

News Fix — yfinance format change

  • Fixed empty headlines: yfinance now nests news fields under content
  • Correct mapping: title, publisher, link, pub_date extracted from content.*
  • Backward compatible: still handles legacy top-level news format

What's New in v0.5.4

API Fix — FastMCP.run() compatibility

  • Fixed TypeError: FastMCP.run() doesn't accept port kwarg
  • Port configuration: Set via mcp.settings.port before calling run()

What's New in v0.5.3

Compatibility Fix — mcp>=1.28 support

  • Fixed breaking import: Replaced removed MCPServer with FastMCP from mcp.server.fastmcp
  • Pinned mcp dependency: mcp>=1.0.0,<3.0.0 to prevent future breakage
  • Added requirements.txt for pip-based installs

What's New in v0.5.2

Screener Fix — screen_stocks works across regions

  • Fixed yfinance EquityQuery parameter: _sizesize in yf.screen() call, restoring screener results for India and other regions

What's New in v0.5.1

Performance Overhaul — 3-19x faster peer analysis

  • Parallel peer fundamentals: ThreadPoolExecutor on get_info() calls (3.7x speedup)
  • Batch history downloads: Single yf.download() for all peers (19.3x speedup)
  • Parallel snippet fetching: News analysis now fetches article snippets concurrently
  • New stock_analyst/utils/ module: Reusable concurrency helpers (parallel_map, parallel_map_dict, batch_download_history)
  • Zero new dependencies: Uses stdlib concurrent.futures

Example: Analyzing LOW (US) with 10 peers now takes ~2-3s instead of 8-10s.

Install

pip install stock-analyst-mcp

Or run directly without installing:

uvx stock-analyst-mcp

MCP Configuration

Add to your MCP client config (Claude Desktop, Devin, Cursor, etc.):

{
  "mcpServers": {
    "stock-analyst": {
      "command": "uvx",
      "args": ["stock-analyst-mcp"]
    }
  }
}

Or if installed via pip:

{
  "mcpServers": {
    "stock-analyst": {
      "command": "stock-analyst-mcp"
    }
  }
}

Tools

ToolDescription
analyze_stockFull analysis: fundamentals + technicals + peers + DCF + forecast + news (any region)
get_fundamentalsFinancial ratios: profitability, liquidity, leverage, efficiency, valuation
get_technicalsTechnical signals: EMA trend, RSI, MACD, Bollinger Bands
get_peer_comparisonPeer fundamental + technical metrics with rankings (region-scoped)
get_dcf_valuationDCF: WACC, equity value/share, sensitivity range
get_revenue_forecastRevenue forecast: base/bull/bear scenarios
get_newsNews headlines with VADER sentiment + article snippets + analyst recommendations
get_market_moodRegion-specific indices + volatility index + market assessment
screen_stocksScreen stocks by filters (sector, PE, ROE, market cap, etc.) in any region
get_screener_filtersList available screener filter keys and sort options
search_tickersSearch for tickers by name or symbol across regions (stocks, ETFs, indices, crypto, etc.)
analyze_assetAnalyze any asset class: stocks, ETFs, indices, commodities, crypto, currencies
compare_stocksSide-by-side comparison of multiple stocks
get_raw_dataFetch cached raw financials for deep dives
get_configView current configuration settings for all analysis tools
set_configUpdate configuration settings dynamically

Configuration Tools

get_config

Retrieve all current configuration settings. Useful for understanding what parameters are available before calling set_config.

from stock_analyst import get_config

config = get_config()
# Returns dict with sections:
# - data_provider, default_exchange, default_period, cache settings
# - technical_analysis: EMA periods, RSI period, MACD params, Bollinger settings
# - financial_analysis: DCF params, WACC settings, forecast scenarios
# - peer_comparison: max count, metrics to compare
# - output: format, pretty-print settings

set_config

Update configuration dynamically without restarting. Changes affect subsequent tool calls.

from stock_analyst import set_config

# Change technical analysis period from 1y to 1d
result = set_config("default_period", "1d")
# Returns: {"status": "success", "key": "default_period", "new_value": "1d", "affected_tools": ["all_tools"]}

# Change RSI period from 14 to 21
result = set_config("ta_rsi_period", "21")
# Returns: {"status": "success", "key": "ta_rsi_period", "new_value": 21, "affected_tools": ["get_technicals", "analyze_stock"]}

# Change DCF projection years from 5 to 10
result = set_config("fa_dcf_projection_years", "10")
# Returns: {"status": "success", "key": "fa_dcf_projection_years", "new_value": 10, "affected_tools": ["get_dcf_valuation", "get_revenue_forecast", "analyze_stock"]}

Common Configuration Keys:

KeyTypeDefaultDescriptionAffects
default_periodstr1yHistorical period: 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, maxall_tools
ta_rsi_periodint14RSI calculation periodget_technicals, analyze_stock
ta_ema_periodsstr20,50,200Comma-separated EMA periodsget_technicals, analyze_stock
ta_macd_paramsstr12,26,9MACD (fast, slow, signal)get_technicals, analyze_stock
ta_bollinger_enabledbooltrueEnable Bollinger Bandsget_technicals, analyze_stock
ta_bollinger_periodint20Bollinger Bands periodget_technicals, analyze_stock
fa_dcf_enabledbooltrueRun DCF valuationanalyze_stock, get_dcf_valuation
fa_dcf_projection_yearsint5DCF projection yearsget_dcf_valuation, get_revenue_forecast, analyze_stock
fa_dcf_terminal_growthfloat0.025Terminal growth rate (2.5%)get_dcf_valuation, analyze_stock
fa_dcf_exit_multiplefloat12.0Exit multiple for DCFget_dcf_valuation, analyze_stock
fa_wacc_risk_free_ratefloat0.07Risk-free rate (7% for India)get_dcf_valuation, analyze_stock
fa_wacc_equity_risk_premiumfloat0.06Equity risk premium (6%)get_dcf_valuation, analyze_stock
fa_wacc_cost_of_debtfloat0.09Cost of debt (9% for India)get_dcf_valuation, analyze_stock
fa_wacc_tax_ratefloat0.25Tax rate (25% for India)get_dcf_valuation, analyze_stock
peers_max_countint10Max peers to compareget_peer_comparison, analyze_stock
cache_ttlint3600Cache TTL in secondsall_tools

Example: Customize Technical Analysis

from stock_analyst import set_config, get_technicals

# Use 1-day data with custom RSI period
set_config("default_period", "1d")
set_config("ta_rsi_period", "21")

# Get technicals with new settings
signals = get_technicals("RELIANCE")

Example: Customize DCF Valuation

from stock_analyst import set_config, get_dcf_valuation

# Use 10-year projection with different growth assumptions
set_config("fa_dcf_projection_years", "10")
set_config("fa_dcf_terminal_growth", "0.03")  # 3% terminal growth
set_config("fa_wacc_risk_free_rate", "0.065")  # 6.5% risk-free rate

# Get DCF with new assumptions
valuation = get_dcf_valuation("RELIANCE")

CLI

Also works as a standalone CLI (no LLM needed):

# Full analysis
stock-analyst --symbol RELIANCE

# Specific analysis
stock-analyst --symbol TCS --analysis fundamentals
stock-analyst --symbol INFY --analysis technicals
stock-analyst --symbol RELIANCE --analysis dcf

# Compare multiple stocks
stock-analyst --symbols RELIANCE,TCS,INFY --compare

# Markdown output
stock-analyst --symbol RELIANCE --format markdown

# Raw data
stock-analyst --symbol RELIANCE --raw financials

# Market mood (no symbol needed)
stock-analyst --analysis market-mood

# Stock screener (India)
stock-analyst --screen --sector Technology --pe-max 30 --roe-min 0.15
stock-analyst --screen --market-cap-min 50000000000 --sort-by pe --limit 20

# Global stocks (any region)
stock-analyst --symbol AAPL --region us
stock-analyst --symbol 0700.HK --region hk
stock-analyst --screen --region gb --sector Technology --pe-max 25

# Market mood (global)
stock-analyst --analysis market-mood --region us
stock-analyst --analysis market-mood --region de

# Ticker search
stock-analyst --search "Apple" --search-type stock --region us
stock-analyst --search "Bitcoin" --search-type cryptocurrency

# Multi-asset analysis
stock-analyst --symbol SPY --analysis asset --asset-type etf
stock-analyst --symbol GC=F --analysis asset --asset-type commodity
stock-analyst --symbol BTC-USD --analysis asset --asset-type crypto

Configuration

All settings configurable via environment variables with SA_ prefix. Defaults work out of the box for Indian markets (NSE). Supports 50+ regions globally.

VariableDefaultDescription
SA_DEFAULT_REGIONinRegion code (us, gb, de, jp, in, etc.)
SA_DEFAULT_EXCHANGE.NSNSE (.NS) or BSE (.BO) — for India only
SA_DEFAULT_PERIOD1yHistorical data period
SA_CACHE_BACKENDredisredis, csv, or none
SA_REDIS_URLredis://localhost:6379/0Redis connection URL
SA_CACHE_TTL3600Cache TTL in seconds
SA_SCREENER_ENABLEDtrueUse screener.in as fallback for peers
SA_FA_DCF_ENABLEDtrueRun DCF valuation
SA_FA_WACC_RISK_FREE_RATE0.07India 10Y govt bond yield
SA_PEERS_MAX_COUNT10Max peers to compare
SA_MCP_TRANSPORTstdiostdio or streamable-http
SA_MCP_PORT3001Port for streamable-http

See configurations.env.example for the full list.

Python Library

from stock_analyst import (
    analyze, get_fundamentals, get_technicals,
    get_news, get_market_mood, screen_stocks,
    search_tickers, analyze_asset,
)

# Indian stocks (default region)
result = analyze("RELIANCE")
ratios = get_fundamentals("TCS")
signals = get_technicals("INFY", period="6mo")

# Global stocks (any region)
us_stock = analyze("AAPL", region="us")
hk_stock = analyze("0700.HK", region="hk")
uk_stock = analyze("HSBA", region="gb")

# News with sentiment
news = get_news("TCS")
# Returns headlines with sentiment_score, sentiment_label, snippet

# Market mood (region-specific)
mood_in = get_market_mood(region="in")  # Includes MMI from tickertape
mood_us = get_market_mood(region="us")  # S&P 500 + VIX
mood_de = get_market_mood(region="de")  # DAX + VDAX

# Stock screener (any region)
results_in = screen_stocks({"sector": "Technology", "pe_max": 30}, region="in")
results_us = screen_stocks({"sector": "Technology", "pe_max": 40}, region="us")

# Ticker search
apple_results = search_tickers("Apple", instrument_type="stock", region="us")
crypto_results = search_tickers("Bitcoin", instrument_type="cryptocurrency")

# Multi-asset analysis
etf = analyze_asset("SPY", asset_type="etf")
commodity = analyze_asset("GC=F", asset_type="commodity")
crypto = analyze_asset("BTC-USD", asset_type="crypto")
currency = analyze_asset("EURUSD=X", asset_type="currency")

Testing

# Install dev dependencies
pip install -e ".[dev]"

# Run all tests
pytest

# Run with coverage
pytest --cov=stock_analyst --cov-report=term-missing

# Run specific test file
pytest tests/test_peers.py -v

Data Sources

  • yfinance — OHLCV, financials, balance sheet, cashflow, info, peer discovery via Industry API, stock screener via EquityQuery (50+ regions)
  • screener.in — peer discovery + stock screener fallback for India (best-effort, graceful degradation)
  • tickertape.in — Market Mood Index (MMI) scraping for India
  • VADER — headline sentiment analysis (vaderSentiment)
  • India-adjusted defaults — risk-free rate 7%, cost of debt 9%, tax 25%

Supported Regions

50+ regions via yfinance: US, UK, Germany, France, Italy, Spain, Netherlands, Belgium, Switzerland, Austria, Sweden, Norway, Denmark, Finland, Poland, Czech Republic, Romania, Portugal, Greece, Hungary, Ireland, Lithuania, Latvia, Estonia, Canada, Mexico, Brazil, Argentina, Chile, Peru, Colombia, Venezuela, Australia, New Zealand, Japan, South Korea, China, Hong Kong, Singapore, Malaysia, Thailand, Philippines, Indonesia, Vietnam, Pakistan, Sri Lanka, UAE, Saudi Arabia, Kuwait, Qatar, Israel, Egypt, Turkey, South Africa, and more.

Regions Quick Reference

RegionCodePrimary IndexVIX
USAusS&P 500 (^GSPC)^VIX
UKgbFTSE 100 (^FTSE)^VIX
GermanydeDAX (^GDAXI)^VDAX
FrancefrCAC 40 (^FCHI)^VDAX
JapanjpNikkei 225 (^N225)^VIX
Hong KonghkHang Seng (^HSI)^VIX
IndiainNifty 50 (^NSEI)^INDIAVIX
AustraliaauASX 200 (^AXJO)^VIX
CanadacaTSX (^GSPTSE)^VIX
BrazilbrBovespa (^BVSP)^VIX

License

MIT