Skip to main content
Glama

wp_list_users

Retrieve and filter WordPress users by role, search term, or activity status to manage site access and permissions.

Instructions

Lists users from a WordPress site with comprehensive filtering and detailed user information including roles, registration dates, and activity status.

Usage Examples: • List all users: wp_list_users • Search users: wp_list_users --search="john" • Filter by role: wp_list_users --roles=["editor","author"] • Find admins: wp_list_users --roles=["administrator"] • Combined search: wp_list_users --search="smith" --roles=["subscriber"]

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoThe ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured.
searchNoLimit results to those matching a search term.
rolesNoLimit results to users with specific roles.

Implementation Reference

  • The main handler function that executes the wp_list_users tool. It fetches users using the WordPressClient, applies streaming for large lists, generates summaries and formatted output with roles, registration dates, and metadata.
    public async handleListUsers(client: WordPressClient, params: UserQueryParams): Promise<unknown> {
      try {
        const users = await client.getUsers(params);
        if (users.length === 0) {
          return "No users found matching the criteria.";
        }
    
        // Use streaming for large user result sets (>30 users)
        if (users.length > 30) {
          const streamResults: StreamingResult<unknown>[] = [];
    
          for await (const result of WordPressDataStreamer.streamUsers(users, {
            includeRoles: true,
            includeCapabilities: false, // Too verbose for large sets
            batchSize: 15,
          })) {
            streamResults.push(result);
          }
    
          return StreamingUtils.formatStreamingResponse(streamResults, "users");
        }
    
        // Enhanced user information with comprehensive details
        const siteUrl = client.getSiteUrl ? client.getSiteUrl() : "Unknown site";
        const userCount = users.length;
        const rolesSummary = users.reduce(
          (acc, u) => {
            const roles = u.roles || [];
            roles.forEach((role) => {
              acc[role] = (acc[role] || 0) + 1;
            });
            return acc;
          },
          {} as Record<string, number>,
        );
    
        const metadata = [
          `👥 **Users Summary**: ${userCount} total users`,
          `🌐 **Source**: ${siteUrl}`,
          `📊 **Roles Distribution**: ${Object.entries(rolesSummary)
            .map(([role, count]) => `${role}: ${count}`)
            .join(", ")}`,
          `📅 **Retrieved**: ${new Date().toLocaleString()}`,
        ];
    
        const content =
          metadata.join("\n") +
          "\n\n" +
          users
            .map((u) => {
              const registrationDate = u.registered_date
                ? new Date(u.registered_date).toLocaleDateString("en-US", {
                    year: "numeric",
                    month: "short",
                    day: "numeric",
                  })
                : "Unknown";
    
              const roles = u.roles?.join(", ") || "No roles";
              const description = u.description || "No description";
              const displayName = u.name || "No display name";
              const userUrl = u.url || "No URL";
    
              return (
                `- **ID ${u.id}**: ${displayName} (@${u.slug})\n` +
                `  📧 Email: ${u.email || "No email"}\n` +
                `  🎭 Roles: ${roles}\n` +
                `  📅 Registered: ${registrationDate}\n` +
                `  🔗 URL: ${userUrl}\n` +
                `  📝 Description: ${description}`
              );
            })
            .join("\n\n");
        return content;
      } catch (_error) {
        throw new Error(`Failed to list users: ${getErrorMessage(_error)}`);
      }
    }
  • The tool definition object specifying the name, description, input parameters schema (search string, roles array), and reference to the handler function.
    {
      name: "wp_list_users",
      description:
        "Lists users from a WordPress site with comprehensive filtering and detailed user information including roles, registration dates, and activity status.\n\n" +
        "**Usage Examples:**\n" +
        "• List all users: `wp_list_users`\n" +
        '• Search users: `wp_list_users --search="john"`\n' +
        '• Filter by role: `wp_list_users --roles=["editor","author"]`\n' +
        '• Find admins: `wp_list_users --roles=["administrator"]`\n' +
        '• Combined search: `wp_list_users --search="smith" --roles=["subscriber"]`',
      parameters: [
        {
          name: "search",
          type: "string",
          description: "Limit results to those matching a search term.",
        },
        {
          name: "roles",
          type: "array",
          items: { type: "string" },
          description: "Limit results to users with specific roles.",
        },
      ],
      handler: this.handleListUsers.bind(this),
  • Generic registration loop in ToolRegistry.registerAllTools() that instantiates UserTools (imported via * as Tools from '@/tools/index.js'), calls getTools() to retrieve the wp_list_users definition, and registers it with the MCP server via registerTool() which adds Zod validation and site selection.
    // Register all tools from the tools directory
    Object.values(Tools).forEach((ToolClass) => {
      let toolInstance: { getTools(): unknown[] };
    
      // Cache and Performance tools need the clients map
      if (ToolClass.name === "CacheTools" || ToolClass.name === "PerformanceTools") {
        toolInstance = new ToolClass(this.wordpressClients);
      } else {
        toolInstance = new (ToolClass as new () => { getTools(): unknown[] })();
      }
    
      const tools = toolInstance.getTools();
    
      tools.forEach((tool: unknown) => {
        this.registerTool(tool as ToolDefinition);
      });
    });
  • src/index.ts:39-40 (registration)
    Calls ToolRegistry.registerAllTools() during server startup after creating the registry, which triggers registration of all tools including wp_list_users.
    private setupTools() {
      this.toolRegistry.registerAllTools();
Behavior2/5

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

With no annotations provided, the description carries full burden but only states it 'lists users with comprehensive filtering and detailed information.' It doesn't disclose behavioral traits like whether this is a read-only operation (implied but not stated), pagination behavior, rate limits, authentication requirements, or what happens with large result sets. For a list tool with no annotations, 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 appropriately sized and front-loaded: the first sentence clearly states the purpose, followed by well-organized usage examples that demonstrate practical applications. Every sentence earns its place by illustrating different parameter combinations.

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

Completeness3/5

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

Given 3 parameters with 100% schema coverage but no annotations and no output schema, the description is adequate for basic usage but incomplete. It doesn't address what the return format looks like (list structure, fields included), pagination, error conditions, or performance considerations for a list operation that could return many users.

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 already fully documents all 3 parameters. The description adds minimal value beyond what's in the schema - it mentions filtering capabilities generally and provides usage examples that illustrate parameter combinations, but doesn't add semantic meaning beyond the schema's parameter descriptions.

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 tool's purpose with specific verb ('Lists') and resource ('users from a WordPress site'), plus it distinguishes from siblings by specifying 'comprehensive filtering and detailed user information' which differentiates it from wp_get_user (singular) and wp_search_site (broader search).

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

Usage Guidelines4/5

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

The description provides clear context through usage examples showing when to use the tool (searching, filtering by role, combined queries), but doesn't explicitly state when NOT to use it or mention alternatives like wp_search_site for broader searches or wp_get_user for single user retrieval.

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