developer-tools

Tree Hugger JS

qckfx

by qckfx

Tree Hugger JS offers advanced JavaScript and TypeScript code analysis, AST parsing, function extraction, and safe code

Provides JavaScript and TypeScript code analysis through AST parsing for function extraction, scope analysis, identifier renaming, unused import removal, and code transformation with safety previews and history tracking.

github stars

2

0 commentsdiscussion

Both formats append explainx.ai attribution and the canonical URL for this MCP server listing.

No setup with npxCSS-like pattern matching syntaxSafe transformations with previews

best for

  • / JavaScript/TypeScript developers doing refactoring
  • / Code review and architecture analysis
  • / Automated dependency cleanup
  • / Large-scale codebase transformations

capabilities

  • / Parse JavaScript/TypeScript/JSX/TSX code into AST
  • / Find code patterns using CSS-like selectors
  • / Extract functions, classes, and imports with metadata
  • / Rename identifiers throughout codebase
  • / Remove unused import statements
  • / Transform code with preview capabilities

what it does

Provides JavaScript and TypeScript code analysis through AST parsing. Enables automated code transformations, refactoring, and dependency management with safety previews.

about

Tree Hugger JS is a community-built MCP server published by qckfx that provides AI assistants with tools and capabilities via the Model Context Protocol. Tree Hugger JS offers advanced JavaScript and TypeScript code analysis, AST parsing, function extraction, and safe code It is categorized under developer tools. This server exposes 12 tools that AI clients can invoke during conversations and coding sessions.

how to install

You can install Tree Hugger JS in your AI client of choice. Use the install panel on this page to get one-click setup for Cursor, Claude Desktop, VS Code, and other MCP-compatible clients. This server runs locally on your machine via the stdio transport.

license

MIT

Tree Hugger JS is released under the MIT license. This is a permissive open-source license, meaning you can freely use, modify, and distribute the software.

readme

Tree-Hugger-JS MCP Server

An MCP (Model Context Protocol) server that provides AI agents with powerful JavaScript/TypeScript code analysis and transformation capabilities using the tree-hugger-js library.

<a href="https://glama.ai/mcp/servers/@qckfx/tree-hugger-js-mcp"> <img width="380" height="200" src="https://glama.ai/mcp/servers/@qckfx/tree-hugger-js-mcp/badge" alt="Tree-Hugger-JS Server MCP server" /> </a>

Features

🔍 Code Analysis

  • Parse JavaScript, TypeScript, JSX, and TSX files or code strings
  • Find patterns using intuitive syntax (e.g., function, class[name="MyClass"])
  • Extract functions, classes, imports with detailed metadata
  • Navigate AST nodes and analyze code structure
  • Get nodes at specific positions

🔧 Code Transformation

  • Rename identifiers throughout code
  • Remove unused imports
  • Chain multiple transformations
  • Insert code before/after patterns
  • Preview transformations before applying

📊 Code Intelligence

  • Scope analysis and variable binding
  • Pattern matching with CSS-like selectors
  • Support for async functions, classes, methods
  • TypeScript type import handling

Installation & Usage

🚀 Quick Start (Recommended)

Try immediately with npx - no installation required:

# Use with Claude Code or any MCP client
npx tree-hugger-js-mcp

📦 Global Installation

# Install globally for repeated use
npm install -g tree-hugger-js-mcp

# Then run anywhere
tree-hugger-js-mcp

🔧 Development Setup

# Clone and build from source
git clone https://github.com/qckfx/tree-hugger-js-mcp.git
cd tree-hugger-js-mcp
npm install
npm run build
npm start

MCP Client Configuration

Using with Claude Code

Add to your MCP client configuration:

{
  "mcpServers": {
    "tree-hugger-js": {
      "command": "npx",
      "args": ["tree-hugger-js-mcp"]
    }
  }
}

Alternative Configurations

{
  "mcpServers": {
    "tree-hugger-js": {
      // If installed globally
      "command": "tree-hugger-js-mcp"
      
      // Or if built from source
      "command": "node",
      "args": ["/path/to/tree-hugger-js-mcp/build/index.js"]
    }
  }
}

Tools

Code Analysis Tools

parse_code

Parse JavaScript/TypeScript code from file or string.

Parameters:

  • source (string): File path or code string to parse
  • isFilePath (boolean, optional): Whether source is a file path (auto-detected if not provided)
  • language (string, optional): Language to use (javascript, typescript, jsx, tsx)

Example:

// Parse a file
await callTool("parse_code", { 
  source: "./src/app.js",
  isFilePath: true 
});

// Parse code string
await callTool("parse_code", { 
  source: "function hello() { console.log('world'); }" 
});

find_pattern

Find first node matching a pattern.

Parameters:

  • pattern (string): Pattern to match using tree-hugger-js syntax

Examples:

// Find any function
await callTool("find_pattern", { pattern: "function" });

// Find async functions
await callTool("find_pattern", { pattern: "function[async]" });

// Find class by name
await callTool("find_pattern", { pattern: "class[name='MyClass']" });

find_all_pattern

