get_user
Retrieve detailed user profile information from Microsoft Teams by providing a user ID or email address. Returns name, email, job title, and department data.
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)Handler for the 'get_user' MCP tool: fetches user profile from Microsoft Graph API using userId (supports ID or email) and returns a UserSummary JSON 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 schema for 'get_user' tool: requires 'userId' string parameter.{ userId: z.string().describe("User ID or email address"), },
- src/tools/users.ts:106-147 (registration)Registration of the 'get_user' tool via server.tool() within registerUsersTools, including 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}`, }, ], }; } } );