Skip to main content
Glama
Ukenn2112

Bangumi TV MCP Service

by Ukenn2112

search_characters

Find anime, manga, and game characters, mechanics, ships, or organizations on Bangumi TV using keywords. Supports pagination and optional NSFW filtering for tailored results.

Instructions

Search for characters on Bangumi.

Supported Character Types (integer enum in result):
1: Character, 2: Mechanic, 3: Ship, 4: Organization

Args:
    keyword: The search keyword.
    limit: Pagination limit. Defaults to 30.
    offset: Pagination offset. Defaults to 0.
    nsfw_filter: Optional NSFW filter (boolean). Set to True to include, False to exclude. Requires authorization for non-default behavior.

Returns:
    Formatted search results or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordYes
limitNo
nsfw_filterNo
offsetNo

Implementation Reference

  • main.py:883-934 (handler)
    Main execution logic for the search_characters tool. Registers the tool via @mcp.tool() decorator, handles API request to Bangumi search/characters endpoint, processes response, formats results using helper, and returns formatted text.
    @mcp.tool()
    async def search_characters(
        keyword: str, limit: int = 30, offset: int = 0, nsfw_filter: Optional[bool] = None
    ) -> str:
        """
        Search for characters on Bangumi.
    
        Supported Character Types (integer enum in result):
        1: Character, 2: Mechanic, 3: Ship, 4: Organization
    
        Args:
            keyword: The search keyword.
            limit: Pagination limit. Defaults to 30.
            offset: Pagination offset. Defaults to 0.
            nsfw_filter: Optional NSFW filter (boolean). Set to True to include, False to exclude. Requires authorization for non-default behavior.
    
        Returns:
            Formatted search results or an error message.
        """
        json_body = {"keyword": keyword, "filter": {}}
        if nsfw_filter is not None:
            json_body["filter"]["nsfw"] = nsfw_filter  # Filter is in JSON body
    
        params = {"limit": limit, "offset": offset}
    
        response = await make_bangumi_request(
            method="POST",
            path="/v0/search/characters",
            query_params=params,
            json_body=json_body,
        )
    
        error_msg = handle_api_error_response(response)
        if error_msg:
            return error_msg
    
        # Expecting a dictionary with 'data' and 'total'
        if not isinstance(response, dict) or "data" not in response:
            return f"Unexpected API response format for search_characters: {response}"
    
        characters = response.get("data", [])
        if not characters:
            return f"No characters found for keyword '{keyword}'."
    
        formatted_results = [format_character_summary(c) for c in characters]
        total = response.get("total", 0)
        results_text = (
            f"Found {len(characters)} characters (Total matched: {total}).\n"
            + "---\n".join(formatted_results)
        )
    
        return results_text
  • Supporting function used by search_characters to format each character result into a concise summary string including type, name, ID, summary, and image URL.
    def format_character_summary(character: Dict[str, Any]) -> str:
        """Formats a character dictionary into a readable summary string."""
        character_id = character.get("id")
        name = character.get("name")
        char_type = character.get("type")  # Integer enum
        summary = character.get("short_summary") or character.get("summary", "")
    
        try:
            type_str = (
                CharacterType(char_type).name if char_type is not None else "Unknown Type"
            )
        except ValueError:
            type_str = f"Unknown Type ({char_type})"
    
        formatted_string = f"[{type_str}] {name} (ID: {character_id})\n"
        if summary:
            formatted_summary = summary  # [:200] + '...' if len(summary) > 200 else summary
            formatted_string += f"  Summary: {formatted_summary}\n"
    
        images = character.get("images")
        if images and images.get("common"):
            formatted_string += f"  Image: {images.get('common')}\n"
    
        return formatted_string
  • MCP prompt that demonstrates usage of search_characters tool as part of a workflow to find voice actors for a character.
    def find_voice_actor(character_name: str) -> str:
        """
        Search for a character by name and find their voice actor.
    
        Args:
            character_name: The name of the character.
        """
        return f"Search for the character '{character_name}' using 'search_characters'. If the search finds characters, identify the most relevant character ID. Then, use 'get_character_persons' with the character ID to list persons related to them (like voice actors). Summarize the voice actors found from the tool output."
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses the supported character types (enum values 1-4), pagination behavior with defaults, and authorization needs for nsfw_filter. However, it doesn't cover rate limits, error conditions beyond a generic mention, or detailed response format, leaving gaps in behavioral context.

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 well-structured with clear sections for purpose, args, and returns. It's appropriately sized with no redundant sentences, though the 'Returns' section is vague ('formatted search results or an error message'), which slightly reduces efficiency.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description provides basic purpose and parameters but lacks details on response structure, error handling, and sibling differentiation. For a search tool with 4 parameters and complex enums, it's adequate but has clear gaps in completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaning for all parameters: keyword as search term, limit/offset for pagination with defaults, and nsfw_filter with authorization details. This goes beyond the bare schema, though it could specify format constraints (e.g., keyword length).

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

Purpose4/5

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

The description clearly states the tool searches for characters on Bangumi, specifying the verb 'search' and resource 'characters'. It distinguishes from siblings like search_persons and search_subjects by focusing on characters, though it doesn't explicitly contrast with them. The mention of supported character types adds specificity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for searching characters, but doesn't explicitly state when to use this tool versus alternatives like get_character_details or browse_subjects. It mentions authorization requirements for nsfw_filter, which provides some context, but lacks clear guidance on tool selection among siblings.

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

Related 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/Ukenn2112/BangumiMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server