compare_plays
Analyze and contrast two dramatic plays by comparing their structural metrics and textual features to identify similarities and differences.
Instructions
Compare two plays in terms of metrics and structure.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| corpus_name1 | Yes | ||
| play_name1 | Yes | ||
| corpus_name2 | Yes | ||
| play_name2 | Yes |
Implementation Reference
- dracor_mcp_fastmcp.py:406-441 (handler)The complete implementation of the 'compare_plays' tool, including registration via the @mcp.tool() decorator and the handler function that fetches play metadata and metrics for two specified plays from the DraCor API and compiles them into a comparison structure. The input schema is defined by the function parameters.@mcp.tool() def compare_plays( corpus_name1: str, play_name1: str, corpus_name2: str, play_name2: str ) -> Dict: """Compare two plays in terms of metrics and structure.""" try: play1 = api_request(f"corpora/{corpus_name1}/plays/{play_name1}") play2 = api_request(f"corpora/{corpus_name2}/plays/{play_name2}") metrics1 = api_request(f"corpora/{corpus_name1}/plays/{play_name1}/metrics") metrics2 = api_request(f"corpora/{corpus_name2}/plays/{play_name2}/metrics") # Compile comparison data comparison = { "plays": [ { "title": play1.get("title"), "author": play1.get("authors", [{}])[0].get("name") if play1.get("authors") else None, "year": play1.get("yearNormalized"), "metrics": metrics1 }, { "title": play2.get("title"), "author": play2.get("authors", [{}])[0].get("name") if play2.get("authors") else None, "year": play2.get("yearNormalized"), "metrics": metrics2 } ] } return comparison except Exception as e: return {"error": str(e)}