get_user_zip_code
Retrieve the user's zip code to enable accurate store location and product availability checks for grocery shopping with Kroger services.
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 handler function for the 'get_user_zip_code' tool. It retrieves the default zip code using the helper function 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)Registration of the location_tools module, which includes the get_user_zip_code tool, in the main MCP server.location_tools.register_tools(mcp)
- Helper function used by the get_user_zip_code tool to obtain the default zip code from environment variables.def get_default_zip_code() -> str: """Get the default zip code from environment or fallback""" return get_zip_code(default="10001")