This service acts as a secure and standardized intermediary between Claude and the third-party FinancialModelingPrep (FMP) API. It simplifies the vast FMP API into a set of logical, consistent MCP endpoints, handles authentication, and enforces standard error handling and logging.
-
Install Dependencies:
pip install -r requirements.txt
-
Configure API Key: Create a
.envfile in the root directory of this project and add your FMP API key:FMP_API_KEY="YOUR_FINANCIAL_MODELING_PREP_API_KEY" -
Start the Service:
python -m mcp_fmp_proxy
The service will be available at
http://127.0.0.1:8000.
This service uses FastAPI, which automatically generates interactive API documentation. Once the service is running, you can access it at:
- Swagger UI: http://127.0.0.1:8000/docs
- ReDoc: http://127.0.0.1:8000/redoc
This documentation provides a complete and interactive reference for all available endpoints, including their request and response models.
Below is a summary of the implemented endpoints. For detailed request/response formats, please refer to the auto-generated documentation linked above.
-
POST /company/profile
- Description: Retrieves core profile information for a single company.
- Request Body:
{"symbol": "AAPL"}
-
POST /company/quote
- Description: Retrieves real-time or delayed price quotes for one or more symbols.
- Request Body:
{"symbols": ["AAPL", "MSFT"]}
- POST /financials/statement
- Description: Retrieves income, balance sheet, or cash flow statements.
- Request Body:
{"symbol": "AAPL", "statement_type": "income", "period": "annual", "limit": 2} statement_typecan beincome,balance_sheet, orcash_flow.periodcan beannualorquarter.
To ensure the service is functioning correctly, you can run the test suite:
- Make sure your
FMP_API_KEYis correctly set in the.envfile. - Run the tests using pytest:
python -m pytest
This service is designed to be easily extensible. To add a new set of endpoints (e.g., for "Market Performance"):
-
Create a new router file: Create
mcp_fmp_proxy/routers/market_performance.py. -
Define Models and Endpoints: In the new file, define the Pydantic models for your requests and implement the FastAPI
APIRouterwith the desired endpoints. Use theget_data_from_fmpfunction fromfmp_client.pyto interact with the FMP API. -
Include the Router: In
mcp_fmp_proxy/main.py, import your new router and include it in the FastAPI app:from .routers import market_performance # ... app.include_router( market_performance.router, prefix="/market", tags=["Market Performance"] )