Skip to main content
Glama
financial-datasets

Financial Datasets MCP Server

Official

get_cash_flow_statements

Retrieve cash flow statements for a company by providing its ticker symbol, period (annual, quarterly, ttm), and the number of statements to return. Ideal for analyzing financial performance and trends.

Instructions

Get cash flow statements for a company.

Args: ticker: Ticker symbol of the company (e.g. AAPL, GOOGL) period: Period of the cash flow statement (e.g. annual, quarterly, ttm) limit: Number of cash flow statements to return (default: 4)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
periodNoannual
tickerYes

Implementation Reference

  • The handler function implementing the get_cash_flow_statements tool. It is registered via the @mcp.tool() decorator. Fetches cash flow statements from the Financial Datasets API based on ticker, period, and limit, formats and returns as JSON string.
    @mcp.tool() async def get_cash_flow_statements( ticker: str, period: str = "annual", limit: int = 4, ) -> str: """Get cash flow statements for a company. Args: ticker: Ticker symbol of the company (e.g. AAPL, GOOGL) period: Period of the cash flow statement (e.g. annual, quarterly, ttm) limit: Number of cash flow statements to return (default: 4) """ # Fetch data from the API url = f"{FINANCIAL_DATASETS_API_BASE}/financials/cash-flow-statements/?ticker={ticker}&period={period}&limit={limit}" data = await make_request(url) # Check if data is found if not data: return "Unable to fetch cash flow statements or no cash flow statements found." # Extract the cash flow statements cash_flow_statements = data.get("cash_flow_statements", []) # Check if cash flow statements are found if not cash_flow_statements: return "Unable to fetch cash flow statements or no cash flow statements found." # Stringify the cash flow statements return json.dumps(cash_flow_statements, indent=2)
  • Helper function used by get_cash_flow_statements (and other tools) to make authenticated API requests to the Financial Datasets API.
    async def make_request(url: str) -> dict[str, any] | None: """Make a request to the Financial Datasets API with proper error handling.""" # Load environment variables from .env file load_dotenv() headers = {} if api_key := os.environ.get("FINANCIAL_DATASETS_API_KEY"): headers["X-API-KEY"] = api_key async with httpx.AsyncClient() as client: try: response = await client.get(url, headers=headers, timeout=30.0) response.raise_for_status() return response.json() except Exception as e: return {"Error": str(e)}
  • server.py:107-107 (registration)
    The @mcp.tool() decorator registers the get_cash_flow_statements function as an MCP tool.
    @mcp.tool()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/financial-datasets/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server