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
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | No | Session 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
- src/tools/advanced.ts:86-118 (handler)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 ), }, ], }; }
- src/tools/advanced.ts:83-85 (schema)Input schema for the evaluate_watches tool, accepting an optional session_id string parameter.{ session_id: z.string().optional().describe('Session ID'), },
- src/tools/advanced.ts:80-119 (registration)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 ), }, ], }; } );