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
| Name | Required | Description | Default |
|---|---|---|---|
| character_name | Yes |
Implementation Reference
- dracor_mcp_fastmcp.py:621-653 (handler)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)}
- dracor_mcp_fastmcp.py:621-621 (registration)The @mcp.tool() decorator registers the find_character_across_plays function as an MCP tool.@mcp.tool()