
A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

A complete MCP server implementation in PHP that lets developers define tools, prompts, and resources using attributes and serve them over stdio or SSE.
Annotation-based PHP framework for building MCP servers is cataloged as an MCP server attributed to he426100. A complete MCP server implementation in PHP that lets developers define tools, prompts, and resources using attributes and serve them over stdio or SSE. It is categorized under developer tools. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.
Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.
Catalog license label: MIT License. Check the source repository's current license and terms before using, modifying or distributing this software.
能力定义尚未审核。未核验的采集内容不会作为可信接口展示。
暂无可展示的已审核记录。这不表示上游不支持此能力。
暂无可展示的已审核记录。这不表示上游不支持此能力。
暂无可展示的已审核记录。这不表示上游不支持此能力。
Email delivery is not connected. This page does not collect email addresses or create subscriptions.
Browse the registry for current listings instead.
Reviews for Annotation-based PHP framework for building MCP servers are not available yet
Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.
Yes, the project supports Docker, and the SSE server can be reached on port 8000.
Resource content exceeding 2MB is truncated automatically.
README.md · 03bb2998f8f5 · 采集于 2026-11-13 09:55:35 UTC
保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。
当前显示最后一次成功采集的文档快照,请以来源页面为准。
这是一个基于 PHP 实现的 MCP (Model Control Protocol) 服务器框架,支持通过注解优雅地定义 MCP 服务。
本项目提供了一个完整的 MCP 服务器实现,特色功能:
# 1. 克隆项目
git clone https://github.com/he426100/php-mcp-server
cd php-mcp-server
# 2. 安装依赖
composer install
# 3. 可选,安装 Swow 扩展(如果没有)
./vendor/bin/swow-builder --install
关于 Swow 扩展的详细安装说明,请参考 Swow 官方文档
php bin/console mcp:test-server
| Parameter | Description | Default Value | Options |
|---|---|---|---|
| --transport | Transport type | stdio | stdio, sse |
| --port | Port to listen on for SSE | 8000 |
本框架提供三种核心注解用于定义 MCP 服务:
用于定义工具类处理器:
use Mcp\Annotation\Tool;
class MyService {
#[Tool(
name: 'calculate-sum',
description: '计算两个数的和',
parameters: [
'num1' => [
'type' => 'number',
'description' => '第一个数字',
'required' => true
],
'num2' => [
'type' => 'number',
'description' => '第二个数字',
'required' => true
]
]
)]
public function sum(int $num1, int $num2): int
{
return $num1 + $num2;
}
}
用于定义提示模板处理器:
use Mcp\Annotation\Prompt;
class MyService {
#[Prompt(
name: 'greeting',
description: '生成问候语',
arguments: [
'name' => [
'description' => '要问候的人名',
'required' => true
]
]
)]
public function greeting(string $name): string
{
return "Hello, {$name}!";
}
}
用于定义资源处理器:
use Mcp\Annotation\Resource;
class MyService {
#[Resource(
uri: 'example://greeting',
name: 'Greeting Text',
description: '问候语资源',
mimeType: 'text/plain'
)]
public function getGreeting(): string
{
return "Hello from MCP server!";
}
}
namespace Your\Namespace;
use Mcp\Annotation\Tool;
use Mcp\Annotation\Prompt;
use Mcp\Annotation\Resource;
class CustomService
{
#[Tool(name: 'custom-tool', description: '自定义工具')]
public function customTool(): string
{
return "Custom tool result";
}
}
namespace Your\Namespace\Command;
use He426100\McpServer\Command\AbstractMcpServerCommand;
use Your\Namespace\CustomService;
class CustomServerCommand extends AbstractMcpServerCommand
{
protected string $serverName = 'custom-server';
protected string $serviceClass = CustomService::class;
protected function configure(): void
{
parent::configure();
$this->setName('custom:server')
->setDescription('运行自定义 MCP 服务器');
}
}
| 参数 | 类型 | 说明 | 必填 |
|---|---|---|---|
| name | string | 工具名称 | 是 |
| description | string | 工具描述 | 是 |
| parameters | array | 参数定义 | 否 |
| 参数 | 类型 | 说明 | 必填 |
|---|---|---|---|
| name | string | 提示模板名称 | 是 |
| description | string | 提示模板描述 | 是 |
| arguments | array | 参数定义 | 否 |
| 参数 | 类型 | 说明 | 必填 |
|---|---|---|---|
| uri | string | 资源URI | 是 |
| name | string | 资源名称 | 是 |
| description | string | 资源描述 | 是 |
| mimeType | string | MIME类型 | 否 |
| 返回类型 | 说明 | 转换结果 |
|---|---|---|
| TextContent/ImageContent/EmbeddedResource | 直接返回内容对象 | 原样保留 |
| TextContent/ImageContent/EmbeddedResource 数组 | 内容对象数组 | 原样保留 |
| ResourceContents | 资源内容对象 | 转换为 EmbeddedResource |
| 字符串或标量类型 | 如 string、int、float、bool | 转换为 TextContent |
| null | 空值 | 转换为空字符串的 TextContent |
| 数组或对象 | 复杂数据结构 | 转换为 JSON 格式的 TextContent |
| 返回类型 | 说明 | 转换结果 |
|---|---|---|
| PromptMessage | 消息对象 | 原样保留 |
| PromptMessage 数组 | 消息对象数组 | 原样保留 |
| Content 对象 | TextContent/ImageContent 等 | 转换为用户角色的 PromptMessage |
| 字符串或标量类型 | 如 string、int、float、bool | 转换为带 TextContent 的用户消息 |
| null | 空值 | 转换为空内容的用户消息 |
| 数组或对象 | 复杂数据结构 | 转换为 JSON 格式的用户消息 |
| 返回类型 | 说明 | 转换结果 |
|---|---|---|
| TextResourceContents/BlobResourceContents | 资源内容对象 | 原样保留 |
| ResourceContents 数组 | 资源内容对象数组 | 原样保留 |
| 字符串或可转字符串对象 | 文本内容 | 根据 MIME 类型转换为对应资源内容 |
| null | 空值 | 转换为空的 TextResourceContents |
| 数组或对象 | 复杂数据结构 | 转换为 JSON 格式的资源内容 |
注意事项:
服务器日志默认保存在 runtime/server_log.txt,可通过继承 AbstractMcpServerCommand 修改:
protected string $logFilePath = '/custom/path/to/log.txt';
构建并运行容器:
docker build -t php-mcp-server .
docker run --name=php-mcp-server -p 8000:8000 -itd php-mcp-server mcp:test-server --transport sse
sse地址:http://127.0.0.1:8000/sse
您可以通过 CPX (Composer Package Executor) 直接运行本项目,无需事先安装:
composer global require cpx/cpx
# 运行测试服务器
cpx he426100/php-mcp-server mcp:test-server
# 使用 SSE 传输模式
cpx he426100/php-mcp-server mcp:test-server --transport=sse
# 查看可用命令
cpx he426100/php-mcp-server list
欢迎提交 Issue 和 Pull Request。
Claim this server with your GitHub account to request manual ownership verification.
Link to the catalog listing for Annotation-based PHP framework for building MCP servers from your README. This badge does not certify ownership, compatibility or security.
[](https://awesome-mcp.com/servers/php-mcp-server)Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.
来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。
尚无已审核的包 / 镜像标识,暂不展示下载统计。
Alternative and complementary servers in the same category

A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

A hosted MCP service for browsing and searching through Singapore mobile-network proxies.

A directory listing describing a Markdown-to-PDF service. The configured public GitHub repository returned 404 during source verification.