Claudeus WordPress MCP

Claudeus WordPress MCP

A Model Context Protocol server for WordPress integration, enabling seamless communication between AI models and WordPress instances.

šŸŽÆ Overview

The Claudeus WordPress MCP serves as a bridge between AI models and WordPress sites, facilitating structured communication and automated interactions while maintaining security and reliability.

šŸ›  Technical Architecture

Core Components

  • TypeScript Foundation: Built with TypeScript for enhanced type safety and developer experience
  • MCP Integration: Implements the Model Context Protocol for standardized AI-WordPress communication
  • WordPress Client: Robust client implementation with authentication support and error handling
  • Express Integration: Optional SSE transport support for real-time communications

Development Stack

TypeScript + Express + Axios ā”œā”€ā”€ src/ # TypeScript source files ā”‚ ā”œā”€ā”€ index.ts # Main entry point ā”‚ ā”œā”€ā”€ types.ts # Type definitions ā”‚ ā””ā”€ā”€ wordpress-client.ts # WordPress API client ā”œā”€ā”€ dist/ # Compiled JavaScript output ā””ā”€ā”€ package.json # Project configuration

Available WordPress API Endpoints

The MCP integrates with the following WordPress REST API endpoints:

Content Management

  • Posts: Full CRUD, revisions, autosaves
  • Pages: Full CRUD, revisions, autosaves
  • Media Library: Upload, edit, post-process
  • Blocks: Full CRUD, revisions, autosaves
  • Comments: Full CRUD, moderation
  • Search functionality
  • Custom Post Types (including Products)
  • Menus and Menu Items
  • Navigation management
  • Sidebars
  • Templates and Template Parts
  • Block Types and Block Renderer

Taxonomy & Categories

  • Categories and Tags
  • Custom Taxonomies
  • Product Categories/Tags
  • Custom Review Tags
  • Pattern Categories

User Management

  • Users CRUD operations
  • Application Passwords
  • User Meta management
  • Authentication
  • Current User operations

System & Settings

  • Site Settings
  • Themes Management
  • Plugin Management
  • Global Styles
  • Font Management

WooCommerce

  • Products management
  • Product Categories/Tags
  • Facebook integration

Performance

  • LiteSpeed Cache (v1 & v3)
  • Performance Settings
  • Cache Controls

Media & Embeds

  • oEmbed Support
  • Media Processing
  • Media Editing

Site Building

  • Elementor Integration
  • Block Editor Support
  • Template Management
  • Global Styles
  • Theme Customization

Batch Operations

  • Multi-request Processing
  • Validation Controls

šŸš€ Getting Started

Prerequisites

  • Node.js 16+
  • TypeScript 5.0+
  • WordPress site with REST API enabled

Installation

# Clone the repository git clone [repository-url] # Install dependencies npm install # Build the project npm run build

Configuration

Create a .env file with your WordPress site configurations:

WP_SITES_PATH=/path/to/sites-config.json PORT=3000 # Optional, for SSE transport

Create a sites-config.json file:

