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
maxPENoMaximum P/E ratio
minPENoMinimum P/E ratio

Implementation Reference

  • Core handler function that implements the tool logic: fetches all companies and filters those within the specified P/E ratio range using client-side filtering.
    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; }); }
  • src/index.ts:88-103 (registration)
    Tool registration including name, description, and input schema definition in the ListToolsRequestSchema handler.
    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', }, }, }, },
  • Dispatch handler in the CallToolRequestSchema switch statement 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;

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