MCP gateway conversion silently drops a server named `__proto__`

未关闭 适合新手
#80,189 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
github-actions, javascript, node.js
领域
devtools

调研方向

从 actions/setup/js/convert_gateway_config_shared.cjs 中的 filterAndTransformServers 开始,其中 result[name] = transformServer(name, entry) 直接赋值到一个普通对象上。与 actions/setup/js/copilot_sdk_tool_config.cjs 中使用 Object.defineProperty 的 loadCopilotSDKMCPServers 进行比较,并查看 copilot_sdk_tool_config.test.cjs 中的 __proto__ 测试。当名为 proto 的服务器在两个目录中都保留下来,且包含的服务器数量与源服务器数量一致时,即完成。

由索引模型根据 Issue 内容生成。

描述

ai-inspected

Summary

The shared gateway-to-Copilot converter copies MCP servers into its result object with a plain property assignment. When a workflow declares an MCP server named __proto__, that assignment mutates the result object's prototype instead of creating an own key, so the server silently disappears from both generated Copilot catalogs: the CLI catalog at $HOME/.copilot/mcp-config.json and the SDK catalog at $RUNNER_TEMP/gh-aw/mcp-config/copilot-sdk.json. The SDK catalog loader in the same repository is explicitly implemented and unit-tested to preserve exactly such names, and the compiler accepts the name, so the producer and the consumer of the same catalog disagree about which servers exist.

Environment

  • Repository: github/gh-aw, commit e507073a5b3dca9ed1e859e9af837561f8652f81; the same converter assignment is still present on the default branch.
  • Files: actions/setup/js/convert_gateway_config_copilot.cjs, actions/setup/js/convert_gateway_config_shared.cjs (function filterAndTransformServers), actions/setup/js/copilot_sdk_tool_config.cjs (function loadCopilotSDKMCPServers).
  • Runtime: Node.js 22.23.5 on Linux.
  • Input: a workflow that declares two MCP servers, one of them named __proto__, and the gateway-output catalog for that configuration.

Expected behavior

A workflow may legally declare an MCP server named __proto__: compilation succeeds and the generated gh-aw-manifest lists it, and the generated gateway configuration contains that server. Conversion should carry the server into the Copilot CLI catalog and the SDK catalog unchanged, and the SDK session loader should register it. That is the contract the repository already asserts in actions/setup/js/copilot_sdk_tool_config.test.cjs with the test named "preserves a literal proto server as an own property without changing the dictionary prototype", and the loader's own comment says it preserves "names such as proto as own keys without invoking inherited setters".

Actual behavior

The compiler accepts the name and emits the server:

compiled manifest mcp server names: ['__proto__', 'github', 'safeoutputs']
gateway configuration emitted for the agent:
  "__proto__": {

The converter then drops it and reports an incorrect filter count, because it computes the filtered number by subtraction from the input size:

[info] Converting gateway configuration to Copilot format...
[info] Target domain: host.docker.internal:80
[info] Servers: 1 included, 1 filtered (CLI-mounted)
[info] Converted servers: github

Both generated catalogs contain only the second server:

{
  "mcpServers": {
    "github": {
      "type": "http",
      "url": "http://host.docker.internal:80/mcp/github",
      "timeout": 30000,
      "tools": [
        "*"
      ]
    }
  }
}

The SDK session therefore cannot register the missing server:

registered server names: ["github"]
__proto__ registered: false

Root cause

filterAndTransformServers in actions/setup/js/convert_gateway_config_shared.cjs builds the converted catalog with a plain object and a dynamic assignment:

const result = {};
for (const [name, value] of Object.entries(servers)) {
  if (cliServers.has(name)) continue;
  const entry = { ...value };
  result[name] = transformServer(name, entry);
}
return result;

When name is __proto__, result["__proto__"] = ... invokes the inherited Object.prototype.__proto__ accessor: it replaces the prototype of result with the transformed server object instead of defining an own enumerable property. JSON.stringify({ mcpServers: result }) only serializes own enumerable properties, so the server is absent from both catalogs that are written from this result. The negative side effect is also visible in the log line "1 included, 1 filtered (CLI-mounted)", which reports a filter that never happened because the count is computed as total minus Object.keys(result).length.

The consumer side already handles the same name correctly: loadCopilotSDKMCPServers in actions/setup/js/copilot_sdk_tool_config.cjs registers each entry with Object.defineProperty(servers, name, { value: server, enumerable: true, configurable: true, writable: true }) and has a dedicated test for __proto__. The converter that produces the catalog read by that loader does not follow the same rule.

Suggested fix

Define own properties in filterAndTransformServers instead of assigning them, for example by building the result from Object.defineProperty(result, name, { value: transformServer(name, entry), enumerable: true, configurable: true, writable: true }), or by returning Object.fromEntries over the filtered entries, which also creates data properties and never invokes inherited setters. Add a regression test that runs a gateway-output catalog containing a __proto__ server through the full conversion pipeline and asserts that the name survives serialization in both the CLI and SDK catalogs, and that the "included" count matches the number of source servers.

主要语言
Go
星标
5.7k
派生
635
平均合并
3 小时 43 分钟
30 天内合并 PR
838

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

github/gh-aw 的其他 Issue

查看 github/gh-aw 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。