Skip to main content
Glama

get_relationship_stats

Analyze Enhanced Index relationship statistics to identify total counts by type, most connected elements, and index health metrics for monitoring and optimization.

Instructions

Get statistics about the Enhanced Index relationships, including total counts by type, most connected elements, and index health metrics.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler for the get_relationship_stats tool. It retrieves relationship statistics from the EnhancedIndexManager, augments with index metadata and top verbs, formats a rich text response, and handles errors.
    async getRelationshipStats() {
      try {
        // Get the index with error handling
        await this.enhancedIndexManager.getIndex().catch(async (error) => {
          logger.error('Failed to get Enhanced Index, attempting rebuild', error);
          return this.enhancedIndexManager.getIndex({ forceRebuild: true });
        });
    
        // FIX: DMCP-SEC-006 - Add security audit logging
        SecurityMonitor.logSecurityEvent({
          type: 'ELEMENT_CREATED',
          severity: 'LOW',
          source: 'EnhancedIndexHandler.getRelationshipStats',
          details: 'Enhanced Index statistics retrieved',
          additionalData: {}
        });
    
        // Get stats
        const stats = await this.enhancedIndexManager.getRelationshipStats();
    
        // Get the index for additional info
        const index = await this.enhancedIndexManager.getIndex();
    
        // Format results
        let text = `${this.personaIndicator}📊 **Enhanced Index Statistics**\n\n`;
        text += `**Index Metadata:**\n`;
        text += `• Version: ${index.metadata.version}\n`;
        text += `• Last Updated: ${new Date(index.metadata.last_updated).toLocaleString()}\n`;
        text += `• Total Elements: ${index.metadata.total_elements}\n\n`;
    
        text += `**Relationship Statistics:**\n`;
        for (const [type, count] of Object.entries(stats)) {
          text += `• ${type}: ${count}\n`;
        }
    
        // Count verb triggers
        const verbCount = Object.keys(index.action_triggers || {}).length;
        text += `\n**Verb Triggers:** ${verbCount} verbs mapped\n`;
    
        // Show top verbs if any
        if (verbCount > 0) {
          const topVerbs = Object.entries(index.action_triggers)
            .sort((a, b) => b[1].length - a[1].length)
            .slice(0, 5);
          text += `**Top Action Verbs:**\n`;
          for (const [verb, elements] of topVerbs) {
            text += `• ${verb}: ${elements.length} elements\n`;
          }
        }
    
        return {
          content: [{
            type: "text",
            text
          }]
        };
      } catch (error: any) {
        ErrorHandler.logError('EnhancedIndexHandler.getRelationshipStats', error);
        return {
          content: [{
            type: "text",
            text: `${this.personaIndicator}❌ Failed to get stats: ${SecureErrorHandler.sanitizeError(error).message}`
          }]
        };
      }
    }
  • Tool registration defining the name, description, empty input schema, and handler delegation to server.getRelationshipStats().
      tool: {
        name: "get_relationship_stats",
        description: "Get statistics about the Enhanced Index relationships, including total counts by type, most connected elements, and index health metrics.",
        inputSchema: {
          type: "object",
          properties: {},
        },
      },
      handler: () => server.getRelationshipStats()
    }
  • Input schema for the tool: an empty object (no parameters required).
    inputSchema: {
      type: "object",
      properties: {},
    },
  • Core utility function that computes relationship statistics by iterating over all elements and counting relationships by type and totals. Called indirectly via EnhancedIndexManager.
    public getRelationshipStats(index: EnhancedIndex): Record<string, number> {
      const stats: Record<string, number> = {
        totalRelationships: 0,
        elementsWithRelationships: 0
      };
    
      // Count by relationship type
      for (const relType of Object.keys(RELATIONSHIP_TYPES)) {
        stats[relType] = 0;
      }
    
      for (const elements of Object.values(index.elements)) {
        for (const element of Object.values(elements)) {
          if (element.relationships) {
            stats.elementsWithRelationships++;
    
            for (const [relType, relations] of Object.entries(element.relationships)) {
              const count = relations.length;
              stats.totalRelationships += count;
              stats[relType] = (stats[relType] || 0) + count;
            }
          }
        }
      }
    
      return stats;
    }
Behavior2/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 of behavioral disclosure. It mentions 'Get statistics,' implying a read-only operation, but doesn't specify if it requires authentication, has rate limits, affects system state, or what the output format looks like. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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

Conciseness5/5

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

The description is a single, well-structured sentence that efficiently conveys the tool's purpose without any wasted words. It's front-loaded with the main action and includes specific examples of statistics, making it easy to understand quickly.

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 the tool has 0 parameters, 100% schema coverage, and no output schema, the description is adequate for a read-only statistical tool. However, it lacks details on behavioral aspects like authentication needs or output format, which are important for an agent to use it correctly. It's minimally viable but could be more complete by addressing these gaps.

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

Parameters4/5

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

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately doesn't discuss parameters, focusing instead on the tool's purpose. This meets the baseline for tools with no parameters, as it doesn't add unnecessary information.

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 statistics about the Enhanced Index relationships' with specific details like 'total counts by type, most connected elements, and index health metrics.' It uses a specific verb ('Get') and resource ('Enhanced Index relationships'), but it doesn't explicitly distinguish it from sibling tools like 'get_element_relationships' or 'get_collection_cache_health,' which might offer overlapping or related functionality.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any prerequisites, exclusions, or comparisons to sibling tools such as 'get_element_relationships' or 'search_collection_enhanced,' leaving the agent to infer usage context without explicit direction.

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/DollhouseMCP/DollhouseMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server