Skip to main content

A Python-based flow for securities analysis using the Model Context Protocol (MCP)

Project description

MCP Securities Analysis

A Python-based flow for securities analysis using the Model Context Protocol (MCP). The repository bundles market data, parsing, analytics and visualisation tools behind a FastMCP server so that they can be consumed locally or remotely by any MCP-aware client (e.g. Claude Desktop, LangChain).

Example deep research report for Tesla.

This report was generated semi-autonomously by the following steps:

  • connect MCP tools to Claude Desktop, including web search, Perplexity, Wikipedia. (see claude_desktop_config.json for details). You can think of the Wikipedia tool as a friend you invite into the chat conversation who knows how to search and navigate Wikipedia, and bring articles, sections, summaries into the chat context, for further discussion with the user and the AI.

  • connect server.py MCP server to Claude Desktop. Think of this as writing your own bots in Python that can bring stuff into the chat context: market data, SEC filings, or anything else you can retrieve or compute.

  • prompt Claude Desktop to query Perplexity, Wikipedia, and the 10-K to bring information about Tesla into the context.

  • prompt Claude Desktop to query market data tools for up-to-date info on Tesla

  • finally, enable deep research and prompt Claude Desktop to write a deep report in 8 sections with details on what each section should cover, using the information retrieved from the chat context, additional web searches and tool calls.

  • see prompts.txt for prompts used in the example.

While it's not a fully autonomous agent and at an early POC level, it shows the way toward a fully autonomous agent. Create an MCP client that autonomously goes through the steps above and generates a deep report on Tesla in a structured format with graphs and tables. Or create an even more advanced multi-agent workflow with a set of parallel agents for each section, and a critic-optimizer workflow, and a final report generator.

server.py Features

  • FastMCP serverserver.py exposes a few MCP tools to get market data, news, charts, SEC filings, fundamental, technical data, research from public web sites, subscription services, and REST APIs.

  • Market data

    • yfinance
    • OpenBB. via the OpenBB platform API, we can call just about any market data REST API via a unified API.
  • SEC filings - a tool gets 10-K Item 1 via sec_downloader and parses it with sec_parser.

  • Technical analysis - computes a few technical indicators with pandas_ta & TA-Lib.

  • Interactive plots - Make a plot with plotly

  • News & Social sentiment - Reddit scraping utilities. At startup we launch a browser context and keep it open for the duration of the session. By pointing the browser at your profile, you can access saved credentials. Then you can open any URL and scrape the links or text or full HTML by prompting the LLM to generate the appropriate tool call.


Quick Start

# 1. Clone and enter the project (or fork and clone your own if you want to commit changes)
$ git clone https://github.com/druce/MCP.git
$ cd MCP

# 2. Create & activate a virtualenv (recommended)
$ python -m venv .venv
$ source .venv/bin/activate

# 3. Install python dependencies
$ pip install -r requirements.txt

# 4. Install Playwright browsers (once)
$ playwright install

# 5. Copy environment template & add your keys
$ cp dotenv.txt .env  # then edit as needed

# 6. Launch and test the server
$ LOGLEVEL=DEBUG mcp dev server.py
# click to the link in the terminal to open the test page, connect, view tools, and then test them individually

# 7. Use the server in your MCP client of choice. For Claude Desktop, edit the provided claude_desktop_config.json file and move it to the proper location for your platform (macOS, Windows).
https://claude.ai/download
https://modelcontextprotocol.io/quickstart/user

# 8. For additional optional market data MCP servers install these repos
Wikipedia MCP (no API key required)
pip install wikipedia-mcp

Filesystem MCP (use local files, no API key required)
git clone https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem

Yahoo Finance MCP (no API key required)
git clone https://github.com/Alex2Yang97/yahoo-finance-mcp.git

FMP MCP (API key required -  https://site.financialmodelingprep.com/developer/docs/stable )
git clone https://github.com/cdtait/fmp-mcp-server

Alpha Vantage MCP (API key required - https://www.alphavantage.co/documentation/)
git clone https://github.com/calvernaz/alphavantage.git
# see alphavantage.patches for edits to alphavantage/src/alphavantage_mcp_server/server.py

Brave Search MCP (API key required https://brave.com/search/api/ )
npm install -g @modelcontextprotocol/server-brave-search

Perplexity Ask MCP (API key, Docker required)
Follow setup instructions here:
https://github.com/ppl-ai/modelcontextprotocol/tree/main

Project Structure

MCP/
├── claude_desktop_config.json # Configuration for Claude Desktop
├── dotenv.txt             # Secrets / Environment variables
├── README.md              # This file
├── server.py              # FastMCP server, launched by mcp dev or Claude desktop or other MCP client
├── requirements.txt       # Python dependencies
├── sources.yaml           # Data-source configuration used by server
├── Market Data.ipynb      # Jupyter notebook to fetch market data
├── TearSheet.ipynb        # Jupyter notebook to do basic analysis

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iflow_mcp_mcp-1.0.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iflow_mcp_mcp-1.0.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file iflow_mcp_mcp-1.0.0.tar.gz.

File metadata

  • Download URL: iflow_mcp_mcp-1.0.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_mcp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 66fe31e990d136ae6d79758b4fe34eec4f5720e2911281a7e7a34ecd9919f0ac
MD5 3c2071c4a5fc6ec544b269f1f538b90f
BLAKE2b-256 c5b927720ef200d99c99dbc2c07488716ba7fb038533a58f7ae9566f9fc5177a

See more details on using hashes here.

File details

Details for the file iflow_mcp_mcp-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_mcp-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_mcp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 566465508afd55f6da66d426fbd78b33364e5dc40db1ba9c2c753a4fce203b96
MD5 a140a415c1fe3ea704fbcd431118b237
BLAKE2b-256 d8ff2baf01428c707cadcb0b1fa0c32a210adce7f4500687341dbfdf141c0a52

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page