get_users
Find Jira users by name or email. Optionally filter by project access and set maximum results.
Instructions
Search for users in Jira
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No | Search query for user name or email | |
| projectKey | No | Filter users by project access | |
| maxResults | No | Maximum number of users to return (1-100) |
Implementation Reference
- src/tools/assignments.ts:62-131 (handler)The handleAssignmentTool function contains the 'get_users' case (lines 81-102) that validates args using getUsersSchema, calls jiraClient.getUsers(), maps results to essential fields, and returns JSON-stringified user data.
export async function handleAssignmentTool( name: string, args: Record<string, unknown>, jiraClient: JiraClient ) { switch (name) { case 'assign_issue': { const validatedArgs = await assignIssueSchema.validate(args); const _result = await jiraClient.assignIssue(validatedArgs); return { content: [ { type: 'text', text: `Issue ${validatedArgs.issueKey} assigned successfully`, }, ], }; } case 'get_users': { const validatedArgs = await getUsersSchema.validate(args); const users = await jiraClient.getUsers(validatedArgs); // Extract essential fields, improve syntax const essentialUsers = users.map((user) => ({ id: user.accountId, // Shorter field name name: user.displayName, // Shorter field name email: user.emailAddress, // Shorter field name active: user.active, type: user.accountType // Shorter field name })); return { content: [ { type: 'text', text: JSON.stringify(essentialUsers, null, 2), }, ], }; } case 'get_current_user': { const user = await jiraClient.getCurrentUser(); // Extract essential fields, improve syntax const userData = user; const essentialUser = { id: userData.accountId, // Shorter field name name: userData.displayName, // Shorter field name email: userData.emailAddress, // Shorter field name active: userData.active, timezone: userData.timeZone, // Shorter field name type: userData.accountType // Shorter field name }; return { content: [ { type: 'text', text: JSON.stringify(essentialUser, null, 2), }, ], }; } default: throw new Error(`Unknown assignment tool: ${name}`); } } - src/tools/assignments.ts:29-60 (registration)The tool 'get_users' is registered as an MCP tool with name 'get_users', description 'Search for users in Jira', and inputSchema defining query, projectKey, and maxResults parameters.
{ name: 'get_users', description: 'Search for users in Jira', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query for user name or email', }, projectKey: { type: 'string', description: 'Filter users by project access', }, maxResults: { type: 'number', description: 'Maximum number of users to return (1-100)', default: 50, }, }, }, }, { name: 'get_current_user', description: 'Get information about the current authenticated user', inputSchema: { type: 'object', properties: {}, }, }, ]; } - src/schemas/index.ts:126-130 (schema)The getUsersSchema Yup validation schema defines optional 'query' (string), optional 'projectKey' (string), and 'maxResults' (number, min 1, max 100, default 50).
export const getUsersSchema = yup.object({ query: yup.string().optional(), projectKey: yup.string().optional(), maxResults: yup.number().min(1).max(100).default(50), }); - src/schemas/index.ts:251-251 (schema)The GetUsersInput TypeScript type is inferred from the getUsersSchema.
export type GetUsersInput = yup.InferType<typeof getUsersSchema>; - src/jira-client.ts:418-428 (helper)The JiraClient.getUsers() method calls the Jira API's userSearch.findUsers() with query and maxResults from the validated input, returning the raw response.
async getUsers(input: GetUsersInput) { try { const response = await this.jira.userSearch.findUsers({ query: input.query, maxResults: input.maxResults, }); return response; } catch (error) { throw new Error(`Failed to get users: ${error instanceof Error ? error.message : 'Unknown error'}`); } } - src/index.ts:90-95 (registration)In the main server's CallToolRequestSchema handler, tools starting with 'get_users' are routed to handleAssignmentTool.
} else if ( name.startsWith('assign_issue') || name.startsWith('get_users') || name.startsWith('get_current_user') ) { return await handleAssignmentTool(name, args || {}, this.jiraClient);