get_users
Retrieve all user data from Mantis Bug Tracker using brute-force methods for comprehensive user analysis and integration.
Instructions
用暴力法強制取得所有用戶
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:423-443 (handler)Handler function for the 'get_users' tool. It uses a brute-force approach by sequentially fetching users starting from ID 1 via mantisApi.getUser(id) until encountering 10 consecutive 404 errors, then returns the collected users as JSON.async () => { return withMantisConfigured("get_users", async () => { let notFoundCount = 0; let id = 1; let users: User[] = []; do { try { const user = await mantisApi.getUser(id); users.push(user); id++; notFoundCount = 0; // 重置計數器 } catch (error) { if (error instanceof MantisApiError && error.statusCode === 404) { notFoundCount++; id++; } } } while (notFoundCount < 10); return JSON.stringify(users, null, 2); }); }
- src/server.ts:420-444 (registration)Registration of the MCP 'get_users' tool on the McpServer instance, including description, empty input schema, and inline handler."get_users", "用暴力法強制取得所有用戶", {}, async () => { return withMantisConfigured("get_users", async () => { let notFoundCount = 0; let id = 1; let users: User[] = []; do { try { const user = await mantisApi.getUser(id); users.push(user); id++; notFoundCount = 0; // 重置計數器 } catch (error) { if (error instanceof MantisApiError && error.statusCode === 404) { notFoundCount++; id++; } } } while (notFoundCount < 10); return JSON.stringify(users, null, 2); }); } );
- src/services/mantisApi.ts:56-66 (schema)TypeScript interface defining the User type, used for typing the users array returned by the tool.export interface User { id: number; name: string; email: string; real_name?: string; access_level?: { id: number; name: string; }; enabled?: boolean; }
- src/services/mantisApi.ts:262-274 (helper)mantisApi.getUser(userId) helper function that fetches a single user by ID from the Mantis API (with caching), repeatedly called in the tool's brute-force loop.async getUser(userId: number): Promise<User> { log.info('獲取用戶信息', { userId }); if (!userId) { throw new MantisApiError('必須提供用戶 ID'); } const cacheKey = `user-${userId}`; return this.cachedRequest<User>(cacheKey, () => { return this.api.get(`/users/${userId}`); }); }