定制 vodmal/composer-scripts-mcp-server 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

vodmal/composer-scripts-mcp-server

Composer 安装命令:

composer require vodmal/composer-scripts-mcp-server

包简介

A PHP library that exposes Composer scripts as capabilities through a Model Context Protocol (MCP) server

README 文档

README

A PHP library that exposes your project's Composer scripts as MCP (Model Context Protocol) tools. Once installed, AI assistants (or any MCP client) can discover and execute your Composer scripts automatically—no need to explain commands each time.

This works with any PHP project, and you can connect multiple projects without limits. Each project's MCP tool name is derived automatically from its composer.json (e.g., the "name" field).

Why Use Composer Scripts?

Composer scripts let you standardize and automate common tasks (tests, linting, code generation, etc.) without adding extra dependencies. Key benefits include:

  • Zero extra dependencies: Scripts work immediately after composer install.
  • Consistent interface: Every team member uses the same commands, regardless of OS or local setup.
  • Self-documenting workflows: Your composer.json doubles as documentation for available commands.
  • Cross-platform: Scripts run uniformly on macOS, Linux, and Windows.

While this approach has many advantages, there are some limitations:

  • You need to remember the specific script names for each project
  • Complex script chains can be harder to debug than standalone tools
  • Performance may be slightly slower than native binaries

Despite these minor drawbacks, the convenience of having commands available immediately after composer install without additional external dependencies is a significant advantage. This is where this tool comes in - it allows AI assistants to discover and execute your Composer scripts without you having to explain the commands each time.

Real-World Example

Here's an example of how powerful Composer scripts can be in a real project:

"scripts": {
    "check:before:commit": [
        "@test",
        "@check:code:style",
        "@check:code:static",
        "@check:code:dependency"
    ],
    "check:before:push": [
        "@check:config",
        "@check:before:commit",
        "@check:code:security"
    ],
    "check:code:static": [
        "@check:code:lint",
        "@rector",
        "@psalm",
        "@phpstan",
        "@classleak",
        "@check:code:comments"
    ],
    "test": [
        "@test:unit:phpunit"
    ],
    "test:unit:phpunit": [
        "@phpunit --testsuite Unit"
    ],
    "phpunit": "./vendor/bin/phpunit"
}

With these scripts, developers can run comprehensive checks before committing or pushing code with simple commands like composer check:before:commit. The MCP server exposes these scripts to AI assistants, allowing them to understand and execute the appropriate commands without requiring you to explain your project's specific testing or validation procedures each time.

One of the biggest advantages of this approach is that you don't need to repeatedly explain to each LLM how to run tests, check code style, or perform other common development tasks. Instead, the LLM can discover the available commands through the MCP server and suggest the appropriate command for the task at hand. This saves time and reduces friction when working with AI assistants on your PHP projects.

Features

By installing VoDmAl Composer Scripts MCP Server, you get two major advantages:

  1. Automatic discovery of all Composer scripts in your project as MCP tools.
  2. One-step integration with AI assistants (e.g., Claude Desktop), so they can list and run any script without manual setup.
  • Automatically reads Composer scripts from composer.json
  • Exposes scripts as MCP tools that can be discovered and executed
  • Support for both stdio and HTTP transports
  • Simple integration with any PHP project
  • Automatically adds scripts to your project's composer.json when installed

Requirements

  • PHP 8.1 or higher
  • Composer
  • php-mcp/server ^2.1

Simple Installation & Automatic Setup

To get started, run:

composer require vodmal/composer-scripts-mcp-server
composer install

As soon as Composer finishes, your project's composer.json will include two new scripts:

"scripts": {
    "mcp:server:start": "vendor/bin/mcp-server-start",
    "mcp:server:install": "vendor/bin/mcp-server-install"
}

You now have everything you need. You do not need to run composer mcp:server:start immediately. Instead, if you want to integrate with Claude Desktop (or any MCP-compatible LLM), run:

composer mcp:server:install

If Claude Desktop is installed and its configuration file is detected, this command merges the MCP configuration automatically.

