Tree-Hugger-JS
About
Analyze and transform JavaScript/TypeScript code using the tree-hugger-js library.
Details
- Author
- qckfx
- Categories
- Developer Tools
Jump to
Setup
Install Tree-Hugger-JS in your MCP client (Claude Desktop, Cursor, Windsurf, and others).
Repository: https://github.com/qckfx/tree-hugger-js-mcp
Follow the installation instructions in the repository README, then restart your MCP client.
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.
- 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
- Rename identifiers throughout code
- Remove unused imports
- Chain multiple transformations
- Insert code before/after patterns
- Preview transformations before applying
- Scope analysis and variable binding
- Pattern matching with CSS-like selectors
- Support for async functions, classes, methods
- TypeScript type import handling
Try immediately with npx - no installation required:
# Use with Claude Code or any MCP client npx tree-hugger-js-mcp
# Install globally for repeated use npm install -g tree-hugger-js-mcp # Then run anywhere tree-hugger-js-mcp
# 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
{ "mcpServers": { "tree-hugger-js": { "command": "npx", "args": ["tree-hugger-js-mcp"] } } }
{ "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"] } } }
Parse JavaScript/TypeScript code from file or string.
- 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)
// 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'); }" });
- pattern(string): Pattern to match using tree-hugger-js syntax
// 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']" });
- pattern(string): Pattern to match
- limit(number, optional): Maximum matches to return
- includeAnonymous(boolean, optional): Include anonymous functions (default: true)
- asyncOnly(boolean, optional): Only return async functions (default: false)
Get all classes with methods and properties.
- includeProperties(boolean, optional): Include class properties (default: true)
- includeMethods(boolean, optional): Include class methods (default: true)
- includeTypeImports(boolean, optional): Include TypeScript type-only imports (default: true)
Rename all occurrences of an identifier.
- oldName(string): Current identifier name
- newName(string): New identifier name
- preview(boolean, optional): Return preview only (default: false)
await callTool("rename_identifier", { oldName: "fetchData", newName: "fetchUserData", preview: true });
- preview(boolean, optional): Return preview only (default: false)
Apply multiple transformations in sequence.
- operations(array): Array of transformation operations
- preview(boolean, optional): Return preview only (default: false)
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 before or after nodes matching a pattern.
- 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)
Get AST node at specific line and column.
- line(number): Line number (1-based)
- column(number): Column number (0-based)
- includeBuiltins(boolean, optional): Include built-in identifiers (default: false)
The server provides three resources for accessing internal state:
Current parsed AST state with metadata and statistics.
Results from the most recent code analysis (functions, classes, imports).
History of code transformations and available operations.
Tree-hugger-js uses intuitive patterns instead of verbose tree-sitter node types:
- 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
- [name="foo"]- Nodes with specific name
- [async]- Async functions
- [text="test"]- Nodes containing text
- class method- Methods inside classes
- function > return- Return statements directly in functions
- :has()and:not()pseudo-selectors
// 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" });
// Rename a function and remove unused imports await callTool("transform_code", { operations: [ { type: "rename", parameters: { oldName: "getUserData", newName: "fetchUserProfile" } }, { type: "removeUnusedImports" } ] });
// 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'])" });
# Install dependencies npm install # Build the project npm run build # Watch mode for development npm run dev # Test with MCP inspector npm run inspector
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
This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.
AI-to-AI code review platform — Claude, Codex, and Gemini cross-check each other via MCP, REST API, and CLI for consensus-based results.
A stateful LSP runtime for AI agents: warm language server sessions with 50+ tools for go-to-definition, find-references, diagnostics, rename, and more across 30+ languages.
Persistent code index using Tree-sitter for fast, precise code search. Replaces grep with ~50 token responses instead of 2000+.
Orchestrates a dual-AI engineering loop where a Primary AI plans and implements, while a Review AI validates and reviews, with continuous feedback for optimal code quality. Supports custom AI pairing (Claude, Codex, Gemini, etc.)
AmazingMCP — MCP Server for .NET / C# Codebases
An MCP server that gives AI agents deep understanding of C# codebases via Roslyn — type search, dependency graphs, usage analysis, and architecture overviews, all from a live in-memory compilation.
A platform-agnostic code analysis library with semantic search capabilities and MCP server support.
Enforce consistent C++ style and best practices across your codebase. Analyze naming conventions, memory safety, and const correctness, and get actionable modernization suggestions up to C++23. Accelerate reviews with ready-made prompts and quick access to curated guidelines.
AI-Safe Code Analysis with 113+ MCP tools for guard validation, memory, workflow, and testing.
A Rust-based CLI tool for code-related tasks, operating as an MCP server.
Provides AI assistants with a comprehensive, one-time analysis for complete codebase context and understanding.
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