{ "site-alias": { "URL": "https://your-wordpress-site.com", "USER": "username", "PASS": "application-password", "authType": "basic" # or "jwt" } }

Development Commands

npm run build # Build the project npm run watch # Watch mode for development npm run start # Start the server npm run dev # Development mode with auto-restart

šŸŽ¼ TypeScript Architecture

Key Types

interface SiteConfig { url: string; username: string; auth: string; authType: 'basic' | 'jwt'; } interface WordPressSiteResource { id: string; name: string; type: 'wordpress_site'; uri: string; metadata: { url: string; authType: string; }; }

MCP Functions

// Content Management content__get_posts(filters?: PostFilters): Promise<Post[]> content__create_post(data: PostData): Promise<Post> content__update_post(id: number, data: Partial<PostData>): Promise<Post> content__delete_post(id: number): Promise<void> content__get_post_revisions(id: number): Promise<Revision[]> content__get_post_autosaves(id: number): Promise<Autosave[]> content__get_pages(filters?: PageFilters): Promise<Page[]> content__create_page(data: PageData): Promise<Page> content__update_page(id: number, data: Partial<PageData>): Promise<Page> content__delete_page(id: number): Promise<void> content__get_page_revisions(id: number): Promise<Revision[]> content__get_page_autosaves(id: number): Promise<Autosave[]> content__search(query: string, filters?: SearchFilters): Promise<SearchResult[]> // Media Management media__upload(file: File, data?: MediaData): Promise<Media> media__update(id: number, data: Partial<MediaData>): Promise<Media> media__delete(id: number): Promise<void> media__process(id: number, options: ProcessOptions): Promise<Media> media__get_embed(url: string, options?: EmbedOptions): Promise<Embed> // Navigation & Structure nav__get_menus(): Promise<Menu[]> nav__create_menu_item(data: MenuItemData): Promise<MenuItem> nav__update_menu_item(id: number, data: Partial<MenuItemData>): Promise<MenuItem> nav__delete_menu_item(id: number): Promise<void> nav__get_sidebars(): Promise<Sidebar[]> nav__update_sidebar(id: string, data: SidebarData): Promise<Sidebar> nav__get_templates(): Promise<Template[]> nav__update_template(id: string, data: TemplateData): Promise<Template> // Taxonomy Management tax__get_categories(taxonomy?: string): Promise<Category[]> tax__create_category(data: CategoryData): Promise<Category> tax__update_category(id: number, data: Partial<CategoryData>): Promise<Category> tax__delete_category(id: number): Promise<void> tax__get_tags(taxonomy?: string): Promise<Tag[]> tax__create_tag(data: TagData): Promise<Tag> tax__update_tag(id: number, data: Partial<TagData>): Promise<Tag> tax__delete_tag(id: number): Promise<void> // User Management user__get_all(filters?: UserFilters): Promise<User[]> user__create(data: UserData): Promise<User> user__update(id: number, data: Partial<UserData>): Promise<User> user__delete(id: number): Promise<void> user__get_current(): Promise<User> user__create_app_password(userId: number, data: AppPasswordData): Promise<AppPassword> user__delete_app_password(userId: number, uuid: string): Promise<void> // System & Settings system__get_settings(): Promise<Settings> system__update_settings(data: Partial<Settings>): Promise<Settings> system__get_themes(): Promise<Theme[]> system__activate_theme(stylesheet: string): Promise<Theme> system__get_plugins(): Promise<Plugin[]> system__activate_plugin(plugin: string): Promise<Plugin> system__deactivate_plugin(plugin: string): Promise<Plugin> // WooCommerce Integration woo__get_products(filters?: ProductFilters): Promise<Product[]> woo__create_product(data: ProductData): Promise<Product> woo__update_product(id: number, data: Partial<ProductData>): Promise<Product> woo__delete_product(id: number): Promise<void> woo__sync_facebook(productId: number): Promise<void> woo__get_facebook_status(productId: number): Promise<FacebookSyncStatus> // Performance & Cache perf__purge_cache(type?: CacheType): Promise<void> perf__get_cache_status(): Promise<CacheStatus> perf__update_cache_settings(data: CacheSettings): Promise<CacheSettings> // Block Editor block__get_all(): Promise<Block[]> block__create(data: BlockData): Promise<Block> block__update(id: number, data: Partial<BlockData>): Promise<Block> block__delete(id: number): Promise<void> block__render(name: string, attributes: object): Promise<string> // Batch Operations batch__process(requests: BatchRequest[]): Promise<BatchResponse[]> batch__validate(requests: BatchRequest[]): Promise<ValidationResult[]>

Each function includes:

  • Full TypeScript type safety
  • Automatic authentication handling
  • Error handling with custom types
  • Rate limiting support
  • Comprehensive documentation
  • Filtering and pagination where applicable

šŸ”’ Security Considerations

  • Secure authentication handling
  • Environment variable management
  • Request validation and sanitization
  • Rate limiting capabilities
  • Error message sanitization

šŸŽø Developer Notes

The architecture follows the principles of:

  • Clean Architecture
  • Type Safety
  • Error Resilience
  • Extensibility

The codebase is structured to allow easy addition of new WordPress APIs and MCP tools while maintaining type safety and code quality.

šŸ¤˜ Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

šŸ“œ License

MIT License - Rock on! šŸŽø