Skip to main content
Glama
marksverdhei

DHLAB MCP Server

by marksverdhei

word_concordance

Extract structured word concordances from Norwegian digital collections for programmatic analysis, separating matched words from surrounding context with before/target/after fields.

Instructions

Find concordances with structured output (no HTML formatting).

Returns clean format with separate before/target/after fields instead of HTML-formatted text. This is useful for programmatic analysis where you need the matched word separated from context.

Args: urn: URN identifier for the document word: Word to find concordances for window: Number of words before and after the match (default: 12, max: 24) limit: Maximum number of concordances to return (default: 100)

Returns: JSON string containing structured concordance results with fields: - dhlabid: Document identifier - before: Text before the matched word - target: The matched word itself - after: Text after the matched word

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urnYes
wordYes
windowNo
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The @mcp.tool()-decorated function that defines and implements the 'word_concordance' tool handler. It delegates to an external dhlab.api function but handles input parameters, error handling, and JSON output formatting.
    @mcp.tool()
    def word_concordance(
        urn: str,
        word: str,
        window: int = 12,
        limit: int = 100,
    ) -> str:
        """Find concordances with structured output (no HTML formatting).
    
        Returns clean format with separate before/target/after fields instead of HTML-formatted text.
        This is useful for programmatic analysis where you need the matched word separated from context.
    
        Args:
            urn: URN identifier for the document
            word: Word to find concordances for
            window: Number of words before and after the match (default: 12, max: 24)
            limit: Maximum number of concordances to return (default: 100)
    
        Returns:
            JSON string containing structured concordance results with fields:
            - dhlabid: Document identifier
            - before: Text before the matched word
            - target: The matched word itself
            - after: Text after the matched word
        """
        try:
            from dhlab.api.dhlab_api import word_concordance as dhlab_word_concordance
    
            # Call dhlab's word_concordance method directly
            # Note: urn parameter expects a list, words parameter expects a list
            result = dhlab_word_concordance(
                urn=[urn],
                words=[word],
                before=window,
                after=window,
                limit=limit
            )
    
            if result is not None and len(result) > 0:
                return result.to_json(orient='records', force_ascii=False)
            return "No concordances found"
        except Exception as e:
            return f"Error finding word concordances: {str(e)}"
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: the tool returns structured JSON output (not HTML), includes default values for 'window' and 'limit', and specifies max constraints ('max: 24'). However, it does not cover potential errors, rate limits, or authentication needs, leaving some gaps in behavioral context.

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 appropriately sized and front-loaded, starting with the core purpose and key differentiator. Each sentence earns its place by explaining output format, usage context, parameters, and return values without redundancy. The structured bullet points for parameters and returns enhance readability without unnecessary verbosity.

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

Completeness5/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 (4 parameters, no annotations, but with an output schema), the description is complete enough. It covers purpose, usage, parameters, and return format in detail. Since an output schema exists, the description does not need to explain return values beyond what's provided, and it adequately addresses the lack of annotations and schema coverage.

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

Parameters5/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 fully. It adds significant meaning beyond the input schema by explaining each parameter's purpose: 'urn' as a 'URN identifier for the document', 'word' as 'Word to find concordances for', 'window' with default and max details, and 'limit' with default. This provides complete parameter semantics not present in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Find concordances') and resource ('structured output'), distinguishing it from siblings like 'find_concordances' by emphasizing 'structured output (no HTML formatting)' and 'clean format with separate before/target/after fields'. This explicit differentiation ensures the agent understands this tool's unique purpose.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('useful for programmatic analysis where you need the matched word separated from context'), but it does not explicitly state when not to use it or name alternatives among siblings (e.g., 'find_concordances' might offer HTML formatting). This gives good guidance but lacks explicit exclusions.

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