Skip to main content
Glama

wp_get_current_user

Retrieve the currently authenticated WordPress user's profile, roles, capabilities, and account details to verify permissions and confirm identity.

Instructions

Retrieves the currently authenticated user with comprehensive profile information including roles, capabilities, and account details.

Usage Examples: • Get current user: wp_get_current_user • Check permissions: Use this to verify your current user's capabilities and roles • Account verification: Confirm you're authenticated with the correct account • Profile details: View registration date, email, and user metadata

Input Schema

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

Implementation Reference

  • The handler function that executes the wp_get_current_user tool logic. It fetches the current user from the WordPressClient, extracts and formats key details like roles, capabilities, registration date, and returns a formatted string with user profile information.
    public async handleGetCurrentUser(
      client: WordPressClient,
      params: Record<string, unknown>,
    ): Promise<Record<string, unknown>> {
      try {
        const user = await client.getCurrentUser();
        const siteUrl = client.getSiteUrl();
    
        // Extract meaningful information from capabilities
        const capabilities = user.capabilities || {};
        const keyCapabilities = [
          "edit_posts",
          "edit_pages",
          "publish_posts",
          "publish_pages",
          "delete_posts",
          "delete_pages",
          "manage_categories",
          "manage_options",
          "moderate_comments",
          "upload_files",
          "edit_others_posts",
          "delete_others_posts",
        ];
    
        const userCapabilities = keyCapabilities.filter((cap) => capabilities[cap]).join(", ");
        const totalCapabilities = Object.keys(capabilities).length;
    
        // Format registration date more clearly
        const registrationDate = user.registered_date
          ? new Date(user.registered_date).toLocaleDateString("en-US", {
              year: "numeric",
              month: "long",
              day: "numeric",
            })
          : "Not available";
    
        // Extract role information
        const roles = user.roles || [];
        const primaryRole = roles[0] || "No role assigned";
        const allRoles = roles.length > 1 ? roles.join(", ") : primaryRole;
    
        // Build comprehensive user information
        const content =
          `**Current User Details for ${siteUrl}**\n\n` +
          `- **ID:** ${user.id}\n` +
          `- **Display Name:** ${user.name || "Not set"}\n` +
          `- **Username:** ${user.slug || "Not set"}\n` +
          `- **Email:** ${user.email || "Not set"}\n` +
          `- **User URL:** ${user.url || "Not set"}\n` +
          `- **Nickname:** ${user.nickname || user.name || "Not set"}\n` +
          `- **Description:** ${user.description || "No description provided"}\n` +
          `- **Locale:** ${user.locale || "Default"}\n` +
          `- **Registration Date:** ${registrationDate}\n` +
          `- **Primary Role:** ${primaryRole}\n` +
          `- **All Roles:** ${allRoles}\n` +
          `- **Total Capabilities:** ${totalCapabilities} capabilities\n` +
          `- **Key Capabilities:** ${userCapabilities || "None"}\n` +
          `- **Profile Link:** ${user.link || `${siteUrl}/wp-admin/profile.php`}`;
    
        return { content };
      } catch (_error) {
        throw new Error(`Failed to get current user: ${getErrorMessage(_error)}`);
      }
    }
  • The registration of the wp_get_current_user tool within the UserTools class's getTools() method, defining its name, description, empty parameters, and binding to the handleGetCurrentUser handler.
    {
      name: "wp_get_current_user",
      description:
        "Retrieves the currently authenticated user with comprehensive profile information including roles, capabilities, and account details.\n\n" +
        "**Usage Examples:**\n" +
        "• Get current user: `wp_get_current_user`\n" +
        "• Check permissions: Use this to verify your current user's capabilities and roles\n" +
        "• Account verification: Confirm you're authenticated with the correct account\n" +
        "• Profile details: View registration date, email, and user metadata",
      parameters: [],
      handler: this.handleGetCurrentUser.bind(this),
    },
Behavior3/5

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

With no annotations provided, the description carries the full burden. It clearly indicates this is a read operation ('Retrieves') and specifies what information is returned (profile, roles, capabilities, account details). However, it doesn't mention authentication requirements, error conditions, or rate limits that would be important for a tool accessing user data.

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

Conciseness4/5

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

The description is well-structured with a clear purpose statement followed by bulleted usage examples. Every sentence earns its place by providing specific guidance. It could be slightly more concise by integrating the examples more tightly with the main description.

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

Completeness4/5

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

For a read-only tool with no output schema and no annotations, the description provides good coverage of purpose, usage, and return information. It explains what data is returned (profile, roles, capabilities, account details) which compensates for the missing output schema. The main gap is lack of behavioral details like authentication requirements.

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

Parameters4/5

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

The schema has 100% description coverage for its single optional parameter, so the baseline is 3. The description doesn't mention parameters directly, but the usage examples imply no parameters are needed for basic use ('Get current user: wp_get_current_user'), which adds context about when the optional 'site' parameter is required (only for multi-site configurations).

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

Purpose5/5

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

The description clearly states the specific action ('Retrieves') and resource ('the currently authenticated user') with detailed scope ('comprehensive profile information including roles, capabilities, and account details'). It distinguishes from sibling tools like wp_get_user (which retrieves a specific user) by focusing on the current authenticated user context.

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

Usage Guidelines5/5

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

The description provides explicit usage examples that clarify when to use this tool: for getting current user info, checking permissions, account verification, and viewing profile details. It implicitly distinguishes from alternatives like wp_get_user (which requires a user ID) by focusing on the authenticated context without needing 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

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