Uses .env files for storing and managing sensitive configuration like API keys and tokens for various external services.
Uses local Ollama models (specifically Mistral) to generate detailed, sentiment-tagged summaries of financial news articles for contextual financial insights.
Sends formatted financial alerts and summaries to a configured Telegram chat, including price threshold notifications, trading opportunities, and system errors.
Financial MCP Server
A custom Model Context Protocol (MCP) server for advanced financial analysis, stock monitoring, and real-time market intelligence. This server provides a suite of tools and API endpoints for portfolio management, market summaries, stock alerts, and contextual financial insights, designed for seamless integration with Claude Desktop and other MCP-compatible clients.
Key Features
- Real-time Stock Price Monitoring: Track and alert on price movements for user-defined stocks and thresholds.
- Portfolio Management: Add, remove, and view tracked stocks in a persistent portfolio.
- Market Summaries: Retrieve live global market data, including indices, top gainers/losers, and news headlines.
- Contextual Financial Insights: Analyze user queries, extract financial entities, fetch and summarize relevant news, and generate actionable prompts.
- Automated Alerts: Receive Telegram notifications for price thresholds, trading opportunities, and system errors.
- Customizable Configuration: JSON-based sector and stock configuration for flexible alerting.
- Robust Logging & Error Handling: Detailed logs and error messages for transparency and troubleshooting.
System Overview
Core Endpoints & Tools
- financial_context(query: str)
- Extracts tickers and keywords from a user query, fetches and summarizes relevant news, and returns a structured context and prompt for downstream analysis.
- market_summary()
- Returns a live summary of global markets, including indices, top movers, and news headlines.
- get_portfolio()
- Retrieves the current list of tracked stocks in the user's portfolio.
- add_stock(ticker: str) / remove_stock(ticker: str)
- Add or remove a stock from the portfolio, with cache invalidation and verification.
- portfolio_alerts(random_string: str)
- Returns all triggered alerts for the portfolio, or for a specific ticker if provided.
- check_stock_alerts(ticker: str) / single_stock_alert(ticker: str)
- Returns alerts for a specific stock, with detailed error handling.
Automated Alerting
- Telegram Integration: Sends formatted alerts and summaries to a configured Telegram chat.
- Trading Opportunities: Detects and notifies about actionable trading signals.
Contextual Summarization
- News Summarizer: Uses a local LLM (Ollama/Mistral) to generate detailed, sentiment-tagged summaries of financial news articles.
- Prompt Builder: Constructs a market-aware prompt for use in downstream LLMs or assistants.
File Structure
Configuration & Customization
Alert Configuration (config/alerts_config.json
)
- Organize stocks by sector, with customizable upper/lower price thresholds and descriptions.
- Example structure:
Environment Variables
Set these in a .env
file or your system environment:
Installation & Running from Claude Desktop
Prerequisites
- Python 3.7+
- Claude Desktop (or any MCP-compatible client)
- Telegram bot credentials (for alerting)
- Internet connection (for market/news data)
Step-by-Step Guide
- Clone the Repository
- Create and Activate a Virtual Environment
- Install Dependencies
- Configure Environment Variables
- Create a
.env
file in the project root with your API keys and tokens:
- Create a
- Edit Alert Configurations
- Modify
config/alerts_config.json
andconfig/tech_alerts_config.json
to set your stocks, sectors, and thresholds.
- Modify
- Install the MCP Server with the CLI
- Use the MCP CLI to install and register the server for Claude Desktop:
- This will register the server as a custom MCP tool, making it discoverable by Claude Desktop and other MCP clients.
- Use the MCP CLI to install and register the server for Claude Desktop:
- Run the MCP Server via MCP CLI
- Start the server using the MCP CLI:
- The server will start and listen for MCP requests via stdio.
- Start the server using the MCP CLI:
- Connect from Claude Desktop
- In Claude Desktop, add a new custom MCP server connection.
- Set the executable/command to
mcp run server.py
(or select the registered "Financial MCP Server" from the MCP CLI list). - Claude Desktop will communicate with the server using the MCP protocol, enabling all the described tools and endpoints.
Example: Claude Desktop MCP Server Configuration
After installing and registering the Financial MCP Server, you can add it to your Claude Desktop configuration. Here is a sample claude_desktop_config.json
snippet:
- Update the
env
section with your actual API keys and tokens as needed. - This configuration ensures Claude Desktop can launch and communicate with your Financial MCP Server using the correct environment and command-line arguments.
Using Your Tools in Claude Desktop
After installing and connecting your custom Financial MCP Server, all available tools will automatically appear in Claude Desktop's tool menu. You can enable or disable each tool individually, making it easy to access functionalities such as financial context analysis, market summaries, portfolio management, and stock alerts directly from the Claude interface.
Below is a screenshot showing how the tools from your MCP server will be listed and toggled in Claude Desktop:
- Each tool (e.g.,
financial_context
,market_summary
,add_stock
, etc.) can be enabled or disabled as needed. - This seamless integration allows you to interact with your financial analysis server using natural language and tool-based workflows within Claude Desktop.
Usage Examples
- Get Market Summary: Use the
market_summary
tool to fetch live indices, movers, and news. - Manage Portfolio: Use
add_stock
,remove_stock
, andget_portfolio
to update and view your tracked stocks. - Receive Alerts: Configure thresholds and receive Telegram notifications for price movements and trading opportunities.
- Contextual Analysis: Use
financial_context
to analyze a query, extract tickers, and get summarized news and a market-aware prompt.
Troubleshooting & Logs
- All logs are written to
financial_mcp.log
in the project root. - For debugging, check the log file and ensure your environment variables and configuration files are correct.
- If you encounter issues with Telegram or news fetching, verify your API keys and internet connection.
This server cannot be installed
A custom Model Context Protocol server that provides real-time financial analysis tools including stock monitoring, portfolio management, market summaries, and automated price alerts with Telegram notifications.
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol server providing real-time stock data and options analysis through Yahoo Finance, enabling LLMs to access market data, analyze stocks, and evaluate options strategies.Last updated -4PythonMIT License
- AsecurityAlicenseAqualityA Model Context Protocol server providing tools for querying A-share stock market data, including historical prices, financial reports, market indices, and macroeconomic indicators.Last updated -28178PythonMIT License
- -securityAlicense-qualityA Model Context Protocol server focused on China's A-share stock market that provides data on stocks, financials, market indices, and macroeconomic indicators.Last updated -178PythonMIT License
- -security-license-qualityA Model Context Protocol server that provides tools for interacting with Yahoo Finance, allowing users to retrieve stock prices, company information, and perform financial data comparisons.Last updated -PythonMIT License