Skip to main content
Glama
Stock Tools MCP Server

Stock Tools MCP Server

Stock Tools MCP Server

An MCP (Model Context Protocol) server providing financial analysis and stock market utility tools. Designed for use with AI assistants to perform technical analysis, portfolio calculations, and market data operations.

Features

  • Returns Analysis - Calculate total returns, Sharpe ratio, volatility, and max drawdown

  • Volatility Analysis - Rolling volatility, VaR, CVaR, and volatility regime classification

  • Stock Comparison - Compare multiple stocks with correlation analysis and rankings

  • Stock Screening - Filter stocks by financial criteria (P/E, market cap, sector, etc.)

  • Portfolio Metrics - Portfolio performance, weights, and beta calculation

  • Technical Levels - Pivot points, Fibonacci retracements, and moving average support/resistance

  • Moving Averages - SMA and EMA calculations with distance from current price

  • Pivot Points - Standard, Woodie's, and Camarilla pivot calculations

Related MCP server: Financial Modeling Prep MCP Server

Installation

Requires Python 3.10-3.12 and uv.

# Clone the repository
cd stock_tools_mcp

# Install dependencies
uv sync

# Install with dev dependencies (for testing)
uv sync --extra dev

Usage

Running the Server

# Using uv (recommended)
uv run stock-tools-mcp-server

# Using the launcher script (Unix/macOS)
./launch-stock-tools.sh

# Using the Python launcher (cross-platform)
python launch.py

# With SSE transport
uv run stock-tools-mcp-server --sse

# With streamable HTTP transport
uv run stock-tools-mcp-server --streamable

MCP Client Configuration

Add to your MCP client configuration. Use launch.py as it can locate uv even when PATH is not available (common when launched from AI assistants):

{
  "mcpServers": {
    "stock-tools": {
      "command": "python3",
      "args": ["/path/to/stock_tools_mcp/launch.py"]
    }
  }
}

Alternative using uv directly (requires uv in PATH):

{
  "mcpServers": {
    "stock-tools": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/stock_tools_mcp", "stock-tools-mcp-server"]
    }
  }
}

Configuration

Configure via environment variables:

Variable

Default

Description

STOCK_TOOLS_DEBUG

false

Enable debug mode

STOCK_TOOLS_LOG_LEVEL

INFO

Log level (DEBUG, INFO, WARNING, ERROR)

STOCK_TOOLS_RISK_FREE_RATE

0.02

Risk-free rate for Sharpe ratio (2%)

STOCK_TOOLS_TRADING_DAYS

252

Trading days per year for annualization

STOCK_TOOLS_PORT

8003

Server port for SSE/streamable transports

STOCK_TOOLS_MAX_DATA_POINTS

50

Max data points returned in time series

MCP_TRANSPORT

stdio

Transport protocol (stdio, sse, streamable)

Example:

STOCK_TOOLS_DEBUG=true STOCK_TOOLS_LOG_LEVEL=DEBUG uv run stock-tools-mcp-server

Available Tools

calculate_returns

Calculate stock returns and performance metrics from a price series.

prices = [100.0, 102.0, 101.0, 105.0, 108.0]
periods = [3, 5]  # Optional: specific period returns

Returns: total return, average daily return, volatility, Sharpe ratio, max drawdown, period returns.

analyze_volatility

Calculate volatility and risk metrics.

prices = [100.0, 102.0, ...]  # At least window+1 prices
window = 20  # Rolling window size

Returns: current/historical volatility, VaR (95%), CVaR, volatility regime (high/normal/low).

compare_stocks

Compare multiple stocks side by side.

stock_data = {
    "AAPL": [150.0, 152.0, 155.0, ...],
    "MSFT": [300.0, 305.0, 310.0, ...]
}

Returns: metrics per stock, correlation matrix, rankings by return and Sharpe ratio.

screen_stocks

Filter stocks based on financial criteria.

criteria = {
    "stocks": [
        {"symbol": "AAPL", "sector": "Technology", "market_cap": 3000000000000, ...}
    ],
    "min_market_cap": 1000000000000,
    "max_pe_ratio": 30.0,
    "sectors": ["Technology", "Healthcare"]
}

calculate_portfolio_metrics

Analyze portfolio performance.

holdings = {"AAPL": 10, "MSFT": 5}
prices = {"AAPL": [...], "MSFT": [...]}
benchmark_prices = [...]  # Optional: for beta calculation

