Skip to main content
Glama
marksverdhei

DHLAB MCP Server

by marksverdhei

get_corpus_statistics

Analyze document collections by calculating statistical metrics from specified URN identifiers to understand corpus characteristics and patterns.

Instructions

Get statistical information about a corpus of documents.

Args: urns: List of URN identifiers for documents

Returns: JSON string containing corpus statistics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urnsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary handler function for the 'get_corpus_statistics' tool. It is registered via the @mcp.tool() decorator. The function fetches metadata statistics for a list of URNs using the external dhlab library's get_metadata function and returns it as a JSON string.
    @mcp.tool()
    def get_corpus_statistics(urns: list[str]) -> str:
        """Get statistical information about a corpus of documents.
    
        Args:
            urns: List of URN identifiers for documents
    
        Returns:
            JSON string containing corpus statistics
        """
        try:
            from dhlab.api.dhlab_api import get_metadata
    
            metadata = get_metadata(urns=urns)
    
            if metadata is not None and len(metadata) > 0:
                return metadata.to_json(orient='records', force_ascii=False)
            return "No metadata available"
        except Exception as e:
            return f"Error getting corpus statistics: {str(e)}"
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 that the tool returns 'JSON string containing corpus statistics,' which hints at output format, but does not cover critical aspects like whether it's read-only, performance implications, error handling, or data size limits. For a tool with no annotations, this leaves significant behavioral gaps.

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 appropriately sized and front-loaded, with the core purpose stated first. The additional details about args and returns are structured but slightly verbose (e.g., 'JSON string' could be more concise). Overall, it avoids unnecessary fluff, earning a high score for efficiency.

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 moderate complexity (1 parameter, no annotations, but has an output schema), the description is minimally adequate. The output schema likely covers return values, reducing the need for detailed output explanation. However, with no annotations and low parameter clarity, it lacks completeness in behavioral and usage aspects, making it just viable but with clear gaps.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate for undocumented parameters. It adds minimal value: it names the parameter ('urns') and describes it as 'List of URN identifiers for documents,' but does not explain what URNs are, their format, or constraints. This is insufficient to fully clarify the parameter's meaning beyond the basic schema.

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 statistical information about a corpus of documents.' It specifies the verb ('Get') and resource ('corpus of documents'), making the function unambiguous. However, it does not explicitly differentiate from sibling tools like 'ngram_frequencies' or 'search_texts', which might also involve corpus analysis, preventing a score of 5.

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?

No guidance is provided on when to use this tool versus alternatives. The description lacks context about scenarios where statistical information is needed over other operations like searching or concordance analysis. Without explicit when/when-not instructions or named alternatives, it offers minimal usage 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/marksverdhei/dhlab-mcp'

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