github / github/copilot-cli

feat: Explicit MCP tool triggering via @mcp or #mcp- syntax in Copilot CLI

Aberta
#2,690 2 comentários 3 reações 0 responsáveis Ver no GitHub
area:mcp
Linguagem predominante
Shell
Estrelas
11.2k
Forks
1.9k
Merge médio
14h 16min
PRs com merge (30d)
6

Descrição

### Describe the feature or problem you'd like to solve

When multiple MCP servers are configured in Copilot CLI, there is no way to explicitly trigger a specific MCP tool from a prompt. The model decides autonomously whether and which MCP to invoke — and often doesn't, even when the user has a clear intent. Even with local or global MCP setups, it is sometimes random if -- or which -- MCP is used in response to a user query.

VS Code Copilot Chat has a more reliable, user-triggered tool interface (e.g., @tool selectors), making it easier to guarantee the right tool is used at the right time. The CLI currently lacks this precision.

This leads to two compounding problems:

1. **MCPs are frequently not used** even when they would be the best tool for the job (e.g. a code analysis MCP, a memory/context MCP like Serena, or a domain-specific search MCP).
2. **All configured MCPs consume tokens at session start** regardless of whether they are ever invoked, increasing cost with every prompt turn.

### Proposed solution

Introduce an explicit invocation syntax — similar to @mention in IDEs or # references — that allows users to directly target a specific MCP server or tool from their prompt:

```
@mcp-zen-of-languages analyze this file for code quality
#mcp-serena remember that we use conventional commits in this project
@github-mcp search for open issues labeled "bug"
```

This syntax would:
- **Force** the named MCP to be invoked for that turn, bypassing model-side tool selection uncertainty
- Allow **lazy loading** of MCPs that are not in the autoConnect pool until explicitly called (complementing #1938)
- Give users **cost control** — only paying token costs for MCPs they deliberately invoke

### Example prompts or workflows

```
# Trigger a specific MCP for code review
@Anselmoo/mcp-zen-of-languages review src/parser.ts

# Explicitly write to a memory MCP
@serena remember: this repo uses trunk-based development

# Force a GitHub MCP search instead of a generic web search
@github-mcp list open PRs in github/copilot-cli
```

### Additional context

- Related to #212 — interactive MCP selector per prompt
- Related to #1938 — deferred/lazy MCP loading to reduce token cost
- Related to #2235 — MCP profiles for context-based activation
- Cross-repo reference: cli/cli#12522 — making `gh` better for agents
- Example MCP that would benefit from explicit triggering: [Anselmoo/mcp-zen-of-languages](https://github.com/Anselmoo/mcp-zen-of-languages) for quick per-file code analysis

This is the terminal equivalent of the @tool selector in VS Code Copilot Chat's agent mode. Other CLI tools (Claude Code, Gemini CLI) are moving toward explicit tool invocation surfaces — Copilot CLI should have parity.

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

Start by reviewing the related issues #212, #1938, and #2235, along with the referenced cross-repo issue cli/cli#12522. Done means users can explicitly target an MCP server or tool from a prompt, with the requested invocation and lazy-loading behavior defined and covered by the project’s relevant checks.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Domínio
ai, cli
Tipo de issue
Funcionalidade
Dificuldade
5/5
Tempo estimado
Mais de uma semana
Status de atividade
Pouca atividade
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.