get_companies_by_sector
Retrieve Spanish stock exchange companies filtered by specific sectors like Banking, Technology, or Energy to analyze market relationships and sector composition.
Instructions
Get companies filtered by sector
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sector | Yes | Sector name or partial match (e.g., Banking, Technology, Energy) |
Implementation Reference
- src/index.ts:585-587 (handler)Handler logic in the MCP tool dispatcher switch statement that extracts the sector argument and delegates execution to the DatabaseManager's getCompaniesBySector method.case 'get_companies_by_sector': result = await this.db.getCompaniesBySector((args as any)?.sector); break;
- src/index.ts:73-86 (schema)Tool schema definition in the ListTools response, specifying name, description, and input schema that requires a 'sector' string parameter.{ name: 'get_companies_by_sector', description: 'Get companies filtered by sector', inputSchema: { type: 'object', properties: { sector: { type: 'string', description: 'Sector name or partial match (e.g., Banking, Technology, Energy)', }, }, required: ['sector'], }, },
- src/database.ts:62-67 (helper)DatabaseManager method that implements the core filtering logic: fetches all companies via API and returns those whose sector name contains the provided sector string (case-insensitive partial match).async getCompaniesBySector(sector: string): Promise<any[]> { const companies = await this.getAllCompanies(); return companies.filter(company => company.sector && company.sector.toLowerCase().includes(sector.toLowerCase()) ); }