Financial AI Assistant is a modular backend service that answers financial questions using tool-based reasoning.
It combines:
- FastAPI for HTTP serving
- Finnhub API for live market data
- LlamaIndex + FAISS for retrieval-augmented knowledge
- MCP Python SDK for tool exposure and execution
- A reasoning agent that routes and aggregates tool output
flowchart TD
U[User Query] --> A[FastAPI POST /ask]
A --> B[FinancialAgent]
B --> C{Tool Selection}
C --> D[Market Data Tool\nFinnhub API]
C --> E[RAG Query Engine\nLlamaIndex + FAISS]
D --> F[Context Aggregation]
E --> F
F --> G[Analysis + Insight]
G --> H[Structured JSON Response]
- What is P/E ratio?
- How did AAPL perform this week?
- Explain market capitalization.
- Compare valuation metrics used in equity analysis.
git clone https://github.com/MercuryConnor/marketmind-ai
cd marketmind-ai/financial-ai-assistantpython -m venv venv
.\venv\Scripts\Activate.ps1pip install -r requirements.txtCopy financial-ai-assistant/.env.example to .env in the project root and set your Finnhub key:
FINNHUB_API_KEY=your_real_finnhub_keypython -c "from app.rag.index_builder import build_financial_index; build_financial_index()"uvicorn app.main:app --reloadcurl http://127.0.0.1:8000/health
curl -X POST http://127.0.0.1:8000/ask -H "Content-Type: application/json" -d '{"query":"What is P/E ratio?"}'- GET /health
- Returns service status.
- POST /ask
- Request: {"query": "..."}
- Response: {"analysis": "...", "data": {...}, "insight": "..."}
Detailed API docs: docs/api.md
financial-ai-assistant/
app/
api/
agents/
rag/
tools/
mcp/
services/
main.py
data/
tests/
docs/
requirements.txt
README.md
- Architecture: docs/architecture.md
- Setup: docs/setup.md
- API: docs/api.md
python -m unittest discover -s tests -p "test_*.py" -vMIT