Skip to main content
Glama

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
NameRequiredDescriptionDefault
userIdYesUser ID or email address

Implementation Reference

  • 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}`,
            },
          ],
        };
      }
    }
  • Input schema for 'get_user' tool: requires 'userId' string parameter.
    {
      userId: z.string().describe("User ID or email address"),
    },
  • 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}`,
              },
            ],
          };
        }
      }
    );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/floriscornel/teams-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server