This project implements a Model Context Protocol (MCP) server that provides AI assistants with intelligent, secure access to a PostgreSQL database containing comprehensive mutual fund data.
- Secure PostgreSQL connection via
asyncpg
- Tool-based architecture using FastAPI endpoints
- OpenAI-powered natural language summaries
- Structured JSON responses
- Pluggable LLM backend (OpenAI or Ollama)
- Read-only access for query safety
Tool Name | Endpoint | Purpose |
---|---|---|
postgres_query |
/postgres_query |
General SELECT execution |
describe_schema |
/describe_schema |
Schema introspection |
search_funds |
/search_funds |
Fund discovery via smart filters |
analyze_performance |
/analyze_performance |
Compare fund performance |
correlate_performance |
/correlate_performance |
Fund return correlation matrix |
sector_analysis |
/sector_analysis |
AUM/category-level aggregation |
nav_trend_analysis |
/nav_trend_analysis |
NAV time-series insight |
risk_return_scatter |
/risk_return_scatter |
Risk-return mapping data |
- Read-only DB user
- Parameterized queries
- Query complexity limits
- Secure
.env
credential loading - No raw query logging
python3.12 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --reload