TA-Lib MCP Server
Technical analysis indicators MCP server and HTTP API for the Model Context Protocol.
Quick Start
Architecture
This project provides three independent access methods:
1. MCP Server (--mode mcp)
Pure MCP protocol implementation exposing all TA-Lib indicators as MCP tools
Supports both STDIO and HTTP transports
For use with MCP clients (Claude Desktop, MCP Inspector, MCP.js, etc.)
No REST endpoints
Run with STDIO (for Claude Desktop):
Run with HTTP (for MCP Inspector or web clients):
2. HTTP API Server (--mode api)
Pure REST API with
/api/tools/*JSON endpointsFor programmatic HTTP access to indicators
No MCP protocol, just clean REST
Run HTTP API:
Example request:
3. CLI Tools
Direct command-line access to all indicators via Typer:
Features
All TA-Lib Overlap Studies: BBANDS, DEMA, EMA, HT_TRENDLINE, KAMA, MA, MAMA, MAVP, MIDPOINT, MIDPRICE, SAR, SAREXT, SMA, T3, TEMA, TRIMA, WMA
Three Access Methods: MCP, HTTP REST, CLI
Dual Transport: STDIO and HTTP for MCP
Cross-platform: Works on Linux, macOS, Windows
Comprehensive Testing: 26+ unit and integration tests
Error Handling: Detailed error messages and validation
Logging Configuration
The server requires a logging.conf file for configuration. Copy the example:
Customize logging levels, format, and output file in logging.conf. The server logs to console.log to maintain MCP protocol compliance.
Client Configuration
Claude Desktop Integration
Create a configuration file at
~/Library/Application Support/Claude/claude_desktop_config.json(macOS) or appropriate location for your OS.Add the MCP server configuration:
Restart Claude Desktop to load the TA-Lib server.
Verify installation by asking Claude: "What technical analysis tools do you have?"
MCP Inspector (HTTP)
For HTTP transport, configure MCP Inspector to connect to:
Run the MCP server with HTTP:
Important: The HTTP transport includes CORS middleware to support browser-based MCP clients like MCP Inspector. If you're behind a reverse proxy or need to restrict access, update the allow_origins setting in transport/http.py.
MCP.js Client Example
HTTP API Client (Python)
Available Tools
The server provides MCP tools and HTTP endpoints for all TA-Lib overlap studies:
calculate_sma- Simple Moving Averagecalculate_ema- Exponential Moving Averagecalculate_rsi- Relative Strength Indexcalculate_bbands- Bollinger Bandscalculate_dema- Double Exponential Moving Averagecalculate_ht_trendline- Hilbert Transform Trendlinecalculate_kama- Kaufman Adaptive Moving Averagecalculate_ma- Moving Average (with matype)calculate_mama- MESA Adaptive Moving Averagecalculate_mavp- Moving Average Variable Periodcalculate_midpoint- Midpointcalculate_midprice- Midpoint Pricecalculate_sar- Parabolic SARcalculate_sarext- Parabolic SAR Extendedcalculate_t3- T3 Moving Averagecalculate_tema- Triple Exponential Moving Averagecalculate_trima- Triangular Moving Averagecalculate_wma- Weighted Moving Average
Development
TA-Lib Platform Requirements
This project uses the ta-lib Python bindings which require the native TA-Lib C library. On CI or developer machines, you must install the system TA-Lib library before installing Python dependencies.
Links and notes:
TA-Lib (C library): https://ta-lib.org/ (download and build instructions)
ta-lib-python (Python bindings): https://github.com/TA-Lib/ta-lib-python
Example (Ubuntu) CI steps:
If you prefer not to build the C library, use pre-built wheels where available or run tests in an environment that provides TA-Lib (e.g., manylinux CI images).
HTTP API & CLI
This project exposes the same MCP tools as both HTTP JSON endpoints and a Typed CLI (Typer).
HTTP Endpoint
POST /api/tools/{tool_name}
Request JSON: { "close": [..], ...params } (e.g., timeperiod)
Response JSON: { "success": true, "values": [...], "metadata": {...} }
Example:
MCP Endpoint
The MCP endpoint remains at /mcp for MCP clients (MCP Inspector, MCP.js, etc.). The HTTP API mounts the MCP app so both APIs coexist.
CLI (Typer)
Access tools from the command line via src/mcp_talib/cli_tools.py:
List available tools:
Call a tool:
Implementation Notes
Requests are validated using Pydantic
The underlying indicator implementations are the single source of truth (registered in the MCP registry)
HTTP API and CLI call the same code so results match exactly
For browser clients, CORS is enabled and
mcp-session-idis exposed in responses
License
MIT