clear_user
Remove specific users or clear all authentication tokens from storage to manage access control and maintain security.
Instructions
Remove a specific user or clear the token store
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| folder | Yes | Folder where the token file is stored | |
| file | No | Optional token file name (default: tokens.json) | |
| user_title | No | Specific user title to remove. If omitted, all users are removed. | |
| preserveDefault | No | When clearing all users, keep the 'default' user entry if it exists |
Implementation Reference
- src/index.ts:948-1014 (handler)The handler for the 'clear_user' tool in the CallToolRequestSchema switch statement. It reads the token store from the specified folder/file, removes the specified user_title or clears all (optionally preserving 'default'), updates the file, and returns the result or error.case "clear_user": { const folder = String(args?.folder || ''); const file = args?.file ? String(args.file) : undefined; const userTitle = args?.user_title ? String(args.user_title) : undefined; const preserveDefault = Boolean(args?.preserveDefault); if (!folder) { throw new Error("folder is required to clear users from the token store"); } try { const { filePath, tokens } = readTokenStore(folder, file); let updatedTokens = tokens; let message: string | undefined; if (userTitle) { const remaining = tokens.filter((entry) => entry?.user_title_name !== userTitle); const removedCount = tokens.length - remaining.length; if (removedCount === 0) { message = `No entry found for user_title '${userTitle}' in ${filePath}`; } updatedTokens = remaining; } else { updatedTokens = preserveDefault ? tokens.filter((entry) => entry?.user_title_name === 'default') : []; if (preserveDefault && tokens.some((entry) => entry?.user_title_name === 'default')) { message = `Cleared all users except default from ${filePath}`; } } writeTokenStore(filePath, folder, updatedTokens); const responsePayload = { file: filePath, users: updatedTokens, message: message || (userTitle ? `Removed user '${userTitle}' from ${filePath}` : `Cleared token store at ${filePath}`) }; return { content: [{ type: "text", text: JSON.stringify(responsePayload, null, 2) }] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: JSON.stringify( { error: 'Unable to clear user(s) from token store', details: errorMessage }, null, 2 ) }] }; } }
- src/index.ts:305-330 (schema)The input schema definition for the 'clear_user' tool, returned in the ListTools response. Defines parameters: folder (required), file, user_title, preserveDefault.{ name: "clear_user", description: "Remove a specific user or clear the token store", inputSchema: { type: "object", properties: { folder: { type: "string", description: "Folder where the token file is stored" }, file: { type: "string", description: "Optional token file name (default: tokens.json)" }, user_title: { type: "string", description: "Specific user title to remove. If omitted, all users are removed." }, preserveDefault: { type: "boolean", description: "When clearing all users, keep the 'default' user entry if it exists" } }, required: ["folder"] } }