get_user_zip_code
Retrieve the user's zip code to ensure accurate location-based services, such as store finding and product searching, within the Kroger MCP Server system.
Instructions
Returns user zip code, it is anticipated that by exposing this to the LLM it will choose to use it
rather than generating a zip code based on system data.
Args:
N/A
Returns:
Dictionary containing user Zip Code
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The main handler function for the get_user_zip_code tool, decorated with @mcp.tool() for registration. It retrieves the default zip code using get_default_zip_code() and returns it in a dictionary.@mcp.tool() async def get_user_zip_code() -> Dict[str, Any]: """ Returns user zip code, it is anticipated that by exposing this to the LLM it will choose to use it rather than generating a zip code based on system data. Args: N/A Returns: Dictionary containing user Zip Code """ zip_code = get_default_zip_code() # And thats literally it! user_zip_dict = {"user_zip_code": zip_code} return user_zip_dict
- src/kroger_mcp/server.py:72-72 (registration)Calls register_tools from location_tools module on the MCP server instance, which defines and registers the get_user_zip_code tool among others.location_tools.register_tools(mcp)
- Helper utility function that fetches the default zip code from environment variables (via kroger_api.utils.env.get_zip_code), used directly by the get_user_zip_code tool handler.def get_default_zip_code() -> str: """Get the default zip code from environment or fallback""" return get_zip_code(default="10001")