Microsoft Learn MCP 服务器入门

本文帮助你开始在 Visual Studio (VS) Code 中将 Microsoft Learn 模型上下文协议 (MCP) 服务器与 GitHub Copilot 配合使用。 如果你不熟悉 MCP 服务器,建议先查看 Learn MCP 服务器概述文章 。 请注意,尽管 VS Code 是 Learn MCP Server 的常见客户端,但 MCP 是一种开放协议,因此许多客户端都支持此类协议,包括 Copilot Studio 中的代理、Foundry 和其他许多代理 IDE 中的代理。

我们通过的高层次过程是:

  1. 配置编辑器
  2. 使用 MCP 服务器
  3. 设定指令

使用另一个代理开发环境时,详细信息可能会有所不同,但该过程应可比较。 请参阅 GitHub 存储库中其他客户端应用的配置选项。

Prerequisites

若要按照本文中的步骤作,需要 Visual Studio CodeGitHub Copilot

配置编辑器

配置 Learn MCP 服务器的最简单方法是使用这些按钮。

在 VS Code 中安装 在 Visual Studio 中安装

MCP 服务器可以在用户级别和工作区级别配置。 用户设置将应用于每个 VS Code 会话,这在大多数情况下使用 Microsoft 技术时十分便利。 还可以为使用Microsoft技术的工作区配置 MCP 设置,并为不使用的工作区配置其他 MCP 服务器。

有关详细信息,请参阅 Learn MCP - 安装和入门

使用 MCP 服务器

  1. 打开聊天
  2. 选择代理模式
  3. 提出与Microsoft Learn 内容相关的问题,例如: How to create a Microsoft Foundry instance using az cli?
  4. 允许代理使用 MCP 服务器
  5. 获取响应

当 AI 代理在预期情况下不使用 MCP 工具时,为该工具配置特定说明可能很有用:

  1. 使用 GitHub Copilot 在 VS Code 中打开聊天窗口
  2. 选择代理模式
  3. 在窗口顶部,单击设置滚轮并选择“说明”
  4. 选择用于创建说明文件的位置
  5. 提供如下说明:
---
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 服务器的详细信息: