egg icon indicating copy to clipboard operation
egg copied to clipboard

[Bug] 启用 mcpProxy 后启动失败:Can not find plugin mcpProxy / coreMiddleware 断言错误

Open hahaliu1029 opened this issue 2 weeks ago • 1 comments

在此输入你需要反馈的 Bug 具体信息(Bug in Detail):

背景 / 描述

在 Egg v4 项目中启用 MCP 功能时,按照文档在 config/plugin.ts 开启 mcpProxy 后,应用启动失败,报错显示 Loader 将 mcpProxy 识别为外部插件包来解析,进一步触发 MODULE_NOT_FOUND;同时在迁移/调整配置过程中还遇到一次 Can not define coreMiddleware in app or plugin 的断言错误。

期望行为 • 启动成功; • mcpProxy 能作为框架内置能力被正确开启,而不是被当作外部 npm 插件解析; • 不出现 coreMiddleware 相关断言错误。

实际行为 / 日志

关键报错: ERROR nodejs.Error: Can not find plugin mcpProxy in ".../node_modules/egg/dist" cause: MODULE_NOT_FOUND: Cannot find module 'mcpProxy/package.json' ... ERROR nodejs.AssertionError: Can not define coreMiddleware in app or plugin

可复现问题的仓库地址(Reproduction Repo)

https://github.com/hahaliu1029/egg-mcp.git

Node 版本号:

v22.18.0

Eggjs 版本号:

beta

相关插件名称与版本号(PlugIn and Name):

mcpProxy

操作平台与版本号(Platform and Version):

macOS 26.1 (25B78)/ Apple Silicon

hahaliu1029 avatar Dec 08 '25 06:12 hahaliu1029

@hahaliu1029 在 egg 中还没有添加 mcp plugin 的定义,需要手动安装并且声明 package。

相关插件可以在 https://github.com/eggjs/tegg/tree/master/plugin 这里找到。

killagu avatar Dec 08 '25 11:12 killagu