概要
What is PHP MCP Server?
PHP MCP Server is a PHP implementation of the Model Context Protocol (MCP) framework that enables developers to define MCP services using annotations. It supports Tool, Prompt, and Resource handlers and can operate over Stdio or SSE transports. It is intended for PHP developers building MCP-compatible servers for AI assistants or other contextual agents.
How to use PHP MCP Server?
Clone the repository and install dependencies via Composer. Run the test server with php bin/console mcp:test-server and optionally pass --transport (stdio or sse) and --port (default 8000 for SSE). The server can also be executed without local installation via CPX (Composer Package Executor) using cpx he426100/php-mcp-server mcp:test-server.
Key features of PHP MCP Server
- Annotation-based definition of MCP services
- Support for Tool, Prompt, and Resource handlers
- Stdio and SSE transport modes
- Compatible with Swow (>1.5) and Swoole (>5.1) environments
- Integrated logging system
- Docker support for containerized deployment
Use cases of PHP MCP Server
- Build custom MCP tools that AI assistants can invoke
- Expose reusable prompt templates via MCP Prompt handlers
- Serve structured resources (text, binary, JSON) through MCP Resource endpoints
- Run a lightweight MCP server in containerized or serverless environments
FAQ from PHP MCP Server
What are the system requirements?
PHP >=8.1, Composer, and either Swow extension >1.5 or Swoole >5.1. Docker is optional.
What transport types does it support?
Stdio and SSE (Server-Sent Events). The default transport is stdio.
Can I run PHP MCP Server without installing it locally?
Yes, via CPX (Composer Package Executor). Run cpx he426100/php-mcp-server mcp:test-server directly.
Is Docker supported?
Yes. Build the image with docker build -t php-mcp-server . and run with the SSE transport on port 8000.
Where are server logs stored?
Logs are saved to runtime/server_log.txt by default. The path can be customised by overriding $logFilePath in a subclass of AbstractMcpServerCommand.