get_companies_by_sector
Filter and retrieve companies from the Spanish stock exchange based on specific industry sectors such as Banking, Technology, or Energy.
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/database.ts:62-67 (handler)Core handler implementing the tool logic: fetches all companies and filters those whose sector name contains the provided sector string (case-insensitive).async getCompaniesBySector(sector: string): Promise<any[]> { const companies = await this.getAllCompanies(); return companies.filter(company => company.sector && company.sector.toLowerCase().includes(sector.toLowerCase()) ); }
- src/index.ts:76-85 (schema)Input schema definition for the get_companies_by_sector tool, specifying a required 'sector' string parameter.inputSchema: { type: 'object', properties: { sector: { type: 'string', description: 'Sector name or partial match (e.g., Banking, Technology, Energy)', }, }, required: ['sector'], },
- src/index.ts:73-86 (registration)Tool registration metadata including name, description, and input schema, added to the MCP server's tools list.{ 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/index.ts:585-587 (handler)MCP request handler dispatch case that invokes the database method with the tool argument.case 'get_companies_by_sector': result = await this.db.getCompaniesBySector((args as any)?.sector); break;