check_department_exists
Verify the existence of a department in Kroger's system by inputting a department ID. Returns a dictionary confirming department presence.
Instructions
Check if a department exists in the Kroger system.
Args:
department_id: The department ID to check
Returns:
Dictionary indicating whether the department exists
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| department_id | Yes |
Implementation Reference
- The main handler function decorated with @mcp.tool(), which implements the logic to check if a Kroger department exists using the API client.@mcp.tool() async def check_department_exists( department_id: str, ctx: Context = None ) -> Dict[str, Any]: """ Check if a department exists in the Kroger system. Args: department_id: The department ID to check Returns: Dictionary indicating whether the department exists """ if ctx: await ctx.info(f"Checking if department '{department_id}' exists") client = get_client_credentials_client() try: exists = client.location.department_exists(department_id) return { "success": True, "department_id": department_id, "exists": exists, "message": f"Department '{department_id}' {'exists' if exists else 'does not exist'}" } except Exception as e: if ctx: await ctx.error(f"Error checking department existence: {str(e)}") return { "success": False, "error": str(e) }
- src/kroger_mcp/server.py:75-75 (registration)Invocation of register_tools from info_tools module, which defines and registers the check_department_exists tool with the MCP server.info_tools.register_tools(mcp)