Copilot CLI executes prompt before MCP servers finish connecting (missing tools on first turn)
- Lenguaje dominante
- Shell
- Estrellas
- 11.2k
- Forks
- 1.9k
- Merge medio
- 14 h 16 min
- PR fusionados (30 d)
- 6
Descripción
### Describe the bug
Summary
When running single-command prompts (non-interactive / child sessions), Copilot CLI appears to execute the prompt before MCP servers have finished connecting, causing the tool schema to be empty or incomplete on the first turn.
This results in:
MCP tools not being available to the model
Immediate failures or incorrect behavior
Intermittent reproducibility (timing-dependent)
Observations / Evidence
This behavior correlates with MCP startup latency (~1–2s range observed)
CLI seems to:
Start session
Build tool schema
Send prompt
Only then finish MCP connection asynchronously
Internal observation:
Tool schema is constructed before MCP client connection completes, so the model cannot see tools on first turn [Plugin Prototyping | Teams]
Behavior is significantly more visible in:
non-interactive mode (copilot "...")
child sessions (spawned by skills / eval frameworks)
Impact
Breaks reliability of MCP-based workflows
Makes automation (evals, scripts, CI usage) flaky
Forces workarounds like:
artificial delays
warm-up prompts
re-running commands
Workarounds (temporary)
Run an initial “no-op” prompt before actual command
Add delay before issuing prompt (~2s)
Avoid spawning new sessions; reuse a warmed session
Pre-run MCP setup outside of Copilot CLI process
Additional Context
This appears related to async MCP connection lifecycle + lack of readiness barrier
CLI currently behaves as if tools exist only after MCP fully loads, with no blocking initialization step [[github.com]](https://github.com/github/copilot-cli/issues/679)
Similar instability in MCP connectivity has been reported in recent CLI versions (timing / connection issues) [[github.com]](https://github.com/github/copilot-cli/issues/3257)
Suggested Fix
Introduce a synchronization / readiness barrier before prompt execution:
Block until:
MCP servers are connected, OR
a configurable timeout is reached
Alternatively:
allow "lazy tool schema refresh" after MCP connects
or expose an --await-mcp / --wait-for-tools flag
Environment
Copilot CLI version: GitHub Copilot CLI 1.0.48
OS: Windows 11
MCP server type(s): http
Repro frequency: high frequency as of 5/14/2026
### Affected version
GitHub Copilot CLI 1.0.48
### Steps to reproduce the behavior
Repro Steps
Configure one or more MCP servers (local or remote) in ~/.copilot/mcp-config.json
Run a single-command prompt, for example:
Shellcopilot "run "Show more lines
or trigger via:
evaluation scripts
skills that spawn a child session
Observe behavior on first execution
### Expected behavior
Expected Behavior
Copilot CLI should wait until MCP servers are fully connected and tools are registered before:
building the tool schema
sending the prompt to the model
MCP tools should be consistently available on the first turn
Actual Behavior
CLI begins prompt execution before MCP initialization completes
The LLM receives a tool schema that:
contains no MCP tools or only partial set
### Additional context
Subsequent runs or retries sometimes succeed (after MCP finishes connecting)
Guía de contribución
Línea de trabajo
Reproduce el fallo del primer turno usando ~/.copilot/mcp-config.json y un prompt de copilot de un solo comando que requiera una herramienta MCP; después, inspecciona el inicio de la sesión y la creación del esquema de herramientas en relación con la finalización de la conexión MCP. Se considera terminado cuando las herramientas MCP están presentes de forma consistente en el esquema del primer turno y también se ha comprobado el comportamiento para sesiones secundarias y un timeout u otro resultado de disponibilidad.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- shell
- Área
- cli
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 48/100