If it doesn't find Claude's config, it prints out a JSON snippet. Paste that snippet into your claude_config.json under "tools" and restart Claude.

Connect to any number of projects You can run composer mcp:server:install in each PHP project folder without limit. Each project's tool name is pulled from its own composer.json "name" field, so multiple projects appear distinctly in Claude's tool list.

If you're not using Claude Running:

composer mcp:server:install

will output a JSON block showing exactly how to launch the MCP server. Copy that into whatever LLM or MCP client configuration you need. Once that's configured, your AI assistant can call the composer_list and composer_run MCP methods without further setup.

Advanced Manual Configuration & Startup

With stdio Transport

To start the server with stdio transport (for integration with AI assistants):

vendor/bin/mcp-server-start

With HTTP Transport

To start the server with HTTP transport (for testing with the client):

vendor/bin/mcp-server-start --http [--host=<host>] [--port=<port>]

By default, the server will listen on 127.0.0.1:8088.

Integration with Claude Desktop

To integrate this MCP server with Claude Desktop, you can use the provided mcp-server-install command:

vendor/bin/mcp-server-install

This command will automatically detect your operating system and search for the Claude Desktop configuration file. If found, it will update it to include the MCP server configuration. If not found, it will output the configuration that you need to manually merge with your Claude Desktop configuration file. The server will automatically expose all Composer scripts in your project as MCP tools.

Command Options

  • --output=<file>: Specify a custom output file (by default, the command will try to find the Claude Desktop configuration file for your OS)
  • --name=<name>: Specify the server name (default: the project name from composer.json)

Multiple Servers

If you have multiple PHP projects with this library installed, you can add each of them to the same configuration file:

# In project1
vendor/bin/mcp-server-install --name=project1

# In project2
vendor/bin/mcp-server-install --name=project2 --output=/path/to/claude_desktop_config.json

Using the Configuration

  1. Restart Claude Desktop completely
  2. After restarting, you should see a slider icon in the bottom left corner of the input box
  3. Click on the slider icon to see the available tools (your Composer scripts)
  4. You can now ask Claude to run any of your Composer scripts

Troubleshooting

If the server isn't being picked up by Claude Desktop:

  1. Make sure Claude Desktop is on the latest version
  2. Check that the configuration file syntax is correct
  3. Verify that the file paths in the configuration are valid and absolute (not relative)
  4. Look at logs to see why the server is not connecting:
    • macOS: ~/Library/Logs/Claude
    • Windows: %APPDATA%\Claude\logs
  5. Try manually running the server to see if you get any errors:
    vendor/bin/mcp-server-start

Note: When using stdio transport with LLM applications, all log messages are written to stderr instead of stdout. This prevents log messages from interfering with the JSON communication between the server and the LLM application, which could cause JSON parsing errors.

Available MCP Tools

The library provides the following MCP tools:

composer_list

Lists all available Composer scripts.

Parameters: None

Returns:

  • scripts: Array of script information (name and command)
  • count: Number of available scripts

composer_run

Runs a Composer script.

Parameters:

  • script (string, required): The name of the script to run
  • arguments (array, optional): Additional arguments to pass to the script

Returns:

  • script: The name of the script that was run
  • command: The command that was executed
  • output: The output of the command
  • return_code: The return code of the command
  • success: Whether the command was successful (return code 0)

License

This project is dual-licensed:

Open Source License

This project is licensed under the GNU General Public License v3.0 (GPL-3.0) for open source use. See the LICENSE-GPL file for details.

Commercial License

For commercial use in proprietary software, a separate commercial license is available. Contact [ваш email] for commercial licensing terms.

License Summary

  • GPL-3.0: Free for open source projects that are also GPL-3.0 licensed
  • Commercial: Paid license for proprietary/commercial use without GPL restrictions

If you're unsure which license applies to your use case, please contact us.

vodmal/composer-scripts-mcp-server 适用场景与选型建议

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

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

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

围绕 vodmal/composer-scripts-mcp-server 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2025-06-03