Skip to main content
Glama
stijn-meijers

DraCor MCP Server

analyze_play_structure

Analyze dramatic text structure by extracting acts, scenes, and structural metrics from plays in the Drama Corpora Project.

Instructions

Analyze the structure of a play including acts, scenes, and metrics.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
corpus_nameYes
play_nameYes

Implementation Reference

  • The handler function for the analyze_play_structure tool. It retrieves play metadata, metrics, characters, and spoken text data from the DraCor API, extracts structural elements like acts and scenes, computes gender counts and speaking distribution, and returns a comprehensive analysis dictionary.
    @mcp.tool()
    def analyze_play_structure(corpus_name: str, play_name: str) -> Dict:
        """Analyze the structure of a play including acts, scenes, and metrics."""
        try:
            play = api_request(f"corpora/{corpus_name}/plays/{play_name}")
            metrics = api_request(f"corpora/{corpus_name}/plays/{play_name}/metrics")
            
            # Extract structural information from segments
            acts = []
            scenes = []
            for segment in play.get("segments", []):
                if segment.get("type") == "act":
                    acts.append({
                        "number": segment.get("number"),
                        "title": segment.get("title")
                    })
                elif segment.get("type") == "scene":
                    scenes.append({
                        "number": segment.get("number"),
                        "title": segment.get("title"),
                        "speakers": segment.get("speakers", [])
                    })
            
            # Get character data
            characters = api_request(f"corpora/{corpus_name}/plays/{play_name}/characters")
            
            # Count characters by gender
            gender_counts = {"MALE": 0, "FEMALE": 0, "UNKNOWN": 0}
            for character in characters:
                gender = character.get("gender")
                if gender in gender_counts:
                    gender_counts[gender] += 1
            
            # Get spoken text by character data
            spoken_text_by_char = api_request(f"corpora/{corpus_name}/plays/{play_name}/spoken-text-by-character")
            
            # Calculate total words and distribution
            total_words = sum(char.get("numOfWords", 0) for char in characters)
            speaking_distribution = []
            
            if total_words > 0:
                for char in characters:
                    char_words = char.get("numOfWords", 0)
                    speaking_distribution.append({
                        "character": char.get("name"),
                        "words": char_words,
                        "percentage": round((char_words / total_words) * 100, 2)
                    })
                
                # Sort by word count
                speaking_distribution.sort(key=lambda x: x["words"], reverse=True)
            
            # Get structural information
            structure = {
                "title": play.get("title"),
                "authors": [author.get("name") for author in play.get("authors", [])],
                "year": play.get("yearNormalized"),
                "yearWritten": play.get("yearWritten"),
                "yearPrinted": play.get("yearPrinted"),
                "yearPremiered": play.get("yearPremiered"),
                "acts": acts,
                "scenes": scenes,
                "numOfActs": len(acts),
                "numOfScenes": len(scenes),
                "segments": metrics.get("segments"),
                "dialogues": metrics.get("dialogues"),
                "wordCount": total_words,
                "characters": {
                    "total": len(characters),
                    "byGender": gender_counts
                },
                "speakingDistribution": speaking_distribution[:10],  # Top 10 characters by speaking time
            }
            
            return structure
        except Exception as e:
            return {"error": str(e)}
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions analyzing 'acts, scenes, and metrics' but doesn't specify what 'metrics' entail, whether the analysis is read-only or modifies data, or what the output format might be (e.g., structured data, summary). This leaves gaps in understanding the tool's behavior, especially for a tool with parameters and no output schema.

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, consisting of a single, efficient sentence that directly states the tool's purpose. There's no unnecessary information or redundancy, making it easy to parse quickly. However, it could be slightly improved by adding a brief usage hint without sacrificing conciseness.

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 tool's complexity (analyzing play structure with metrics), lack of annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like whether it's a read operation, what 'metrics' includes, or how results are returned. For a tool with parameters and analytical functions, more context is needed to ensure the agent can use it effectively.

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?

The schema description coverage is 0%, so the description must compensate for the lack of parameter documentation. It doesn't add any meaning beyond what the input schema provides—it doesn't explain what 'corpus_name' or 'play_name' refer to, their expected formats, or examples. With 2 parameters and no schema descriptions, this is a significant gap, as the description fails to clarify parameter usage.

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 with a specific verb ('analyze') and resource ('structure of a play'), including what aspects it covers ('acts, scenes, and metrics'). It distinguishes itself from siblings like 'analyze_character_relations' or 'analyze_full_text' by focusing on structural analysis rather than character or textual analysis. However, it doesn't explicitly differentiate from 'compare_plays' or 'search_plays' in terms of structural vs. comparative/search functions.

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, such as needing a specific corpus or play format, or when to choose this over siblings like 'analyze_full_text' for broader analysis or 'compare_plays' for structural comparisons. Usage is implied by the name and purpose but not explicitly stated.

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/stijn-meijers/dracor-mcp'

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