MCP gateway conversion silently drops a server named `__proto__`

Abierto Apto para principiantes
#80,189 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
github-actions, javascript, node.js
Área
devtools

Línea de trabajo

Empieza en filterAndTransformServers en actions/setup/js/convert_gateway_config_shared.cjs, donde result[name] = transformServer(name, entry) asigna valores sobre un objeto plano. Compara con loadCopilotSDKMCPServers en actions/setup/js/copilot_sdk_tool_config.cjs, que usa Object.defineProperty, y con su prueba de __proto__ en copilot_sdk_tool_config.test.cjs. Está terminado cuando un servidor proto sobrevive en ambos catálogos y la cantidad de servidores incluidos coincide con la cantidad de servidores de origen.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Go
Estrellas
5.7k
Forks
635
Merge medio
3 h 43 min
PR fusionados (30 d)
838

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de github/gh-aw

Todos los issues de github/gh-aw

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.