get_function_history
Retrieve function call history during PHP debugging to analyze execution flow and identify issues.
Instructions
Get the history of function calls made during debugging
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum entries | |
| search | No | Search query to filter |
Implementation Reference
- src/session/step-filter.ts:152-157 (handler)The core handler method that retrieves the list of recent function calls from the internal history buffer, limited by the optional 'limit' parameter. This is the primary logic executed by the MCP tool.getFunctionHistory(limit?: number): FunctionCallEntry[] { if (limit) { return this.functionHistory.slice(-limit); } return [...this.functionHistory]; }
- src/tools/advanced.ts:392-433 (registration)MCP server tool registration for 'get_function_history', including description, input schema, and the tool handler function that delegates to StepFilter methods and formats the response.server.tool( 'get_function_history', 'Get the history of function calls made during debugging', { limit: z.number().int().default(50).describe('Maximum entries'), search: z.string().optional().describe('Search query to filter'), }, async ({ limit, search }) => { let history = search ? ctx.stepFilter.searchHistory(search) : ctx.stepFilter.getFunctionHistory(limit); if (limit && history.length > limit) { history = history.slice(-limit); } const stats = ctx.stepFilter.getCallStatistics(); const topCalls = Array.from(stats.entries()) .sort((a, b) => b[1].count - a[1].count) .slice(0, 10); return { content: [ { type: 'text', text: JSON.stringify( { history, topFunctions: topCalls.map(([name, stat]) => ({ name, count: stat.count, lastCall: stat.lastCall, })), }, null, 2 ), }, ], }; } );
- src/session/step-filter.ts:169-176 (helper)Helper method to filter function history by search query on name or file, used when 'search' parameter is provided in the tool call.searchHistory(query: string): FunctionCallEntry[] { const lowerQuery = query.toLowerCase(); return this.functionHistory.filter( (entry) => entry.name.toLowerCase().includes(lowerQuery) || entry.file.toLowerCase().includes(lowerQuery) ); }
- src/session/step-filter.ts:137-147 (helper)Helper method that records new function calls to the history buffer, maintaining a maximum size limit.recordFunctionCall(entry: Omit<FunctionCallEntry, 'timestamp'>): void { this.functionHistory.push({ ...entry, timestamp: new Date(), }); // Trim history if too large if (this.functionHistory.length > this.maxHistorySize) { this.functionHistory = this.functionHistory.slice(-this.maxHistorySize); } }
- src/session/step-filter.ts:181-197 (helper)Helper method that computes statistics (call count and last call time) for each function in the history, used to provide top functions in the tool response.getCallStatistics(): Map<string, { count: number; lastCall: Date }> { const stats = new Map<string, { count: number; lastCall: Date }>(); for (const entry of this.functionHistory) { const existing = stats.get(entry.name); if (existing) { existing.count++; if (entry.timestamp > existing.lastCall) { existing.lastCall = entry.timestamp; } } else { stats.set(entry.name, { count: 1, lastCall: entry.timestamp }); } } return stats; }