get_current_user
Retrieve the authenticated user's Microsoft Teams profile, including display name, email, job title, and department, for identity verification and personalization.
Instructions
Get the current authenticated user's profile information including display name, email, job title, and department.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/users.ts:12-45 (handler)The handler function that executes the get_current_user tool. It retrieves the current authenticated user's profile from the Microsoft Graph API using the /me endpoint, maps it to a UserSummary, stringifies to JSON, and returns as text content. Includes error handling to return an error message if the request fails.async () => { try { const client = await graphService.getClient(); const user = (await client.api("/me").get()) as User; const userSummary: UserSummary = { displayName: user.displayName, userPrincipalName: user.userPrincipalName, mail: user.mail, id: user.id, jobTitle: user.jobTitle, department: user.department, }; 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:11-11 (schema)Empty schema indicating the get_current_user tool requires no input parameters.{},
- src/tools/users.ts:8-46 (registration)Registers the get_current_user tool using server.tool(), providing the tool name, description, schema, and inline handler function.server.tool( "get_current_user", "Get the current authenticated user's profile information including display name, email, job title, and department.", {}, async () => { try { const client = await graphService.getClient(); const user = (await client.api("/me").get()) as User; const userSummary: UserSummary = { displayName: user.displayName, userPrincipalName: user.userPrincipalName, mail: user.mail, id: user.id, jobTitle: user.jobTitle, department: user.department, }; 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}`, }, ], }; } } );