Skip to main content
Glama
stijn-meijers

DraCor MCP Server

analyze_character_relations

Analyze character relationships in a play to identify connections and interactions between characters.

Instructions

Analyze the character relationships in a play.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
corpus_nameYes
play_nameYes

Implementation Reference

  • The handler function decorated with @mcp.tool(), which registers and implements the 'analyze_character_relations' tool. It analyzes character relationships by fetching play data, characters, network CSV data, parsing relations with weights, attempting to fetch formal relations, and returning structured analysis including top relations and metrics.
    @mcp.tool()
    def analyze_character_relations(corpus_name: str, play_name: str) -> Dict:
        """Analyze the character relationships in a play."""
        try:
            # Get play data
            play = api_request(f"corpora/{corpus_name}/plays/{play_name}")
            
            # Get character data
            characters = api_request(f"corpora/{corpus_name}/plays/{play_name}/characters")
            
            # Get network data in CSV format
            url = f"{DRACOR_API_BASE_URL}/corpora/{corpus_name}/plays/{play_name}/networkdata/csv"
            response = requests.get(url)
            response.raise_for_status()
            csv_data = response.text
            
            # Parse CSV data to extract relations
            relations = []
            lines = csv_data.strip().split('\n')
            if len(lines) > 1:  # Skip header
                headers = lines[0].split(',')
                for line in lines[1:]:
                    parts = line.split(',')
                    if len(parts) >= 4:
                        source = parts[0].strip('"')
                        target = parts[2].strip('"')
                        weight = int(parts[3]) if parts[3].isdigit() else 0
                        
                        # Find character names from IDs
                        source_name = None
                        target_name = None
                        for char in characters:
                            if char.get("id") == source:
                                source_name = char.get("name")
                            if char.get("id") == target:
                                target_name = char.get("name")
                        
                        relations.append({
                            "source": source_name or source,
                            "source_id": source,
                            "target": target_name or target,
                            "target_id": target,
                            "weight": weight
                        })
            
            # Sort by weight to identify strongest relationships
            relations.sort(key=lambda x: x.get("weight", 0), reverse=True)
            
            # Try to get relations data if available
            try:
                relations_url = f"{DRACOR_API_BASE_URL}/corpora/{corpus_name}/plays/{play_name}/relations/csv"
                relations_response = requests.get(relations_url)
                formal_relations = []
                
                if relations_response.status_code == 200:
                    rel_lines = relations_response.text.strip().split('\n')
                    if len(rel_lines) > 1:  # Skip header
                        for line in rel_lines[1:]:
                            parts = line.split(',')
                            if len(parts) >= 4:
                                source = parts[0].strip('"')
                                target = parts[2].strip('"')
                                relation_type = parts[3].strip('"')
                                
                                # Find character names from IDs
                                source_name = None
                                target_name = None
                                for char in characters:
                                    if char.get("id") == source:
                                        source_name = char.get("name")
                                    if char.get("id") == target:
                                        target_name = char.get("name")
                                
                                formal_relations.append({
                                    "source": source_name or source,
                                    "target": target_name or target,
                                    "type": relation_type
                                })
            except:
                formal_relations = []
            
            # Get metrics
            metrics = api_request(f"corpora/{corpus_name}/plays/{play_name}/metrics")
            
            return {
                "play": {
                    "title": play.get("title"),
                    "author": play.get("authors", [{}])[0].get("name") if play.get("authors") else None,
                    "year": play.get("yearNormalized")
                },
                "totalCharacters": len(characters),
                "totalRelations": len(relations),
                "strongestRelations": relations[:10],  # Top 10 strongest relations
                "weakestRelations": relations[-10:] if len(relations) >= 10 else relations,  # Bottom 10
                "formalRelations": formal_relations,  # Explicit relations if available
                "metrics": metrics
            }
        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 states the action ('analyze') but doesn't describe what the analysis involves, such as output format, computational intensity, or any constraints like data availability. This is a significant gap for a tool with zero annotation coverage.

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 with zero waste, making it appropriately sized and front-loaded. However, its brevity contributes to under-specification rather than optimal clarity, slightly reducing its effectiveness despite the concise structure.

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 (analysis task), lack of annotations, no output schema, and low schema coverage, the description is incomplete. It doesn't cover behavioral aspects, parameter details, or output expectations, making it inadequate for guiding an AI agent effectively in this context.

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 description adds no meaning beyond the input schema, which has 0% schema description coverage for its 2 parameters. It doesn't explain what 'corpus_name' or 'play_name' refer to, their expected formats, or how they relate to the analysis. With low coverage, the description fails to compensate, leaving parameters largely undocumented.

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

Purpose3/5

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

The description states the tool's purpose as analyzing character relationships in a play, which is clear but vague. It specifies the verb 'analyze' and resource 'character relationships in a play', but doesn't differentiate from siblings like 'find_character_across_plays' or explain what analysis entails. It avoids tautology but lacks specificity about scope or output.

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 siblings like 'analyze_full_text' or 'analyze_play_structure', nor does it specify prerequisites, exclusions, or context for usage. This leaves the agent with minimal direction for tool 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