list_user
Retrieve stored user data and token information from a token store to manage authentication records.
Instructions
List stored users and tokens from a 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) | |
| titlesOnly | No | Return only user titles instead of full token entries |
Implementation Reference
- src/index.ts:901-946 (handler)Handler for the 'list_user' tool. Reads the token store file from the given folder (and optional file), parses tokens, and returns either full entries or just titles based on 'titlesOnly' flag. Handles errors by returning error details.case "list_user": { const folder = String(args?.folder || ''); const file = args?.file ? String(args.file) : undefined; const titlesOnly = Boolean(args?.titlesOnly); if (!folder) { throw new Error("folder is required to read the token store"); } try { const { filePath, tokens } = readTokenStore(folder, file); const result = titlesOnly ? tokens .map((entry) => entry?.user_title_name) .filter((title): title is string => Boolean(title)) : tokens; return { content: [{ type: "text", text: JSON.stringify( { file: filePath, users: result }, null, 2 ) }] }; } catch (error) { return { content: [{ type: "text", text: JSON.stringify( { error: 'Unable to list users from token store', details: error instanceof Error ? error.message : String(error) }, null, 2 ) }] }; } }
- src/index.ts:283-304 (registration)Tool registration for 'list_user' including name, description, and input schema definition in the ListTools response.{ name: "list_user", description: "List stored users and tokens from a 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)" }, titlesOnly: { type: "boolean", description: "Return only user titles instead of full token entries" } }, required: ["folder"] } },
- src/index.ts:286-302 (schema)Input schema for the 'list_user' tool defining parameters: folder (required), optional file, and titlesOnly boolean.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)" }, titlesOnly: { type: "boolean", description: "Return only user titles instead of full token entries" } }, required: ["folder"]
- src/index.ts:343-363 (helper)Helper function called by the list_user handler to resolve the token file path, read its contents, parse JSON, validate array format, and return filePath and tokens.function readTokenStore(folder: string, file?: string): { filePath: string; tokens: any[] } { const filePath = resolveCustomTokenPath(folder, file); if (!existsSync(filePath)) { throw new Error(`Token store not found at ${filePath}`); } try { const raw = readFileSync(filePath, 'utf-8'); const parsed = JSON.parse(raw); if (!Array.isArray(parsed)) { throw new Error(`Token store at ${filePath} is not an array`); } return { filePath, tokens: parsed }; } catch (error) { throw new Error( `Unable to read token store at ${filePath}: ${error instanceof Error ? error.message : String(error)}` ); }