Tree-Hugger-JS is an MCP server that connects AI clients like Claude Code to the tree-hugger-js library for parsing, inspecting, and manipulating JavaScript and TypeScript codebases. Designed for software developers and automated coding assistants, it allows language models to run structural AST analyses rather than relying on brittle text searches. The server enables clients to parse source files or raw strings across JavaScript, TypeScript, JSX, and TSX formats. Agents can locate code constructs using CSS-like pattern selectors, such as querying functions, classes, imports, or specific async methods. Beyond passive analysis, the server provides automated transformation tools to rename identifiers throughout a project, prune unused imports, inject code snippets, and chain multi-step refactoring operations with rollback and preview capabilities. It also exposes internal resources to track active AST states, metadata summaries, and transformation histories.
Category: Developer Tools & Code Intelligence
Tags: ast, code analysis, javascript, refactoring, typescript
bash npx tree-hugger-js-mcp Alternatively, install it globally: bash npm install -g tree-hugger-js-mcp 2. Open your client configuration file (such as Claude Code or your MCP client's settings). 3. Add the server under the mcpServers object: json { "mcpServers": { "tree-hugger-js": { "command": "npx", "args": ["tree-hugger-js-mcp"] } } } 4. Save your configuration and restart your client to expose the AST tools.• Parse JavaScript and TypeScript files into abstract syntax trees to extract functions, classes, and method signatures. • Locate specific code patterns and async calls using CSS-style selectors like attribute and hierarchy matching. • Automate refactoring tasks by renaming identifiers across files with a safe preview mode before applying changes. • Clean up module imports automatically by identifying and removing unused declarations across the project AST. • Insert code snippets before or after matched structural elements such as constructors or function declarations.
Part of MCP Servers
You can run Tree-Hugger-JS immediately using npx by calling npx tree-hugger-js-mcp without prior installation. Alternatively, install it globally on your machine using npm install -g tree-hugger-js-mcp, or clone the GitHub repository and run npm run build to start it locally via Node.js.
Tree-Hugger-JS provides tools to parse JavaScript, TypeScript, JSX, and TSX code, match patterns via CSS-like queries, and inspect AST nodes. It also supports code transformation tools that rename identifiers, delete unused imports, and insert code segments before or after targeted patterns.
Tree-Hugger-JS works with Claude Code and any client implementing the Model Context Protocol that supports standard input and output command execution. It can be registered by declaring the npx command inside the client configuration file.
Yes, Tree-Hugger-JS is open source software released under the MIT license. You can view the code, build from source, and inspect the project repository on GitHub at https://github.com/qckfx/tree-hugger-js-mcp.