get_corpus_statistics
Analyze statistical information from a corpus of documents by providing URN identifiers. Returns JSON with corpus statistics for Norwegian digital collections.
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
| Name | Required | Description | Default |
|---|---|---|---|
| urns | Yes |
Implementation Reference
- src/dhlab_mcp/server.py:274-294 (handler)The main handler function decorated with @mcp.tool(), which both implements the tool logic and registers it. Fetches document metadata for given URNs and returns JSON statistics.@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)}"
- src/dhlab_mcp/server.py:274-274 (registration)The @mcp.tool() decorator registers the get_corpus_statistics function as an MCP tool.@mcp.tool()
- src/dhlab_mcp/server.py:275-275 (schema)Type hints define the input schema (urns: list[str]) and output (str, JSON).def get_corpus_statistics(urns: list[str]) -> str: