Generate a complete PHP Model Context Protocol server project with tools, resources, prompts, tests, and Claude Desktop configuration using the official PHP SDK. Use this skill when the user asks for a PHP MCP server, PHP SDK MCP project, stdio or HTTP MCP transport, tool/resource/prompt scaffolding, or production-ready MCP server requirements.
Generate a production-ready PHP MCP server by collecting project requirements, reading the bundled implementation reference, then producing a Composer project with typed tools, optional resources and prompts, tests, runnable stdio or HTTP transport configuration, and clear tools/resources boundaries.
When to invoke
"Generate a PHP MCP server."
"Create a complete MCP server project using the PHP SDK."
"Scaffold MCP tools, resources, prompts, and tests in PHP."
"Build a stdio or HTTP PHP MCP server for Claude Desktop."
"I need project requirements for a PHP MCP server."
Prerequisites and context
PHP 8.2 or higher is required.
Composer is required for dependency installation and autoloading.
Read references/templates-and-development.md before generating files or implementing PHP tools/resources.
Use the official PHP SDK patterns from the bundled reference; do not invent framework APIs when the reference gives an attribute, bootstrap, or test pattern.
Required inputs
Input
Required
Notes
Project name
Yes
Kebab-case directory such as my-mcp-server; reuse as Composer package suffix.
Server description
Yes
One sentence, for example A file management MCP server.
Transport type
Yes
stdio, http, or both.
Tools to include
Yes
Examples: file read, file write, list directory; each needs name, inputs, output, and failure modes.
Resources and prompts
Conditional
Include only when the user requests read-only resources or reusable prompt templates.
PHP version
Yes
Require PHP 8.2+; reject lower versions or raise the target.
Project structure
Generate this tree and omit only optional folders the user explicitly excludes:
Use a stable lower camel or snake name that describes the action, not the transport.
Tool description
State what the tool does, required inputs, side effects, and output shape.
Inputs
Validate with schema attributes; reject path traversal, unsupported protocols, and ambiguous defaults.
Outputs
Return structured arrays or DTOs that serialize predictably.
Side effects
Mark write operations clearly in descriptions and tests.
Completion provider
Add {CompletionProvider} only when argument completion is useful and supported by the generated server.
Progressive disclosure and bundled resources
references/templates-and-development.md: PHP MCP templates, SDK development details, and implementation patterns. Open it before generating composer.json, server.php, tool classes, resources, prompts, providers, or tests.
Gotchas
Do not skip the bundled reference: the reference carries the SDK-specific templates that prevent plausible but wrong PHP MCP APIs.
Do not generate untyped PHP: strict types, PHPDoc, and return types are required because MCP schemas are inferred from code.
Do not make every transport default: implement stdio, http, or both according to the user's requirement.
Do not cache discovery only in memory for production: use PSR-16 cache for stable production discovery.
The project name, description, transport type, tools, resource/prompt choice, and PHP version are known.
references/templates-and-development.md was read before generating implementation code.
The generated tree contains composer.json, .gitignore, README.md, server.php, src/, and tests/.
Tool classes use #[McpTool]; resource and prompt classes use #[McpResource] and #[McpPrompt] when present.
Parameters use #[Schema], strict types, PHPDoc, and explicit return types.
Production discovery uses PSR-16 cache.
README includes composer install, vendor/bin/phpunit, php server.php, inspector usage, and Claude Desktop JSON.
1---2name: php-mcp-server-generator-23description: Generate a complete PHP Model Context Protocol server project with tools, resources, prompts, tests, and Claude Desktop configuration using the official PHP SDK. Use this skill when the user asks for a PHP MCP server, PHP SDK MCP project, stdio or HTTP MCP transport, tool/resource/prompt scaffolding, or production-ready MCP server requirements.4---56# PHP MCP server generator78Generate a production-ready PHP MCP server by collecting project requirements, reading the bundled implementation reference, then producing a Composer project with typed tools, optional resources and prompts, tests, runnable stdio or HTTP transport configuration, and clear tools/resources boundaries.910## When to invoke1112- "Generate a PHP MCP server."13- "Create a complete MCP server project using the PHP SDK."14- "Scaffold MCP tools, resources, prompts, and tests in PHP."15- "Build a stdio or HTTP PHP MCP server for Claude Desktop."16- "I need project requirements for a PHP MCP server."1718## Prerequisites and context1920- PHP 8.2 or higher is required.21- Composer is required for dependency installation and autoloading.22- Read `references/templates-and-development.md` before generating files or implementing PHP tools/resources.23- Use the official PHP SDK patterns from the bundled reference; do not invent framework APIs when the reference gives an attribute, bootstrap, or test pattern.2425## Required inputs2627| Input | Required | Notes |28| --- | --- | --- |29| Project name | Yes | Kebab-case directory such as `my-mcp-server`; reuse as Composer package suffix. |30| Server description | Yes | One sentence, for example `A file management MCP server`. |31| Transport type | Yes | `stdio`, `http`, or `both`. |32| Tools to include | Yes | Examples: `file read`, `file write`, `list directory`; each needs name, inputs, output, and failure modes. |33| Resources and prompts | Conditional | Include only when the user requests read-only resources or reusable prompt templates. |34| PHP version | Yes | Require PHP 8.2+; reject lower versions or raise the target. |3536## Project structure3738Generate this tree and omit only optional folders the user explicitly excludes:3940```text41{project-name}/42├── composer.json43├── .gitignore44├── README.md45├── server.php46├── src/47│ ├── Tools/48│ │ └── {ToolClass}.php49│ ├── Resources/50│ │ └── {ResourceClass}.php51│ ├── Prompts/52│ │ └── {PromptClass}.php53│ └── Providers/54│ └── {CompletionProvider}.php55└── tests/56 └── ToolsTest.php57```5859## Implementation rules6061| Area | Requirement |62| --- | --- |63| Attributes | Use `#[McpTool]`, `#[McpResource]`, and `#[McpPrompt]` for clean discovery. |64| Parameters | Use `#[Schema]` attributes for validation and document each input in PHPDoc. |65| Types | Put `declare(strict_types=1);` at the top of all PHP files and use explicit return types. |66| Style | Follow PSR-12 and Composer PSR-4 autoloading. |67| Errors | Throw specific exceptions with clear user-safe messages; do not leak credentials or local paths. |68| Tests | Write PHPUnit tests for every tool, including success, validation failure, and domain failure. |69| Documentation | Include README setup, transport, Claude Desktop configuration, and inspector commands. |70| Discovery cache | Always use PSR-16 cache for discovery in production. |7172## Commands and runtime configuration7374| Purpose | Command or file |75| --- | --- |76| Install dependencies | `composer install` |77| Run tests | `vendor/bin/phpunit` |78| Start stdio server | `php server.php` |79| Test with inspector | `npx @modelcontextprotocol/inspector php server.php` |80| Claude Desktop command | `php` |81| Claude Desktop args | `["/absolute/path/to/server.php"]` |8283Claude Desktop configuration:8485```json86{87 "mcpServers": {88 "{project-name}": {89 "command": "php",90 "args": ["/absolute/path/to/server.php"]91 }92 }93}94```9596## Tool design checklist9798| Field | Rule |99| --- | --- |100| `{tool_name}` | Use a stable lower camel or snake name that describes the action, not the transport. |101| Tool description | State what the tool does, required inputs, side effects, and output shape. |102| Inputs | Validate with schema attributes; reject path traversal, unsupported protocols, and ambiguous defaults. |103| Outputs | Return structured arrays or DTOs that serialize predictably. |104| Side effects | Mark write operations clearly in descriptions and tests. |105| Completion provider | Add `{CompletionProvider}` only when argument completion is useful and supported by the generated server. |106107## Progressive disclosure and bundled resources108109- `references/templates-and-development.md`: PHP MCP templates, SDK development details, and implementation patterns. Open it before generating `composer.json`, `server.php`, tool classes, resources, prompts, providers, or tests.110111## Gotchas112113- **Do not skip the bundled reference**: the reference carries the SDK-specific templates that prevent plausible but wrong PHP MCP APIs.114- **Do not generate untyped PHP**: strict types, PHPDoc, and return types are required because MCP schemas are inferred from code.115- **Do not make every transport default**: implement `stdio`, `http`, or `both` according to the user's requirement.116- **Do not cache discovery only in memory for production**: use PSR-16 cache for stable production discovery.117118## Output template119120````markdown121## PHP MCP server project122123**Status:** generated | requirements needed | blocked124**Project:** `{project-name}`125**Transport:** stdio | http | both126**PHP target:** `8.2+`127128### Files129| Path | Purpose |130| --- | --- |131| `composer.json` | Dependencies, scripts, autoloading |132| `server.php` | MCP server entrypoint |133| `src/Tools/{ToolClass}.php` | Tool implementation |134| `src/Resources/{ResourceClass}.php` | Resource implementation, if requested |135| `src/Prompts/{PromptClass}.php` | Prompt implementation, if requested |136| `tests/ToolsTest.php` | PHPUnit coverage for tools |137138### Commands139- `composer install`140- `vendor/bin/phpunit`141- `php server.php`142- `npx @modelcontextprotocol/inspector php server.php`143144### Claude Desktop145```json146{147 "mcpServers": {148 "{project-name}": {149 "command": "php",150 "args": ["/absolute/path/to/server.php"]151 }152 }153}154```155````156157## Quality gate158159- [ ] The project name, description, transport type, tools, resource/prompt choice, and PHP version are known.160- [ ] `references/templates-and-development.md` was read before generating implementation code.161- [ ] The generated tree contains `composer.json`, `.gitignore`, `README.md`, `server.php`, `src/`, and `tests/`.162- [ ] Tool classes use `#[McpTool]`; resource and prompt classes use `#[McpResource]` and `#[McpPrompt]` when present.163- [ ] Parameters use `#[Schema]`, strict types, PHPDoc, and explicit return types.164- [ ] Production discovery uses PSR-16 cache.165- [ ] README includes `composer install`, `vendor/bin/phpunit`, `php server.php`, inspector usage, and Claude Desktop JSON.
Run npx skillmds@latest add paulasilvatech/php-mcp-server-generator-2 in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Generate a complete PHP Model Context Protocol server project with tools, resources, prompts, tests, and Claude Desktop configuration using the official PHP SDK. Use this skill when the user asks for a PHP MCP server, PHP SDK MCP project, stdio or HTTP MCP transport, tool/resource/prompt scaffolding, or production-ready MCP server requirements. It is listed under AI & ML on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
paulasilvatech (@paulasilvatech) published this skill. Their other Agent Skills are listed on their SkillMD profile.