mcp-server-public-markets

robert-garay/mcp-server-public-markets

3.1

If you are the rightful owner of mcp-server-public-markets 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.

This server provides a Model Context Protocol (MCP) interface to retrieve public market data using the Financial Modeling Prep (FMP) API.

MCP Server for Public Markets Data Retrieval

This server provides a Model Context Protocol (MCP) interface to retrieve public market data (stocks, company metrics, etc.) using the Financial Modeling Prep (FMP) API.

Features

  • Strict MCP compatibility: single /mcp endpoint using JSON-RPC-like schema
  • Retrieve stock prices, company metrics, and more
  • OAuth support (demo token)
  • Error handling
  • Local testing with stdio transport

Setup

  1. Clone the repository (if not already):

    git clone <repo-url>
    cd mcp-server-public-markets
    
  2. Create a .env file with your FMP API key:

    echo "FMP_API_KEY=wQfRLCIqXg0Q681eMZye1mxPCC12jFua" > .env
    
  3. Install dependencies:

    pip install -r requirements.txt
    
  4. Run the server locally (HTTP API):

    uvicorn mcp_server:app --reload
    # or
    python mcp_server.py
    
  5. Run the server in stdio mode (for agent/CLI testing):

    STDIO_MODE=1 python mcp_server.py
    

MCP Protocol Usage

All requests are sent to the /mcp endpoint (HTTP) or as JSON lines (stdio). The schema is:

Request:

{
  "id": 1,
  "method": "company.metrics",
  "params": { "symbol": "AAPL" }
}

Response:

{
  "id": 1,
  "result": { ... },
  "error": null
}

If an error occurs, result is null and error contains a code/message.

Supported Methods

  • stock.price — params: { "symbol": "AAPL" }
  • company.metrics — params: { "symbol": "AAPL" }

Authentication

  • Use the OAuth2 Bearer token test-token for local testing.
  • For HTTP, add header: Authorization: Bearer test-token
  • For stdio, add field: "token": "test-token" in your request JSON.

Examples

HTTP (curl)

curl -X POST http://127.0.0.1:8000/mcp \
  -H "Authorization: Bearer test-token" \
  -H "Content-Type: application/json" \
  -d '{"id": 1, "method": "company.metrics", "params": {"symbol": "AAPL"}}'

STDIO

Start:

STDIO_MODE=1 python mcp_server.py

Then type:

{"id": 1, "method": "company.metrics", "params": {"symbol": "AAPL"}, "token": "test-token"}

Error Handling

  • All errors are returned in the error field with a code and message, MCP-style.

Note: This project is for educational/testing purposes. For production use, review security and scalability considerations.