使用说明
FinTest MCP Server
An MCP (Model Context Protocol) server that provides Claude with read-only access to the FinTest PostgreSQL database. Enables querying of stock tickers, historical price data, ML training runs, and job tracking information over the STDIO transport.
Prerequisites
- Docker and Docker Compose
- Parent FinTest stack running (provides the
fintest_ps_defaultnetwork and PostgreSQL instance)
Project Structure
mcp/
├── server/
│ ├── __init__.py # FastMCP server initialization
│ ├── __main__.py # Entry point (STDIO transport)
│ ├── db.py # Database connection and queries
│ ├── logger.py # Logging config (stderr only)
│ └── tools.py # MCP tool definitions
├── Dockerfile
├── docker-compose.yml
├── .mcp.json # Claude Code MCP integration config
├── .env # Database connection env vars
└── requirements.txt
Setup
-
Ensure the parent FinTest stack is running and the
fintest_ps_defaultnetwork exists. -
Build and start the MCP server:
docker compose up -d fintest_mcp -
For Claude Code integration, the server is registered as
fintest-dbin.mcp.jsonand starts automatically when needed.
Available Tools
| Tool | Description |
|---|---|
query(sql) |
Execute arbitrary read-only SQL queries |
list_tables() |
List all tables/views with column details |
get_tickers() |
Get all tracked stock tickers |
get_ticker_history(ticker, limit) |
Recent OHLCV price history for a ticker |
get_training_runs(status) |
ML training run records, optionally filtered |
get_job_details(gid_job_unit) |
Full job details including logs and stats |
get_timeseries(ticker, limit) |
Joined daily aggregates with SMA indicators |
Database
Connects to the FinTest PostgreSQL instance via a read-only user (claude_readonly). Multiple safety layers are in place:
- Dedicated read-only database user
- Connection-level
default_transaction_read_only=on - Large result sets are automatically truncated to 100 rows
Tech Stack
- Python 3.11 with FastMCP (MCP SDK)
- psycopg2 for PostgreSQL connectivity
- Docker for containerized deployment
- STDIO transport (JSON-RPC over stdin/stdout)