Find all nodes matching a pattern.

Parameters:

  • pattern (string): Pattern to match
  • limit (number, optional): Maximum matches to return

get_functions

Get all functions with details.

Parameters:

  • includeAnonymous (boolean, optional): Include anonymous functions (default: true)
  • asyncOnly (boolean, optional): Only return async functions (default: false)

get_classes

Get all classes with methods and properties.

Parameters:

  • includeProperties (boolean, optional): Include class properties (default: true)
  • includeMethods (boolean, optional): Include class methods (default: true)

get_imports

Get all import statements.

Parameters:

  • includeTypeImports (boolean, optional): Include TypeScript type-only imports (default: true)

Code Transformation Tools

rename_identifier

Rename all occurrences of an identifier.

Parameters:

  • oldName (string): Current identifier name
  • newName (string): New identifier name
  • preview (boolean, optional): Return preview only (default: false)

Example:

await callTool("rename_identifier", {
  oldName: "fetchData",
  newName: "fetchUserData",
  preview: true
});

remove_unused_imports

Remove unused import statements.

Parameters:

  • preview (boolean, optional): Return preview only (default: false)

transform_code

Apply multiple transformations in sequence.

Parameters:

  • operations (array): Array of transformation operations
  • preview (boolean, optional): Return preview only (default: false)

Example:

await callTool("transform_code", {
  operations: [
    { type: "rename", parameters: { oldName: "oldFunc", newName: "newFunc" } },
    { type: "removeUnusedImports" },
    { type: "replaceIn", parameters: { nodeType: "string", pattern: /localhost/g, replacement: "api.example.com" } }
  ],
  preview: true
});

insert_code

Insert code before or after nodes matching a pattern.

Parameters:

  • pattern (string): Pattern to match for insertion points
  • code (string): Code to insert
  • position (string): "before" or "after"
  • preview (boolean, optional): Return preview only (default: false)

Navigation Tools

get_node_at_position

Get AST node at specific line and column.

Parameters:

  • line (number): Line number (1-based)
  • column (number): Column number (0-based)

analyze_scopes

Analyze variable scopes and bindings.

Parameters:

  • includeBuiltins (boolean, optional): Include built-in identifiers (default: false)

Resources

The server provides three resources for accessing internal state:

ast://current

Current parsed AST state with metadata and statistics.

ast://analysis

Results from the most recent code analysis (functions, classes, imports).

ast://transforms

History of code transformations and available operations.

Pattern Syntax

Tree-hugger-js uses intuitive patterns instead of verbose tree-sitter node types:

Basic Patterns

  • function - Any function (declaration, expression, arrow, method)
  • class - Class declarations and expressions
  • string - String and template literals
  • import/export - Import/export statements
  • call - Function calls
  • loop - For, while, do-while loops

Attribute Selectors

  • [name="foo"] - Nodes with specific name
  • [async] - Async functions
  • [text*="test"] - Nodes containing text

CSS-like Selectors

  • class method - Methods inside classes
  • function > return - Return statements directly in functions
  • :has() and :not() pseudo-selectors

Examples

Basic Code Analysis

// Parse and analyze a React component
await callTool("parse_code", { source: "./components/UserProfile.jsx" });

// Get all functions
const functions = await callTool("get_functions", { asyncOnly: true });

// Find JSX elements
const jsxElements = await callTool("find_all_pattern", { pattern: "jsx" });

Code Refactoring

// Rename a function and remove unused imports
await callTool("transform_code", {
  operations: [
    { type: "rename", parameters: { oldName: "getUserData", newName: "fetchUserProfile" } },
    { type: "removeUnusedImports" }
  ]
});

Pattern Matching

// Find all async functions that call console.log
await callTool("find_all_pattern", { 
  pattern: "function[async]:has(call[text*='console.log'])" 
});

// Find classes with constructor methods
await callTool("find_all_pattern", { 
  pattern: "class:has(method[name='constructor'])" 
});

Development

# Install dependencies
npm install

# Build the project
npm run build

# Watch mode for development
npm run dev

# Test with MCP inspector
npm run inspector

Error Handling

The server provides detailed error messages and suggestions:

  • File not found errors for invalid file paths
  • Parse errors with helpful context
  • Pattern matching errors with suggestions
  • Transformation errors with rollback capability

License

MIT

FAQ

What is the Tree Hugger JS MCP server?
Tree Hugger JS is a Model Context Protocol (MCP) server profile on explainx.ai. MCP lets AI hosts (e.g. Claude Desktop, Cursor) call tools and resources through a standard interface; this page summarizes categories, install hints, and community ratings.
How do MCP servers relate to agent skills?
Skills are reusable instruction packages (often SKILL.md); MCP servers expose live capabilities. Teams frequently combine both—skills for workflows, MCP for APIs and data. See explainx.ai/skills and explainx.ai/mcp-servers for parallel directories.
How are reviews shown for Tree Hugger JS?
This profile displays 37 aggregated ratings (sample rows for discoverability plus signed-in user reviews). Average score is about 4.6 out of 5—verify behavior in your own environment before production use.

