Skip to main content
Glama

evaluate_watches

Get current values of all watch expressions during PHP debugging sessions to monitor variables and expressions in real-time.

Instructions

Evaluate all watch expressions and return their current values

Input Schema

NameRequiredDescriptionDefault
session_idNoSession ID

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "session_id": { "description": "Session ID", "type": "string" } }, "type": "object" }

Implementation Reference

  • The handler function that executes the evaluate_watches tool. It resolves the debug session, evaluates all watch expressions using the WatchManager, processes the results (including detecting changes), and returns a formatted JSON response with watch IDs, expressions, values, change status, errors, and count of changed watches.
    async ({ session_id }) => { const session = ctx.sessionManager.resolveSession(session_id); if (!session) { return { content: [{ type: 'text', text: JSON.stringify({ error: 'No active session' }) }], }; } const results = await ctx.watchManager.evaluateAll(session); const changedWatches = results.filter((r) => r.hasChanged); return { content: [ { type: 'text', text: JSON.stringify( { watches: results.map((r) => ({ id: r.id, expression: r.expression, value: r.value, hasChanged: r.hasChanged, error: r.error, })), changedCount: changedWatches.length, }, null, 2 ), }, ], }; }
  • Input schema for the evaluate_watches tool, accepting an optional session_id string parameter.
    { session_id: z.string().optional().describe('Session ID'), },
  • Registration of the evaluate_watches tool on the MCP server, including name, description, input schema, and handler function reference.
    server.tool( 'evaluate_watches', 'Evaluate all watch expressions and return their current values', { session_id: z.string().optional().describe('Session ID'), }, async ({ session_id }) => { const session = ctx.sessionManager.resolveSession(session_id); if (!session) { return { content: [{ type: 'text', text: JSON.stringify({ error: 'No active session' }) }], }; } const results = await ctx.watchManager.evaluateAll(session); const changedWatches = results.filter((r) => r.hasChanged); return { content: [ { type: 'text', text: JSON.stringify( { watches: results.map((r) => ({ id: r.id, expression: r.expression, value: r.value, hasChanged: r.hasChanged, error: r.error, })), changedCount: changedWatches.length, }, null, 2 ), }, ], }; } );

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