VOOZH about

URL: https://deepwiki.com/WordPress/mcp-adapter/8.1-composer-configuration

⇱ Composer Configuration | WordPress/mcp-adapter | DeepWiki


Loading...
Menu

Composer Configuration

This document details the composer.json configuration for the MCP Adapter package, including dependency management, autoloading setup, and development tooling integration. For installation instructions and usage examples, see Installation.

Package Definition

The MCP Adapter is defined as a Composer library package that can be required by WordPress plugins or themes. The package metadata establishes its identity in the Composer ecosystem.


Sources: composer.json2-4

Package Metadata

FieldValuePurpose
namewordpress/mcp-adapterPackage identifier in Packagist
typelibraryIndicates this is a reusable library, not a standalone application
licenseGPL-2.0-or-laterGPL v2+ license for WordPress compatibility
homepagehttps://github.com/wordpress/mcp-adapterSource repository location

Sources: composer.json2-26

Keywords and Discoverability

The package uses targeted keywords for discoverability in package registries:

  • wordpress - WordPress ecosystem integration
  • mcp / model-context-protocol - Protocol implementation
  • abilities-api - WordPress Abilities API integration
  • adapter / integration - Architectural role
  • ai - AI agent functionality

Sources: composer.json6-15

Stability Configuration

The stability configuration controls which package versions Composer considers during dependency resolution:






















SettingValueEffect
minimum-stabilitydevAllows dev, alpha, beta, RC, and stable versions
prefer-stabletruePrioritizes stable releases when available

This combination allows installation of development versions when necessary (e.g., unreleased WordPress Abilities API) while preferring stable releases when they exist.

Sources: composer.json27-28

Platform and Build Configuration

Platform Targeting

The platform configuration enforces PHP 7.4 compatibility for dependency resolution:


This ensures dependencies are resolved as if running on PHP 7.4, even when using newer PHP versions for development. This prevents inadvertently requiring dependencies that need PHP 8.0+.

Sources: composer.json29-32

Optimization Settings

SettingValuePurpose
sort-packagestrueMaintains alphabetical ordering in composer.json
optimize-autoloadertrueGenerates optimized class maps for production
preferred-installdistDownloads distributions (zip/tar) instead of cloning repositories

Sources: composer.json33-35

Allowed Plugins

Composer plugins require explicit permission. The MCP Adapter allows these plugins:



























PluginPurpose
automattic/jetpack-autoloaderVersion conflict resolution for shared dependencies
composer/installersCustom installation paths for WordPress plugins/themes
dealerdirect/phpcodesniffer-composer-installerAutomatic PHPCS standards registration
phpstan/extension-installerAutomatic PHPStan extension loading

Sources: composer.json36-41

Repository Configuration

The package uses Wpackagist to access WordPress plugins via Composer:


This allows requiring WordPress plugins like wpackagist-plugin/plugin-check as Composer dependencies for development tooling.

Sources: composer.json43-52

Autoloading Configuration

PSR-4 Namespace Mapping

The MCP Adapter uses PSR-4 autoloading to map the WP\MCP namespace to the includes/ directory:

Autoload Structure Diagram


Sources: composer.json60-64

Production Autoload


This maps any class with namespace WP\MCP\* to a file under includes/. For example:

  • WP\MCP\Core\McpAdapterincludes/Core/McpAdapter.php
  • WP\MCP\Transport\HttpTransportincludes/Transport/HttpTransport.php

Sources: composer.json60-64

Development Autoload


Test classes use the WP\MCP\Tests namespace mapped to the tests/ directory. This is only loaded in development environments when running tests.

Sources: composer.json65-71

Jetpack Autoloader Integration

When multiple plugins use the MCP Adapter, the Jetpack Autoloader prevents version conflicts by loading the newest version of shared classes.

Jetpack Autoloader Usage Flow


Sources: docs/getting-started/installation.md15-41

Benefits of Jetpack Autoloader

BenefitDescription
Version Conflict ResolutionAutomatically loads the newest version of shared classes
Plugin CompatibilityMultiple plugins can require different versions of MCP Adapter
WordPress OptimizationDesigned specifically for WordPress plugin ecosystems
Automatic ManagementNo manual class version tracking required

To use Jetpack Autoloader:

  1. Require it as a dependency:

    
    
  2. Load via autoload_packages.php instead of autoload.php:

    
    

Sources: docs/getting-started/installation.md15-41

Dependencies

Required Dependencies

The package has minimal runtime requirements:

















DependencyVersion ConstraintRationale
php^7.4 || ^8.0Supports PHP 7.4 through 8.4, matching WordPress minimum requirements

The WordPress Abilities API is a runtime dependency but is not listed in composer.json because it's expected to be provided by the WordPress environment (either as a plugin or in core).

Sources: composer.json72-74

Development Dependencies

The package includes extensive development tooling:

Development Dependency Categories


Sources: composer.json75-90

Development Dependencies Table

CategoryPackageVersionPurpose
Coding Standardsautomattic/vipwpcs^3.0WordPress VIP coding standards
slevomat/coding-standard^8.0Strict PHP coding standards
phpcompatibility/php-compatibility10.x-devPHP cross-version compatibility checks
phpcompatibility/phpcompatibility-wp^2.1WordPress-specific compatibility
Static Analysisphpstan/phpstan^2.1.22Static analysis engine
phpstan/extension-installer^1.3Automatic extension loading
phpstan/phpstan-deprecation-rules^2.0.3Deprecation warnings
szepeviktor/phpstan-wordpress^2.0WordPress-specific type definitions
Testingphpunit/phpunit^9.6Unit test framework
wp-phpunit/wp-phpunit^6.5WordPress test suite integration
yoast/phpunit-polyfills^4.0PHPUnit version compatibility
Type Stubsphp-stubs/wp-cli-stubs^2.12WP-CLI type definitions for StdioServerBridge
phpstan/php-8-stubs^0.4.24PHP 8 function stubs for PHP 7.4 analysis
WordPress Toolswpackagist-plugin/plugin-check^1.6WordPress plugin validation tool

Sources: composer.json75-90

Custom Installer Paths

The package configures custom installation paths for specific dependencies:


This ensures the plugin-check WordPress plugin is installed to a custom location where it can be accessed for plugin validation during development.

Sources: composer.json53-59

Composer Scripts

The package defines scripts for common development tasks:

Script Command Mapping


Sources: composer.json91-96

Available Scripts

ScriptCommandPurpose
lint:phpphpcsCheck PHP code against WordPress coding standards
lint:php:fixphpcbfAutomatically fix coding standard violations
lint:php:stanvendor/bin/phpstan analyse --memory-limit=1GRun PHPStan static analysis with 1GB memory limit
testphpunit --strict-coverageRun PHPUnit tests with strict coverage enforcement

These scripts can be executed via:


For CI/CD integration details, see CI/CD Pipeline. For PHPStan configuration specifics, see PHPStan Configuration.

Sources: composer.json91-96

Integration with Development Tools

PHPStan Integration

The composer.json platform configuration works in conjunction with PHPStan configuration for cross-version analysis:


This ensures dependencies are resolved for PHP 7.4, while PHPStan is configured to analyze code for PHP 7.4–8.4 compatibility via phpstan.neon.dist. See PHPStan Configuration for the full analysis configuration.

Sources: composer.json30-32 phpstan.neon.dist17-19

WordPress Plugin Check

The wpackagist-plugin/plugin-check dependency enables validation of the MCP Adapter against WordPress plugin standards:


This tool checks for:

  • Plugin header requirements
  • File structure standards
  • Security best practices
  • WordPress coding standards compliance

Sources: composer.json88 composer.json54-58