Skip to main content
Glama

get-user

Retrieve WordPress user details by ID using secure REST API integration. Provide site URL, credentials, and user ID to access user information under specified context (view, embed, edit).

Instructions

Get a specific user by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextNoScope under which the request is madeview
passwordYesWordPress application password
siteUrlYesWordPress site URL
userIdYesUser ID or 'me' for current user
usernameYesWordPress username

Implementation Reference

  • Handler function that retrieves a specific WordPress user by ID using the WP REST API via makeWPRequest and returns formatted user details.
      async ({ siteUrl, username, password, userId, context }) => {
        try {
          const user = await makeWPRequest<WPUser>({
            siteUrl,
            endpoint: `users/${userId}`,
            auth: { username, password },
            params: { context }
          });
          
          return {
            content: [
              {
                type: "text",
                text: `User Details:\nID: ${user.id}\nName: ${user.name || "No name"}\nSlug: ${user.slug || "No slug"}\nRoles: ${user.roles?.join(', ') || "No roles"}`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error retrieving user: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • Zod input schema defining parameters for the get-user tool: siteUrl, credentials, userId (supports 'me'), and optional context.
    {
      siteUrl: z.string().url().describe("WordPress site URL"),
      username: z.string().describe("WordPress username"),
      password: z.string().describe("WordPress application password"),
      userId: z.union([z.string(), z.number(), z.literal("me")]).describe("User ID or 'me' for current user"),
      context: z.enum(["view", "embed", "edit"]).optional().default("view").describe("Scope under which the request is made"),
    },
  • src/index.ts:301-339 (registration)
    Registration of the 'get-user' tool on the MCP server, including name, description, input schema, and handler function.
    server.tool(
      "get-user",
      "Get a specific user by ID",
      {
        siteUrl: z.string().url().describe("WordPress site URL"),
        username: z.string().describe("WordPress username"),
        password: z.string().describe("WordPress application password"),
        userId: z.union([z.string(), z.number(), z.literal("me")]).describe("User ID or 'me' for current user"),
        context: z.enum(["view", "embed", "edit"]).optional().default("view").describe("Scope under which the request is made"),
      },
      async ({ siteUrl, username, password, userId, context }) => {
        try {
          const user = await makeWPRequest<WPUser>({
            siteUrl,
            endpoint: `users/${userId}`,
            auth: { username, password },
            params: { context }
          });
          
          return {
            content: [
              {
                type: "text",
                text: `User Details:\nID: ${user.id}\nName: ${user.name || "No name"}\nSlug: ${user.slug || "No slug"}\nRoles: ${user.roles?.join(', ') || "No roles"}`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error retrieving user: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • TypeScript interface defining the structure of a WordPress user object used in the get-user tool response.
    interface WPUser {
      id: number;
      name?: string;
      slug?: string;
      roles?: string[];
    }
  • Helper function makeWPRequest used by get-user to make authenticated HTTP requests to WordPress REST API endpoints.
    async function makeWPRequest<T>({
      siteUrl, 
      endpoint,
      method = 'GET',
      auth,
      data = null,
      params = null
    }: {
      siteUrl: string;
      endpoint: string;
      method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
      auth: { username: string; password: string };
      data?: any;
      params?: any;
    }): Promise<T> {
      const authString = Buffer.from(`${auth.username}:${auth.password}`).toString('base64');
      
      try {
        const response = await axios({
          method,
          url: `${siteUrl}/wp-json/wp/v2/${endpoint}`,
          headers: {
            'Authorization': `Basic ${authString}`,
            'Content-Type': 'application/json',
          },
          data: data,
          params: params
        });
        
        return response.data as T;
      } catch (error) {
        if (axios.isAxiosError(error) && error.response) {
          throw new Error(`WordPress API error: ${error.response.data?.message || error.message}`);
        }
        throw error;
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states it 'gets' a user, implying a read operation, but doesn't disclose behavioral traits like authentication requirements (implied by parameters but not explicit), rate limits, error conditions, or what happens with invalid IDs. For a tool with 5 parameters and no annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose. There's zero waste or redundancy, making it highly concise and well-structured for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has 5 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain the return values, authentication requirements, or how parameters interact (e.g., 'userId' with 'me' option). For a user retrieval tool in a WordPress context with multiple siblings, more context is needed to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all 5 parameters. The description adds no parameter-specific meaning beyond implying 'userId' is the key input. This meets the baseline of 3 where the schema does the heavy lifting, but the description doesn't compensate with additional context like explaining the 'context' enum or authentication flow.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('a specific user by ID'), making the purpose unambiguous. However, it doesn't differentiate from sibling tools like 'get-users' (plural) which likely retrieves multiple users, so it misses full sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get-users' for listing users or 'update-user' for modifications, nor does it specify prerequisites or contextual constraints beyond what's implied by the parameters.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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

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