Massive.com MCP Server

repository·master·Indexed 18 days ago

https://github.com/massive-com/mcp_massive

A Model Context Protocol (MCP) server (v0.10.0) providing LLMs with a composable interface to the Massive.com financial data API. It features tools for searching endpoints, calling REST APIs, and querying results via an in-memory SQLite database. The server includes built-in financial functions for Black-Scholes Greeks (e.g., bs_price, bs_delta), returns (e.g., sharpe_ratio, log_return), and technical indicators (sma, ema), which can be applied to data using a post-processing pipeline.

Tokens
5.3K
Snippets
18
Records
26
Agent score
63%

What's inside mcp_massive

  1. Overview of Massive.com MCP Server Tools

    master

    The Massive.com MCP server provides three composable tools to interact with the full Massive.com financial data API. Instead of one tool per endpoint, these tools allow an LLM to discover, call, and query data dynamically.

    • search_endpoints: Use natural language to find API endpoints and built-in functions.
      • detail: Set to "more" for query parameter documentation or "verbose" for full documentation.
      • max_results: Limits the number of results returned.
    • call_api: Executes a request to any Massive.com REST API endpoint.
      • store_as: Allows storing the API response in an in-memory SQLite database table.
      • apply: Applies post-processing functions (like financial calculations) to the result.
    • query_data: Runs SQL queries against the in-memory SQLite database containing stored API results. Supports standard SQL including SHOW TABLES, `DESCRIBE <table

    , DROP TABLE <table , CTEs, and window functions. Can also use the apply` parameter for post-processing.

  2. Built-in Financial Functions in Massive.com MCP

    master

    The server includes built-in functions that can be applied to API results or query outputs using the apply parameter in call_api or query_data. You can discover all available functions by calling search_endpoints with scope="functions".

    Available Categories:

    • Greeks (Black-Scholes): bs_price, bs_delta, bs_gamma, bs_theta, bs_vega, bs_rho
    • Returns: simple_return, log_return, cumulative_return, sharpe_ratio, sortino_ratio
    • Technical Indicators: sma (simple moving average), ema (exponential moving average)
  3. Install the Massive.com MCP Server for Claude Desktop

    master

    To integrate the Massive.com MCP server with Claude Desktop:

    1. Install the server using uv:
    uv tool install "mcp_massive @ git+https://github.com/massive-com/mcp_massive@v0.10.0"
    1. Find the absolute path to the installed binary:
    • Mac/Linux: which mcp_massive
    • Windows: where mcp_massive
    1. Add the server to your claude_desktop_config.json file. Replace <path_to_mcp_massive> with your binary path and <your_api_key_here> with your actual Massive.com API key.
    {
        "mcpServers": {
            "massive": {
                "command": "<path_to_mcp_massive>",
                "env": {
                    "MASSIVE_API_KEY": "<your_api_key_here>",
                    "HOME": "<your_home_directory>"
                }
            }
        }
    }
  4. Install the Massive.com MCP Server for Claude Code

    master

    To use the Massive.com MCP server with Claude Code, follow these steps. Ensure you have Astral UV (v0.4.0+) and Python 3.12+ installed.

    1. Install Claude Code via npm:
    npm install -g @anthropic-ai/claude-code
    1. Install the MCP server using uv tool install (this ensures fast startup by downloading dependencies ahead of time):
    uv tool install "mcp_massive @ git+https://github.com/massive-com/mcp_massive@v0.10.0"
    1. Register the server with Claude Code:
    claude mcp add massive -e MASSIVE_API_KEY=your_api_key_here -- mcp_massive

    To upgrade the server in the future, use:

    uv tool upgrade mcp_massive
    npm install -g @anthropic-ai/claude-code
    uv tool install "mcp_massive @ git+https://github.com/massive-com/mcp_massive@v0.10.0"
    claude mcp add massive -e MASSIVE_API_KEY=your_api_key_here -- mcp_massive
  5. Understand Endpoint query parameter filtering

    master

    The API documentation supports consistent filter-operator suffixes for query parameters. When using the more detail level in Endpoint.format(), these are collapsed into a single annotation for the base parameter.

    Supported Filter Operators:

    • gt (greater than)
    • gte (greater than or equal to)
    • lt (less than)
    • lte (less than or equal to)
    • any_of (matches any in a list)
    • all_of (matches all in a list)

    Example parameter name in docs: market_cap.gt

  6. Parameter interpretation with ParamKind

    master

    When providing inputs to functions, the ParamKind determines how your input value is interpreted:

    KindInput TypeInterpretation
    columnstrInterpreted as a column name in the current table.
    literalint or floatInterpreted as a constant numeric value.
    col_or_litstr or int/floatIf a string, treated as a column; if a number, treated as a literal.
    literal_strstrTreated as a literal string (not a column reference).
  7. Configure MCP Transport Protocol

    master

    By default, the server uses stdio transport. You can change this using the MCP_TRANSPORT environment variable or the --transport CLI argument (the CLI argument takes precedence).

    Using CLI argument:

    MASSIVE_API_KEY=<your_api_key_here> uv run mcp_massive --transport streamable-http

    Using Environment variable:

    MCP_TRANSPORT=streamable-http MASSIVE_API_KEY=<your_api_key_here> uv run mcp_massive
  8. How to apply finance functions to Tables

    master

    You can enrich a Table by applying a sequence of pre-defined finance functions (like Greeks, returns, or technical indicators) using the apply_pipeline function. This allows for post-processing data without arbitrary code execution.

    Each step in the pipeline is a dictionary containing:

    • function: The name of the registered function (e.g., bs_price, sma).
    • inputs: A dictionary mapping parameter names to values.
      • Use a string to reference an existing column name.
      • Use a number to provide a literal value.
    • output: The name of the new column to be created (defaults to the function name if omitted).

    Constraints:

    • Maximum of 20 steps per pipeline.
    • Output column names must match the regex ^[a-zA-Z_][a-zA-Z0-9_]{0,62}$.
    steps = [
        {
            "function": "simple_return",
            "inputs": {"column": "price"},
            "output": "returns"
        },
        {
            "function": "sma",
            "inputs": {"column": "price", "window": 20},
            "output": "price_sma_20"
        }
    ]
    
    enriched_table = apply_pipeline(table, steps)
  9. Build the EndpointIndex from a URL

    master

    Use the build_index function to asynchronously fetch and index the llms-full.txt documentation file.

    By default, it looks for the MASSIVE_LLMS_TXT_URL environment variable. If not set, it uses a default URL.

    Note: This process involves downloading the documentation, parsing endpoints, and initializing an in-memory SQLite FTS5 database.

    import os
    from mcp_massive.index import build_index
    
    # Optional: Set the URL via environment variable
    os.environ["MASSIVE_LLMS_TXT_URL"] = "https://example.com/llms-full.txt"
    
    index = await build_index()
  10. Debug the Massive.com MCP Server with MCP Inspector

    master

    To debug or test the server, use the MCP Inspector. This provides a browser interface to interact with tools and view I/O.

    Run the following command:

    npx @modelcontextprotocol/inspector uv --directory /path/to/mcp_massive run mcp_massive

    In the browser UI, select STDIO as the transport type and use uv with run mcp_massive as the arguments.

  11. Configure the Massive MCP server via environment variables

    master

    The server uses several environment variables for configuration. These are loaded from a .env file if present, or directly from the system environment.

    VariableDescription
    MASSIVE_API_KEYRequired. Your Massive API key.
    POLYGON_API_KEYDeprecated. Use MASSIVE_API_KEY instead.
    MASSIVE_API_BASE_URLThe base URL for the Massive API. Defaults to https://api.massive.com.
    MASSIVE_LLMS_TXT_URLURL for the LLMs text resource.
    MASSIVE_MAX_TABLESInteger limit for the maximum number of tables returned.
    MASSIVE_MAX_ROWSInteger limit for the maximum number of rows returned.
    MCP_TRANSPORTSets the transport protocol (stdio, sse, or streamable-http).

    Note: The --transport CLI argument takes precedence over the MCP_TRANSPORT environment variable.

    export MASSIVE_API_KEY="your_key_here"
    export MASSIVE_MAX_ROWS=100
    python -m mcp_massive.main
  12. Configure the mcp_massive Docker container

    master

    The mcp_massive service can be run using Docker Compose. It requires a MASSIVE_API_KEY environment variable to authenticate with the Massive API. When using Docker Compose, ensure the MASSIVE_API_KEY is set in your host environment or a .env file so it can be interpolated into the container.

    services:
      mcp_massive:
        build: .
        volumes:
          - .:/app
        container_name: mcp_massive_server
        environment:
          - MASSIVE_API_KEY=${MASSIVE_API_KEY}
        stdin_open: true
        tty: true