Skip to main content
Glama

get_user

Retrieve user details by providing a user ID to access information stored in the Kapiti CMS platform for management purposes.

Instructions

Get user details by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesUser ID

Implementation Reference

  • The handler function that executes the get_user tool logic: fetches user details from the Headlesshost API endpoint `/tools/membership/users/${id}` and returns the JSON response.
    async ({ id }) => {
      try {
        const response: AxiosResponse<ApiResponse<User>> = await apiClient.get(`/tools/membership/users/${id}`);
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(response.data, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: handleApiError(error),
            },
          ],
          isError: true,
        };
      }
    }
  • TypeScript interface defining the User object structure, used in the tool's response typing (ApiResponse<User>).
    interface User {
      id: string;
      email: string;
      firstName: string;
      lastName: string;
      isActive: boolean;
      role?: string;
      createdAt: string;
      updatedAt: string;
    }
  • Zod input schema for the get_user tool, validating the required 'id' parameter as a string.
    inputSchema: {
      id: z.string().describe("User ID"),
    },
  • src/index.ts:342-376 (registration)
    MCP server registration of the 'get_user' tool, specifying name, metadata, input schema, and handler function.
    server.registerTool(
      "get_user",
      {
        title: "Get User",
        description: "Get user details by ID",
        inputSchema: {
          id: z.string().describe("User ID"),
        },
      },
      async ({ id }) => {
        try {
          const response: AxiosResponse<ApiResponse<User>> = await apiClient.get(`/tools/membership/users/${id}`);
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(response.data, null, 2),
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: handleApiError(error),
              },
            ],
            isError: true,
          };
        }
      }
    );
  • Helper function used in the error handling of the get_user tool to format API error messages.
    function handleApiError(error: any): string {
      if (error.response) {
        return `API Error ${error.response.status}: ${error.response.data?.message || error.response.statusText}`;
      } else if (error.request) {
        return "Network Error: Unable to reach API server";
      } else {
        return `Error: ${error.message}`;
      }
    }

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/Headlesshost/mcp-server'

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