mcp
Model Context Protocol for Hyperf
claude mcp add --transport stdio friendsofhyperf-mcp-server php bin/hyperf.php start \ --env APP_ENV="production" \ --env REDIS_URL="redis://localhost" \ --env MCP_LOG_LEVEL="info"
How to use
This MCP server implements the Model Context Protocol (MCP) using the Hyperf PHP framework. It provides complete MCP protocol support, including tools, resources, and prompts management, and supports both STDIO and HTTP transport methods. The server automatically discovers and registers components via annotations, and uses Redis for distributed session management. To use it, first install and configure the server in your Hyperf application, publish the MCP server configuration, and start the Hyperf server. Clients can connect via HTTP to the configured endpoint (default /mcp) or interact with the STDIO-based command line tool for real-time MCP operations. The included tooling lets you create tools, resources, and prompts, and manage them through MCP-compliant requests and responses.
How to install
Prerequisites:
- PHP >= 8.1
- Hyperf ~3.1.0
- Redis extension for PHP
- Composer
-
Install the MCP server package:
composer require friendsofhyperf/mcp-server
-
Publish the configuration:
php bin/hyperf.php vendor:publish friendsofhyperf/mcp-server
-
Configure MCP servers: Edit the published config to enable and customize servers, capabilities, routing, and discovery as needed. Example settings include enabling tools, resources, prompts, and completions, setting protocol_version, pagination_limit, and discovery paths.
-
Start the Hyperf server:
php bin/hyperf.php start
-
Verify:
- Access the HTTP MCP endpoint (default path /mcp) if HTTP transport is enabled.
- Use the STDIO tool via the built-in command signature (mcp:stdio) if you require STDIO transport.
Note: Ensure Redis is running and accessible if you rely on Redis-based session management. You can customize session storage and discovery behavior in the published configuration.
Additional notes
Tips and common considerations:
- Ensure PHP 8.1+ and the Redis PHP extension are installed and enabled.
- When running multiple MCP server instances, you can configure multiple entries under mcpServers in the config.
- The HTTP transport defaults to route /mcp; you can customize the path and middleware in the config under http.
- The server auto-discovers tools, resources, and prompts via annotations; ensure your PHP classes use the appropriate Mcp\Capability\Attribute attributes.
- For deployment, consider configuring a proper process manager and ensuring Redis connection health for session storage.
- If you encounter issues with annotations discovery, verify that your code autoloads correctly and that base_path/scan_dirs are set to include your app source directories.
Related MCP Servers
drift
Codebase intelligence for AI. Detects patterns & conventions + remembers decisions across sessions. MCP server for any IDE. Offline CLI.
laravel
A Laravel package for implementing secure Model Context Protocol servers using Streamable HTTP and SSE transport, providing real-time communication and a scalable tool system for enterprise environments.
relay
An MCP client tool for Prism
php
基于 PHP 实现的 MCP (Model Control Protocol) 服务器框架,通过注解优雅地定义 MCP 服务,支持 Tool、Prompt、Resource 三种处理器,支持Stdio、Sse 两种 transport。
mcp-profiler-bundle
The Symfony MCP Profiler Bundle mimics the WebProfiler Bundle. It bridges the gap between Profiler data and your favorite MCP-enabled AI-powered IDE.
elementor
Comprehensive Elementor MCP Server plugin.