本文將協助您在 Visual Studio (VS) Code 中,開始搭配 GitHub Copilot 使用 Microsoft Learn 模型內容通訊協定 (MCP) 伺服器。 如果您不熟悉 MCP 伺服器,建議您先檢閱 Learn MCP 伺服器概觀一文 。 請注意,雖然 VS Code 是 Learn MCP Server 的常見客戶端,但 MCP 是一個開放協議,因此被許多客戶端支援,包括 Copilot Studio、Foundry 及其他代理型 IDE。
我們將逐步解說的高階程序如下:
- 設定您的編輯器
- 使用 MCP 伺服器
- 設定說明
當您使用另一個代理程式開發環境時,詳細數據可能會有所不同,但程式應該可以比較。 請參閱 GitHub 存放庫中其他用戶端應用程式的組態選項。
Prerequisites
若要遵循本文中的步驟,您需要 Visual Studio Code 和 GitHub Copilot。
設定您的編輯器
設定 Learn MCP Server 的最簡單方法是使用這些按鈕。
MCP 伺服器可以在用戶層級和工作區層級設定。 用戶設定會套用到每一個 VS Code 工作階段,這對於主要使用 Microsoft 技術的用戶來說,非常方便。 您也可以針對使用Microsoft技術的工作區設定 MCP 設定,併為未使用的工作區設定其他 MCP 伺服器。
如需詳細資訊,請參閱 學習 MCP - 安裝和開始使用
使用 MCP 伺服器
- 開啟聊天室
- 選取代理程式模式
- 詢問與 Microsoft Learn 內容相關的問題,例如:
How to create a Microsoft Foundry instance using az cli? - 允許代理程式使用 MCP 伺服器
- 取得回應
設定指令(建議)
當 AI 代理程式未如預期使用 MCP 工具時,設定工具的特定指示可能會很有用:
- 使用 GitHub Copilot 在 VS Code 中開啟聊天視窗
- 選取代理程式模式
- 在視窗頂端,點擊設定齒輪,然後選取 [指示]
- 選取要建立指示檔案的位置
- 提供指示,例如:
---
applyTo: '**'
---
## Querying Microsoft Documentation
You have access to MCP tools called `microsoft_docs_search`, `microsoft_docs_fetch`, and `microsoft_code_sample_search` - these tools allow you to search through and fetch Microsoft's latest official documentation and code samples, and that information might be more detailed or newer than what's in your training data set.
When handling questions around how to work with native Microsoft technologies, such as C#, F#, ASP.NET Core, Microsoft.Extensions, NuGet, Entity Framework, the `dotnet` runtime - please use these tools for research purposes when dealing with specific / narrowly defined questions that may occur.
後續步驟
您可以瀏覽下列連結,以深入瞭解 Learn MCP 伺服器:
- 了解 MCP 伺服器存放庫以回應意見和問題。
- 在 Foundry 中建立自訂解決方案