Skip to main content
Glama
DollhouseMCP

DollhouseMCP

Official

get_relationship_stats

Analyze Enhanced Index relationships to view total counts by type, identify most connected elements, and assess index health metrics.

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

  • Executes the tool logic: retrieves relationship stats from EnhancedIndexManager, formats a detailed text response with index metadata, relationship counts, and top verb triggers, handles errors and security logging.
    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}`
          }]
        };
      }
  • Registers the 'get_relationship_stats' tool with the MCP server, defining its name, description, empty input schema, and handler that delegates to the server's getRelationshipStats method.
    {
      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()
    }
  • Defines the input schema for the tool (empty object, no parameters required) and metadata.
    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: {},
      },
    },
  • Computes raw relationship statistics (counts by type, totals) by iterating over all elements in the EnhancedIndex; called by EnhancedIndexManager.getRelationshipStats().
    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 states the tool retrieves statistics, implying a read-only operation, but doesn't specify if it requires authentication, has rate limits, returns real-time or cached data, or what the output format might be. 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 unnecessary words. It's front-loaded with the main action ('Get statistics') and includes specific details, making every part of the sentence earn its place.

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's complexity (retrieving statistics with multiple metrics), lack of annotations, and no output schema, the description is minimally adequate. It outlines what statistics are included but doesn't cover behavioral aspects like authentication needs or output format. For a read operation with no parameters, it's passable but could be more complete by addressing missing behavioral details.

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 need to compensate for schema gaps.

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 identifies the resource ('Enhanced Index relationships'), but it doesn't explicitly differentiate from sibling tools like 'get_element_relationships' or 'get_collection_cache_health,' which might offer 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 prerequisites, context, or exclusions, and with many sibling tools (e.g., 'get_element_relationships,' 'search_all'), there's no indication of how this tool fits into the workflow or when it should be preferred over others.

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/mcp-server'

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