Skip to main content
Glama

get_knowledge_statistics

Analyze and retrieve detailed statistics from a knowledge graph to understand its structure and metadata, supporting informed decision-making and insights.

Instructions

Get statistics about the knowledge graph.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function implementing the get_knowledge_statistics tool. It computes statistics on the knowledge graph (entities by type/language, relations, patterns, style conventions) and returns a formatted string report. Registered via @self.mcp.tool() decorator.
    def get_knowledge_statistics() -> str:
        """Get statistics about the knowledge graph."""
        # Count entities by type
        entity_types = {}
        for entity in self.knowledge.entities.values():
            entity_types[entity.entity_type] = (
                entity_types.get(entity.entity_type, 0) + 1
            )
    
        # Count entities by language
        languages = {}
        for entity in self.knowledge.entities.values():
            if entity.language:
                languages[entity.language] = languages.get(entity.language, 0) + 1
    
        # Count relations by type
        relation_types = {}
        for relation in self.knowledge.relations.values():
            relation_types[relation.relation_type] = (
                relation_types.get(relation.relation_type, 0) + 1
            )
    
        # Count patterns by language
        pattern_languages = {}
        for pattern in self.knowledge.patterns.values():
            if pattern.language:
                pattern_languages[pattern.language] = (
                    pattern_languages.get(pattern.language, 0) + 1
                )
    
        # Format output
        output = "Knowledge Graph Statistics:\n\n"
    
        output += f"Total Entities: {len(self.knowledge.entities)}\n"
        output += f"Total Relations: {len(self.knowledge.relations)}\n"
        output += f"Total Patterns: {len(self.knowledge.patterns)}\n"
        output += (
            f"Total Style Conventions: {len(self.knowledge.style_conventions)}\n\n"
        )
    
        if entity_types:
            output += "Entities by Type:\n"
            for entity_type, count in entity_types.items():
                output += f"- {entity_type}: {count}\n"
            output += "\n"
    
        if languages:
            output += "Entities by Language:\n"
            for language, count in languages.items():
                output += f"- {language}: {count}\n"
            output += "\n"
    
        if relation_types:
            output += "Relations by Type:\n"
            for relation_type, count in relation_types.items():
                output += f"- {relation_type}: {count}\n"
            output += "\n"
    
        if pattern_languages:
            output += "Patterns by Language:\n"
            for language, count in pattern_languages.items():
                output += f"- {language}: {count}\n"
    
        return output
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It states what the tool does but doesn't reveal any behavioral traits such as whether it's read-only, its performance characteristics, error conditions, or what format the statistics are returned in. This leaves significant gaps for a tool with zero annotation coverage.

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, efficient sentence that directly states the tool's purpose without any wasted words. It's appropriately sized and front-loaded, making it easy to parse quickly.

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

Completeness2/5

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

Given the complexity of a knowledge graph statistics tool with no annotations and no output schema, the description is insufficient. It doesn't explain what statistics are returned (e.g., counts, metrics, trends), how they're formatted, or any limitations. This leaves the agent with inadequate context to use the tool effectively.

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 tool has 0 parameters with 100% schema description coverage (since there are no parameters to describe). The description doesn't need to compensate for any parameter documentation gaps, and it correctly implies no inputs are required. This meets the baseline for a parameterless tool.

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 action ('Get statistics') and the target ('about the knowledge graph'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from potential siblings like 'dump_project_understanding' or 'query_entities' that might also provide statistical insights, which prevents a perfect score.

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 offers no guidance on when to use this tool versus alternatives. With siblings like 'dump_project_understanding' and 'query_entities' that might overlap in providing knowledge graph insights, there's no indication of context, prerequisites, or exclusions for this specific statistics tool.

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

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/sarathsp06/sourcesage'

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