This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
NEVER manually edit files in src/. All PHP code in src/ is auto-generated by the TypeScript generator in generator/.
To fix PHP issues (PHPStan errors, bugs, etc.):
- Modify the generator code in
generator/src/ - Regenerate with
npm run generate(fromgenerator/directory) - Validate with
composer analyse(from root)
This repository contains PHP DTOs for the Model Context Protocol (MCP) specification, distributed as a Composer package. It also includes a TypeScript generator (in generator/) that creates PHP code from the official MCP TypeScript schema.
composer analyse # Run PHPStan static analysis (level max)
composer phpstan # Alias for analysecd generator
npm install # Install dependencies
npm run build # Compile TypeScript
npm run generate # Generate PHP schema to ../src
npm run lint # ESLint
npm run format # Prettiercd generator
npx mcp-php-generator generate -c config/2025-11-25.json
npm run generate:check -- -c config/2025-11-25.json # Generate + PHPStan validationsrc/- Generated PHP DTOs (the Composer package distributed via Packagist)generator/- TypeScript generator (excluded from Packagist via.gitattributes)
Organized by MCP domain with PSR-4 autoloading (WP\McpSchema\ → src/):
Common/- Shared base classes, traits, JSON-RPC, protocol typesServer/- Server-side types (Tools, Resources, Prompts, Logging)Client/- Client-side types (Sampling, Elicitation, Roots, Tasks)
schema.ts → parser/ → extractors/ → generators/ → writers/ → PHP files
fetcher/- Downloads schema from GitHub with cachingparser/- ts-morph AST parsingextractors/- Extract type info, @category tags, inheritancegenerators/- PHP code generation (DTO, Enum, Union, Factory)writers/- File output organized by domain/subdomaincli/- Command-line interface
- PHP 7.4 compatibility (class-based enums, typed properties)
- Uses
@categoryJSDoc tags for domain classification - Generator outputs to
../srcrelative togenerator/directory - PHPStan level max for strictest static analysis