force_reauthenticate
Clear current authentication tokens to resolve login issues or switch user accounts in the Kroger MCP Server.
Instructions
Force re-authentication by clearing the current authentication token.
Use this if you're having authentication issues or need to log in as a different user.
Returns:
Dictionary indicating the re-authentication was initiated
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The main handler function for the 'force_reauthenticate' tool. It clears the current authentication token by calling invalidate_authenticated_client() and returns a success message instructing the user on next steps.@mcp.tool() async def force_reauthenticate(ctx: Context = None) -> Dict[str, Any]: """ Force re-authentication by clearing the current authentication token. Use this if you're having authentication issues or need to log in as a different user. Returns: Dictionary indicating the re-authentication was initiated """ if ctx: await ctx.info("Forcing re-authentication by clearing current token") try: # Clear the current authenticated client invalidate_authenticated_client() if ctx: await ctx.info("Authentication token cleared. Next cart operation will trigger re-authentication.") return { "success": True, "message": "Authentication token cleared. The next cart operation will open your browser for re-authentication.", "note": "You will need to log in again when you next use cart-related tools." } except Exception as e: if ctx: await ctx.error(f"Error clearing authentication: {str(e)}") return { "success": False, "error": str(e) }
- src/kroger_mcp/server.py:76-76 (registration)The registration call for the profile_tools module, which includes the force_reauthenticate tool.profile_tools.register_tools(mcp)
- Helper function used by force_reauthenticate to invalidate (clear) the global authenticated client reference.def invalidate_authenticated_client(): """Invalidate the authenticated client to force re-authentication""" global _authenticated_client _authenticated_client = None