Skip to main content
Glama

wp_get_user

Retrieve a WordPress user by their unique ID to access profile information, manage permissions, or verify account details for site administration tasks.

Instructions

Retrieves a single user by their ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoThe ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured.
idYesThe unique identifier for the user.

Implementation Reference

  • The handler function that executes the wp_get_user tool logic: extracts user ID, fetches user data from WordPressClient, formats details (name, username, email, roles), and returns formatted string or throws error.
    public async handleGetUser(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> { const { id } = params as { id: number }; try { const user = await client.getUser(id); const content = `**User Details (ID: ${user.id})**\n\n` + `- **Name:** ${user.name}\n` + `- **Username:** ${user.slug}\n` + `- **Email:** ${user.email}\n` + `- **Roles:** ${user.roles?.join(", ") || "N/A"}`; return content; } catch (_error) { throw new Error(`Failed to get user: ${getErrorMessage(_error)}`); } }
  • The tool registration within UserTools.getTools(): defines name, description, input parameters schema, and binds to the handleGetUser handler.
    { name: "wp_get_user", description: "Retrieves a single user by their ID.", parameters: [ { name: "id", type: "number", required: true, description: "The unique identifier for the user.", }, ], handler: this.handleGetUser.bind(this), },
  • Input schema definition for the wp_get_user tool: requires a numeric 'id' parameter.
    parameters: [ { name: "id", type: "number", required: true, description: "The unique identifier for the user.", }, ],

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

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