Skip to main content
Glama

get_companies_with_pe_ratio

Filter companies in the Spanish stock exchange by P/E ratio range to identify investment opportunities based on valuation metrics.

Instructions

Get companies filtered by P/E ratio range

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
minPENoMinimum P/E ratio
maxPENoMaximum P/E ratio

Implementation Reference

  • src/index.ts:87-103 (registration)
    Registration of the 'get_companies_with_pe_ratio' tool, including name, description, and input schema definition.
    {
      name: 'get_companies_with_pe_ratio',
      description: 'Get companies filtered by P/E ratio range',
      inputSchema: {
        type: 'object',
        properties: {
          minPE: {
            type: 'number',
            description: 'Minimum P/E ratio',
          },
          maxPE: {
            type: 'number',
            description: 'Maximum P/E ratio',
          },
        },
      },
    },
  • Handler dispatch in the main CallToolRequest handler that invokes the database method with parsed arguments.
    case 'get_companies_with_pe_ratio':
      result = await this.db.getCompaniesWithPERatio((args as any)?.minPE, (args as any)?.maxPE);
      break;
  • Core implementation of the tool logic: fetches all companies and filters those within the specified P/E ratio range using price_to_earnings or pe_ratio fields.
    async getCompaniesWithPERatio(minPE?: number, maxPE?: number): Promise<any[]> {
      const companies = await this.getAllCompanies();
      return companies.filter(company => {
        const pe = company.price_to_earnings || company.pe_ratio;
        if (pe === null || pe === undefined) return false;
        
        if (minPE !== undefined && pe < minPE) return false;
        if (maxPE !== undefined && pe > maxPE) return false;
        return true;
      });
    }
  • Input schema definition for the tool, specifying optional minPE and maxPE numeric parameters.
    inputSchema: {
      type: 'object',
      properties: {
        minPE: {
          type: 'number',
          description: 'Minimum P/E ratio',
        },
        maxPE: {
          type: 'number',
          description: 'Maximum P/E ratio',
        },
      },
    },

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/anbrme/ibex35-mcp-server'

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