get_character_details
Retrieve detailed information about a specific character using their unique ID for anime, manga, music, or game-related queries on Bangumi TV.
Instructions
Get details of a specific character.
Args:
character_id: The ID of the character.
Returns:
Formatted character details or an error message.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| character_id | Yes |
Input Schema (JSON Schema)
{
"properties": {
"character_id": {
"title": "Character Id",
"type": "integer"
}
},
"required": [
"character_id"
],
"title": "get_character_detailsArguments",
"type": "object"
}
Implementation Reference
- main.py:937-1002 (handler)The handler function for the 'get_character_details' tool. Decorated with @mcp.tool() for registration in FastMCP. Fetches character data from Bangumi API endpoint /v0/characters/{character_id}, handles errors, and formats details including name, type, summary, gender, blood type, birth date, infobox note, stats, and image.@mcp.tool() async def get_character_details(character_id: int) -> str: """ Get details of a specific character. Args: character_id: The ID of the character. Returns: Formatted character details or an error message. """ response = await make_bangumi_request( method="GET", path=f"/v0/characters/{character_id}" ) error_msg = handle_api_error_response(response) if error_msg: return error_msg # Expecting a dictionary if not isinstance(response, dict): return f"Unexpected API response format for get_character_details: {response}" character = response infobox = character.get("infobox") details_text = f"Character Details (ID: {character_id}):\n" details_text += f" Name: {character.get('name')}\n" char_type_int = character.get("type") char_type_str = "Unknown Type" if char_type_int is not None: try: char_type_str = CharacterType(char_type_int).name except ValueError: char_type_str = f"Unknown Type ({char_type_int})" details_text += f" Type: {char_type_str}\n" details_text += f" Summary:\n{character.get('summary')}\n" details_text += f" Locked: {character.get('locked')}\n" if character.get("gender"): details_text += f" Gender: {character.get('gender')}\n" if character.get("blood_type") is not None: try: details_text += ( f" Blood Type: {BloodType(character.get('blood_type')).name}\n" ) except ValueError: details_text += f" Blood Type: Unknown ({character.get('blood_type')})\n" if character.get("birth_year"): details_text += f" Birth Date: {character.get('birth_year')}-{character.get('birth_mon')}-{character.get('birth_day')}\n" if infobox: details_text += ( " Infobox: (Details available in raw response, potentially complex)\n" ) stat = character.get("stat", {}) details_text += f" Comments: {stat.get('comments', 0)}, Collections: {stat.get('collects', 0)}\n" images = character.get("images") if images and images.get("large"): details_text += f" Image: {images.get('large')}\n" return details_text