Skip to main content
Glama

set_call_breakpoint

Set a breakpoint that triggers when a specific function is called, enabling debugging of PHP applications by pausing execution at function entry points.

Instructions

Set a breakpoint that triggers when a specific function is called. Can be set before a debug session starts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
function_nameYesFunction name to break on (e.g., 'myFunction' or 'MyClass::myMethod')
session_idNoSession ID

Implementation Reference

  • Executes the set_call_breakpoint tool: resolves session or adds as pending, calls session.setCallBreakpoint or pendingBreakpoints.addCallBreakpoint, returns JSON response with breakpoint info
    async ({ function_name, session_id }) => {
      const session = sessionManager.resolveSession(session_id);
    
      // If no active session, store as pending breakpoint
      if (!session) {
        const pendingBp = pendingBreakpoints.addCallBreakpoint(function_name);
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(
                {
                  success: true,
                  pending: true,
                  message: 'Call breakpoint stored as pending - will be applied when a debug session connects',
                  breakpoint: {
                    id: pendingBp.id,
                    type: 'call',
                    function: function_name,
                    enabled: pendingBp.enabled,
                  },
                },
                null,
                2
              ),
            },
          ],
        };
      }
    
      try {
        const breakpoint = await session.setCallBreakpoint(function_name);
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(
                {
                  success: true,
                  breakpoint: {
                    id: breakpoint.id,
                    type: 'call',
                    function: function_name,
                    state: breakpoint.state,
                  },
                },
                null,
                2
              ),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                error: 'Failed to set call breakpoint',
                message: error instanceof Error ? error.message : String(error),
              }),
            },
          ],
        };
      }
    }
  • Input schema using Zod: function_name (required string), session_id (optional string)
    {
      function_name: z
        .string()
        .describe(
          "Function name to break on (e.g., 'myFunction' or 'MyClass::myMethod')"
        ),
      session_id: z.string().optional().describe('Session ID'),
    },
  • Registers the MCP tool 'set_call_breakpoint' with server.tool(), including description, input schema, and handler
    server.tool(
      'set_call_breakpoint',
      'Set a breakpoint that triggers when a specific function is called. Can be set before a debug session starts.',
      {
        function_name: z
          .string()
          .describe(
            "Function name to break on (e.g., 'myFunction' or 'MyClass::myMethod')"
          ),
        session_id: z.string().optional().describe('Session ID'),
      },
      async ({ function_name, session_id }) => {
        const session = sessionManager.resolveSession(session_id);
    
        // If no active session, store as pending breakpoint
        if (!session) {
          const pendingBp = pendingBreakpoints.addCallBreakpoint(function_name);
    
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(
                  {
                    success: true,
                    pending: true,
                    message: 'Call breakpoint stored as pending - will be applied when a debug session connects',
                    breakpoint: {
                      id: pendingBp.id,
                      type: 'call',
                      function: function_name,
                      enabled: pendingBp.enabled,
                    },
                  },
                  null,
                  2
                ),
              },
            ],
          };
        }
    
        try {
          const breakpoint = await session.setCallBreakpoint(function_name);
    
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(
                  {
                    success: true,
                    breakpoint: {
                      id: breakpoint.id,
                      type: 'call',
                      function: function_name,
                      state: breakpoint.state,
                    },
                  },
                  null,
                  2
                ),
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify({
                  error: 'Failed to set call breakpoint',
                  message: error instanceof Error ? error.message : String(error),
                }),
              },
            ],
          };
        }
      }
    );
  • DebugSession.setCallBreakpoint: sends DBGP 'breakpoint_set -t call -m <function>' command, parses response, stores breakpoint
    async setCallBreakpoint(functionName: string): Promise<Breakpoint> {
      const response = await this.connection.sendCommand('breakpoint_set', {
        t: 'call',
        m: functionName,
      });
    
      if (response.error) {
        throw new Error(`Failed to set call breakpoint: ${response.error.message}`);
      }
    
      const result = this.connection.parseBreakpointSet(response);
    
      const breakpoint: Breakpoint = {
        id: result.id,
        type: 'call',
        state: 'enabled',
        function: functionName,
      };
    
      this.breakpoints.set(breakpoint.id, breakpoint);
      return breakpoint;
    }
  • PendingBreakpointsManager.addCallBreakpoint: stores call breakpoint as pending before session starts, emits event
    addCallBreakpoint(functionName: string): PendingBreakpoint {
      const id = `pending_${++this.breakpointIdCounter}`;
      const bp: PendingBreakpoint = {
        id,
        type: 'call',
        functionName,
        enabled: true,
        createdAt: new Date(),
      };
      this.pendingBreakpoints.set(id, bp);
      logger.info(`Pending call breakpoint added: ${id} for ${functionName}`);
      this.emit('breakpointAdded', bp);
      return bp;
    }

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