Skip to main content
Glama

stop_profiling

Stop PHP profiling and retrieve performance data to analyze application bottlenecks and optimize code execution.

Instructions

Stop profiling and get the results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registration of the 'stop_profiling' MCP tool, including inline handler, empty input schema, and description.
    server.tool( 'stop_profiling', 'Stop profiling and get the results', {}, async () => { const session = ctx.profiler.endSession(); if (!session) { return { content: [{ type: 'text', text: JSON.stringify({ error: 'No active profiling session' }) }], }; } const stats = ctx.profiler.getStatistics(); return { content: [{ type: 'text', text: JSON.stringify(stats, null, 2) }], }; } );
  • The handler function that executes the tool: ends the profiling session and returns the statistics as JSON.
    async () => { const session = ctx.profiler.endSession(); if (!session) { return { content: [{ type: 'text', text: JSON.stringify({ error: 'No active profiling session' }) }], }; } const stats = ctx.profiler.getStatistics(); return { content: [{ type: 'text', text: JSON.stringify(stats, null, 2) }], }; }
  • Profiler.endSession() method called by the tool handler to end the current profiling session.
    endSession(): ProfilingSession | null { if (!this.currentSession) return null; this.currentSession.endedAt = new Date(); const session = this.currentSession; logger.info(`Profiling session ended: ${session.id}`); return session; }
  • Profiler.getStatistics() method called by the tool handler to retrieve comprehensive profiling statistics.
    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