WordPress MCP Adapter: Making Your Site AI-Agent Ready

Noqta TeamAI Bot
By Noqta Team & AI Bot ·

Loading the Text to Speech Audio Player...

WordPress meets AI Agents. The new MCP Adapter makes your WordPress site agent-ready, allowing AI tools like Cursor and Claude Desktop to discover and execute WordPress "Abilities" directly.

What You Will Learn

In this tutorial, you will:

  • Understand what the WordPress MCP Adapter is and why it matters
  • Install and configure the MCP Adapter on your WordPress site
  • Connect AI agents (Cursor, Claude Desktop) to your WordPress site
  • Explore practical use cases for AI-WordPress integration
  • Implement security best practices for agent access

Prerequisites

Before starting, ensure you have:

  • WordPress 6.4+ installed and running
  • PHP 8.1+ on your server
  • Admin access to your WordPress dashboard
  • Cursor IDE or Claude Desktop (for testing)
  • Basic familiarity with WordPress plugins and REST API

What is the WordPress MCP Adapter?

The WordPress MCP Adapter is a plugin that implements the Model Context Protocol (MCP) for WordPress, allowing AI agents to:

  1. Discover available WordPress capabilities ("Abilities")
  2. Execute actions like creating posts, managing users, or fetching site data
  3. Interact with your site programmatically through a standardized protocol

Why This Matters

Traditional IntegrationWith MCP Adapter
Custom API development for each AI toolSingle standardized protocol
Complex authentication flowsBuilt-in secure handshake
Limited to specific AI providersWorks with any MCP-compatible agent
Manual capability documentationAuto-discovered abilities

The MCP Adapter transforms your WordPress site into an AI-ready platform that any MCP-compatible agent can interact with.


Step 1: Install the WordPress MCP Adapter

Option A: Install via WordPress Plugin Repository

  1. Go to Plugins > Add New in your WordPress admin
  2. Search for "MCP Adapter" or "Model Context Protocol"
  3. Click Install Now then Activate

Option B: Manual Installation

Download and install manually.

# Navigate to your WordPress plugins directory
cd /var/www/html/wp-content/plugins
 
# Clone the MCP Adapter repository
git clone https://github.com/developer-wordpress/mcp-adapter.git
 
# Or download the latest release
wget https://github.com/developer-wordpress/mcp-adapter/releases/latest/download/mcp-adapter.zip
unzip mcp-adapter.zip

Then activate from the WordPress admin panel.


Step 2: Configure the MCP Adapter

Basic Configuration

Navigate to Settings > MCP Adapter in your WordPress admin.

// wp-config.php - Add these constants for MCP configuration
 
// Enable MCP Adapter
define('MCP_ADAPTER_ENABLED', true);
 
// Set the MCP server port (default: 3001)
define('MCP_ADAPTER_PORT', 3001);
 
// Enable debug logging
define('MCP_ADAPTER_DEBUG', false);
 
// Restrict to specific IP addresses (optional)
define('MCP_ADAPTER_ALLOWED_IPS', '127.0.0.1,::1');

Generate API Credentials

  1. Go to Settings > MCP Adapter > API Keys
  2. Click Generate New Key
  3. Name your key (e.g., "Cursor Local Development")
  4. Set permissions (read-only, read-write, or full-admin)
  5. Copy the generated API key securely

Store your API key securely. It provides direct access to your WordPress site through AI agents.


Step 3: Understanding WordPress Abilities

The MCP Adapter exposes WordPress functionality as "Abilities" that AI agents can discover and use.

Core Abilities

{
  "abilities": [
    {
      "name": "get_site_info",
      "description": "Retrieve basic WordPress site information",
      "parameters": {}
    },
    {
      "name": "list_posts",
      "description": "List published posts with optional filters",
      "parameters": {
        "status": "string (publish|draft|pending)",
        "category": "string",
        "limit": "number",
        "offset": "number"
      }
    },
    {
      "name": "create_post",
      "description": "Create a new WordPress post",
      "parameters": {
        "title": "string (required)",
        "content": "string (required)",
        "status": "string",
        "categories": "array",
        "tags": "array"
      }
    },
    {
      "name": "update_post",
      "description": "Update an existing post",
      "parameters": {
        "post_id": "number (required)",
        "title": "string",
        "content": "string",
        "status": "string"
      }
    },
    {
      "name": "manage_media",
      "description": "Upload, list, or delete media files",
      "parameters": {
        "action": "string (upload|list|delete)",
        "file": "base64 string (for upload)",
        "media_id": "number (for delete)"
      }
    }
  ]
}

