Skip to main content
Glama

get_profile_stats

Retrieve current profiling statistics for PHP applications to analyze performance and identify bottlenecks during debugging sessions.

Instructions

Get current profiling statistics

Input Schema

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "properties": {}, "type": "object" }

Implementation Reference

  • Handler function for the 'get_profile_stats' tool. Retrieves profiling statistics from ctx.profiler.getStatistics() and returns them as formatted JSON text content, or an error message if no profiling data is available.
    async () => { const stats = ctx.profiler.getStatistics(); if (!stats) { return { content: [{ type: 'text', text: JSON.stringify({ error: 'No profiling data. Start profiling first.' }) }], }; } return { content: [{ type: 'text', text: JSON.stringify(stats, null, 2) }], }; }
  • Registration of the 'get_profile_stats' MCP tool using server.tool(), including description, empty input schema, and inline handler.
    server.tool( 'get_profile_stats', 'Get current profiling statistics', {}, async () => { const stats = ctx.profiler.getStatistics(); if (!stats) { return { content: [{ type: 'text', text: JSON.stringify({ error: 'No profiling data. Start profiling first.' }) }], }; } return { content: [{ type: 'text', text: JSON.stringify(stats, null, 2) }], }; } );
  • Input schema for 'get_profile_stats': no input parameters required (empty object).
    {},
  • Profiler.getStatistics() method invoked by the tool handler. Computes and returns detailed profiling statistics including session ID, activity status, duration, snapshot count, peak memory usage, function count, and top 10 functions by total execution time.
    getStatistics(): { sessionId: string | null; isActive: boolean; duration: number; snapshotCount: number; peakMemoryUsage: number; functionCount: number; topFunctions: FunctionProfile[]; } | null { if (!this.currentSession) return null; const duration = this.currentSession.endedAt ? this.currentSession.endedAt.getTime() - this.currentSession.startedAt.getTime() : Date.now() - this.currentSession.startedAt.getTime(); const functions = Array.from(this.currentSession.functionProfiles.values()); const topFunctions = functions .sort((a, b) => b.totalTime - a.totalTime) .slice(0, 10); return { sessionId: this.currentSession.id, isActive: !this.currentSession.endedAt, duration, snapshotCount: this.currentSession.snapshots.length, peakMemoryUsage: this.currentSession.peakMemoryUsage, functionCount: functions.length, topFunctions, }; }

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