Skip to main content
Glama

Tree-Hugger-JS MCP Server

by qckfx
MIT License
165
1

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault

No arguments

Schema

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription
Current AST StateCurrently parsed AST with metadata and basic statistics
Last Analysis ResultsResults from the most recent code analysis (functions, classes, imports, etc.)
Transformation HistoryHistory of code transformations and available operations

Tools

Functions exposed to the LLM to take actions

NameDescription
parse_code

Parse JavaScript/TypeScript code from file or string and load it into the AST state. Must be called before using other analysis tools.

Examples: • Parse a React component: parse_code('./src/UserProfile.jsx') • Parse code string: parse_code('function hello() { return "world"; }') • Parse with explicit language: parse_code('./config.js', language='javascript') • Analyze legacy code: parse_code('./old-script.js') then use other tools to understand structure • Code review prep: parse_code('./feature.ts') then get_functions() to review all functions

find_pattern

Find first node matching the specified pattern using tree-hugger-js intuitive syntax. Use for targeted searches when you need one specific match.

Examples: • Find main function: find_pattern('function[name="main"]') • Find React component: find_pattern('function[name="UserProfile"]') • Find async functions: find_pattern('function[async]') • Find specific class: find_pattern('class[name="UserManager"]') • Find error handling: find_pattern('call[text*="catch"]') • Find JSX with props: find_pattern('jsx(jsx-attribute[name="className"])') • Debug specific calls: find_pattern('call[text*="console.log"]')

find_all_pattern

Find all nodes matching the specified pattern. Use for comprehensive analysis when you need all matches.

Examples: • Audit all functions: find_all_pattern('function') • Find all TODO comments: find_all_pattern('comment[text*="TODO"]') • Security audit: find_all_pattern('call[text*="eval"]') • Performance review: find_all_pattern('call[text*="console.log"]') to find debug logs • API usage: find_all_pattern('call[text*="fetch"]') to find all API calls • React hooks: find_all_pattern('call[text*="use"]') for hooks usage • Error patterns: find_all_pattern('string[text*="error"]') for error messages • Database queries: find_all_pattern('string[text*="SELECT"]') for SQL • Event handlers: find_all_pattern('function[text*="onClick"]')

get_functions

Get all functions with metadata including name, type, location, and async status. Includes class methods, arrow functions, and declarations.

Examples: • Code review: get_functions() to see all functions in a file • Find async operations: get_functions({asyncOnly: true}) • API analysis: get_functions() then look for functions with 'fetch' or 'api' in names • Test coverage: get_functions() to identify functions needing tests • Refactoring prep: get_functions({includeAnonymous: false}) to focus on named functions • Performance audit: get_functions() to find large/complex functions by line count

get_classes

Get all classes with comprehensive method and property analysis. Perfect for OOP code review.

Examples: • Architecture review: get_classes() to understand class structure • API design: get_classes() to see public method interfaces • Inheritance analysis: get_classes() to identify class hierarchies • Method-only view: get_classes({includeProperties: false}) to focus on behavior • Property audit: get_classes({includeMethods: false}) to review state management • Testing prep: get_classes() to identify methods needing unit tests

get_imports

Get all import statements with detailed module and specifier information. Essential for dependency analysis.

Examples: • Dependency audit: get_imports() to see all external dependencies • Bundle analysis: get_imports() to identify heavy imports • Security audit: get_imports() to check for suspicious packages • TypeScript analysis: get_imports({includeTypeImports: false}) to focus on runtime imports • Refactoring prep: get_imports() to understand module structure before changes • License compliance: get_imports() to generate dependency list

rename_identifier

Intelligently rename all occurrences of an identifier throughout the code. Avoids renaming in strings/comments.

Examples: • Refactor function names: rename_identifier('fetchData', 'fetchUserData') • Improve variable names: rename_identifier('data', 'userData') • Update class names: rename_identifier('Manager', 'UserManager') • API consistency: rename_identifier('getUserInfo', 'fetchUserInfo') • Preview first: rename_identifier('oldName', 'newName', {preview: true}) • Legacy code update: rename_identifier('XMLHttpRequest', 'fetch')

remove_unused_imports

Automatically remove unused import statements to clean up code. Safely detects which imports are actually used.

Examples: • Bundle size optimization: remove_unused_imports() to reduce bundle size • Code cleanup: remove_unused_imports() after refactoring • Linting compliance: remove_unused_imports() to fix ESLint warnings • Before deployment: remove_unused_imports({preview: true}) to see what will be removed • Legacy cleanup: remove_unused_imports() after removing old code • Development workflow: remove_unused_imports() during feature development

transform_code

Apply multiple transformations in a single operation. Most powerful tool for complex refactoring workflows.

Examples: • API refactor: [{type: 'rename', parameters: {oldName: 'getData', newName: 'fetchData'}}, {type: 'removeUnusedImports'}] • Environment update: [{type: 'replaceIn', parameters: {nodeType: 'string', pattern: /localhost/g, replacement: 'api.production.com'}}, {type: 'removeUnusedImports'}] • Add logging: [{type: 'insertAfter', parameters: {pattern: 'function_declaration', text: 'console.log("Function called");'}}, {type: 'removeUnusedImports'}] • Bulk rename: [{type: 'rename', parameters: {oldName: 'user', newName: 'customer'}}, {type: 'rename', parameters: {oldName: 'id', newName: 'customerId'}}] • Legacy migration: [{type: 'replaceIn', parameters: {nodeType: 'call_expression', pattern: /XMLHttpRequest/g, replacement: 'fetch'}}, {type: 'removeUnusedImports'}]

get_node_at_position

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

analyze_scopes

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

insert_code

Insert code before or after nodes with smart formatting. Professional-quality code insertion with proper indentation.

Examples: • Add logging: insert_code('function_declaration', 'console.log("Function started");', 'after') • Add validation: insert_code('method_definition[name="save"]', 'if (!this.isValid()) return;', 'after') • Add comments: insert_code('class_declaration', '// Main user management class', 'before') • Add error handling: insert_code('function[async]', 'try {', 'after') + insert_code('function[async]', '} catch(e) { console.error(e); }', 'after') • Add metrics: insert_code('function[name*="api"]', 'performance.mark("api-start");', 'after') • Debug mode: insert_code('call[text*="fetch"]', 'console.log("API call:", url);', 'before')

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