Skip to main content
Glama
stijn-meijers

DraCor MCP Server

analyze_full_text

Analyze complete play texts including dialogue and stage directions to extract insights from dramatic works across languages and periods.

Instructions

Analyze the full text of a play, including dialogue and stage directions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
corpus_nameYes
play_nameYes

Implementation Reference

  • The complete implementation of the 'analyze_full_text' tool. Includes the @mcp.tool decorator for registration and the full handler function that analyzes the play's TEI XML structure (acts, scenes, speeches, stage directions), metadata, characters, plain text stats, and returns a comprehensive dictionary with the analysis.
    @mcp.tool("analyze_full_text")
    def analyze_full_text(corpus_name: str, play_name: str) -> Dict:
        """Analyze the full text of a play, including dialogue and stage directions."""
        try:
            # Get the TEI XML as primary source
            tei_result = get_tei_text(corpus_name, play_name)
            if "error" in tei_result:
                # Fall back to the plain text if TEI fails
                full_text = get_full_text(corpus_name, play_name)
                if "error" in full_text:
                    return {"error": full_text["error"]}
                has_tei = False
                text_content = full_text["text"]
            else:
                has_tei = True
                tei_text = tei_result["tei_text"]
                
                # Simple XML parsing to extract basic structure
                # In a production environment, use a proper XML parser library
                import re
                
                # Extract title
                title_match = re.search(r'<title[^>]*>([^<]+)</title>', tei_text)
                title = title_match.group(1) if title_match else "Unknown"
                
                # Extract author(s)
                author_matches = re.findall(r'<author[^>]*>([^<]+)</author>', tei_text)
                authors = author_matches if author_matches else ["Unknown"]
                
                # Extract acts
                acts = re.findall(r'<div type="act"[^>]*>(.*?)</div>', tei_text, re.DOTALL)
                act_count = len(acts)
                
                # Extract scenes
                scenes = re.findall(r'<div type="scene"[^>]*>(.*?)</div>', tei_text, re.DOTALL)
                scene_count = len(scenes)
                
                # Extract speeches
                speeches = re.findall(r'<sp[^>]*>(.*?)</sp>', tei_text, re.DOTALL)
                speech_count = len(speeches)
                
                # Extract stage directions
                stage_directions = re.findall(r'<stage[^>]*>(.*?)</stage>', tei_text, re.DOTALL)
                stage_direction_count = len(stage_directions)
                
                # Also get the plain text for easier processing
                full_text = get_full_text(corpus_name, play_name)
                text_content = full_text.get("text", "")
                
            # Get play metadata
            play_info = get_play(corpus_name, play_name)
            if "error" in play_info:
                return {"error": play_info["error"]}
                
            # Get character list
            characters = get_characters(corpus_name, play_name)
            if "error" in characters:
                return {"error": characters["error"]}
            
            result = {
                "play": play_info.get("play", {}),
                "characters": characters.get("characters", []),
                "text": text_content,
            }
            
            # Add TEI-specific analysis if available
            if has_tei:
                result["tei_analysis"] = {
                    "title": title,
                    "authors": authors,
                    "structure": {
                        "acts": act_count,
                        "scenes": scene_count,
                        "speeches": speech_count,
                        "stage_directions": stage_direction_count
                    },
                    "text_sample": {
                        "first_speech": speeches[0] if speeches else "",
                        "first_stage_direction": stage_directions[0] if stage_directions else ""
                    }
                }
            
            # Add basic text analysis in either case
            result["analysis"] = {
                "text_length": len(text_content),
                "character_count": len(characters.get("characters", [])),
                "dialogue_to_direction_ratio": text_content.count("\n\nDIALOGUE:") / 
                                              (text_content.count("\n\nSTAGE DIRECTIONS:") or 1)
            }
            
            return result
        except Exception as e:
            return {"error": str(e)}
  • The MCP tool registration decorator specifically naming this tool 'analyze_full_text'.
    @mcp.tool("analyze_full_text")
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 states the tool analyzes full text but doesn't describe what the analysis entails (e.g., returns insights, statistics, or summaries), any limitations (e.g., corpus availability, processing time), or side effects. This leaves key behavioral traits unspecified for a tool with no structured safety hints.

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 a single, efficient sentence that front-loads the core purpose. It avoids redundancy and wastes no words, though it could be more informative by elaborating on analysis outcomes or usage context without sacrificing brevity.

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 (analysis tool with no annotations, 0% schema coverage, and no output schema), the description is incomplete. It doesn't explain what the tool returns, how parameters are used, or behavioral aspects like error handling. For a tool that likely produces detailed outputs, this lack of context makes it inadequate for informed use.

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 mentions 'full text of a play' but doesn't explain the parameters 'corpus_name' and 'play_name', such as what values are expected or how they relate to the analysis. This adds minimal meaning beyond the schema, failing to address the coverage gap.

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 ('analyze') and resource ('full text of a play'), specifying it includes dialogue and stage directions. It distinguishes from siblings like 'analyze_character_relations' or 'analyze_play_structure' by focusing on full text analysis, though it doesn't explicitly name alternatives. The purpose is specific but could be more precise about what 'analyze' entails.

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 scenarios, prerequisites, or exclusions, such as when to choose 'analyze_play_structure' instead. Without this context, users must infer usage from tool names alone, which is insufficient for effective selection.

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