Skip to main content
Glama

Tree-Hugger-JS MCP Server

by qckfx

get_classes

Analyze class structures in JavaScript/TypeScript code to review architecture, API design, inheritance, and method or property specifics. Use to prepare for testing or audits.

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

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

Input Schema (JSON Schema)

{ "properties": { "includeMethods": { "description": "Include class methods (default: true). Set false to focus only on properties.", "type": "boolean" }, "includeProperties": { "description": "Include class properties (default: true). Set false to focus only on methods.", "type": "boolean" } }, "type": "object" }

Implementation Reference

  • The main handler function that executes the get_classes tool logic, retrieving class details from the AST using tree.getClassDetails(), mapping with truncation, optionally including methods and properties based on args, updating lastAnalysis, and returning formatted JSON output.
    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, }; } }
  • src/index.ts:425-426 (registration)
    The switch case dispatcher in the CallToolRequestSchema handler that routes calls to the 'get_classes' tool to the private getClasses method.
    case "get_classes": return await this.getClasses(args as { includeProperties?: boolean; includeMethods?: boolean });
  • The tool definition object registered in ListToolsRequestSchema, including name, detailed description with examples, and inputSchema specifying optional boolean parameters for including properties and methods.
    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:251-267 (registration)
    Registration of the get_classes tool in the tools array returned by ListToolsRequestSchema handler.
    { 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." } }, }, },

Other Tools

Related Tools

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