Skip to main content
Glama

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
NameRequiredDescriptionDefault
siteNoThe ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured.
methodYesThe new authentication method to use.
usernameNoThe username for 'app-password' or 'basic' authentication.
passwordNoThe Application Password for 'app-password' or password for 'basic' auth.
jwt_tokenNoThe token for 'jwt' authentication.

Implementation Reference

  • 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)}`);
      }
    }
  • 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),
    },

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