claudeus-wp-mcp
Version:
The most comprehensive WordPress MCP server - 145 production-ready tools for complete WordPress management with AI
97 lines • 3.02 kB
JavaScript
/**
* WordPress Users API Client
* Handles users, authentication, and application passwords
*/
import { BaseApiClient } from './base-client.js';
export class UsersApiClient extends BaseApiClient {
// ==========================================
// USERS CRUD
// ==========================================
/**
* Get a list of users with pagination metadata
*/
async getUsers(filters) {
return this.getPaginated('/users', filters);
}
/**
* Get a single user by ID
*/
async getUser(id) {
return this.get(`/users/${id}`);
}
/**
* Get the current authenticated user
*/
async getCurrentUser() {
return this.get('/users/me');
}
/**
* Create a new user
*/
async createUser(data) {
return this.post('/users', data);
}
/**
* Update an existing user
*/
async updateUser(id, data) {
return this.put(`/users/${id}`, data);
}
/**
* Delete a user
* @param id User ID
* @param force Whether to bypass trash and force deletion
* @param reassign Reassign the deleted user's posts and links to this user ID
*/
async deleteUser(id, force = false, reassign) {
const params = {};
if (force)
params.force = 'true';
if (reassign !== undefined)
params.reassign = String(reassign);
const queryString = new URLSearchParams(params).toString();
const endpoint = `/users/${id}${queryString ? `?${queryString}` : ''}`;
return this.delete(endpoint);
}
// ==========================================
// APPLICATION PASSWORDS
// ==========================================
/**
* Get all application passwords for a user
*/
async getApplicationPasswords(userId) {
return this.get(`/users/${userId}/application-passwords`);
}
/**
* Create a new application password for a user
*/
async createApplicationPassword(userId, data) {
return this.post(`/users/${userId}/application-passwords`, data);
}
/**
* Get a specific application password
*/
async getApplicationPassword(userId, uuid) {
return this.get(`/users/${userId}/application-passwords/${uuid}`);
}
/**
* Update an application password
*/
async updateApplicationPassword(userId, uuid, data) {
return this.put(`/users/${userId}/application-passwords/${uuid}`, data);
}
/**
* Delete (revoke) an application password
*/
async deleteApplicationPassword(userId, uuid) {
return this.delete(`/users/${userId}/application-passwords/${uuid}`);
}
/**
* Introspect (validate) the current application password
* This endpoint uses the application password in the Authorization header
*/
async introspectApplicationPassword(userId) {
return this.get(`/users/${userId}/application-passwords/introspect`);
}
}
//# sourceMappingURL=users.js.map