github / github/copilot-engine-sdk
Bound and cancel MCP proxy discovery during session startup
- Linguagem predominante
- TypeScript
- Estrelas
- 23
- Forks
- 4
- Merge médio
- 10min
- PRs com merge (30d)
- 1
Descrição
## Summary
`discoverMCPServers()` performs MCP proxy health and server-list requests sequentially. The health request can consume five seconds and the list request can then consume another ten seconds. Callers cannot cancel the operation, and an unavailable or transiently failing proxy is returned as the same empty configuration as a healthy proxy with no configured servers.
Discovery should have one caller-controlled cancellation and deadline contract so startup cannot continue doing work after its caller has abandoned the session.
## Current behavior
In `src/mcp-proxy.ts`:
1. `discoverMCPServers()` awaits `isMCPProxyAvailable()`.
2. Only after that request succeeds does it request the server list.
3. Each request owns a separate timeout, making the total wait additive.
4. The public function does not accept an `AbortSignal` or deadline.
5. Proxy unavailability and a valid empty server list both produce an empty object.
This behavior can add the full health timeout and list timeout to a startup path. It also leaves no structured way for callers to distinguish a valid empty configuration from discovery that could not complete.
## Expected behavior
- Callers can cancel discovery through the SDK API.
- Health and list discovery share one overall time budget rather than independent additive budgets.
- Cancellation stops the active fetch and does not leave a timer or request running.
- A valid empty server list remains a successful result.
- Consumers have a documented way to observe that discovery was unavailable, cancelled, timed out, or invalid without parsing log output.
- Existing consumers that rely on the convenience API can migrate without an unrelated MCP configuration rewrite.
## Reproduction and test cases
Add deterministic tests for:
- Healthy proxy with one server.
- Healthy proxy with an empty server list.
- Health endpoint that never responds.
- List endpoint that never responds after a successful health check.
- Cancellation during health discovery.
- Cancellation during list discovery.
- Connection failure, non-success response, and malformed response body.
The elapsed time test should prove that one overall deadline is enforced rather than the sum of two request timeouts.
## Proposed scope
- Add caller cancellation and an overall discovery deadline.
- Define how discovery outcome is reported without conflating a valid empty list with failure.
- Preserve the current conversion from discovered proxy entries to Copilot SDK MCP server configuration.
## Non-goals
- Caching MCP discovery results.
- Adding a general retry policy.
- Changing the MCP proxy protocol.
- Changing MCP authentication behavior.
- Adding GitHub App-specific startup behavior to this SDK.
## Acceptance criteria
- A caller can abort either discovery request.
- One elapsed-time budget bounds the full operation.
- Tests distinguish valid-empty, unavailable, timed-out, cancelled, and invalid-response outcomes.
- No request or timeout remains active after cancellation.
- The API and migration behavior are documented.
Guia de contribuição
Direção de pesquisa
Comece em src/mcp-proxy.ts com discoverMCPServers(), isMCPProxyAvailable() e o fluxo de requisição da lista de servidores. Adicione cobertura determinística para a descoberta nos estados saudável, vazio, indisponível, inválido, com tempo limite excedido e cancelado durante ambas as requisições, incluindo um único prazo geral e a limpeza após o cancelamento. Considera-se concluído quando os chamadores conseguem observar resultados distintos e a conversão da configuração MCP existente e a migração da convenience API continuam sendo compatíveis.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- typescript
- Domínio
- api, backend-api-design
- Tipo de issue
- Funcionalidade
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Ativa
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 48/100