Skip to main content
Glama

add_logpoint

Add a logpoint to PHP code that logs messages during execution without stopping the program. Use {varName} placeholders to include variable values in log output.

Instructions

Add a logpoint that logs messages without stopping execution. Use {varName} placeholders for variables.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYesFile path
lineYesLine number
messageYesMessage template with {var} placeholders (e.g., 'User {$userId} logged in')
conditionNoOptional condition

Implementation Reference

  • The core handler implementation for the 'add_logpoint' MCP tool. Registers the tool, defines input schema with Zod, creates the logpoint via LogpointManager, and returns a JSON-formatted success response with logpoint details.
    server.tool( 'add_logpoint', 'Add a logpoint that logs messages without stopping execution. Use {varName} placeholders for variables.', { file: z.string().describe('File path'), line: z.number().int().describe('Line number'), message: z.string().describe("Message template with {var} placeholders (e.g., 'User {$userId} logged in')"), condition: z.string().optional().describe('Optional condition'), }, async ({ file, line, message, condition }) => { const logpoint = ctx.logpointManager.createLogpoint(file, line, message, condition); return { content: [ { type: 'text', text: JSON.stringify({ success: true, logpoint: { id: logpoint.id, file, line, message, condition, }, }), }, ], }; } );
  • Zod schema for input validation of the add_logpoint tool parameters.
    { file: z.string().describe('File path'), line: z.number().int().describe('Line number'), message: z.string().describe("Message template with {var} placeholders (e.g., 'User {$userId} logged in')"), condition: z.string().optional().describe('Optional condition'), },
  • Helper method in LogpointManager that creates, initializes, and stores a new Logpoint instance. Called by the tool handler.
    createLogpoint( file: string, line: number, message: string, condition?: string ): Logpoint { const id = `logpoint_${++this.logpointIdCounter}`; const logpoint: Logpoint = { id, file, line, message, condition, hitCount: 0, createdAt: new Date(), enabled: true, logHistory: [], }; this.logpoints.set(id, logpoint); logger.debug(`Logpoint created: ${id} at ${file}:${line}`); return logpoint; }
  • TypeScript interface defining the Logpoint data structure used by the manager and tool.
    export interface Logpoint { id: string; breakpointId?: string; file: string; line: number; message: string; condition?: string; hitCount: number; lastHitAt?: Date; createdAt: Date; enabled: boolean; logHistory: LogEntry[]; }
  • Registration call to registerAdvancedTools function, which includes the add_logpoint tool registration, invoked from the main registerAllTools.
    registerAdvancedTools(server, ctx as AdvancedToolsContext);

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