Token导航 LogoToken导航TokenDH.com
Enhanced Php MCP Server logo
开发工具未说明官方级别未说明来源级核验

Enhanced Php MCP Server

MCP Server

一个具有Web仪表板的PHP MCP服务器,提供多种远程可调用工具和管理功能。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
PHP开发工具命令行工具

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

mafio69

提供方

mafio69

最后核验

2026/5/17 20:22

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

增强型PHP MCP服务器,配备Web控制面板

高级PHP MCP服务器,配备全面的工具集和网页界面。该服务器通过基于JSON的协议使用标准输入/输出进行通信,并提供了一套丰富的可远程调用工具,以及用于管理和测试的现代网页仪表板。

🚀 功能特点

  • 10个内置工具你好,时间、计算器、文件操作、系统信息、JSON解析、天气、HTTP请求
  • 网络仪表盘用于工具管理、测试和监控的现代网页界面
  • 安全路径限制、文件大小限制、输入验证
  • 配置支持环境的集中式配置系统
  • 记录日志可配置级别的全面日志记录
  • CLI(命令行界面)和HTTP(超文本传输协议)支持双模式操作
  • 现代PHP需要PHP 8.1+版本,并且需要正确的自动加载配置
  • 全面测试单元测试、集成测试、性能测试

📋 要求

  • PHP 版本 >= 8.1
  • Composer(在软件开发领域,通常指用于管理PHP依赖关系的工具)
  • 所需的扩展: jsoncurl

🛠️ 安装

  1. 克隆或下载该仓库
  2. 安装依赖项:
   composer install
  1. 使启动脚本可执行:
   chmod +x start.sh

🎯 快速入门

🚀 快速入门(推荐)

# 1. Install dependencies
./start.sh 6

# 2. Run web server (browser interface)
./start.sh 2

在浏览器中打开http://localhost:8888以访问API。

🎮 交互式菜单

./start.sh

这将显示一个包含可选项目的多彩菜单。

🌐 Web API(用于浏览器)

./start.sh 2      # Run web server on http://localhost:8888

📡 CLI 模式(适用于 MCP 客户端)

./start.sh 1      # Run MCP server via stdin/stdout

🔍 服务器管理

./start.sh 4      # Check status
./start.sh 5      # View logs

🖥️ CLI 模式(交互式菜单)

./start.sh

如果终端不是交互式的,它将显示带有选项的菜单:

./start.sh        # Show menu with options
./start.sh 1      # CLI Mode - MCP server via stdin/stdout
./start.sh 2      # Web Mode - HTTP server with Slim Framework
./start.sh 3      # All Modes - CLI + Web simultaneously
./start.sh 4      # Status - check server status
./start.sh 5      # Logs - show recent logs
./start.sh 6      # Install - install dependencies

CLI 使用示例

# Run server in interactive mode (shows menu)
./start.sh

# Run directly in CLI mode (for MCP clients)
./start.sh 1

# Run web server (for browser)
./start.sh 2

# Check status of running servers
./start.sh 4

# View recent logs
./start.sh 5

手动启动

php index.php

Composer 脚本

composer start

📚 可用工具

该服务器提供了10款强大的工具:

1. 你好

以名字打招呼。

echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"hello","arguments":{"name":"John"}}}' | php index.php

2. 获取时间

返回当前的日期和时间信息。

echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_time"}}' | php index.php

3. 计算

执行数学运算(加、减、乘、除)。

echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"calculate","arguments":{"operation":"add","a":10,"b":5}}}' | php index.php

4. 读取文件

安全地读取项目目录中的文件内容。

echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"read_file","arguments":{"path":"README.md"}}}' | php index.php

5. 写文件

安全地将内容写入项目目录内的文件。

echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"write_file","arguments":{"path":"test.txt","content":"Hello World"}}}' | php index.php

6. 列出文件

列出指定路径中的文件和目录。

echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"list_files","arguments":{"path":"."}}}' | php index.php

7. 系统信息

返回全面的系统和PHP信息。

echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"system_info"}}' | php index.php

8. HTTP请求

向外部API发出HTTP请求。

echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"http_request","arguments":{"url":"https://api.github.com","method":"GET"}}}' | php index.php

9. JSON解析

解析并格式化JSON字符串。

echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"json_parse","arguments":{"json":"{\"test\": true}"}}}' | php index.php

10. 获取天气

获取指定城市的天气信息。

echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_weather","arguments":{"city":"London"}}}' | php index.php

🌐 Web API(HTTP模式)

当服务器以Web模式运行时(./start.sh 2), 以下端点可用:

