github/awesome-copilot/skills/php-mcp-server-generator/SKILL.md
php-mcp-server-generator
Generate a complete PHP Model Context Protocol server project with tools, resources, prompts, and tests using the official PHP SDK
- Source repository stars
- 37,126
- Declared platforms
- 0
- Static risk flags
- 4
- Last source update
- 2026-07-28
- Source checked
- 2026-07-28
Decision brief
What it does—and where it fits
You are a PHP MCP server generator. Create a complete, production-ready PHP MCP server project using the official PHP SDK.
Not for
- Tasks that require unconfirmed production actions or broad system permissions.
- Environments where the pinned source and install steps cannot be inspected.
Compatibility matrix
Platform support, with evidence labels
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
Inspect first. Install second.
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/github/awesome-copilot --skill "skills/php-mcp-server-generator"Inspect the Agent Skill "php-mcp-server-generator" from https://github.com/github/awesome-copilot/blob/9933dcad5be5caeb288cebcd370eeeb2fc2f1685/skills/php-mcp-server-generator/SKILL.md at commit 9933dcad5be5caeb288cebcd370eeeb2fc2f1685. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
What the source asks the agent to do
- 01
Usage
Review the “Usage” section in the pinned source before continuing.
Review and apply the “Usage” source section. - 02
Implementation Guidelines
1. Use PHP Attributes: Leverage [McpTool], [McpResource], [McpPrompt] for clean code 2. Type Declarations: Use strict types (declare(stricttypes=1);) in all files 3. PSR-12 Coding Standard: Follow PHP-FIG standards 4. Schema Validation: Use [Schema] attributes for parameter vali…
Use PHP Attributes: Leverage [McpTool], [McpResource], [McpPrompt] for clean codeType Declarations: Use strict types (declare(stricttypes=1);) in all filesPSR-12 Coding Standard: Follow PHP-FIG standards - 03
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.…
Project name (e.g., "my-mcp-server")Server description (e.g., "A file management MCP server")Transport type (stdio, http, or both) - 04
Project Structure
Review the “Project Structure” section in the pinned source before continuing.
Review and apply the “Project Structure” source section. - 05
File Templates
Review the “File Templates” section in the pinned source before continuing.
Review and apply the “File Templates” source section.
Permission review
Static risk signals and limitations
Reads files
The documentation asks the agent to read local files, directories, or repositories.
**Tools to include** (e.g., "file read", "file write", "list directory")Writes files
The documentation asks the agent to create, modify, or delete local files.
**Tools to include** (e.g., "file read", "file write", "list directory")Network access
The documentation includes network, browsing, or remote request actions.
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"Runs scripts
The documentation asks the agent to run terminal commands or scripts.
npx @modelcontextprotocol/inspector php server.phpEvidence record
Why each signal appears
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 83/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 37,126 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Provenance and original SKILL.md
- Repository
- github/awesome-copilot
- Skill path
- skills/php-mcp-server-generator/SKILL.md
- Commit
- 9933dcad5be5caeb288cebcd370eeeb2fc2f1685
- License
- MIT
- Collected
- 2026-07-28
- Default branch
- main
View the original SKILL.md
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:
- Project name (e.g., "my-mcp-server")
- Server description (e.g., "A file management MCP server")
- Transport type (stdio, http, or both)
- Tools to include (e.g., "file read", "file write", "list directory")
- Whether to include resources and prompts
- 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
{
"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
# {Project Name}
{Server description}
## Requirements
- PHP 8.2 or higher
- Composer
## Installation
```bash
composer install
Usage
Start Server (Stdio)
php server.php
Configure in Claude Desktop
{
"mcpServers": {
"{project-name}": {
"command": "php",
"args": ["/absolute/path/to/server.php"]
}
}
}
Testing
vendor/bin/phpunit
Tools
- {tool_name}: {Tool description}
Development
Test with MCP Inspector:
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
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,
'divide' => $b != 0 ? $a / $b :
throw new \InvalidArgumentException('Division by zero'),
default => throw new \InvalidArgumentException('Invalid operation')
};
}
}
src/Resources/ConfigResource.php
<?php
declare(strict_types=1);
namespace App\Resources;
use Mcp\Capability\Attribute\McpResource;
class ConfigResource
{
/**
* Provides application configuration.
*/
#[McpResource(
uri: 'config://app/settings',
name: 'app_config',
mimeType: 'application/json'
)]
public function getConfiguration(): array
{
return [
'version' => '1.0.0',
'environment' => 'production',
'features' => [
'logging' => true,
'caching' => true
]
];
}
}
src/Resources/DataProvider.php
<?php
declare(strict_types=1);
namespace App\Resources;
use Mcp\Capability\Attribute\McpResourceTemplate;
class DataProvider
{
/**
* Provides data by category and ID.
*/
#[McpResourceTemplate(
uriTemplate: 'data://{category}/{id}',
name: 'data_resource',
mimeType: 'application/json'
)]
public function getData(string $category, string $id): array
{
// Example data retrieval
return [
'category' => $category,
'id' => $id,
'data' => "Sample data for {$category}/{$id}"
];
}
}
src/Prompts/PromptGenerator.php
<?php
declare(strict_types=1);
namespace App\Prompts;
use Mcp\Capability\Attribute\McpPrompt;
use Mcp\Capability\Attribute\CompletionProvider;
class PromptGenerator
{
/**
* Generates a code review prompt.
*/
#[McpPrompt(name: 'code_review')]
public function reviewCode(
#[CompletionProvider(values: ['php', 'javascript', 'python', 'go', 'rust'])]
string $language,
string $code,
#[CompletionProvider(values: ['performance', 'security', 'style', 'general'])]
string $focus = 'general'
): array {
return [
[
'role' => 'assistant',
'content' => 'You are an expert code reviewer specializing in best practices and optimization.'
],
[
'role' => 'user',
'content' => "Review this {$language} code with focus on {$focus}:\n\n```{$language}\n{$code}\n```"
]
];
}
/**
* Generates documentation prompt.
*/
#[McpPrompt]
public function generateDocs(string $code, string $style = 'detailed'): array
{
return [
[
'role' => 'user',
'content' => "Generate {$style} documentation for:\n\n```\n{$code}\n```"
]
];
}
}
tests/ToolsTest.php
<?php
declare(strict_types=1);
namespace Tests;
use PHPUnit\Framework\TestCase;
use App\Tools\ExampleTool;
class ToolsTest extends TestCase
{
private ExampleTool $tool;
protected function setUp(): void
{
$this->tool = new ExampleTool();
}
public function testGreet(): void
{
$result = $this->tool->greet('World');
$this->assertSame('Hello, World!', $result);
}
public function testCalculateAdd(): void
{
$result = $this->tool->performCalculation(5, 3, 'add');
$this->assertSame(8.0, $result);
}
public function testCalculateDivide(): void
{
$result = $this->tool->performCalculation(10, 2, 'divide');
$this->assertSame(5.0, $result);
}
public function testCalculateDivideByZero(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Division by zero');
$this->tool->performCalculation(10, 0, 'divide');
}
public function testCalculateInvalidOperation(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid operation');
$this->tool->performCalculation(5, 3, 'modulo');
}
}
phpunit.xml.dist
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</phpunit>
Implementation Guidelines
- Use PHP Attributes: Leverage
#[McpTool],#[McpResource],#[McpPrompt]for clean code - Type Declarations: Use strict types (
declare(strict_types=1);) in all files - PSR-12 Coding Standard: Follow PHP-FIG standards
- Schema Validation: Use
#[Schema]attributes for parameter validation - Error Handling: Throw specific exceptions with clear messages
- Testing: Write PHPUnit tests for all tools
- Documentation: Use PHPDoc blocks for all methods
- Caching: Always use PSR-16 cache for discovery in production
Tool Patterns
Simple Tool
#[McpTool]
public function simpleAction(string $input): string
{
return "Processed: {$input}";
}
Tool with Validation
#[McpTool]
public function validateEmail(
#[Schema(format: 'email')]
string $email
): bool {
return filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
}
Tool with Enum
enum Status: string {
case ACTIVE = 'active';
case INACTIVE = 'inactive';
}
#[McpTool]
public function setStatus(string $id, Status $status): array
{
return ['id' => $id, 'status' => $status->value];
}
Resource Patterns
Static Resource
#[McpResource(uri: 'config://settings', mimeType: 'application/json')]
public function getSettings(): array
{
return ['key' => 'value'];
}
Dynamic Resource
#[McpResourceTemplate(uriTemplate: 'user://{id}')]
public function getUser(string $id): array
{
return $this->users[$id] ?? throw new \RuntimeException('User not found');
}
Running the Server
# Install dependencies
composer install
# Run tests
vendor/bin/phpunit
# Start server
php server.php
# Test with inspector
npx @modelcontextprotocol/inspector php server.php
Claude Desktop Configuration
{
"mcpServers": {
"{project-name}": {
"command": "php",
"args": ["/absolute/path/to/server.php"]
}
}
}
Now generate the complete project based on user requirements!
Alternatives
Compare before choosing
github/awesome-copilot
screen-recording
Create annotated animated GIF demos and screen recordings for pull requests and documentation. Covers frame capture, timing, imageio-based GIF creation, and per-frame annotation workflows.
github/awesome-copilot
swift-mcp-server-generator
Generate a complete Model Context Protocol server project in Swift using the official MCP Swift SDK package.
event4u-app/agent-config
guideline-writing
Use when creating or editing a guideline in docs/guidelines/ — reference material cited by skills, no auto-triggers — even when the user just says 'write up our naming conventions'.
event4u-app/agent-config
test-performance
Use when optimizing test suite performance — database setup, seeder optimization, parallel testing, CI pipeline efficiency, or RefreshDatabase alternatives.