get_current_user
Retrieve the current authenticated user’s profile details, such as display name, email, job title, and department, directly from Microsoft Teams via Microsoft Graph APIs.
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:8-46 (registration)Registers the 'get_current_user' tool using server.tool(). The inline handler fetches the current user's profile from Microsoft Graph API (/me endpoint), extracts relevant fields into UserSummary, and returns as JSON text content. Handles errors by returning error message.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}`, }, ], }; } } );
- src/tools/users.ts:12-46 (handler)Handler function for get_current_user tool: obtains Graph client, calls /me endpoint, maps to UserSummary, returns JSON stringified in text content. Catches and reports errors.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}`, }, ], }; } } );