Skip to main content
Glama
stijn-meijers

DraCor MCP Server

find_character_across_plays

Locate a specific character's appearances across multiple dramatic plays in the DraCor database to analyze their roles and relationships in different works.

Instructions

Find a character across multiple plays in the DraCor database.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
character_nameYes

Implementation Reference

  • The handler function decorated with @mcp.tool() that implements the logic to find occurrences of a character across all plays in all corpora by querying the DraCor API for corpora, plays, and characters, matching by name (case-insensitive), and collecting relevant metadata.
    @mcp.tool()
    def find_character_across_plays(character_name: str) -> Dict:
        """Find a character across multiple plays in the DraCor database."""
        try:
            all_corpora = api_request("corpora")
            matches = []
            
            for corpus in all_corpora:
                corpus_name = corpus["name"]
                corpus_data = api_request(f"corpora/{corpus_name}")
                
                for play in corpus_data.get("plays", []):
                    play_name = play.get("name")
                    
                    try:
                        characters = api_request(f"corpora/{corpus_name}/plays/{play_name}/characters")
                        
                        for character in characters:
                            if character_name.lower() in (character.get("name") or "").lower():
                                matches.append({
                                    "corpus": corpus_name,
                                    "play": play.get("title"),
                                    "character": character.get("name"),
                                    "gender": character.get("gender"),
                                    "numOfSpeechActs": character.get("numOfSpeechActs"),
                                    "numOfWords": character.get("numOfWords")
                                })
                    except:
                        continue
            
            return {"matches": matches}
        except Exception as e:
            return {"error": str(e)}
  • The @mcp.tool() decorator registers the find_character_across_plays function as an MCP tool.
    @mcp.tool()

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