Skip to main content
Glama
qckfx
by qckfx

evaluate_expression

Evaluate JavaScript expressions during Node.js debugging to inspect variables, test code snippets, or check runtime values in the current debug context.

Instructions

Evaluate an expression in the current debug context

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expressionYesExpression to evaluate

Implementation Reference

  • The core handler function that executes the tool logic. Evaluates JavaScript expressions in the Node.js debug session using Chrome DevTools Protocol (CDP), handling both paused (call frame) and running contexts.
    private async evaluateExpression(args: { expression: string }) { if (!this.debugSession.connected || !this.debugSession.client) { return { content: [ { type: "text", text: "No active debug session. Please attach debugger first.", }, ], isError: true, }; } try { const { Runtime, Debugger } = this.debugSession.client; let result; // If we're paused and have a call stack, evaluate in the current call frame if (this.debugSession.isPaused && this.debugSession.callStack && this.debugSession.callStack.length > 0) { const currentFrame = this.debugSession.callStack[0]; result = await Debugger.evaluateOnCallFrame({ callFrameId: currentFrame.callFrameId, expression: args.expression, returnByValue: true }); } else { // Otherwise, evaluate in the runtime context result = await Runtime.evaluate({ expression: args.expression, contextId: this.debugSession.currentExecutionContext, includeCommandLineAPI: true, returnByValue: true }); } if (result.exceptionDetails) { return { content: [ { type: "text", text: `Exception: ${result.exceptionDetails.exception?.description || 'Unknown error'}`, }, ], isError: true, }; } const value = result.result.value !== undefined ? result.result.value : result.result.description || '[Object]'; return { content: [ { type: "text", text: `${args.expression} = ${JSON.stringify(value, null, 2)}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error evaluating expression: ${error}`, }, ], isError: true, }; } }
  • Input schema defining the expected parameters for the evaluate_expression tool: an object with a required 'expression' string.
    inputSchema: { type: "object", properties: { expression: { type: "string", description: "Expression to evaluate" } }, required: ["expression"], },
  • src/index.ts:226-236 (registration)
    Tool registration in the ListToolsRequestSchema response, specifying name, description, and input schema.
    { name: "evaluate_expression", description: "Evaluate an expression in the current debug context", inputSchema: { type: "object", properties: { expression: { type: "string", description: "Expression to evaluate" } }, required: ["expression"], }, },
  • src/index.ts:265-266 (registration)
    Dispatch registration in the CallToolRequestSchema handler's switch statement, routing tool calls to the evaluateExpression method.
    case "evaluate_expression": return await this.evaluateExpression(args as { expression: string });

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/qckfx/node-debugger-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server