wp_switch_auth_method
Change authentication methods for WordPress site sessions to use app passwords, basic credentials, or JWT tokens as needed.
Instructions
Switches the authentication method for a site for the current session.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| site | No | The ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured. | |
| method | Yes | The new authentication method to use. | |
| username | No | The username for 'app-password' or 'basic' authentication. | |
| password | No | The Application Password for 'app-password' or password for 'basic' auth. | |
| jwt_token | No | The token for 'jwt' authentication. |
Implementation Reference
- src/tools/auth.ts:148-169 (handler)The handler function that executes the 'wp_switch_auth_method' tool logic. Currently throws an error stating that dynamic authentication method switching is not supported.public async handleSwitchAuthMethod(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> { const { method: _method, username: _username, password: _password, jwt_token: _jwt_token, } = params as { method: AuthMethod; username?: string; password?: string; jwt_token?: string; }; try { // This functionality is not currently supported as the client // doesn't have an updateAuthConfig method throw new Error( "Dynamic authentication method switching is not currently supported. Please update your configuration file and restart the server.", ); } catch (_error) { throw new Error(`Failed to switch auth method: ${getErrorMessage(_error)}`); } }
- src/tools/auth.ts:47-75 (registration)Registers the 'wp_switch_auth_method' tool in the AuthTools.getTools() array, including its name, description, input parameters schema, and handler binding.{ name: "wp_switch_auth_method", description: "Switches the authentication method for a site for the current session.", parameters: [ { name: "method", type: "string", required: true, description: "The new authentication method to use.", enum: ["app-password", "jwt", "basic", "api-key", "cookie"], }, { name: "username", type: "string", description: "The username for 'app-password' or 'basic' authentication.", }, { name: "password", type: "string", description: "The Application Password for 'app-password' or password for 'basic' auth.", }, { name: "jwt_token", type: "string", description: "The token for 'jwt' authentication.", }, ], handler: this.handleSwitchAuthMethod.bind(this), },