Custom Abilities

You can register custom abilities for your specific WordPress setup.

// functions.php or custom plugin
 
add_action('mcp_adapter_register_abilities', function($adapter) {
 
    // Register a custom ability
    $adapter->register_ability([
        'name' => 'get_woocommerce_orders',
        'description' => 'Fetch WooCommerce orders with filters',
        'parameters' => [
            'status' => [
                'type' => 'string',
                'description' => 'Order status (pending, processing, completed)',
                'required' => false
            ],
            'date_from' => [
                'type' => 'string',
                'description' => 'Start date (YYYY-MM-DD)',
                'required' => false
            ],
            'limit' => [
                'type' => 'integer',
                'description' => 'Maximum orders to return',
                'default' => 10
            ]
        ],
        'handler' => function($params) {
            // Your custom logic here
            $args = [
                'limit' => $params['limit'] ?? 10,
                'status' => $params['status'] ?? 'any',
            ];
 
            if (!empty($params['date_from'])) {
                $args['date_created'] = '>=' . $params['date_from'];
            }
 
            $orders = wc_get_orders($args);
 
            return array_map(function($order) {
                return [
                    'id' => $order->get_id(),
                    'status' => $order->get_status(),
                    'total' => $order->get_total(),
                    'customer' => $order->get_billing_email(),
                    'date' => $order->get_date_created()->format('Y-m-d H:i:s')
                ];
            }, $orders);
        }
    ]);
});

Step 4: Connect Cursor IDE to WordPress

Cursor is an AI-powered code editor that supports MCP. Here is how to connect it to your WordPress site.

Configure Cursor MCP Settings

Create or edit your Cursor MCP configuration.

// ~/.cursor/mcp.json (macOS/Linux)
// %APPDATA%\Cursor\mcp.json (Windows)
 
{
  "mcpServers": {
    "wordpress-local": {
      "command": "npx",
      "args": [
        "mcp-remote-client",
        "https://your-wordpress-site.com/wp-json/mcp/v1"
      ],
      "env": {
        "MCP_API_KEY": "your-api-key-here"
      }
    }
  }
}

Alternative: Direct HTTP Transport

If your WordPress site supports HTTP transport.

{
  "mcpServers": {
    "wordpress-production": {
      "transport": "http",
      "url": "https://your-wordpress-site.com/wp-json/mcp/v1",
      "headers": {
        "Authorization": "Bearer your-api-key-here"
      }
    }
  }
}

Test the Connection in Cursor

  1. Restart Cursor after saving the configuration
  2. Open the AI chat panel
  3. Ask Cursor to interact with your WordPress site:
"List my recent WordPress posts"
"Create a draft post about AI automation"
"What's my WordPress site name and version?"

Step 5: Connect Claude Desktop to WordPress

Claude Desktop also supports MCP servers. Here is the configuration.

Configure Claude Desktop

Edit your Claude Desktop configuration file.

// macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
// Windows: %APPDATA%\Claude\claude_desktop_config.json
 
{
  "mcpServers": {
    "wordpress": {
      "command": "node",
      "args": [
        "/path/to/mcp-wordpress-client/index.js"
      ],
      "env": {
        "WORDPRESS_URL": "https://your-wordpress-site.com",
        "WORDPRESS_MCP_KEY": "your-api-key-here"
      }
    }
  }
}

Using the Node.js Client

Create a simple MCP client for WordPress.

// mcp-wordpress-client/index.js
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
 
const WORDPRESS_URL = process.env.WORDPRESS_URL;
const API_KEY = process.env.WORDPRESS_MCP_KEY;
 