Returns: total return, volatility, Sharpe ratio, max drawdown, beta, portfolio weights.

calculate_technical_levels

Calculate support and resistance levels.

prices = [100.0, 102.0, ...]
method = "pivot"  # or "fibonacci", "moving_average"

calculate_moving_averages

Calculate SMA and EMA for given periods.

prices = [100.0, 102.0, ...]
periods = [5, 10, 20, 50, 200]  # Optional, these are defaults

calculate_pivot_points

Calculate pivot points from OHLC data.

high = 110.0
low = 100.0
close = 105.0

Returns: standard, Woodie's, and Camarilla pivot levels.

Development

Running Tests

# Run all tests
uv run pytest

# Run with verbose output
uv run pytest -v

# Run specific test file
uv run pytest tests/test_server.py

# Run specific test
uv run pytest -k "test_basic_returns"

Project Structure

stock_tools_mcp/
├── server.py           # Main MCP server implementation
├── launch.py           # Cross-platform launcher
├── launch-stock-tools.sh  # Unix launcher script
├── pyproject.toml      # Project configuration
├── uv.lock             # Dependency lock file
├── shared/
│   ├── __init__.py
│   └── types.py        # MCPResponse type definition
└── tests/
    ├── __init__.py
    ├── conftest.py     # Test fixtures
    └── test_server.py  # Test suite (41 tests)

License

Proprietary - Onyx R&D

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    • Real SEC, 13F, insider, congress & macro data your AI agent can cite. Hosted MCP, 24 tools.

      https://mcp.ko.io/mcp
    • > TradingMCP puts a market analyst inside your AI assistant. Paste one URL into Claude, ChatGPT, Cursor, VS Code or any MCP client and ask in plain language: screen for breakouts, run a multi-timeframe analysis, backtest a strategy with walk-forward validation, scan for smart-money and volume signals, or get a one-prompt morning market brief. In clients that support MCP Apps, price charts and the Markets panel are drawn right in the chat. > 40+ tools covering crypto (real-time), stocks, ETFs, FX, futures and commodities across major global exchanges. > Hosted, nothing to install: Pro $9/month (2,500 tool calls) or Pro+ $29/month (10,000). Paid upfront with a 14-day money-back guarantee; your API key arrives right after checkout. > Built on the open-source tradingview-mcp core (MIT, ~5k GitHub stars): self-host it free, or use the hosted version with zero ops. > For research and education, not financial advice. Not affiliated with TradingView

      https://mcp.cryptosieve.com/mcp
    • Research-only MCP server: your AI as a quant research desk. 90 tools, no trades, no brokers.

      https://helveticresearch.com/mcp
    • Research US-listed companies and funds with the StockPortfolio.pro MCP server. Tools cover SEC filing-grounded financials, filing timelines, company comparisons, watchlist screens, fund profiles, and cited filing questions. Filed figures include their fiscal period and EDGAR source URL; missing filing data is returned as null. Public tools work without authentication; optional API-key or OAuth access is supported. US-listed, USD-reporting companies only. Keyless access includes 3 free AI questions per rolling 30-day window. To get more now, choose the Dev plan ($19.99/month, 200 credits) at https://www.stockportfolio.pro/register?plan=dev, then follow https://www.stockportfolio.pro/docs/api-mcp to connect with OAuth or an API key. Or wait for the free allowance to renew.

    Related MCP Servers

    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI assistants to retrieve and analyze multi-market stock data, including real-time quotes, K-lines, technical indicators, sector and futures/options information, and to perform screening, comparison, and market overview workflows through MCP tools, prompts, and resources.
      153 npm
      ISC
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI assistants to access and analyze financial data, stock information, company fundamentals, and market insights through a standardized MCP interface. It provides 250+ tools across categories such as financial statements, quotes, technical indicators, ETFs, crypto, forex, commodities, economics, and SEC filings.
      360 npm
      Apache 2.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI assistants to query US stock market and financial data across SEC filings, fundamentals, institutional holdings, insider and congressional trades, earnings transcripts, options, live quotes, IPOs, short interest, macro indicators, and portfolio tracking through MCP tools.
      7
      MIT
    • A
      license
      C
      quality
      D
      maintenance
      Enables LLM applications to retrieve stock prices, historical data, financial statements, analyst insights, options chains, news, and bulk comparisons through 30 MCP tools.
      28
      1
      MIT