Skip to main content
Glama
qckfx

Node.js Debugger MCP Server

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 });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool evaluates expressions but doesn't describe what happens (e.g., returns a value, modifies state, requires specific permissions), potential side effects, error conditions, or output format. This leaves significant gaps for a tool that likely interacts with runtime state.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It is front-loaded with the core purpose and includes essential context ('current debug context'). Every element earns its place, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of debug operations, no annotations, and no output schema, the description is incomplete. It lacks details on behavioral traits (e.g., read-only vs. mutating), expected results, error handling, and dependencies on other tools (like 'attach_debugger'). For a debug tool with potential side effects, this is insufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the single parameter 'expression' fully documented in the schema. The description adds no additional meaning beyond what the schema provides (e.g., no examples of valid expressions, syntax rules, or scope limitations). The baseline score of 3 reflects adequate but minimal value addition.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('evaluate') and resource ('expression'), and specifies the context ('in the current debug context'), which distinguishes it from general evaluation tools. However, it doesn't explicitly differentiate from potential sibling tools like 'step_debug' or 'set_breakpoint' that also operate in debug contexts.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides minimal guidance by mentioning 'current debug context', implying it should be used during debugging sessions. However, it offers no explicit when-to-use rules, no alternatives among the seven sibling tools, and no prerequisites (e.g., whether a debugger must be attached first).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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