pavel-rp/talib-mcp-server
If you are the rightful owner of talib-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The talib-mcp-server is a server implementation designed to facilitate communication and data exchange using the Model Context Protocol (MCP).
TA-Lib MCP Server
A production-ready Model Context Protocol (MCP) server exposing a handful of technical analysis indicators powered by TA-Lib.
- β‘ Built with FastMCP β automatic schema generation & HTTP transport out of the box.
- π Secured by a minimal Bearer token middleware β set
MCP_API_KEY
and you are done. - π³ First-class Docker support β
docker-compose up --build
starts it onhttp://localhost:8000
. - β Comprehensive test-suite & CI β indicator math validated against raw TA-Lib values.
Table of contents
- Quick start
- Project layout
- Tools / indicators
- Authentication
- Local development
- Running the test-suite
- CI pipeline
- Docker
- License
Quick start
# 1. Clone & enter repo
$ git clone <repo> && cd talib-mcp-server
# 2. Install system deps (TA-Lib C library)
# Build TA-Lib C library (binary package often unavailable)
$ sudo apt-get install -y build-essential wget
$ wget -q http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
$ tar -xzf ta-lib-0.4.0-src.tar.gz && cd ta-lib
$ ./configure --prefix=/usr && make -j"$(nproc)" && sudo make install
$ cd .. && rm -rf ta-lib ta-lib-0.4.0-src.tar.gz
# 3. Create virtualenv & install Python deps
$ python -m venv .venv && source .venv/bin/activate
$ pip install -r requirements.txt
# 4. Configure auth
$ cp .env.example .env # edit MCP_API_KEY as desired
# 5. Run the server (HTTP on :8000)
$ python -m app.main
Visit http://localhost:8000/tools
with header Authorization: Bearer <token>
to see the generated MCP tool schema.
Project layout
talib-mcp-server/
βββ app/ # Application code
β βββ __init__.py
β βββ auth.py # Bearer-token middleware
β βββ indicators.py # Stateless TA-Lib wrappers
β βββ main.py # FastMCP server definition
βββ tests/ # Pytest unit & integration tests
βββ Dockerfile # Container image (python:3.11-slim)
βββ docker-compose.yml # Convenience runner
βββ requirements.txt # Python dependencies
βββ .env.example # Environment template
βββ .github/workflows/ci.yml # GitHub Actions pipeline
Tools / indicators
Tool | Signature | Description |
---|---|---|
rsi | rsi(prices: List[float], period: int = 14) | Relative Strength Index |
macd | macd(prices: List[float], fast: int = 12, slow: int = 26, signal: int = 9) | MACD line, signal & histogram |
ema | ema(prices: List[float], period: int) | Exponential Moving Average |
sma | sma(prices: List[float], period: int) | Simple Moving Average |
bbands | bbands(prices: List[float], period: int = 20, std_dev: float = 2.0) | Bollinger Bands upper/middle/lower |
All outputs are JSON-serialisable (floats or null
when the value cannot yet be computed).
Authentication
Every MCP endpoint requires:
Authorization: Bearer <token>
The token must match the value of MCP_API_KEY
(via environment variable or .env
file). Unauthorized requests receive 401 {"error": "Unauthorized"}
.
Example API Calls
Here are some example HTTP requests to demonstrate how to use the MCP server:
RSI (Relative Strength Index)
curl -X POST http://localhost:8000/call \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"name": "rsi",
"arguments": {
"prices": [44.0, 44.34, 44.09, 44.15, 43.61, 44.33, 44.83, 45.15, 45.42, 45.84, 46.08, 45.89, 46.03, 46.28, 46.28],
"period": 14
}
}'
MACD (Moving Average Convergence Divergence)
curl -X POST http://localhost:8000/call \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"name": "macd",
"arguments": {
"prices": [12.0, 12.5, 13.0, 12.8, 13.2, 13.1, 13.5, 13.3, 13.8, 14.0, 14.2, 13.9, 14.1, 14.5, 14.3],
"fast": 12,
"slow": 26,
"signal": 9
}
}'
Response:
{
"macd": [null, null, ..., 0.123],
"signal": [null, null, ..., 0.089],
"histogram": [null, null, ..., 0.034]
}
Simple Moving Average (SMA)
curl -X POST http://localhost:8000/call \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"name": "sma",
"arguments": {
"prices": [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
"period": 5
}
}'
Exponential Moving Average (EMA)
curl -X POST http://localhost:8000/call \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"name": "ema",
"arguments": {
"prices": [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
"period": 10
}
}'
Bollinger Bands
curl -X POST http://localhost:8000/call \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"name": "bbands",
"arguments": {
"prices": [20, 21, 19, 22, 20, 23, 21, 24, 22, 25, 23, 26, 24, 27, 25, 28, 26, 29, 27, 30],
"period": 20,
"std_dev": 2.0
}
}'
Response:
{
"upper": [null, null, ..., 25.8],
"middle": [null, null, ..., 23.5],
"lower": [null, null, ..., 21.2]
}
Getting Available Tools
curl -X GET http://localhost:8000/tools \
-H "Authorization: Bearer your-api-key"
Local development
# install pre-commit hooks (flake8, black)
$ pip install pre-commit
$ pre-commit install
Live reload
FastMCP itself doesnβt ship autoreload; use hot reloaders like watchfiles
or run inside your IDE.
Running the test-suite
$ MCP_API_KEY=testtoken pytest -q
Unit tests compare indicator outputs with TA-Lib to guarantee correctness and exercise auth/error handling for MCP endpoints using Starletteβs TestClient
.
CI pipeline
.github/workflows/ci.yml
runs on every push / PR:
- Install TA-Lib system libs
- Install Python deps
flake8
&black --check
pytest
- Build the Docker image to ensure Dockerfile stays valid
Docker
# Build image
$ docker build -t talib-mcp-server .
# Run container with key env var
$ docker run -e MCP_API_KEY=mytoken -p 8000:8000 talib-mcp-server
Alternatively:
$ cp .env.example .env # customise key
$ docker-compose up --build
The server will be available at http://localhost:8000
.
License
MIT β Β© 2025 Your Name