Skip to main content
Glama

Tree-Hugger-JS MCP Server

by qckfx

insert_code

Add or modify code in JavaScript/TypeScript files with precise node targeting and automatic formatting. Use patterns to insert logging, validation, error handling, or comments before or after specific code blocks.

Instructions

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')

Input Schema

NameRequiredDescriptionDefault
codeYesCode to insert. Will be formatted with proper indentation automatically.
patternYesPattern to match: 'function_declaration', 'class[name="MyClass"]', 'method_definition[async]'
positionYesInsert position: 'before' (above) or 'after' (below) the matched nodes
previewNoReturn preview only without applying changes (default: false). Always preview first!

Input Schema (JSON Schema)

{ "properties": { "code": { "description": "Code to insert. Will be formatted with proper indentation automatically.", "type": "string" }, "pattern": { "description": "Pattern to match: 'function_declaration', 'class[name=\"MyClass\"]', 'method_definition[async]'", "type": "string" }, "position": { "description": "Insert position: 'before' (above) or 'after' (below) the matched nodes", "enum": [ "before", "after" ], "type": "string" }, "preview": { "description": "Return preview only without applying changes (default: false). Always preview first!", "type": "boolean" } }, "required": [ "pattern", "code", "position" ], "type": "object" }
Install Server

Other Tools from Tree-Hugger-JS MCP Server

Related Tools

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