Skip to main content
Glama
vivek081166

japan-utils-mcp

lookup_postal_code

Resolve a 7-digit Japanese postal code to its prefecture, city, and area, with kanji and kana readings.

Instructions

Look up a Japanese postal code (郵便番号) and return address components.

Args: postal_code: 7-digit JP postal code. Accepts '150-0001', '1500001', '150 0001', or with full-width digits.

Returns: dict with keys: - postal_code: str (normalized 7-digit form) - prefecture: str (都道府県) - city: str (市区町村) - area: str (町域 — neighborhood/area) - prefecture_kana: str (katakana reading of prefecture) - city_kana: str - area_kana: str - found: bool (true if the code resolved)

Examples: lookup_postal_code("150-0001") → { "postal_code": "1500001", "prefecture": "東京都", "city": "渋谷区", "area": "神宮前", ... "found": True, }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
postal_codeYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the lookup_postal_code tool. Decorated with @mcp.tool(), it accepts a postal code string, normalizes it to 7 digits, queries the posuto database, and returns address components (prefecture, city, area) along with their kana readings.
    @mcp.tool()
    def lookup_postal_code(postal_code: str) -> dict[str, Any]:
        """Look up a Japanese postal code (郵便番号) and return address components.
    
        Args:
            postal_code: 7-digit JP postal code. Accepts '150-0001', '1500001',
                '150 0001', or with full-width digits.
    
        Returns:
            dict with keys:
                - postal_code: str (normalized 7-digit form)
                - prefecture: str (都道府県)
                - city: str (市区町村)
                - area: str (町域 — neighborhood/area)
                - prefecture_kana: str (katakana reading of prefecture)
                - city_kana: str
                - area_kana: str
                - found: bool (true if the code resolved)
    
        Examples:
            lookup_postal_code("150-0001") → {
                "postal_code": "1500001",
                "prefecture": "東京都",
                "city": "渋谷区",
                "area": "神宮前",
                ...
                "found": True,
            }
        """
        digits = re.sub(r"[^0-9]", "", postal_code)
        digits = digits.translate(str.maketrans("0123456789", "0123456789"))
    
        if len(digits) != 7 or not digits.isdigit():
            return {
                "postal_code": postal_code,
                "found": False,
                "error": "Postal code must be 7 digits.",
            }
    
        try:
            entry = posuto.get(digits)
        except KeyError:
            return {
                "postal_code": digits,
                "found": False,
                "error": "Postal code not found in dataset.",
            }
        except Exception as exc:
            return {
                "postal_code": digits,
                "found": False,
                "error": f"Lookup failed: {exc}",
            }
    
        return {
            "postal_code": digits,
            "prefecture": entry.prefecture,
            "city": entry.city,
            "area": entry.neighborhood,
            "prefecture_kana": entry.prefecture_kana,
            "city_kana": entry.city_kana,
            "area_kana": entry.neighborhood_kana,
            "found": True,
        }
  • The tool is registered via the @mcp.tool() decorator on line 216, which is the FastMCP framework's mechanism for registering tools. No separate registration call exists.
    @mcp.tool()
  • The posuto library import used to perform the actual postal code lookup. posuto is a Python library for Japanese postal code data.
    import posuto  # type: ignore[import-untyped]
    import pykakasi  # type: ignore[import-untyped]
Behavior4/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 that the tool accepts multiple formats, normalizes to 7 digits, and returns a 'found' boolean. However, it does not explicitly state whether it is read-only or rely on external APIs, though these are reasonably inferred.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear purpose statement, parameter description, return value definition, and a concrete example. It is concise with no unnecessary information, and the example enhances understanding efficiently.

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?

For a simple lookup tool with one parameter, the description covers input format, output structure, and example. Despite the existence of an output schema (not shown), the description adds value by detailing return keys. Error cases are implied via the 'found' field. The description is complete given the tool's complexity.

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 input schema only defines 'postal_code' as a string with no description. The description compensates fully by explaining accepted formats (with hyphen, spaces, full-width), length requirement, and provides an example, adding significant meaning beyond the schema.

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 explicitly states 'Look up a Japanese postal code' with a specific verb and resource. It clearly distinguishes from sibling tools like era conversion or name splitting, as it is the only postal code lookup tool.

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 does not provide explicit guidance on when to use this tool versus alternatives or when not to use it. Usage is implied by the specific domain (Japanese postal codes), but no direct comparisons or exclusions are given.

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