Skip to main content
Glama
vivek081166

japan-utils-mcp

convert_kana

Convert Japanese text between hiragana, katakana, and half-width katakana. Specify the target script to transform any mix of characters.

Instructions

Convert between hiragana, katakana, and half-width katakana.

Args: text: Input string. Mix of hiragana, katakana, kanji, ASCII is fine — non-target characters pass through unchanged. to: Target script. One of: - 'hiragana' : ひらがな (e.g. ヤマダ → やまだ) - 'katakana' : カタカナ (full-width) (e.g. やまだ → ヤマダ) - 'half_kana' : ハンカクカタカナ (half-width katakana) (e.g. ヤマダ → ヤマダ) - 'full_kana' : ヤマダ (half-width → full-width katakana)

Returns: dict with keys: - input: str - output: str - to: str

Examples: convert_kana("ヤマダタロウ", "hiragana") → "やまだたろう" convert_kana("やまだたろう", "katakana") → "ヤマダタロウ" convert_kana("ヤマダ", "half_kana") → "ヤマダ" convert_kana("ヤマダ", "full_kana") → "ヤマダ"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYes
toYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The `convert_kana` function — the actual handler implementation of the 'convert_kana' MCP tool. Uses jaconv to convert between hiragana, katakana, and half-width/full-width katakana based on the 'to' parameter.
    @mcp.tool()
    def convert_kana(text: str, to: str) -> dict[str, Any]:
        """Convert between hiragana, katakana, and half-width katakana.
    
        Args:
            text: Input string. Mix of hiragana, katakana, kanji, ASCII is fine —
                non-target characters pass through unchanged.
            to: Target script. One of:
                - 'hiragana'  : ひらがな (e.g. ヤマダ → やまだ)
                - 'katakana'  : カタカナ (full-width) (e.g. やまだ → ヤマダ)
                - 'half_kana' : ハンカクカタカナ (half-width katakana) (e.g. ヤマダ → ヤマダ)
                - 'full_kana' : ヤマダ (half-width → full-width katakana)
    
        Returns:
            dict with keys:
                - input: str
                - output: str
                - to: str
    
        Examples:
            convert_kana("ヤマダタロウ", "hiragana") → "やまだたろう"
            convert_kana("やまだたろう", "katakana") → "ヤマダタロウ"
            convert_kana("ヤマダ", "half_kana") → "ヤマダ"
            convert_kana("ヤマダ", "full_kana") → "ヤマダ"
        """
        target = to.strip().lower()
    
        if target in ("hiragana", "hira", "h"):
            # Half-width katakana → full-width katakana → hiragana
            normalized = jaconv.h2z(text, kana=True)
            out = jaconv.kata2hira(normalized)
        elif target in ("katakana", "kata", "k", "full_katakana"):
            normalized = jaconv.h2z(text, kana=True)
            out = jaconv.hira2kata(normalized)
        elif target in ("half_kana", "halfwidth_kana", "hankaku"):
            # Convert hiragana → katakana → half-width
            full = jaconv.hira2kata(text)
            out = jaconv.z2h(full, kana=True, digit=False, ascii=False)
        elif target in ("full_kana", "fullwidth_kana", "zenkaku"):
            out = jaconv.h2z(text, kana=True, digit=False, ascii=False)
        else:
            raise ValueError(
                f"Unknown 'to' value: {to!r}. "
                "Use 'hiragana', 'katakana', 'half_kana', or 'full_kana'."
            )
    
        return {"input": text, "output": out, "to": target}
  • The `@mcp.tool()` decorator on the `convert_kana` function — this registers the tool with the FastMCP server instance, making it available as an MCP tool named 'convert_kana'.
    @mcp.tool()
  • The `jaconv` library import — this is the third-party helper used by the convert_kana function to perform kana conversions (hiragana/katakana, half-width/full-width).
    import jaconv  # type: ignore[import-untyped]
  • The type annotations and docstring for the convert_kana function act as the schema — defining the parameter types (text: str, to: str) and return type (dict[str, Any]) with documented valid values for 'to'.
    def convert_kana(text: str, to: str) -> dict[str, Any]:
        """Convert between hiragana, katakana, and half-width katakana.
    
        Args:
            text: Input string. Mix of hiragana, katakana, kanji, ASCII is fine —
                non-target characters pass through unchanged.
            to: Target script. One of:
                - 'hiragana'  : ひらがな (e.g. ヤマダ → やまだ)
                - 'katakana'  : カタカナ (full-width) (e.g. やまだ → ヤマダ)
                - 'half_kana' : ハンカクカタカナ (half-width katakana) (e.g. ヤマダ → ヤマダ)
                - 'full_kana' : ヤマダ (half-width → full-width katakana)
    
        Returns:
Behavior4/5

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

Without annotations, the description carries the full burden. It clearly explains that non-target characters pass through unchanged, lists all target script options with examples, and describes the return dictionary structure. No side effects, permissions, or error behavior are mentioned, but the core transformation is transparent.

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 Args, Returns, and Examples sections, and the main purpose is front-loaded. It is somewhat lengthy but every sentence adds value. Minor redundancy could be trimmed, but overall it is efficient.

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

Completeness5/5

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

Given the tool's simplicity and the presence of an output schema (implied by context), the description provides complete information: parameter details, transformation behavior, and return structure. The examples cover all four conversion directions, leaving no ambiguity.

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

Parameters5/5

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

The schema coverage is 0%, but the description fully compensates. It defines 'text' as input string and 'to' with four explicit allowed values and examples. Examples illustrate usage, making parameter semantics clear and actionable.

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

Purpose5/5

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

The description clearly states 'Convert between hiragana, katakana, and half-width katakana,' specifying the verb (convert) and resource (kana scripts). This distinctively sets it apart from sibling tools like kanji_to_romaji or lookup_postal_code, which handle different conversions.

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

Usage Guidelines2/5

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

The description does not provide any when-to-use or when-not-to-use guidance, nor does it mention alternatives among siblings. The absence of usage context leaves the agent without explicit direction on when this tool is appropriate versus others.

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

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/vivek081166/japan-utils-mcp'

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