Use Cases

Extended AI Capabilities

Add new capabilities to Claude beyond text generation

Example

Access external data sources, execute code, interact with tools and services

Transform Claude from chatbot to action-taking agent

Context Enhancement

Provide Claude with access to relevant context and data

Example

Load project documentation, access knowledge bases, query databases

Get more accurate, context-aware responses

Workflow Automation

Automate multi-step workflows combining AI and external tools

Example

Research → Summarize → Create document → Send notification

Complete complex tasks end-to-end without manual steps

Implementation Guide

Prerequisites

  • Claude Desktop 0.7.0+ or Cursor IDE with MCP support
  • Basic understanding of MCP architecture and capabilities
  • Access credentials for integrated services (if required)
  • Willingness to experiment and iterate on configuration

Time Estimate

15-60 minutes depending on server complexity

Installation Steps

  1. 1.Install MCP server: npm install -g [package-name] or via GitHub
  2. 2.Add server configuration to ~/.claude/mcp.json
  3. 3.Provide required credentials and configuration
  4. 4.Restart Claude Desktop to load new server
  5. 5.Test basic functionality with simple prompts
  6. 6.Explore capabilities and experiment with use cases
  7. 7.Document successful patterns for reuse

Troubleshooting

  • MCP server not loading: Check config syntax, verify installation
  • Connection errors: Check network, firewall, credentials
  • Feature not working: Read server docs, check required parameters
  • Performance issues: Monitor resource usage, check for network latency
  • Conflicts with other servers: Check port assignments, namespace collisions

Best Practices

✓ Do

  • +Read server documentation thoroughly before setup
  • +Start with simple use cases to validate functionality
  • +Test in non-production environment first
  • +Monitor resource usage and performance
  • +Keep servers updated for bug fixes and new features
  • +Document configuration for team members
  • +Use environment variables for sensitive configuration

✗ Don't

  • Don't grant overly permissive access to MCP servers
  • Don't skip reading security considerations in docs
  • Don't expose sensitive data without proper controls
  • Don't run untrusted MCP servers without code review
  • Don't ignore error messages—investigate root cause

💡 Pro Tips

  • Combine multiple MCP servers for powerful workflows
  • Create custom MCP servers for your specific needs
  • Share successful configurations with team
  • Use MCP inspector for debugging
  • Join MCP community for tips and troubleshooting

Technical Details

Architecture

Model Context Protocol standardizes how AI hosts (Claude, Cursor) communicate with external tools and data sources through server implementations.

Protocols

  • Model Context Protocol (MCP)
  • JSON-RPC 2.0
  • stdio or HTTP transport

Compatibility

  • Claude Desktop
  • Cursor IDE
  • Custom MCP clients

When to Use This

✓ Use When

Use when you need Claude to access external data, execute actions, or integrate with tools. Best for extending AI capabilities beyond conversation.

✗ Avoid When

Avoid when native integrations exist (use official APIs directly), for real-time critical systems, or when security/compliance requires zero external dependencies.

Integration

  • Tool composition: Chain multiple MCP tools in workflows
  • Context augmentation: Provide AI with relevant external data
  • Action delegation: Let AI execute tasks on external systems
  • Bidirectional sync: Keep AI context and external systems in sync

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.

List & Promote Your MCP Server

Share your MCP server with the developer community

GET_STARTED →
MCP server reviews

Ratings

4.637 reviews
  • Sakura Jackson· Dec 24, 2024

    We evaluated Tree Hugger JS against two servers with overlapping tools; this profile had the clearer scope statement.

  • Dhruvi Jain· Dec 16, 2024

    Strong directory entry: Tree Hugger JS surfaces stars and publisher context so we could sanity-check maintenance before adopting.

  • Diya Huang· Dec 16, 2024

    Tree Hugger JS is among the better-indexed MCP projects we tried; the explainx.ai summary tracks the official description.

  • Neel Menon· Nov 15, 2024

    Useful MCP listing: Tree Hugger JS is the kind of server we cite when onboarding engineers to host + tool permissions.

  • Min Sethi· Nov 11, 2024

    We wired Tree Hugger JS into a staging workspace; the listing’s GitHub and npm pointers saved time versus hunting across READMEs.

  • Oshnikdeep· Nov 7, 2024

    Tree Hugger JS has been reliable for tool-calling workflows; the MCP profile page is a good permalink for internal docs.

  • Kiara Reddy· Nov 7, 2024

    Tree Hugger JS reduced integration guesswork — categories and install configs on the listing matched the upstream repo.

  • Ganesh Mohane· Oct 26, 2024

    According to our notes, Tree Hugger JS benefits from clear Model Context Protocol framing — fewer ambiguous “AI plugin” claims.

  • Soo Abebe· Oct 26, 2024

    Useful MCP listing: Tree Hugger JS is the kind of server we cite when onboarding engineers to host + tool permissions.

  • Luis Rahman· Oct 6, 2024

    Tree Hugger JS reduced integration guesswork — categories and install configs on the listing matched the upstream repo.

showing 1-10 of 37

1 / 4