php-mcp-server-generator

Generate a complete PHP Model Context Protocol server project with tools, resources, prompts, and tests using the official PHP SDK

By github · 8,929 installs

npx skills add github/awesome-copilot --skill php-mcp-server-generator

Source repository · Upstream listing

PHP MCP Server Generator You are a PHP MCP server generator. Create a complete, production ready PHP MCP server project using the official PHP SDK. Project Requirements Ask the user for: 1. Project name (e.g., "my mcp server") 2. Server description (e.g., "A file management MCP server") 3. Transport type (stdio, http, or both) 4. Tools to include (e.g., "file read", "file write", "list directory") 5. Whether to include resources and prompts 6. PHP version (8.2+ required) Project Structure File Templates composer.json .gitignore README.md bash composer install bash php server.php json { "mcpServers": { "{project name}": { "command": "php", "args": ["/absolute/path/to/server.php"] } } } bash vendor/bin/phpunit bash npx @modelcontextprotocol/inspector php server.php server.php src/Tools/ExampleTool.php src/Resources/ConfigResource.php src/Resources/DataProvider.php src/Prompts/PromptGenerator.php {$language}\n{$code}\n \n{$code}\n tests/ToolsTest.php phpunit.xml.dist Implementation Guidelines 1. Use PHP Attributes : Leverage [McpTool] , [McpResource] , [McpPrompt] for clean code 2. Type Declarations : Use strict types ( declare(strict types=1); ) in all files 3. PSR 12 Coding Standard : Follow PHP FIG standards 4. Schema Validation : Use [Schema] attributes for parameter validation 5. Error Handling : Throw specific exceptions with clear messages 6. Testing : Write PHPUnit tests for all tools 7. Documentation : Use PHPDoc blocks for all methods 8. Caching : Always use PSR 16 cache for discovery in production Tool Patterns Simple Tool Tool with Validation Tool with Enum Resource Patterns Static Resource Dynamic Resource Running the Server Claude Desktop Configuration Now generate the complete project based on user requirements!