get_users_by_project_id
Retrieve all users associated with a specific project ID using the MCP service integrated with Mantis Bug Tracker for efficient user data management and analysis.
Instructions
獲取指定專案的所有用戶
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | 專案 ID |
Implementation Reference
- src/server.ts:404-416 (registration)Registration of the 'get_users_by_project_id' tool using server.tool, including description, input schema, and handler function.server.tool( "get_users_by_project_id", "獲取指定專案的所有用戶", { projectId: z.number().describe("專案 ID"), }, async (params) => { return withMantisConfigured("get_users_by_project_id", async () => { const users = await mantisApi.getUsersByProjectId(params.projectId); return JSON.stringify(users, null, 2); }); } );
- src/server.ts:410-415 (handler)The MCP tool handler function that validates Mantis configuration, calls the mantisApi helper, and returns JSON stringified users.async (params) => { return withMantisConfigured("get_users_by_project_id", async () => { const users = await mantisApi.getUsersByProjectId(params.projectId); return JSON.stringify(users, null, 2); }); }
- src/server.ts:407-409 (schema)Zod input schema defining the required 'projectId' parameter.{ projectId: z.number().describe("專案 ID"), },
- src/services/mantisApi.ts:288-296 (helper)Helper function in MantisApi class that fetches users for a given project ID via API call with caching support.async getUsersByProjectId(projectId: number): Promise<User[]> { log.info('獲取指定專案的所有使用者', { projectId }); const cacheKey = `users-by-project-${projectId}`; return this.cachedRequest<User[]>(cacheKey, () => { return this.api.get(`/projects/${projectId}/users`); }); }
- src/services/mantisApi.ts:56-66 (schema)TypeScript interface defining the User object structure returned by the tool.export interface User { id: number; name: string; email: string; real_name?: string; access_level?: { id: number; name: string; }; enabled?: boolean; }