Skip to main content

📊 Stock Analysis MCP Server

This is a modular, async-capable Multi-Component Protocol (MCP) server for comprehensive stock portfolio analysis using yfinance, pandas, numpy, and BeautifulSoup. It exposes a set of tools for use by LLM agents or other MCP clients via the uvx ecosystem.


🚀 Features

  • Fetch historical market data and fundamentals
  • Analyze volatility, RSI, moving averages, drawdowns, P&L
  • Sentiment scraping via Yahoo Finance
  • Portfolio aggregation (returns, weight concentration, volatility)
  • Async parallel processing for multiple tickers
  • Generates markdown-based report summaries with insights

🧠 UVX Integration Config

Include this block in your UVX configuration:

{
  "name": "mcp_stock_analysis",
  "command": "uvx",
  "args": [
    "mcp-stock-analysis@latest"  /// The package name and executable name are different
  ]
}

This MCP module will then be discoverable and callable by your agents or chains.


🧰 Tools Overview

fetch_market_data(symbol)

Fetches OHLCV history, company info, dividends, splits, analyst recommendations, and insider transactions for a stock.

fetch_market_data_multiple_tickers_parallel(symbols)

Parallel async variant of above for multiple stocks.

analyze_stock(data, qty, avg_cost)

Computes:

  • Invested amount, current value, P&L
  • Volatility (annualized), drawdown
  • RSI, MA50, MA200

analyze_multiple_stocks_parallel(stock_inputs)

Parallelized multi-stock analyzer. Accepts a list of dictionaries with each stock’s market data, quantity, and average cost.

summarize_sentiment(symbol)

Scrapes Yahoo Finance news headlines for the stock. Returns recent 5 with title + timestamp.

aggregate_portfolio(analyses)

Computes overall portfolio metrics:

  • Total invested, current value, return %
  • Concentration risks (stocks >10%)
  • Weighted volatility

generate_recommendations(summary, analyses)

Alerts for:

  • Overweight positions (>20%)
  • High RSI (>70)
  • Concentration risks

render_report(analyses, summary, recommendations)

Outputs full Markdown report with tables, highlights, and headlines.


🧪 Example Workflow (in code)

symbols = ["AAPL", "TSLA", "INFY.NS"]
data_list = await fetch_market_data_multiple_tickers_parallel(symbols)

# Example: user holds shares of each
inputs = [
    {"data": data_list[0], "qty": 10, "avg_cost": 120},
    {"data": data_list[1], "qty": 5, "avg_cost": 700},
    {"data": data_list[2], "qty": 15, "avg_cost": 1500}
]

analyses = await analyze_multiple_stocks_parallel(inputs)
summary = await aggregate_portfolio(analyses)
recommendations = await generate_recommendations(summary, analyses)
report = await render_report(analyses, summary, recommendations)

📎 Notes

  • Designed to be called as an MCP server over stdio using uvx run
  • Ensure Python packages yfinance, pandas, beautifulsoup4, requests, numpy are installed in the environment
  • MCP tools are fully async and support concurrent processing for scalability

📤 Author / Contact

This module was built as part of an intelligent portfolio assistant. For integration help or feedback, reach out via the associated MCP registry or support forums.


📌 License

MIT License (or customize as needed)

To Re-Build

Update .toml file with a version bump

'uv sync' will update every packages 'uv build' will build the package 'uv publish --token <your_token>' will publish the package to the MCP registry

Metadata

Release files for mcp-stock-analysis 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-stock-analysis 0.1.1
File Size Uploaded Provenance
mcp_stock_analysis-0.1.1.tar.gz 62.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-stock-analysis 0.1.1
File Interpreter ABI Platform
mcp_stock_analysis-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 68.1 kB

Release files / mcp_stock_analysis-0.1.1.tar.gz

Download URL mcp_stock_analysis-0.1.1.tar.gz
Size 62.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0888c5de5942c87b5d9b143fb4ec1a76ed88735fe7d0471c73599996d52f0f92
BLAKE2b-256 checksum
How to use checksums
b0f5d470f9cbfd800e465e3fad13d6a212044600937ed9d6e7a0c2ed8b4c5a7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.17

Release files / mcp_stock_analysis-0.1.1-py3-none-any.whl

Download URL mcp_stock_analysis-0.1.1-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b9309296eed7557ca7cb2a19929e7340779485f3fb307c19d01c319de1804ae
BLAKE2b-256 checksum
How to use checksums
200b9b8c0dbbc6b7425c22cfe1a41035043f176ff3eb6b697e6e69817df009e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.17

Security for mcp-stock-analysis 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page