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
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum entries | |
| search | No | Search query to filter |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"limit": {
"default": 50,
"description": "Maximum entries",
"type": "integer"
},
"search": {
"description": "Search query to filter",
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/tools/advanced.ts:399-432 (handler)The tool handler that processes inputs, retrieves function call history (with optional search), applies limits, computes top called functions statistics, and returns a formatted text response.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/tools/advanced.ts:395-398 (schema)Zod input schema defining the parameters for the tool: optional limit (default 50) and optional search query.{ limit: z.number().int().default(50).describe('Maximum entries'), search: z.string().optional().describe('Search query to filter'), },
- src/tools/advanced.ts:392-433 (registration)Full registration of the get_function_history tool on the MCP server, including name, description, input schema, and handler function.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:152-157 (helper)Core helper method in StepFilter class that returns the recent function call history entries, limited if specified.getFunctionHistory(limit?: number): FunctionCallEntry[] { if (limit) { return this.functionHistory.slice(-limit); } return [...this.functionHistory]; }
- src/session/step-filter.ts:169-176 (helper)Helper method to search function history by name or file.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:16-23 (schema)TypeScript interface defining the structure of function call entries returned by the tool.export interface FunctionCallEntry { timestamp: Date; name: string; file: string; line: number; depth: number; args?: string[]; }