
Php Mcp Server Generator
Scaffold a production-style PHP MCP server with tools, optional resources and prompts, transport choice, and PHPUnit tests from a short requirements interview.
Overview
PHP MCP Server Generator is an agent skill for the Build phase that scaffolds a complete PHP MCP server project with tools, optional resources and prompts, and tests via the official PHP SDK.
Install
npx skills add https://github.com/github/awesome-copilot --skill php-mcp-server-generatorWhat is this skill?
- Full tree: composer.json, server.php, src/Tools|Resources|Prompts|Providers, tests/ToolsTest.php
- User-driven spec: project name, description, stdio/http/both transport, tool list, PHP 8.2+
- Official mcp/sdk dependency with PSR-4 App\ autoloading
- Optional resources, prompts, and completion providers from the same generator pass
- PHPUnit 10 dev stack with Symfony cache for test support
- PHP ^8.2 required
- Top-level dirs: src/Tools, Resources, Prompts, Providers, plus tests/
Adoption & trust: 8.6k installs on skills.sh; 34.6k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need an MCP server in PHP but do not want to manually assemble SDK wiring, PSR-4 layout, transports, and PHPUnit from scratch.
Who is it for?
PHP-first indie builders shipping custom MCP tools for agents on PHP 8.2+ with stdio or HTTP transports.
Skip if: Teams needing Node/Python MCP servers only, or production hardening (auth, rate limits, hosting) without follow-up work beyond the scaffold.
When should I use this skill?
User wants a complete PHP MCP server project generated with chosen tools, transport, and optional resources/prompts.
What do I get? / Deliverables
You receive a runnable {project-name}/ tree with composer dependencies, tool classes, server entrypoint, and tests ready to customize and register with MCP clients.
- Full {project-name}/ repository tree with server.php and SDK wiring
- README.md and tests/ToolsTest.php starter
Recommended Skills
Journey fit
Build is where you wire agent-facing integrations; generating an MCP server is core integration work, not launch or operate maintenance. integrations covers protocol bridges like MCP; PHP SDK layout, transports, and tool classes belong on that shelf.
How it compares
Generator skill for PHP MCP repos—not an MCP host itself and not a generic REST API scaffold.
Common Questions / FAQ
Who is php-mcp-server-generator for?
Solo builders and small teams using PHP who want a standard MCP SDK project with tools, optional resources/prompts, and starter tests.
When should I use php-mcp-server-generator?
During Build/integrations when you are adding agent-accessible PHP capabilities before connecting clients in agent-tooling.
Is php-mcp-server-generator safe to install?
Review the Security Audits panel on this Prism page; generated servers may expose filesystem or custom tools you define—audit tool implementations before exposing network transports.
SKILL.md
READMESKILL.md - Php Mcp Server Generator
# 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 ``` {project-name}/ ├── composer.json ├── .gitignore ├── README.md ├── server.php ├── src/ │ ├── Tools/ │ │ └── {ToolClass}.php │ ├── Resources/ │ │ └── {ResourceClass}.php │ ├── Prompts/ │ │ └── {PromptClass}.php │ └── Providers/ │ └── {CompletionProvider}.php └── tests/ └── ToolsTest.php ``` ## File Templates ### composer.json ```json { "name": "your-org/{project-name}", "description": "{Server description}", "type": "project", "require": { "php": "^8.2", "mcp/sdk": "^0.1" }, "require-dev": { "phpunit/phpunit": "^10.0", "symfony/cache": "^6.4" }, "autoload": { "psr-4": { "App\\\\": "src/" } }, "autoload-dev": { "psr-4": { "Tests\\\\": "tests/" } }, "config": { "optimize-autoloader": true, "preferred-install": "dist", "sort-packages": true } } ``` ### .gitignore ``` /vendor /cache composer.lock .phpunit.cache phpstan.neon ``` ### README.md ```markdown # {Project Name} {Server description} ## Requirements - PHP 8.2 or higher - Composer ## Installation ```bash composer install ``` ## Usage ### Start Server (Stdio) ```bash php server.php ``` ### Configure in Claude Desktop ```json { "mcpServers": { "{project-name}": { "command": "php", "args": ["/absolute/path/to/server.php"] } } } ``` ## Testing ```bash vendor/bin/phpunit ``` ## Tools - **{tool_name}**: {Tool description} ## Development Test with MCP Inspector: ```bash npx @modelcontextprotocol/inspector php server.php ``` ``` ### server.php ```php #!/usr/bin/env php <?php declare(strict_types=1); require_once __DIR__ . '/vendor/autoload.php'; use Mcp\Server; use Mcp\Server\Transport\StdioTransport; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Psr16Cache; // Setup cache for discovery $cache = new Psr16Cache(new FilesystemAdapter('mcp-discovery', 3600, __DIR__ . '/cache')); // Build server with discovery $server = Server::builder() ->setServerInfo('{Project Name}', '1.0.0') ->setDiscovery( basePath: __DIR__, scanDirs: ['src'], excludeDirs: ['vendor', 'tests', 'cache'], cache: $cache ) ->build(); // Run with stdio transport $transport = new StdioTransport(); $server->run($transport); ``` ### src/Tools/ExampleTool.php ```php <?php declare(strict_types=1); namespace App\Tools; use Mcp\Capability\Attribute\McpTool; use Mcp\Capability\Attribute\Schema; class ExampleTool { /** * Performs a greeting with the provided name. * * @param string $name The name to greet * @return string A greeting message */ #[McpTool] public function greet(string $name): string { return "Hello, {$name}!"; } /** * Performs arithmetic calculations. */ #[McpTool(name: 'calculate')] public function performCalculation( float $a, float $b, #[Schema(pattern: '^(add|subtract|multiply|divide)$')] string $operation ): float { return match($operation) { 'add' => $a + $b, 'subtract' => $a - $b, 'multiply' => $a * $b,