stribus/mcp-flightphp-server-skeleton 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

stribus/mcp-flightphp-server-skeleton

Composer 安装命令:

composer require stribus/mcp-flightphp-server-skeleton

包简介

A Flight PHP framework skeleton app for MCP Server

README 文档

README

A PHP-based Model Context Protocol (MCP) server skeleton that supports both HTTP and stdio communication methods. This server can be integrated with VS Code Copilot and other MCP-compatible clients.

Features

  • Dual Communication: HTTP REST API and stdio (JSON-RPC 2.0)
  • Auto-discovery: Automatically discovers tools, prompts, and resources
  • Code Generation: Built-in commands to generate new tools and prompts
  • Flight PHP Framework: Lightweight and fast PHP framework
  • Logging: Comprehensive logging for debugging
  • Testing Scripts: Ready-to-use test scripts for both modes

Quick Start

  1. Install Run this command from the directory in which you want to install your new Flight PHP application. (this will require PHP 7.4 or newer)

     composer create-project stribus/mcp-flightphp-server-skeleton cool-project-name

Run this command from the directory in which you want to install your new Flight PHP application. (this will require PHP 7.4 or newer)

  1. Test HTTP Server

    composer start
    # or
    php -S localhost:8000 -t public
  2. Test stdio Server

    php mcp-server.php

Usage Methods

1. HTTP Server Mode

The HTTP server exposes MCP functionality via REST endpoints:

Start the server:

composer start

Available endpoints:

  • GET / - Server information
  • POST /tools/list - List available tools
  • POST /tools/call - Execute a tool
  • POST /prompts/list - List available prompts
  • POST /prompts/get - Get a prompt
  • POST /resources/list - List available resources
  • POST /resources/read - Read a resource

Test the HTTP server:

# Windows PowerShell
.\test-http-server.ps1

# Or manually test endpoints
curl -X POST http://localhost:8000/tools/list
curl -X POST http://localhost:8000/tools/call -H "Content-Type: application/json" -d '{"name":"hello-world-tool","arguments":{"firstName":"John","lastName":"Doe"}}'

2. stdio Mode (JSON-RPC 2.0)

The stdio server communicates via standard input/output using JSON-RPC 2.0 protocol:

Start the server:

php mcp-server.php

Test JSON-RPC commands:

# Windows PowerShell
.\test-mcp-server.ps1

# Or send commands manually
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' | php mcp-server.php
echo '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' | php mcp-server.php
echo '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"hello-world-tool","arguments":{"firstName":"VS Code","lastName":"Copilot"}}}' | php mcp-server.php

3. VS Code Integration

For VS Code Copilot integration, configure the MCP server in your VS Code settings:

mcp-config.json example:

{
  "mcpServers": {
    "php-mcp-server": {
      "command": "php",
      "args": ["path/to/mcp-server.php"],
      "env": {}
    }
  }
}

Creating Tools

Tools are executable functions that can be called by MCP clients.

Generate a new tool:

vendor/bin/runway make:tool MyCustomTool

Tool Structure:

<?php

namespace app\tools;

use app\helpers\AbstractMCPTool;

class MyCustomTool extends AbstractMCPTool
{
    protected string $name = 'my-custom-tool';
    protected string $description = 'Description of what this tool does';
    protected ?string $title = 'My Custom Tool';

    protected array $arguments = [
        [
            'name' => 'input',
            'type' => 'string',
            'description' => 'Input parameter description',
            'required' => true,
        ],
    ];

    protected null|array|string $outputSchema = [
        'type' => 'object',
        'properties' => [
            'result' => [
                'type' => 'string',
                'description' => 'The result of the operation',
            ],
        ],
    ];

    public function execute(array $arguments): mixed
    {
        $input = $arguments['input'] ?? '';
        
        // Your tool logic here
        
        return [
            'result' => 'Processed: ' . $input,
        ];
    }
}

Tool Properties:

  • $name: Unique identifier for the tool
  • $description: What the tool does
  • $title: Human-readable title
  • $arguments: Array of input parameters with types and validation
  • $outputSchema: Expected output structure
  • execute(): Main logic that processes arguments and returns results

Creating Prompts

Prompts are templates that can generate dynamic text based on context.

Generate a new prompt:

vendor/bin/runway make:prompt MyCustomPrompt

Prompt Structure:

<?php

namespace app\prompts;

use app\helpers\AbstractMCPPrompt;

class MyCustomPrompt extends AbstractMCPPrompt
{
    protected string $name = 'my_custom_prompt';
    protected string $description = 'Generate custom content based on input';
    protected ?string $title = 'My Custom Prompt';
    
    protected array $arguments = [
        'topic' => [
            'type' => 'string',
            'description' => 'The topic to generate content about',
            'required' => true,
        ],
        'style' => [
            'type' => 'string',
            'description' => 'Writing style (formal, casual, technical)',
            'required' => false,
        ],
    ];

    public function getPromptText(array $context): string
    {
        $topic = $context['topic'] ?? '';
        $style = $context['style'] ?? 'formal';

        return "Write a {$style} explanation about {$topic}. " .
               "Include examples and practical applications.";
    }
}

Prompt Properties:

  • $name: Unique identifier for the prompt
  • $description: What the prompt generates
  • $title: Human-readable title
  • $arguments: Context variables the prompt expects
  • getPromptText(): Method that generates the prompt text based on context

Project Structure

├── app/
│   ├── tools/           # Tool implementations
│   ├── prompts/         # Prompt implementations
│   ├── resources/       # Resource implementations
│   ├── helpers/         # Abstract base classes
│   └── core/            # MCP service registries
├── commands/            # Runway commands for code generation
├── public/              # HTTP server entry point
├── mcp-server.php       # stdio server entry point
└── vendor/              # Dependencies

Available MCP Methods

JSON-RPC 2.0 Methods:

  • initialize - Initialize the MCP connection
  • tools/list - List all available tools
  • tools/call - Execute a specific tool
  • prompts/list - List all available prompts
  • prompts/get - Get a specific prompt
  • resources/list - List all available resources
  • resources/read - Read a specific resource

Logging and Debugging

The server generates detailed logs in mcp-server.log for debugging purposes. Monitor this file to see:

  • Incoming requests
  • Server responses
  • Errors and exceptions
  • Tool execution details

Common Issues

  1. Server won't start: Ensure PHP is in your PATH and dependencies are installed
  2. JSON parsing errors: Verify JSON-RPC message formatting
  3. Tool not found: Check tool is properly registered and follows naming conventions
  4. Permission errors: Verify write permissions for log files

Requirements

  • PHP 7.4 or higher
  • Composer
  • ext-json extension

License

MIT License - see LICENSE file for details.

stribus/mcp-flightphp-server-skeleton 适用场景与选型建议

stribus/mcp-flightphp-server-skeleton 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 08 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「microframework」 「Skeleton」 「mcp」 「flightphp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 stribus/mcp-flightphp-server-skeleton 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 stribus/mcp-flightphp-server-skeleton 我们能提供哪些服务?
定制开发 / 二次开发

基于 stribus/mcp-flightphp-server-skeleton 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 26
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-14