async function callWordPress(ability, params = {}) {
  const response = await fetch(`${WORDPRESS_URL}/wp-json/mcp/v1/execute`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${API_KEY}`
    },
    body: JSON.stringify({ ability, params })
  });
 
  if (!response.ok) {
    throw new Error(`WordPress API error: ${response.statusText}`);
  }
 
  return response.json();
}
 
const server = new Server(
  { name: "wordpress-mcp-client", version: "1.0.0" },
  { capabilities: { tools: {} } }
);
 
// Dynamically fetch and register WordPress abilities
async function registerAbilities() {
  const abilities = await callWordPress('list_abilities');
 
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
    tools: abilities.map(ability => ({
      name: ability.name,
      description: ability.description,
      inputSchema: {
        type: "object",
        properties: ability.parameters,
        required: ability.required || []
      }
    }))
  }));
 
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
    const result = await callWordPress(request.params.name, request.params.arguments);
    return {
      content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
    };
  });
}
 
async function main() {
  await registerAbilities();
  const transport = new StdioServerTransport();
  await server.connect(transport);
}
 
main().catch(console.error);

Step 6: Practical Use Cases

Use Case 1: Content Management with AI

Ask your AI agent to manage WordPress content.

Agent prompt: "Create a new blog post about our Q1 2026 results.
Title: 'Q1 2026 Performance Review'.
Add it to the 'Company News' category and set it as draft."

The agent will use the create_post ability.

{
  "ability": "create_post",
  "params": {
    "title": "Q1 2026 Performance Review",
    "content": "<!-- AI-generated content here -->",
    "status": "draft",
    "categories": ["company-news"]
  }
}

Use Case 2: Site Monitoring and Reporting

Agent prompt: "Give me a summary of my WordPress site health:
number of posts, active plugins, and recent comments."

The agent combines multiple abilities.

// Agent orchestration
const siteInfo = await callAbility('get_site_info');
const posts = await callAbility('list_posts', { limit: 1000 });
const comments = await callAbility('list_comments', { limit: 10 });
 
return {
  siteName: siteInfo.name,
  totalPosts: posts.length,
  activePlugins: siteInfo.active_plugins.length,
  recentComments: comments
};

Use Case 3: E-commerce Integration (WooCommerce)

Agent prompt: "Show me today's WooCommerce orders and calculate total revenue."
{
  "ability": "get_woocommerce_orders",
  "params": {
    "date_from": "2026-02-05",
    "status": "completed",
    "limit": 100
  }
}

Use Case 4: Automated SEO Optimization

Agent prompt: "Analyze my last 10 posts for SEO issues
and suggest meta description improvements."

The agent fetches posts and analyzes them.

// Custom ability for SEO analysis
$adapter->register_ability([
    'name' => 'analyze_seo',
    'description' => 'Analyze posts for SEO issues',
    'parameters' => [
        'post_ids' => ['type' => 'array', 'required' => true]
    ],
    'handler' => function($params) {
        $results = [];
        foreach ($params['post_ids'] as $post_id) {
            $post = get_post($post_id);
            $meta_desc = get_post_meta($post_id, '_yoast_wpseo_metadesc', true);
 
            $results[] = [
                'post_id' => $post_id,
                'title' => $post->post_title,
                'title_length' => strlen($post->post_title),
                'has_meta_description' => !empty($meta_desc),
                'meta_description' => $meta_desc,
                'word_count' => str_word_count(strip_tags($post->post_content)),
                'issues' => []
            ];
 
            // Check for common SEO issues
            if (strlen($post->post_title) > 60) {
                $results[count($results)-1]['issues'][] = 'Title too long (>60 chars)';
            }
            if (empty($meta_desc)) {
                $results[count($results)-1]['issues'][] = 'Missing meta description';
            }
        }
        return $results;
    }
]);

Step 7: Security Best Practices

1. Use Scoped API Keys

Create different API keys for different purposes.

// In your MCP Adapter settings or code
$read_only_key = mcp_generate_key([
    'name' => 'Read Only - Reporting',
    'permissions' => ['get_site_info', 'list_posts', 'list_comments'],
    'rate_limit' => 100 // requests per minute
]);
 
$content_manager_key = mcp_generate_key([
    'name' => 'Content Manager',
    'permissions' => ['*_post', 'manage_media', 'list_*'],
    'rate_limit' => 50
]);

2. IP Whitelisting

Restrict MCP access to known IPs.

// wp-config.php
define('MCP_ADAPTER_ALLOWED_IPS', implode(',', [
    '127.0.0.1',           // Local development
    '::1',                  // IPv6 localhost
    '203.0.113.50',        // Office IP
    '198.51.100.0/24',     // CI/CD network
]));

3. Audit Logging

Enable comprehensive logging for MCP interactions.

// Enable MCP audit logging
add_action('mcp_adapter_ability_executed', function($ability, $params, $result, $user) {
    $log_entry = [
        'timestamp' => current_time('mysql'),
        'ability' => $ability,
        'params' => json_encode($params),
        'user_agent' => $_SERVER['HTTP_USER_AGENT'] ?? 'unknown',
        'ip_address' => $_SERVER['REMOTE_ADDR'],
        'api_key_name' => $user['key_name'],
        'success' => !is_wp_error($result)
    ];
 
    // Log to custom table or external service
    global $wpdb;
    $wpdb->insert($wpdb->prefix . 'mcp_audit_log', $log_entry);
}, 10, 4);

4. Rate Limiting

Protect against abuse with rate limiting.

// Rate limiting configuration
add_filter('mcp_adapter_rate_limit', function($limit, $api_key) {
    // Different limits for different keys
    $key_limits = [
        'production-key' => 1000,
        'development-key' => 100,
        'default' => 50
    ];
 
    return $key_limits[$api_key['name']] ?? $key_limits['default'];
}, 10, 2);

Troubleshooting

Connection Issues

Problem: Cursor/Claude cannot connect to WordPress

# Test the MCP endpoint directly
curl -X POST https://your-site.com/wp-json/mcp/v1/abilities \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json"
 
# Check for SSL issues
curl -v https://your-site.com/wp-json/mcp/v1/abilities 2>&1 | grep -i ssl

Solution: Ensure:

  • SSL certificate is valid
  • MCP Adapter plugin is activated
  • API key has correct permissions
  • Firewall allows connections

Ability Not Found

Problem: Agent reports "ability not found"

Solution: Check ability registration.

// Debug registered abilities
add_action('init', function() {
    if (defined('WP_DEBUG') && WP_DEBUG) {
        $adapter = MCP_Adapter::get_instance();
        error_log('Registered MCP abilities: ' . print_r($adapter->get_abilities(), true));
    }
});

Performance Issues

Problem: Slow response from WordPress

Solution: Enable caching for read operations.

add_filter('mcp_adapter_cache_ability', function($should_cache, $ability) {
    // Cache read-only abilities
    $cacheable = ['get_site_info', 'list_posts', 'list_categories'];
    return in_array($ability, $cacheable);
}, 10, 2);
 
add_filter('mcp_adapter_cache_ttl', function($ttl, $ability) {
    return $ability === 'get_site_info' ? 3600 : 300; // 1 hour vs 5 minutes
}, 10, 2);

Summary

In this tutorial, you learned how to:

  1. Install the WordPress MCP Adapter plugin
  2. Configure API keys and security settings
  3. Connect Cursor IDE and Claude Desktop to your WordPress site
  4. Use built-in and custom abilities for AI-WordPress interaction
  5. Implement security best practices for production deployments

The WordPress MCP Adapter opens up powerful possibilities for automating content management, monitoring, and integrating AI capabilities directly into your WordPress workflow.


Next Steps


Need help implementing MCP for your WordPress site? Contact Noqta for custom AI integration solutions tailored to your business needs.


Want to read more tutorials? Check out our latest tutorial on Master Structured Data Output with LangChain: Strategies and Techniques for Chat Models.

Discuss Your Project with Us

We're here to help with your web development needs. Schedule a call to discuss your project and how we can assist you.

Let's find the best solutions for your needs.

Related Articles

Introduction to MCP: A Beginner's Quickstart Guide

Get started with the Model Context Protocol (MCP) in 15 minutes. Learn the fundamentals, set up your first MCP server, and connect it to an AI application with step-by-step instructions.

15 min read·