Skip to main content
Glama
qckfx

Tree-Hugger-JS MCP Server

by qckfx

get_classes

Analyze JavaScript/TypeScript class structures to review architecture, identify hierarchies, audit methods and properties, and prepare for testing.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includePropertiesNoInclude class properties (default: true). Set false to focus only on methods.
includeMethodsNoInclude class methods (default: true). Set false to focus only on properties.

Implementation Reference

  • The core handler function that implements the logic for the 'get_classes' tool. It validates the presence of a parsed AST, fetches detailed class information using the tree-hugger-js library's getClassDetails() method, conditionally includes methods and properties based on input parameters, processes and truncates textual representations for output, updates the analysis cache, and returns a formatted text response containing the JSON-stringified class data or an error message.
    private async getClasses(args: { includeProperties?: boolean; includeMethods?: boolean }) { if (!this.currentAST) { return { content: [{ type: "text", text: "No AST loaded. Please use parse_code first.", }], isError: true, }; } try { // Use enhanced library methods for detailed class analysis const classData: ClassInfo[] = this.currentAST.tree.getClassDetails() .map(cls => ({ ...cls, text: cls.text.length > 150 ? cls.text.slice(0, 150) + '...' : cls.text, methods: args.includeMethods !== false ? cls.methods.map(method => ({ ...method, text: method.text.length > 100 ? method.text.slice(0, 100) + '...' : method.text, })) : [], properties: args.includeProperties !== false ? cls.properties : [], })); this.lastAnalysis = { ...this.lastAnalysis, classes: classData, timestamp: new Date(), } as AnalysisResult; return { content: [{ type: "text", text: `Found ${classData.length} classes:\n${JSON.stringify(classData, null, 2)}`, }], }; } catch (error) { return { content: [{ type: "text", text: `Error getting classes: ${error instanceof Error ? error.message : String(error)}`, }], isError: true, }; } }
  • The input schema definition for the 'get_classes' tool, specifying optional boolean parameters for including properties and methods in the class analysis output.
    inputSchema: { type: "object", properties: { includeProperties: { type: "boolean", description: "Include class properties (default: true). Set false to focus only on methods." }, includeMethods: { type: "boolean", description: "Include class methods (default: true). Set false to focus only on properties." } }, },
  • src/index.ts:251-267 (registration)
    The tool registration in the ListToolsRequestSchema handler, including the name, description, and input schema for 'get_classes'.
    { name: "get_classes", description: "Get all classes with comprehensive method and property analysis. Perfect for OOP code review.\n\nExamples:\n• Architecture review: get_classes() to understand class structure\n• API design: get_classes() to see public method interfaces\n• Inheritance analysis: get_classes() to identify class hierarchies\n• Method-only view: get_classes({includeProperties: false}) to focus on behavior\n• Property audit: get_classes({includeMethods: false}) to review state management\n• Testing prep: get_classes() to identify methods needing unit tests", inputSchema: { type: "object", properties: { includeProperties: { type: "boolean", description: "Include class properties (default: true). Set false to focus only on methods." }, includeMethods: { type: "boolean", description: "Include class methods (default: true). Set false to focus only on properties." } }, }, },
  • src/index.ts:425-426 (registration)
    The dispatch registration in the CallToolRequestSchema switch statement that routes calls to the getClasses handler.
    case "get_classes": return await this.getClasses(args as { includeProperties?: boolean; includeMethods?: boolean });

Latest Blog Posts

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