基本端点

  • GET / - 服务器信息和可用的终端节点
  • GET /api/tools - 可用工具列表
  • GET /api/status - 服务器状态和指标
  • GET /api/logs - 最近的日志
  • GET /api/metrics - 系统指标

工具执行

  • POST /api/tools/call - 执行一个工具

工具调用示例:

# Greeting
curl -X POST http://localhost:8888/api/tools/call \
  -H "Content-Type: application/json" \
  -d '{"tool": "hello", "arguments": {"name": "John"}}'

# Calculation
curl -X POST http://localhost:8888/api/tools/call \
  -H "Content-Type: application/json" \
  -d '{"tool": "calculate", "arguments": {"operation": "add", "a": 10, "b": 5}}'

# File listing
curl -X POST http://localhost:8888/api/tools/call \
  -H "Content-Type: application/json" \
  -d '{"tool": "list_files", "arguments": {"path": "src"}}'

🔧 配置

服务器配置通过(某种方式)进行管理 config/server.php

return [
    'server' => [
        'name' => 'enhanced-php-mcp-server',
        'version' => '2.1.0',
    ],
    'logging' => [
        'enabled' => true,
        'file' => __DIR__ . '/../logs/server.log',
        'level' => 'info',
    ],
    'security' => [
        'allowed_paths' => [__DIR__ . '/..'],
        'max_file_size' => 10 * 1024 * 1024, // 10MB
    ],
    // ... more configuration
];

📁 项目结构

enhanced-php-mcp-server/
├── config/           # Configuration files
├── src/             # Source code
├── tests/           # Test files (Unit, Integration, Performance)
├── tools/           # Tool implementations (future)
├── logs/            # Log files
├── storage/         # Temporary storage
├── vendor/          # Composer dependencies
├── index.php        # Main entry point
├── start.sh         # Start script
├── composer.json    # Dependencies and autoloading
└── README.md        # This file

🔒 安全功能

  • 路径限制文件操作仅限于允许的目录
  • 文件大小限制可配置的操作最大文件大小
  • 输入验证所有输入都经过验证和清理
  • 错误处理全面的错误处理,同时不泄露敏感信息
  • 路径遍历防护防止访问项目目录以外的文件

🧪 测试

该项目包含全面的测试套件:

快速测试

# Simple bash tests
./tests/simple_test.sh

PHPUnit 测试

# Run all unit tests
composer test

# Run specific test
./vendor/bin/phpunit --filter testHelloTool

# Generate coverage report
./vendor/bin/phpunit --coverage-html coverage-html

集成测试

# Full HTTP API tests
./tests/run_comprehensive_tests.sh

性能测试

# Performance testing plan
./tests/PERFORMANCE_TESTS_PLAN.md

📝 开发

代码风格

composer cs-check    # Check code style
composer cs-fix      # Fix code style issues

测试

composer test        # Run all tests

依赖项

composer install     # Install dependencies
composer update      # Update dependencies

📝 记录日志

日志会自动创建在 logs/server.log 带有时间戳和严重程度级别:

[2024-01-01 12:00:00] INFO Server started
[2024-01-01 12:00:01] INFO Tool 'hello' executed

🌟 示例

初始化服务器

echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' | php index.php

列出所有工具

echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | php index.php

连锁运营

# Write a file, then read it back
echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"write_file","arguments":{"path":"demo.txt","content":"Hello from MCP!"}}}' | php index.php

echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"read_file","arguments":{"path":"demo.txt"}}}' | php index.php

🚨 故障排除

常见问题

  1. 权限被拒绝确保 start.sh 脚本可执行(chmod +x start.sh)
  2. 缺少依赖项composer install
  3. 缺少扩展程序安装所需的PHP扩展(php-jsonphp-curl)
  4. 文件访问检查项目目录中的文件权限
  5. 端口冲突服务器自动检测到端口8888、8889、8890

调试模式

通过将日志级别设置为启用详细日志记录 debugconfig/server.php

📊 性能指标

服务器内置监控功能:

  • 响应时间跟踪
  • 内存使用监控
  • 工具执行统计
  • 系统指标收集

通过……访问 /api/status 或者 /api/metrics 终端节点。

📄 许可证

MIT 许可证 - 详见 LICENSE 文件。

🤝 贡献(或“参与贡献”)

  1. 为仓库创建分支(或:克隆仓库)
  2. 创建一个特性分支
  3. 进行你的更改
  4. 如适用,请添加测试
  5. 提交拉取请求

📞 支持

对于问题和疑问:

  • 检查日志中的内容 logs/server.log
  • 检查配置中的内容 config/server.php
  • 确保满足所有要求
  • 运行测试套件以诊断问题

目录标签

目录标签

PHP开发工具命令行工具本地部署PHP服务器Web仪表板远程工具JSON协议

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP