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

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

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

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