Overview

How the WPZylos MCP server turns framework source code into AI-powered code generation.

What is MCP?

The Model Context Protocol (MCP) is an open standard that lets AI editors communicate with external tool servers over a structured JSON-RPC channel. Instead of pasting documentation into chat, the editor discovers tools, resources, and prompts automatically -- and the AI calls them as needed.

WPZylos MCP implements an MCP server that exposes the entire WPZylos framework as a set of callable tools. The AI can inspect packages, read architecture guides, generate code from stubs, and validate the result -- all without the developer writing boilerplate.

Transport

The server uses STDIO transport -- the AI editor launches the server as a child process and communicates via stdin/stdout. No HTTP, no ports, no network configuration.

AI Editor (Cursor / VS Code / Claude Desktop)
    |
    | stdin/stdout (JSON-RPC)
    |
WPZylos MCP Server (Node.js)
    |
    +-- Engine Layer (analysis, stubs, docs)
    |
    +-- WPZYLOS_ROOT (framework source)

Engine Layer

Four core engines power the server:

EngineFilePurpose
Package Registrypackage-registry.tsDiscovers all framework packages from the monorepo. Reads composer.json files, maps namespaces, and builds a searchable package catalog.
File Analyzerfile-analyzer.tsExtracts PHP class structure using regex-based parsing. Pulls class names, methods, properties, constants, docblocks, and type hints without requiring a PHP runtime.
Stub Registrystub-registry.tsCompiles .stub template files with variable substitution. Handles conditionals, loops, and nested stub includes for complex generation.
Docs Indexerdocs-indexer.tsIndexes markdown documentation across all packages. Provides full-text search and section-level retrieval for framework guides.

How They Connect

Framework Source (PHP files)
    |
    v
package-registry.ts --> discovers packages, namespaces
    |
    v
file-analyzer.ts --> extracts classes, methods, types
    |
    v
stub-registry.ts --> compiles stubs with extracted data
    |
    v
Generated Code (PHP, JSON, JS files)

The docs-indexer runs in parallel, feeding framework knowledge into resource queries and prompt context.

Tool Categories

79 tools organized into 10 categories:

CategoryCountToolsPurpose
Core6set_project_target, recommend_package, inspect_package, inspect_class, search_framework, find_patternFramework discovery and inspection
Scaffolding6scaffold_plugin, scaffold_crud_module, scaffold_cpt_module, scaffold_rest_module, scaffold_settings_page, build_from_blueprintFull component scaffolding
Generation16generate_from_stub + 15 shortcuts (generate_provider, generate_model, generate_controller, generate_middleware, generate_migration, generate_seeder, generate_request, generate_policy, generate_event, generate_listener, generate_command, generate_shortcode, generate_widget, generate_hook, generate_view)Individual file generation from stubs
Enhancement7scaffold_ajax_handler, scaffold_cron_job, scaffold_admin_notice, scaffold_custom_table, scaffold_meta_box, scaffold_update_checker, validate_rest_schemaWordPress-specific feature additions
Validation4validate_conventions, validate_security, validate_structure, validate_composerCode quality and correctness checks
Gutenberg8scaffold_block, scaffold_block_pattern, scaffold_block_style, scaffold_block_variation, scaffold_block_category, scaffold_block_template, scaffold_block_widget, scaffold_sidebarBlock editor components
WooCommerce10scaffold_woo_product_type, scaffold_woo_gateway, scaffold_woo_shipping, scaffold_woo_discount, scaffold_woo_email, scaffold_woo_widget, scaffold_woo_tab, scaffold_woo_endpoint, scaffold_woo_status, scaffold_woo_data_storeWooCommerce extension scaffolding
Multisite5scaffold_network_admin, scaffold_site_switcher, scaffold_network_option, scaffold_blog_template, scaffold_network_roleWordPress Multisite support
Niche6scaffold_wp_cli_command, scaffold_test_suite, scaffold_phpstan_config, scaffold_github_actions, scaffold_docker_config, scaffold_release_workflowDevOps and tooling
Advanced5scaffold_plugin, inspect_hook_map, inspect_provider_map, analyze_dependencies, generate_documentationDeep analysis and inspection

Resource Types

16 resources across 5 categories:

TypeDescription
ArchitectureFramework design docs -- service container, lifecycle, provider pattern
StubsTemplate listings and variable reference for all stub files
PackagesPackage catalog with descriptions, dependencies, and namespace maps
GuidesStep-by-step walkthroughs for common tasks (CRUD, REST, settings)
CookbookAPI recipe collection -- "how to register a post type", "how to add a menu page", etc.

Prompts

14 guided prompts that walk the AI through multi-step workflows:

  • Plugin creation -- Full plugin from spec to generated code
  • Module addition -- Add CRUD, CPT, or REST modules to existing plugins
  • Code audit -- Review generated code for conventions, security, structure
  • Migration -- Convert legacy WordPress plugins to WPZylos framework
  • Blueprint -- Build a JSON blueprint and generate everything at once

Knowledge Flow

The MCP does not rely on static documentation alone. It reads the actual framework source code at runtime:

1. AI asks: "What methods does BaseModel expose?"
       |
       v
2. inspect_class("BaseModel")
       |
       v
3. package-registry finds the package containing BaseModel
       |
       v
4. file-analyzer parses the PHP file
       |
       v
5. Returns: class name, namespace, methods (with signatures),
   properties, traits, parent class, interfaces
       |
       v
6. AI uses real data to generate correct code

This means generated code stays accurate even as the framework evolves -- no stale documentation problem.

Next Steps