Skip to main content
Glama
MCP-100

Stock Market MCP Server

by MCP-100

get_financial_statement

Retrieve income statements, balance sheets, or cash flow statements for publicly traded companies using stock ticker symbols to analyze financial performance.

Instructions

Get financial statements for a company

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesStock ticker symbol
statementYesType of financial statement

Implementation Reference

  • The core handler function that validates input, maps statement type to Alpha Vantage API function, fetches the financial statement data, and returns it as JSON text.
    private async handleGetFinancialStatement(args: { statement: 'income' | 'balance' | 'cashflow'; symbol: string }) {
      if (!args || typeof args !== 'object' ||
        !args.statement || !['income', 'balance', 'cashflow'].includes(args.statement)) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid statement parameter');
      }
      if (!args.symbol || typeof args.symbol !== 'string') {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid symbol parameter');
      }
    
      const functionMap = {
        income: 'INCOME_STATEMENT',
        balance: 'BALANCE_SHEET',
        cashflow: 'CASH_FLOW'
      };
    
      const response = await this.axiosInstance.get('', {
        params: {
          function: functionMap[args.statement],
          symbol: args.symbol
        }
      });
    
      return {
        content: [{
          type: 'text',
          text: JSON.stringify(response.data, null, 2)
        }]
      };
    }
  • src/index.ts:75-93 (registration)
    Registers the tool in the ListTools response, providing name, description, and input schema.
    {
      name: 'get_financial_statement',
      description: 'Get financial statements for a company',
      inputSchema: {
        type: 'object',
        properties: {
          symbol: {
            type: 'string',
            description: 'Stock ticker symbol'
          },
          statement: {
            type: 'string',
            enum: ['income', 'balance', 'cashflow'],
            description: 'Type of financial statement'
          }
        },
        required: ['symbol', 'statement']
      }
    },
  • Defines the input schema for validation: requires 'symbol' (string) and 'statement' (enum: 'income', 'balance', 'cashflow').
    inputSchema: {
      type: 'object',
      properties: {
        symbol: {
          type: 'string',
          description: 'Stock ticker symbol'
        },
        statement: {
          type: 'string',
          enum: ['income', 'balance', 'cashflow'],
          description: 'Type of financial statement'
        }
      },
      required: ['symbol', 'statement']
    }
  • Dispatcher case in CallToolRequestHandler that validates arguments and delegates to the specific handler.
    case 'get_financial_statement': {
      if (!request.params.arguments || typeof request.params.arguments !== 'object') {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid arguments');
      }
      const args = request.params.arguments as { statement: 'income' | 'balance' | 'cashflow'; symbol: string };
      return await this.handleGetFinancialStatement(args);
    }

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/MCP-100/stock-market-server'

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