Skip to main content
Glama
qckfx

Tree-Hugger-JS MCP Server

by qckfx

get_node_at_position

Retrieve detailed AST node information at a specific cursor position for debugging, code analysis, refactoring, and IDE integration.

Instructions

Get detailed AST node information at a specific cursor position. Perfect for debugging and precise analysis.

Examples: • Debug syntax errors: get_node_at_position(15, 23) to understand what's at error location • Understand code structure: get_node_at_position(line, col) to see AST node type at cursor • Refactoring assistance: get_node_at_position(line, col) to identify exact node before transformation • IDE integration: get_node_at_position(line, col) for hover information • Pattern development: get_node_at_position(line, col) to understand node structure for pattern writing

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
lineYesLine number (1-based) - the line where cursor is positioned
columnYesColumn number (0-based) - the character position within the line

Implementation Reference

  • The primary handler function that executes the tool logic: checks for loaded AST, uses tree.nodeAt(line, column) to find the node, builds a detailed nodeInfo object, and returns formatted text response.
    private async getNodeAtPosition(args: { line: number; column: number }) { if (!this.currentAST) { return { content: [{ type: "text", text: "No AST loaded. Please use parse_code first.", }], isError: true, }; } try { const node = this.currentAST.tree.nodeAt(args.line, args.column); if (!node) { return { content: [{ type: "text", text: `No node found at position ${args.line}:${args.column}`, }], }; } const nodeInfo = { type: node.type, text: node.text.length > 200 ? node.text.slice(0, 200) + '...' : node.text, line: node.line, column: node.column, name: node.name, startPosition: node.startPosition, endPosition: node.endPosition, parent: node.parent ? { type: node.parent.type, name: node.parent.name, } : null, childrenCount: node.children.length, }; return { content: [{ type: "text", text: `Node at position ${args.line}:${args.column}:\n${JSON.stringify(nodeInfo, null, 2)}`, }], }; } catch (error) { return { content: [{ type: "text", text: `Error getting node at position: ${error instanceof Error ? error.message : String(error)}`, }], isError: true, }; } }
  • Input schema defining the required parameters: line (1-based number) and column (0-based number).
    inputSchema: { type: "object", properties: { line: { type: "number", description: "Line number (1-based) - the line where cursor is positioned" }, column: { type: "number", description: "Column number (0-based) - the character position within the line" } }, required: ["line", "column"], },
  • src/index.ts:349-365 (registration)
    Tool registration entry in the MCP server's tools list, including name, description, and input schema.
    name: "get_node_at_position", description: "Get detailed AST node information at a specific cursor position. Perfect for debugging and precise analysis.\n\nExamples:\n• Debug syntax errors: get_node_at_position(15, 23) to understand what's at error location\n• Understand code structure: get_node_at_position(line, col) to see AST node type at cursor\n• Refactoring assistance: get_node_at_position(line, col) to identify exact node before transformation\n• IDE integration: get_node_at_position(line, col) for hover information\n• Pattern development: get_node_at_position(line, col) to understand node structure for pattern writing", inputSchema: { type: "object", properties: { line: { type: "number", description: "Line number (1-based) - the line where cursor is positioned" }, column: { type: "number", description: "Column number (0-based) - the character position within the line" } }, required: ["line", "column"], }, },
  • src/index.ts:440-441 (registration)
    Dispatch case in the central request handler switch that routes tool calls to the getNodeAtPosition method.
    case "get_node_at_position": return await this.getNodeAtPosition(args as { line: number; column: number });

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/tree-hugger-js-mcp'

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