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 });
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It describes what the tool returns (class analysis with methods/properties) and suggests use cases, but doesn't disclose behavioral traits like performance characteristics, rate limits, authentication needs, or what 'comprehensive analysis' entails. The examples provide some behavioral context but not complete transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear purpose statement followed by specific examples. Each example earns its place by illustrating different use cases. However, the opening 'Perfect for OOP code review' is somewhat promotional and could be more concise. Overall, it's appropriately sized and front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description provides good usage context but lacks information about what the analysis output actually contains. For a tool with 2 parameters and no structured output documentation, the description should ideally specify what 'comprehensive method and property analysis' returns (e.g., class names, method signatures, property types, inheritance chains).

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents both parameters. The description adds value by showing practical examples of parameter usage (e.g., 'Method-only view: get_classes({includeProperties: false})'), but doesn't add semantic meaning beyond what the schema provides. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get all classes with comprehensive method and property analysis.' It specifies the resource (classes) and the type of analysis (method and property). However, it doesn't explicitly differentiate from sibling tools like 'get_functions' or 'analyze_scopes' beyond mentioning OOP code review context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides excellent usage guidance with specific examples for different scenarios: architecture review, API design, inheritance analysis, method-only view, property audit, and testing prep. It explicitly shows when to use parameter variations (includeProperties/includeMethods) for different purposes.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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