Skip to main content
Glama
README.md
# WordPress MCP Server

A production-ready Model Context Protocol (MCP) server for WordPress integration. Enables AI agents to interact with WordPress websites through structured tools.

## Features

- **39 WordPress tools** covering posts, pages, media, users, categories, tags, plugins, themes, menus, and WooCommerce
- **Secure authentication** using WordPress Application Passwords
- **Destructive operation protection** requiring explicit confirmation
- **Structured error handling** with detailed error codes
- **Pagination support** for list operations
- **Environment-based configuration** for credentials

## Prerequisites

- Node.js 18+ 
- WordPress site with REST API enabled
- WordPress Application Password for authentication

## Installation

```bash
npm install
npm run build
```

## Configuration

Create a `.env` file in the project root:

```env
WORDPRESS_URL=https://your-wordpress-site.com
WORDPRESS_USERNAME=your-username
WORDPRESS_APP_PASSWORD=your-application-password
```

### Generating Application Passwords

1. Go to WordPress Admin → Users → Your Profile
2. Scroll to "Application Passwords"
3. Enter a name (e.g., "MCP Server")
4. Click "Add New Application Password"
5. Copy the generated password

## Usage

### Running the Server

```bash
# Development
npm run dev

# Production
npm start
```

### Integration with MCP Clients

Add to your MCP client configuration:

```json
{
  "mcp": {
    "wordpress": {
      "type": "local",
      "command": ["node", "/path/to/wordpress-mcp-server/dist/index.js"],
      "environment": {
        "WORDPRESS_URL": "https://your-site.com",
        "WORDPRESS_USERNAME": "your-username",
        "WORDPRESS_APP_PASSWORD": "your-app-password"
      }
    }
  }
}
```

## Available Tools

### Site Operations
| Tool | Description |
|------|-------------|
| `get_site_info` | Get site name, description, URLs |
| `get_site_settings` | Get site configuration |
| `get_site_health` | Get health diagnostics |
| `get_performance` | Get performance metrics |
| `search_site` | Search content across site |

### Post Operations
| Tool | Description |
|------|-------------|
| `list_posts` | List posts with filtering |
| `get_post` | Get single post by ID |
| `create_post` | Create new post |
| `update_post` | Update existing post |
| `delete_post` | Delete post (requires confirmation) |
| `publish_post` | Publish draft post |

### Page Operations
| Tool | Description |
|------|-------------|
| `list_pages` | List pages with filtering |
| `get_page` | Get single page by ID |
| `create_page` | Create new page |
| `update_page` | Update existing page |
| `delete_page` | Delete page (requires confirmation) |

### Media Operations
| Tool | Description |
|------|-------------|
| `list_media` | List media library items |
| `upload_media` | Upload media file |
| `delete_media` | Delete media (requires confirmation) |

### User Operations
| Tool | Description |
|------|-------------|
| `list_users` | List users with filtering |
| `get_user` | Get single user by ID |
| `create_user` | Create new user |
| `update_user` | Update existing user |

### Taxonomy Operations
| Tool | Description |
|------|-------------|
| `list_categories` | List categories |
| `create_category` | Create new category |
| `list_tags` | List tags |
| `create_tag` | Create new tag |

### Plugin Operations
| Tool | Description |
|------|-------------|
| `list_plugins` | List installed plugins |
| `activate_plugin` | Activate plugin (requires confirmation) |
| `deactivate_plugin` | Deactivate plugin (requires confirmation) |

### Theme Operations
| Tool | Description |
|------|-------------|
| `list_themes` | List installed themes |
| `activate_theme` | Activate theme (requires confirmation) |

### Menu Operations
| Tool | Description |
|------|-------------|
| `get_menus` | Get navigation menus |
| `update_menu` | Update menu |

### WooCommerce Operations
| Tool | Description |
|------|-------------|
| `get_woocommerce_products` | List products |
| `create_woocommerce_product` | Create product |
| `update_woocommerce_product` | Update product |
| `get_woocommerce_orders` | List orders |
| `get_woocommerce_customer` | List customers |

## Security

- Credentials stored in environment variables (never exposed in output)
- Destructive operations require explicit confirmation
- Read-only operations execute automatically
- Authentication for all protected resources

## Development

```bash
# Run in development mode
npm run dev

# Build for production
npm run build

# Run tests
npm test
```

## Project Structure

```
wordpress-mcp-server/
├── src/
│   ├── index.ts          # Entry point
│   ├── server.ts         # MCP server setup
│   ├── client/
│   │   └── wordpress.ts  # WordPress API client
│   ├── tools/
│   │   ├── index.ts      # Tool registration
│   │   ├── definitions.ts # Tool schemas
│   │   ├── site.ts       # Site tools
│   │   ├── posts.ts      # Post tools
│   │   ├── pages.ts      # Page tools
│   │   ├── media.ts      # Media tools
│   │   ├── users.ts      # User tools
│   │   ├── taxonomies.ts # Taxonomy tools
│   │   ├── plugins.ts    # Plugin tools
│   │   ├── themes.ts     # Theme tools
│   │   ├── menus.ts      # Menu tools
│   │   └── woocommerce.ts # WooCommerce tools
│   ├── validation/
│   │   └── schemas.ts    # Zod validation schemas
│   ├── types/
│   │   └── index.ts      # TypeScript type definitions
│   └── utils/
│       ├── config.ts     # Environment configuration
│       └── logger.ts     # Structured logging
├── package.json
├── tsconfig.json
└── .env.example
```

## License

MIT