Spaces:
Sleeping
Sleeping
metadata
title: Researcher Agent
emoji: π¬
colorFrom: blue
colorTo: purple
sdk: docker
pinned: false
license: mit
Research Service
Financial research service implementing Google's A2A (Agent-to-Agent) protocol. Uses TRUE MCP protocol (subprocess + JSON-RPC) to fetch data from 6 MCP servers and returns aggregated research data for SWOT analysis.
Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Research Service β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β A2A Server (FastAPI + JSON-RPC 2.0) β β
β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β
β β β MCP Client (TRUE MCP: subprocess + JSON-RPC) β β β
β β β ββββββββββββ ββββββββββββ ββββββββββββ β β β
β β β βFinancialsβ βVolatilityβ β Macro β β β β
β β β ββββββββββββ ββββββββββββ ββββββββββββ β β β
β β β ββββββββββββ ββββββββββββ ββββββββββββ β β β
β β β βValuation β β News β βSentiment β β β β
β β β ββββββββββββ ββββββββββββ ββββββββββββ β β β
β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
TRUE MCP Protocol
This service uses TRUE MCP protocol with proper handshake:
- Send
initializerequest (id=1) - Receive initialization response
- Send
notifications/initializednotification - Send
tools/callrequest (id=2) - Parse JSON-RPC response
Each MCP server is called via subprocess + stdio, following the official MCP specification.
A2A Protocol
This agent implements the Google A2A Protocol using JSON-RPC 2.0 over HTTP.
Endpoints
| Endpoint | Method | Description |
|---|---|---|
/ |
POST | JSON-RPC 2.0 endpoint |
/.well-known/agent.json |
GET | Agent card |
/health |
GET | Health check |
JSON-RPC Methods
message/send
Start a new research task.
{
"jsonrpc": "2.0",
"id": 1,
"method": "message/send",
"params": {
"message": {
"parts": [{"type": "text", "text": "Research Tesla"}]
}
}
}
tasks/get
Get task status and results. Includes partial_metrics during WORKING status for real-time streaming.
{
"jsonrpc": "2.0",
"id": 2,
"method": "tasks/get",
"params": {"taskId": "abc-123-def"}
}
tasks/cancel
Cancel a running task.
Data Sources
| MCP Server | Data Source | Metrics |
|---|---|---|
| Financials | SEC EDGAR | Revenue, margins, debt, EPS |
| Volatility | Yahoo Finance, FRED | Beta, VIX, historical volatility |
| Macro | FRED | GDP growth, interest rates, inflation, unemployment |
| Valuation | Yahoo Finance | P/E, P/B, P/S, EV/EBITDA, PEG |
| News | Tavily | Recent news articles |
| Sentiment | Finnhub, Reddit | Composite sentiment score |
Environment Variables
FRED_API_KEY=xxx # For macro indicators
FINNHUB_API_KEY=xxx # For sentiment analysis
TAVILY_API_KEY=xxx # For news search
METRIC_DELAY_MS=300 # Delay between metric emissions (ms)
Local Development
# Install dependencies
pip install -r requirements.txt
# Run the server
python app.py
Server runs on http://localhost:7860
Usage from Main SWOT Agent
The main SWOT Analysis Agent connects to this server via A2A protocol:
# In main agent (Research Gateway)
A2A_RESEARCHER_URL = "https://vn6295337-researcher-agent.hf.space"
# Send research request
response = requests.post(A2A_RESEARCHER_URL, json={
"jsonrpc": "2.0",
"id": 1,
"method": "message/send",
"params": {"message": {"parts": [{"type": "text", "text": "Research TSLA Tesla"}]}}
})
License
MIT