{"id":31646648,"url":"https://github.com/hyperf/mcp-incubator","last_synced_at":"2025-10-07T05:55:21.094Z","repository":{"id":284268472,"uuid":"953945215","full_name":"hyperf/mcp-incubator","owner":"hyperf","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-09T01:35:03.000Z","size":65,"stargazers_count":22,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-21T02:32:36.853Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyperf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"open_collective":"hyperf","custom":"https://hyperf.wiki/#/zh-cn/donate"}},"created_at":"2025-03-24T10:27:08.000Z","updated_at":"2025-07-18T04:06:23.000Z","dependencies_parsed_at":"2025-03-25T03:22:23.854Z","dependency_job_id":"5e88843b-be96-46ba-aa6a-8996b43b86e4","html_url":"https://github.com/hyperf/mcp-incubator","commit_stats":null,"previous_names":["hyperf/mcp-incubator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hyperf/mcp-incubator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf%2Fmcp-incubator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf%2Fmcp-incubator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf%2Fmcp-incubator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf%2Fmcp-incubator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperf","download_url":"https://codeload.github.com/hyperf/mcp-incubator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf%2Fmcp-incubator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278728316,"owners_count":26035412,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-07T05:55:17.296Z","updated_at":"2025-10-07T05:55:21.085Z","avatar_url":"https://github.com/hyperf.png","language":"PHP","funding_links":["https://opencollective.com/hyperf","https://hyperf.wiki/#/zh-cn/donate"],"categories":[],"sub_categories":[],"readme":"# Model Context Protocol (MCP)\n\n开始使用模型上下文协议 Model Context Protocol (MCP)。\n\n## 安装\n\n```bash\ncomposer require hyperf/mcp-incubator\n```\n\n## 使用\n\n### Stdio\n\n\n```php\n\u003c?php\n\nuse Hyperf\\Mcp\\Annotation\\Tool;\nuse Hyperf\\Mcp\\Server\\Annotation\\Server;\n\n#[Server(name: 'stdio', signature: 'mcp:command', description: '这是一个测试命令')]\nclass Foo\n{\n    #[Tool(name: 'sum', description: '计算两个数的和', serverName: 'stdio')]\n    public function sum(#[Description('这是A参数')] int $a, #[Description('这是B参数')] int $b = 0): int\n    {\n        return $a + $b;\n    }\n}\n```\n\n\n\n### SSE\n\n修改`autoload/server.php` (新增 `mcp-sse` 协议)\n\n注意: SSE 协议属于**有状态长连接**协议, 请确保你的 Nginx 配置支持长连接, 并且根据`sessionId` 参数进行负载均衡。\n\n```php\n\u003c?php\n\nuse Hyperf\\Server\\Server;\nuse Hyperf\\Server\\Event;\nuse Hyperf\\Mcp\\Server\\McpServer;\n\nreturn [\n    'type' =\u003e Hyperf\\Server\\CoroutineServer::class, # 建议协程风格\n    'servers' =\u003e [\n        'mcp-sse' =\u003e [\n            'type' =\u003e Server::SERVER_HTTP,\n            'host' =\u003e '0.0.0.0',\n            'port' =\u003e 3000,\n            'sock_type' =\u003e SWOOLE_SOCK_TCP,\n            'callbacks' =\u003e [\n                Event::ON_REQUEST =\u003e [McpServer::class, 'onRequest'],\n                Event::ON_CLOSE =\u003e [McpServer::class, 'onClose'],\n            ],\n            'options' =\u003e [\n                'mcp_path' =\u003e '/sse',\n            ],\n        ],\n    ],\n];\n```\n\n```php\n\u003c?php\n\nuse Hyperf\\Mcp\\Annotation\\Tool;\nuse Hyperf\\Mcp\\Server\\Annotation\\Server;\n\n#[Server(name: 'mcp-sse', description: '这是一个测试命令')]\nclass Foo\n{\n    #[Tool(name: 'sum', description: '计算两个数的和', serverName: 'mcp-sse')]\n    public function sum(#[Description('这是A参数')] int $a, #[Description('这是B参数')] int $b = 0): int\n    {\n        return $a + $b;\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperf%2Fmcp-incubator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperf%2Fmcp-incubator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperf%2Fmcp-incubator/lists"}