修复 HyperfMcpServer 示例 handle 方法#1
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Hyperf integration documentation to reflect the correct HyperfMcpServer entrypoint method and the new server-based annotation registration model.
Changes:
- Update Hyperf route examples from
handler()tohandle('default'). - Replace annotation parameter
groupwithserver, and documentversionas part of registration. - Rename the docs section from group-based registration to server-based registration and update route examples accordingly.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| docs/en/server/hyperf-integration.md | Updates Hyperf route and annotation docs to use handle() and server-based registration terminology. |
| docs/cn/server/hyperf-integration.md | Same as EN doc, for CN localization. |
| README.md | Updates the Hyperf quick integration snippet to call handle('default'). |
| README_CN.md | Same README update for CN localization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+279
to
+291
| // 注册 math MCP 服务 | ||
| Router::addRoute(['POST', 'GET', 'DELETE'], '/mcp/math', function () { | ||
| return \Hyperf\Context\ApplicationContext::getContainer()->get(HyperfMcpServer::class)->handler('math'); | ||
| return \Hyperf\Context\ApplicationContext::getContainer()->get(HyperfMcpServer::class)->handle('math'); | ||
| }); | ||
|
|
||
| // 注册开发工具 | ||
| // 注册 development MCP 服务 | ||
| Router::addRoute(['POST', 'GET', 'DELETE'], '/mcp/dev', function () { | ||
| return \Hyperf\Context\ApplicationContext::getContainer()->get(HyperfMcpServer::class)->handler('development'); | ||
| return \Hyperf\Context\ApplicationContext::getContainer()->get(HyperfMcpServer::class)->handle('development'); | ||
| }); | ||
|
|
||
| // 注册所有工具(默认分组) | ||
| // 注册默认 MCP 服务 | ||
| Router::addRoute(['POST', 'GET', 'DELETE'], '/mcp', function () { | ||
| return \Hyperf\Context\ApplicationContext::getContainer()->get(HyperfMcpServer::class)->handler(); | ||
| return \Hyperf\Context\ApplicationContext::getContainer()->get(HyperfMcpServer::class)->handle('default'); |
| name: 'advanced_calc', | ||
| description: 'Advanced mathematical calculations', | ||
| group: 'math' | ||
| server: 'math' |
| name: 'code_review', | ||
| description: 'Generate code review prompts', | ||
| group: 'development' | ||
| server: 'development' |
Comment on lines
+279
to
+291
| // Register the math MCP server | ||
| Router::addRoute(['POST', 'GET', 'DELETE'], '/mcp/math', function () { | ||
| return \Hyperf\Context\ApplicationContext::getContainer()->get(HyperfMcpServer::class)->handler('math'); | ||
| return \Hyperf\Context\ApplicationContext::getContainer()->get(HyperfMcpServer::class)->handle('math'); | ||
| }); | ||
|
|
||
| // Register development tools | ||
| // Register the development MCP server | ||
| Router::addRoute(['POST', 'GET', 'DELETE'], '/mcp/dev', function () { | ||
| return \Hyperf\Context\ApplicationContext::getContainer()->get(HyperfMcpServer::class)->handler('development'); | ||
| return \Hyperf\Context\ApplicationContext::getContainer()->get(HyperfMcpServer::class)->handle('development'); | ||
| }); | ||
|
|
||
| // Register all tools (default group) | ||
| // Register the default MCP server | ||
| Router::addRoute(['POST', 'GET', 'DELETE'], '/mcp', function () { | ||
| return \Hyperf\Context\ApplicationContext::getContainer()->get(HyperfMcpServer::class)->handler(); | ||
| return \Hyperf\Context\ApplicationContext::getContainer()->get(HyperfMcpServer::class)->handle('default'); |
| name: 'advanced_calc', | ||
| description: '高级数学计算', | ||
| group: 'math' | ||
| server: 'math' |
| name: 'code_review', | ||
| description: '生成代码审查提示', | ||
| group: 'development' | ||
| server: 'development' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.