wordpress-rest-mcp

dmvai/wordpress-rest-mcp

3.1

If you are the rightful owner of wordpress-rest-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

A comprehensive Model Context Protocol (MCP) server for WordPress REST API with multi-site support, providing 15 specialized tools for WordPress content management, media handling, and internal linking.

Tools
15
Resources
0
Prompts
0

🚀 WordPress MCP Server

A comprehensive Model Context Protocol (MCP) server for WordPress REST API with multi-site support, providing 15 specialized tools for WordPress content management, media handling, and internal linking.

🌟 Overview

This MCP server integrates with WordPress sites through the REST API to provide powerful content management capabilities through Claude Code. It supports multiple WordPress sites with individual authentication and offers comprehensive WordPress operations.

✨ Key Features

  • 15 Specialized Tools across 5 main categories
  • Multi-Site Support - Manage multiple WordPress installations
  • JSON-Only Credentials - Organized credential management
  • Internal Linking Tools - Create and manage internal links
  • Media Management - Upload and manage media files
  • Complete Content Management - Posts, pages, and site operations
  • TypeScript Implementation - Type safety and better development experience
  • Rate Limiting - Built-in request throttling
  • WordPress Application Password Support - Secure authentication

🛠️ Available Tools

📝 Posts Management (5 tools)

ToolDescriptionKey Parameters
wp_list_postsList posts with filters and paginationsite, per_page, search, status, categories, tags
wp_create_postCreate new postssite, title, content, status, categories, tags, featured_media
wp_update_postUpdate existing postssite, id, title, content, status, etc.
wp_delete_postDelete postssite, id, force
wp_get_postGet single post by ID or slugsite, id, slug, context

📄 Pages Management (3 tools)

ToolDescriptionKey Parameters
wp_list_pagesList pages with hierarchysite, per_page, search, parent, status
wp_create_pageCreate new pagessite, title, content, parent, menu_order
wp_get_pageGet single page by ID or slugsite, id, slug, context

🖼️ Media Management (3 tools)

ToolDescriptionKey Parameters
wp_upload_mediaUpload files to media librarysite, filename, content (base64), title, alt_text
wp_list_mediaList media librarysite, per_page, media_type, mime_type, search
wp_get_media_urlGet media URLs for embeddingsite, id, size

🔗 Internal Linking (2 tools)

ToolDescriptionKey Parameters
wp_create_internal_linkCreate links between posts/pagessite, fromPost, toPost/toSlug, anchorText, position
wp_update_links_in_postBatch update multiple linkssite, postId, links array

ℹ️ Site Information (2 tools)

ToolDescriptionKey Parameters
wp_get_site_infoGet site metadata and settingssite
wp_search_contentSearch content for linking opportunitiessite, keywords, post_type, limit, context_length

📦 Installation

Prerequisites

  • Node.js 18+
  • Claude Code CLI
  • WordPress sites with REST API enabled (WordPress 4.7+)
  • WordPress Application Passwords configured

Setup

  1. Navigate to the server directory:

    cd servers/wordpress-rest-mcp
    
  2. Install dependencies:

    npm install
    
  3. Build the server:

    npm run build
    

🔐 Configuration

Multi-Site Credentials

Create your credential file:

cp ../../.credentials/wordpress/sites.json.example \
  ../../.credentials/wordpress/sites.json

Edit the file with your WordPress sites:

{
  "sites": {
    "blog": {
      "url": "https://mainblog.com",
      "username": "admin",
      "password": "your-application-password"
    },
    "shop": {
      "url": "https://shop.example.com",
      "username": "shop_admin",
      "password": "shop-application-password"
    },
    "docs": {
      "url": "https://docs.example.com",
      "username": "docs_admin",
      "password": "docs-application-password"
    }
  },
  "default": "blog"
}

WordPress Application Passwords

  1. Go to your WordPress admin dashboard
  2. Navigate to Users > Profile
  3. Scroll to Application Passwords section
  4. Create a new application password
  5. Copy the generated password (format: xxxx xxxx xxxx xxxx)
  6. Use this password in your sites.json file

MCP Configuration

Add to your Claude Code MCP configuration:

{
  "mcpServers": {
    "wordpress": {
      "command": "node",
      "args": [
        "<project-root>/servers/wordpress-rest-mcp/dist/index.js"
      ],
      "cwd": "<project-root>/servers/wordpress-rest-mcp"
    }
  }
}

🚀 Usage Examples

Basic Operations

// List recent posts from default site
wp_list_posts({ per_page: 10, status: "publish" })

// Create a new post on the "blog" site
wp_create_post({
  site: "blog",
  title: "My New Post",
  content: "This is the post content...",
  status: "publish"
})

// Upload an image to the "shop" site
wp_upload_media({
  site: "shop",
  filename: "product.jpg",
  content: "base64-encoded-image-data",
  title: "Product Image"
})

Internal Linking

// Create internal link between posts
wp_create_internal_link({
  site: "blog",
  fromPost: 123,
  toPost: 456,
  anchorText: "Related Article",
  position: "after_paragraph_2"
})

// Search for content to link to
wp_search_content({
  site: "blog",
  keywords: "WordPress tutorial",
  post_type: "post",
  limit: 5
})

Multi-Site Management

// Get info from different sites
wp_get_site_info({ site: "blog" })    // Main blog
wp_get_site_info({ site: "shop" })    // Shop site
wp_get_site_info({ site: "docs" })    // Documentation

// Create posts on specific sites
wp_create_post({ site: "blog", title: "Blog Post", ... })
wp_create_post({ site: "shop", title: "Product Page", ... })

🔧 Development

Running in Development

npm run dev

Building

npm run build

Testing

npm run start

📁 Project Structure

servers/wordpress-rest-mcp/
├── README.md                 # This file
├── PLAN.md                   # Implementation plan
├── package.json              # Dependencies
├── tsconfig.json             # TypeScript config
├── src/
│   ├── index.ts              # Main MCP server
│   ├── handlers/
│   │   ├── base.ts           # Base handler class
│   │   ├── posts.ts          # Posts management
│   │   ├── pages.ts          # Pages management
│   │   ├── media.ts          # Media management
│   │   ├── links.ts          # Internal linking
│   │   └── site.ts           # Site information
│   └── types/
│       └── index.ts          # WordPress types
└── dist/                     # Compiled JavaScript

🔒 Security Notes

  • Never commit credential files - The .credentials/ directory is gitignored
  • Use Application Passwords only - Never use regular WordPress passwords
  • Limit user permissions - Use WordPress users with appropriate role permissions
  • HTTPS only - Always use HTTPS URLs for WordPress sites

🐛 Troubleshooting

Common Issues

  1. Credentials not found

    • Ensure sites.json exists in .credentials/wordpress/
    • Check file permissions and JSON syntax
  2. Authentication failed

    • Verify Application Passwords are correctly generated
    • Check username and site URL are correct
    • Ensure user has appropriate permissions
  3. Site not found

    • Check site alias in sites.json
    • Verify the default site is set correctly
  4. WordPress API errors

    • Ensure WordPress REST API is enabled
    • Check WordPress version (4.7+ required)
    • Verify SSL certificates are valid

Debug Mode

Set DEBUG=1 to enable verbose logging:

DEBUG=1 npm run start

📄 License

This WordPress MCP server is part of the Claude MCP Servers project.