옵션
집집 Skill MCP 도구 php-mcp-server-generator

php-mcp-server-generator

github/awesome-copilot github/awesome-copilot

공식 PHP SDK를 사용하여 도구, 리소스, 프롬프트 및 테스트가 포함된 완전한 PHP Model Context Protocol 서버 프로젝트를 생성합니다.

...모든 것을 확장하십시오
44
업데이트 된 시간 2026년 6월 29일

php-mcp-server-generator 소개

php-mcp-server-generator은 PHP Model Context Protocol(MCP) 서버 프로젝트 생성을 간소화하기 위해 설계된 강력한 도구입니다. 이 도구는 최신 PHP 버전과의 호환성 확보, 의존성 관리, 올바른 프로젝트 구조 구성 등 개발자가 새 서버를 설정할 때 흔히 직면하는 문제들을 해결해 줍니다. 이 스킬은 공식 PHP SDK를 활용하여, 프로덕션 환경에 바로 배포 가능한 완전한 서버 프로젝트를 자동으로 생성하므로, 개발자는 상용구 코드를 작성하는 대신 기능 개발에 집중할 수 있습니다.

자주 묻는 질문

프로젝트 요구 사항은 무엇인가요?

프로젝트 이름, 서버 설명, 전송 유형(stdio, http 또는 둘 다), 포함할 도구, 리소스 및 프롬프트 포함 여부, 그리고 PHP 버전 8.2 이상이 필요합니다.

서버는 어떻게 시작하나요?

터미널에서 'php server.php' 명령을 실행하여 서버를 시작할 수 있습니다.

테스트 프레임워크가 포함되어 있나요?

네, 이 프로젝트에는 테스트를 위한 PHPUnit이 포함되어 있으며, 'vendor/bin/phpunit'을 사용하여 테스트를 실행할 수 있습니다.

프로젝트에 포함된 도구를 사용자 정의할 수 있나요?

네, 프로젝트를 생성할 때 포함할 도구를 지정할 수 있습니다.

이 스킬을 사용하려면 어떤 PHP 버전이 필요합니까?

이 스킬을 사용하려면 PHP 8.2 이상이 필요합니다.

GitHub에서 보기

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

{    "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/cachecomposer.lock.phpunit.cachephpstan.neon

README.md

# {Project Name}{Server description}## Requirements- PHP 8.2 or higher- Composer## Installation```bashcomposer 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<?phpdeclare(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

<?phpdeclare(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

<?phpdeclare(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

<?phpdeclare(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

<?phpdeclare(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}:```{$language}{$code}```"            ]        ];    }        /**     * Generates documentation prompt.     */    #[McpPrompt]    public function generateDocs(string $code, string $style = 'detailed'): array    {        return [            [                'role' => 'user',                'content' => "Generate {$style} documentation for:```{$code}```"            ]        ];    }}

tests/ToolsTest.php

<?phpdeclare(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

  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

#[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 dependenciescomposer install# Run testsvendor/bin/phpunit# Start serverphp server.php# Test with inspectornpx @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!

모든 파일

1개 파일

php-mcp-server-generator 설치

스킬 파일을 다운로드하여 .claude/skills/ 디렉터리에 압축을 풀어주세요.

ZIP 다운로드

저장소를 클론하고 스킬 파일을 프로젝트에 복사하세요.

git clone https://github.com/github/awesome-copilot/blob/main/skills/php-mcp-server-generator/SKILL.md # Copy SKILL.md to your .claude/skills/ directory

복사 복사
빠른 설정: skill 폴더를 .claude/skills/로 복사하면 Claude가 해당 스킬을 자동으로 감지하여 사용합니다.

관련 스킬

office-mcp
업데이트 된 시간 2026년 7월 13일
composio
업데이트 된 시간 2026년 6월 29일
connect-mcp-server
업데이트 된 시간 2026년 6월 29일
mcpgraph
업데이트 된 시간 2026년 6월 29일
OR