get_historical_prices
Retrieve historical stock price data for Spanish companies to analyze market trends and performance over specified time periods.
Instructions
Get historical price data for a company
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| companyId | Yes | Company ID | |
| days | No | Number of days of historical data |
Implementation Reference
- src/index.ts:187-205 (schema)Defines the tool schema for get_historical_prices including name, description, and input schema.{ name: 'get_historical_prices', description: 'Get historical price data for a company', inputSchema: { type: 'object', properties: { companyId: { type: 'string', description: 'Company ID', }, days: { type: 'number', description: 'Number of days of historical data', default: 30, }, }, required: ['companyId'], }, },
- src/index.ts:617-619 (registration)Registers the tool handler in the MCP CallToolRequestSchema switch statement, delegating to DatabaseManager.case 'get_historical_prices': result = await this.db.getHistoricalPrices((args as any)?.companyId, (args as any)?.days || 30); break;
- src/database.ts:203-215 (handler)Implements the core logic for retrieving historical prices by resolving company ID to symbol and calling the API endpoint.async getHistoricalPrices(companyId: string, days: number = 30): Promise<any[]> { // Find company symbol from ID const companies = await this.getAllCompanies(); const company = companies.find(c => c.id === companyId); if (!company) return []; const data = await this.fetchAPI('/api/historical-prices/company', { symbol: company.symbol, days: days }); return data.historicalData || []; }