Skip to main content
Glama
qckfx

Tree-Hugger-JS MCP Server

by qckfx

analyze_scopes

Analyzes JavaScript/TypeScript code to detect variable scope issues, identify naming conflicts, and find unused variables for improved code quality.

Instructions

Analyze variable scopes, bindings, and potential naming conflicts. Advanced tool for code quality analysis.

Examples: • Variable shadowing detection: analyze_scopes() to find naming conflicts • Closure analysis: analyze_scopes() to understand variable capture • Refactoring safety: analyze_scopes() before variable renames • Code review: analyze_scopes() to identify scope-related issues • Learning aid: analyze_scopes({includeBuiltins: true}) to see all identifiers • Dead code detection: analyze_scopes() to find unused variables

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeBuiltinsNoInclude built-in identifiers (default: false). Set true for comprehensive analysis including globals.

Implementation Reference

  • The primary handler function for the 'analyze_scopes' tool. It checks if an AST is loaded, calls the tree-hugger library's analyzeScopes method, and returns a placeholder scope analysis result.
    private async analyzeScopes(args: { includeBuiltins?: boolean }) { if (!this.currentAST) { return { content: [{ type: "text", text: "No AST loaded. Please use parse_code first.", }], isError: true, }; } try { const scopes = this.currentAST.tree.analyzeScopes(); // Note: This is a simplified scope analysis implementation // The actual tree-hugger-js library may have more sophisticated scope analysis const scopeInfo = { message: "Scope analysis completed", scopeCount: "Scope analysis functionality depends on tree-hugger-js implementation", note: "This is a placeholder - actual implementation would use tree-hugger-js scope analysis features", }; return { content: [{ type: "text", text: `Scope Analysis Results:\n${JSON.stringify(scopeInfo, null, 2)}`, }], }; } catch (error) { return { content: [{ type: "text", text: `Error analyzing scopes: ${error instanceof Error ? error.message : String(error)}`, }], isError: true, }; } }
  • src/index.ts:443-444 (registration)
    Dispatch registration in the tool request handler switch statement that maps 'analyze_scopes' calls to the analyzeScopes method.
    case "analyze_scopes": return await this.analyzeScopes(args as { includeBuiltins?: boolean });
  • Tool registration object in the listTools array, defining the name, description, and input schema (optional includeBuiltins boolean) for the analyze_scopes tool.
    { name: "analyze_scopes", description: "Analyze variable scopes, bindings, and potential naming conflicts. Advanced tool for code quality analysis.\n\nExamples:\n• Variable shadowing detection: analyze_scopes() to find naming conflicts\n• Closure analysis: analyze_scopes() to understand variable capture\n• Refactoring safety: analyze_scopes() before variable renames\n• Code review: analyze_scopes() to identify scope-related issues\n• Learning aid: analyze_scopes({includeBuiltins: true}) to see all identifiers\n• Dead code detection: analyze_scopes() to find unused variables", inputSchema: { type: "object", properties: { includeBuiltins: { type: "boolean", description: "Include built-in identifiers (default: false). Set true for comprehensive analysis including globals." } }, }, },

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