wpnav_list_users
Retrieve and filter WordPress user accounts by role, search term, or pagination to manage site access and permissions.
Instructions
List WordPress users with optional filtering. Returns user ID, username, email, roles, and display name.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Page number for pagination (default: 1) | |
| per_page | No | Number of users to return (default: 10, max: 100) | |
| roles | No | Filter by role: administrator, editor, author, contributor, subscriber | |
| search | No | Search term to filter users by username, email, or display name |
Implementation Reference
- src/tools/users/index.ts:35-44 (handler)Handler function that validates pagination and search parameters, constructs WP REST API query for /wp/v2/users, fetches the users list, and returns formatted JSON response.handler: async (args, context) => { const { page, per_page } = validatePagination(args); const qs = buildQueryString({ page, per_page, roles: args.roles, search: args.search }); const users = await context.wpRequest(`/wp/v2/users?${qs}`); return { content: [{ type: 'text', text: context.clampText(JSON.stringify(users, null, 2)) }], }; },
- src/tools/users/index.ts:24-33 (schema)Input schema defining parameters for pagination, role filtering, and search in wpnav_list_users tool.inputSchema: { type: 'object', properties: { page: { type: 'number', description: 'Page number for pagination (default: 1)' }, per_page: { type: 'number', description: 'Number of users to return (default: 10, max: 100)' }, roles: { type: 'string', description: 'Filter by role: administrator, editor, author, contributor, subscriber' }, search: { type: 'string', description: 'Search term to filter users by username, email, or display name' }, }, required: [], },
- src/tools/users/index.ts:20-46 (registration)Tool registration call that defines name, schema, handler, and category (ToolCategory.USERS) for wpnav_list_users.toolRegistry.register({ definition: { name: 'wpnav_list_users', description: 'List WordPress users with optional filtering. Returns user ID, username, email, roles, and display name.', inputSchema: { type: 'object', properties: { page: { type: 'number', description: 'Page number for pagination (default: 1)' }, per_page: { type: 'number', description: 'Number of users to return (default: 10, max: 100)' }, roles: { type: 'string', description: 'Filter by role: administrator, editor, author, contributor, subscriber' }, search: { type: 'string', description: 'Search term to filter users by username, email, or display name' }, }, required: [], }, }, handler: async (args, context) => { const { page, per_page } = validatePagination(args); const qs = buildQueryString({ page, per_page, roles: args.roles, search: args.search }); const users = await context.wpRequest(`/wp/v2/users?${qs}`); return { content: [{ type: 'text', text: context.clampText(JSON.stringify(users, null, 2)) }], }; }, category: ToolCategory.USERS, });