get_user
Retrieve user profile details including name, email, job title, and department using their ID or email address with Teams MCP's integration.
Instructions
Get detailed information about a specific user by their ID or email address. Returns profile information including name, email, job title, and department.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| userId | Yes | User ID or email address |
Implementation Reference
- src/tools/users.ts:112-146 (handler)The core handler function implementing the 'get_user' tool logic. Fetches user profile from Microsoft Graph using the provided userId (supports ID or email), formats as UserSummary, returns JSON stringified text response or error.async ({ userId }) => { try { const client = await graphService.getClient(); const user = (await client.api(`/users/${userId}`).get()) as User; const userSummary: UserSummary = { displayName: user.displayName, userPrincipalName: user.userPrincipalName, mail: user.mail, id: user.id, jobTitle: user.jobTitle, department: user.department, officeLocation: user.officeLocation, }; return { content: [ { type: "text", text: JSON.stringify(userSummary, null, 2), }, ], }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return { content: [ { type: "text", text: `❌ Error: ${errorMessage}`, }, ], }; } }
- src/tools/users.ts:109-111 (schema)Input validation schema for 'get_user' tool using Zod: requires 'userId' as string (User ID or email).{ userId: z.string().describe("User ID or email address"), },
- src/tools/users.ts:106-147 (registration)Registration of the 'get_user' MCP tool within registerUsersTools function, specifying name, description, Zod schema, and inline handler.server.tool( "get_user", "Get detailed information about a specific user by their ID or email address. Returns profile information including name, email, job title, and department.", { userId: z.string().describe("User ID or email address"), }, async ({ userId }) => { try { const client = await graphService.getClient(); const user = (await client.api(`/users/${userId}`).get()) as User; const userSummary: UserSummary = { displayName: user.displayName, userPrincipalName: user.userPrincipalName, mail: user.mail, id: user.id, jobTitle: user.jobTitle, department: user.department, officeLocation: user.officeLocation, }; return { content: [ { type: "text", text: JSON.stringify(userSummary, null, 2), }, ], }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return { content: [ { type: "text", text: `❌ Error: ${errorMessage}`, }, ], }; } } );