from mcp.server.fastmcp import FastMCP
import httpx
mcp = FastMCP(
name="zipcode-search",
description="A Model Context Protocol server for Japanese postal code address lookup"
)
@mcp.tool()
def search_zipcode(zipcode: str) -> dict:
"""Search for address by Japanese postal code
Args:
zipcode: 7-digit postal code (e.g., "1000001")
Returns:
dict: Address information with "address" key
"""
try:
with httpx.Client() as client:
response = client.get(f"https://zipcloud.ibsnet.co.jp/api/search?zipcode={zipcode}")
response.raise_for_status()
data = response.json()
if data.get("results"):
result = data["results"][0]
address = f"{result['address1']}{result['address2']}{result['address3']}"
return {"address": address}
return {"address": "Address not found"}
except Exception as e:
return {"address": f"Error occurred: {str(e)}"}
if __name__ == "__main__":
mcp.run()
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/rooking-oss/zipcode-search-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server