antidrift/zeromcp 问题修复 & 功能扩展

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

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

antidrift/zeromcp

Composer 安装命令:

composer require antidrift/zeromcp

包简介

Zero-config MCP runtime for PHP

README 文档

README

Drop a .php file in a folder, get a sandboxed MCP server. Stdio out of the box, zero dependencies.

Getting started

<?php
// tools/hello.php — this is a complete MCP server
return [
    'description' => 'Say hello to someone',
    'input' => ['name' => 'string'],
    'execute' => function ($args, $ctx) {
        return "Hello, {$args['name']}!";
    },
];
php zeromcp.php serve ./tools

That's it. Stdio works immediately. Drop another .php file to add another tool. Delete a file to remove one.

vs. the official SDK

The official PHP SDK (backed by The PHP Foundation) requires Composer, server setup, transport configuration, and explicit tool registration. ZeroMCP is file-based — each tool is its own file, discovered automatically. Pure PHP, no Composer, no extensions.

In benchmarks, ZeroMCP PHP handles 13,333 requests/second over stdio versus the official SDK's 18 — 740x faster. Over HTTP (Slim), ZeroMCP serves 1,561 rps at 11-33 MB versus the official SDK's 17 rps at 31-64 MB. The official SDK takes 54ms per request. ZeroMCP takes 0.53ms. The official SDK corrupted responses on giant strings and slow tools in chaos testing. ZeroMCP survived 22/22 attacks.

The official SDK has no sandbox. ZeroMCP lets tools declare network, filesystem, and exec permissions.

PHP passes all 10 conformance suites.

HTTP / Streamable HTTP

ZeroMCP doesn't own the HTTP layer. You bring your own framework; ZeroMCP gives you a handleRequest method that takes an associative array and returns an array (or null for notifications).

// $response = $server->handleRequest($request);

Slim

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;

$app = AppFactory::create();

$app->post('/mcp', function (Request $req, Response $res) use ($server) {
    $body = json_decode((string) $req->getBody(), true);
    $response = $server->handleRequest($body);

    if ($response === null) {
        return $res->withStatus(204);
    }
    $res->getBody()->write(json_encode($response));
    return $res->withHeader('Content-Type', 'application/json');
});

$app->run();

Requirements

  • PHP CLI (no extensions required)

Sandbox

<?php
return [
    'description' => 'Fetch from our API',
    'input' => ['url' => 'string'],
    'permissions' => [
        'network' => ['api.example.com', '*.internal.dev'],
        'fs' => false,
        'exec' => false,
    ],
    'execute' => function ($args, $ctx) {
        // ...
    },
];

Directory structure

Tools are discovered recursively. Subdirectory names become namespace prefixes:

tools/
  hello.php          -> tool "hello"
  math/
    add.php          -> tool "math_add"

Testing

php tests/run.php

antidrift/zeromcp 适用场景与选型建议

antidrift/zeromcp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 antidrift/zeromcp 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-06