Skip to main content
Glama

check_department_exists

Verify department availability in the Kroger system by checking if a specific department ID exists, returning confirmation for inventory or organizational queries.

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
NameRequiredDescriptionDefault
department_idYes

Implementation Reference

  • The main handler function decorated with @mcp.tool(), which executes the tool logic: checks if the specified department_id exists using the Kroger API client and returns a success/failure response with existence status. The function signature and docstring define the implicit schema.
    @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) }
  • The explicit registration of the info_tools module (containing check_department_exists) onto the MCP server instance.
    info_tools.register_tools(mcp)
  • Shared helper function that provides the client credentials authenticated KrogerAPI client instance, used in the handler for accessing public department data.
    def get_client_credentials_client() -> KrogerAPI: """Get or create a client credentials authenticated client for public data""" global _client_credentials_client if _client_credentials_client is not None and _client_credentials_client.test_current_token(): return _client_credentials_client _client_credentials_client = None try: load_and_validate_env(["KROGER_CLIENT_ID", "KROGER_CLIENT_SECRET"]) _client_credentials_client = KrogerAPI() # Try to load existing token first token_file = ".kroger_token_client_product.compact.json" token_info = load_token(token_file) if token_info: # Test if the token is still valid _client_credentials_client.client.token_info = token_info if _client_credentials_client.test_current_token(): # Token is valid, use it return _client_credentials_client # Token is invalid or not found, get a new one token_info = _client_credentials_client.authorization.get_token_with_client_credentials("product.compact") return _client_credentials_client except Exception as e: raise Exception(f"Failed to get client credentials: {str(e)}")

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/CupOfOwls/kroger-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server