Skip to main content
Glama
financial-datasets

Financial Datasets MCP Server

Official

get_balance_sheets

Retrieve balance sheets for companies by specifying ticker symbol, period, and limit. Access financial data from the Financial Datasets MCP Server to analyze company performance.

Instructions

Get balance sheets for a company.

Args: ticker: Ticker symbol of the company (e.g. AAPL, GOOGL) period: Period of the balance sheet (e.g. annual, quarterly, ttm) limit: Number of balance sheets to return (default: 4)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
periodNoannual
tickerYes

Implementation Reference

  • The handler function for the 'get_balance_sheets' tool. It is decorated with @mcp.tool() for registration, defines input parameters with type hints serving as schema, and implements the logic to fetch balance sheet data from the Financial Datasets API using the make_request helper, then returns JSON.
    @mcp.tool() async def get_balance_sheets( ticker: str, period: str = "annual", limit: int = 4, ) -> str: """Get balance sheets for a company. Args: ticker: Ticker symbol of the company (e.g. AAPL, GOOGL) period: Period of the balance sheet (e.g. annual, quarterly, ttm) limit: Number of balance sheets to return (default: 4) """ # Fetch data from the API url = f"{FINANCIAL_DATASETS_API_BASE}/financials/balance-sheets/?ticker={ticker}&period={period}&limit={limit}" data = await make_request(url) # Check if data is found if not data: return "Unable to fetch balance sheets or no balance sheets found." # Extract the balance sheets balance_sheets = data.get("balance_sheets", []) # Check if balance sheets are found if not balance_sheets: return "Unable to fetch balance sheets or no balance sheets found." # Stringify the balance sheets return json.dumps(balance_sheets, indent=2)
  • Helper function 'make_request' used by get_balance_sheets (and other tools) to make authenticated HTTP GET 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:75-75 (registration)
    The @mcp.tool() decorator registers the get_balance_sheets 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