Skip to main content
Glama
financial-datasets

Financial Datasets MCP Server

Official

get_balance_sheets

Retrieve company balance sheets by entering a ticker symbol, specifying period (annual/quarterly), and setting result limits for financial analysis.

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
tickerYes
periodNoannual
limitNo

Implementation Reference

  • The handler function for the 'get_balance_sheets' tool. It is decorated with @mcp.tool(), which also serves as registration. Fetches balance sheets data from the Financial Datasets API based on ticker, period, and limit, then returns JSON-formatted data.
    @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 used by get_balance_sheets to make authenticated HTTP 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)}

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