feat: Explicit MCP tool triggering via @mcp or #mcp- syntax in Copilot CLI
- 主要语言
- Shell
- 星标
- 11.2k
- 派生
- 1.9k
- 平均合并
- 14 小时 16 分钟
- 30 天内合并 PR
- 6
描述
### 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.
贡献指南
调研方向
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.
由索引模型根据 Issue 内容生成。
评估
- 领域
- ai, cli
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100