A distributed AI system that combines Model Context Protocol (MCP) with Agent-to-Agent (A2A) communication to provide real-time stock information and analysis.
This project demonstrates the power of combining A2A (Agent-to-Agent) and MCP (Model Context Protocol) architectures to create a practical AI system for stock market information. It features:
- Real-time stock price lookups
- Company ticker symbol searches
- Natural language interaction
- Distributed microservice architecture
The system consists of three main components:
-
MCP Servers
- Stock MCP: Combined service for stock data and search functionality
- Handles ticker symbol lookups and real-time price fetching
-
Stock Agent
- Intermediary service that communicates with MCP servers
- Processes user queries and formats responses
-
Stock Assistant
- Main user interface
- Powered by OpenAI's GPT models
- Natural language processing for user queries
- Python 3.10 or higher
- Dependencies listed in pyproject.toml:
- python-a2a[all] >= 0.5.4
- python-dotenv >= 1.1.0
- requests >= 2.32.3
- yfinance >= 0.2.58
- Clone the repository
- Create a virtual environment using uv:
uv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
uv install
uv add package-name
- Create a
.env
file in the project root - Add your OpenAI API key:
OPENAI_API_KEY=your_api_key_here
- Start the servers:
python run_servers.py
- In a separate terminal, run the interactive client:
python interact_client.py
- Example queries in your terminal:
- Apple
- Apple Inc
- amd
- Provides standardized interfaces for stock data
- Implements DuckDuckGo search for ticker lookup
- Uses YFinance for real-time stock data
- Handles communication between components
- Processes and routes queries
- Formats responses for consistency
- Natural language processing
- Query understanding and decomposition
- Response generation and formatting
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
This project is inspired by the article "The Power Duo: How A2A & MCP Let You Build Practical AI Systems Today".