Skip to main content
Glama

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
NameRequiredDescriptionDefault
limitNoMaximum entries
searchNoSearch query to filter

Implementation Reference

  • 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]; }
  • 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 ), }, ], }; } );
  • 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) ); }
  • 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); } }
  • 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; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kpanuragh/xdebug-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server