MBS MCP服务器:MBS副驾驶devcontext(又名真棒副驾驶)
这是一个MCP服务器,用于从 mbs副驾驶舱 存储库。
安装
先决条件
- C#开发工具包 扩展
- Azure命令行界面
- Azure开发者命令行界面
- -通过GitHub API访问awsome-copilot存储库需要
包含什么
出色的Copilot MCP服务器包括:
| 积木 | 名称 | 描述 | 用途 |
|---|---|---|---|
| 工具 | search_instructions | 根据描述中的关键字搜索自定义说明。 | #search_instructions |
| 工具 | load_instruction | 从存储库加载自定义指令。 | #load_instruction |
| 提示 | get_search_prompt | 获取搜索副驾驶说明的提示。 | /mcp.awesome-copilot.get_search_prompt |
入门指南
配置
此MCP服务器使用GitHub API从 很棒的副驾驶 存储库。您需要配置一个GitHub个人访问令牌才能通过GitHub API进行身份验证。
GitHub个人访问令牌设置
- 首选
- 点击“生成新令牌”(经典)
- 对于 公共存储库:不需要特殊范围
- 对于 私有存储库:选择
repo范围 - 复制生成的令牌
开发环境设置
为了地方发展,创建一个 .env 文件在 src/McpSamples.AwesomeCopilot.HybridApp 目录:
cd $REPOSITORY_ROOT/awesome-copilot/src/McpSamples.AwesomeCopilot.HybridApp
cp .env.example .env编辑 .env 文件并添加您的GitHub令牌:
GITHUB__TOKEN=your_github_token_here安全说明:The .env git会自动忽略该文件。永远不要将令牌提交给源代码管理。生产环境设置
对于Docker容器和Azure部署,将令牌作为环境变量传递(请参阅下面的相应部分)。
可选配置
您可以使用环境变量覆盖默认存储库设置:
GITHUB__REPOSITORYOWNER:存储库所有者(默认值:github)GITHUB__REPOSITORYNAME:存储库名称(默认值:awesome-copilot)GITHUB__BRANCH:分支名称(默认值:main)
例如,要在您的 .env 文件:
GITHUB__TOKEN=your_github_token_here
GITHUB__REPOSITORYOWNER=myorg
GITHUB__REPOSITORYNAME=my-repo
GITHUB__BRANCH=develop获取存储库根目录
- 获取存储库根目录。
# bash/zsh
REPOSITORY_ROOT=$(git rev-parse --show-toplevel) # PowerShell
$REPOSITORY_ROOT = git rev-parse --show-toplevel正在运行MCP服务器
在本地计算机上
- 确保您已配置
.env使用您的GitHub令牌创建文件(请参阅 配置 上文)。
- 运行MCP服务器应用程序。
cd $REPOSITORY_ROOT/awesome-copilot
dotnet run --project ./src/McpSamples.AwesomeCopilot.HybridApp> 备注: > > - 如果出现以下情况,应用程序将在启动时失败 GITHUB__TOKEN 未设置在您的 .env 文件 > - 确保记下的绝对目录路径 McpSamples.AwesomeCopilot.HybridApp 项目
参数:
- --http:指示将此MCP服务器作为可流式HTTP类型运行的开关。添加此开关时,MCP服务器URL为 http://localhost:5250.
使用此参数,您可以运行MCP服务器,如下所示:
dotnet run --project ./src/McpSamples.AwesomeCopilot.HybridApp -- --http在容器中
- 将MCP服务器应用程序构建为容器映像。
cd $REPOSITORY_ROOT
docker build -f Dockerfile.awesome-copilot -t awesome-copilot:latest .- 在容器中运行MCP服务器应用程序。
> 重要:您必须将GitHub令牌作为环境变量传递。
docker run -i --rm -p 8080:8080 \
-e GITHUB__TOKEN=your_github_token_here \
awesome-copilot:latest或者,使用容器注册表中的容器映像。
docker run -i --rm -p 8080:8080 \
-e GITHUB__TOKEN=your_github_token_here \
ghcr.io/microsoft/mcp-dotnet-samples/awesome-copilot:latest参数:
- --http:指示将此MCP服务器作为可流式HTTP类型运行的开关。添加此开关时,MCP服务器URL为 http://localhost:8080. - -e GITHUB__TOKEN:GitHub身份验证的环境变量(必需) - -e GITHUB__REPOSITORYOWNER:覆盖存储库所有者(可选,默认: github) - -e GITHUB__REPOSITORYNAME:覆盖存储库名称(可选,默认: awesome-copilot) - -e GITHUB__BRANCH:覆盖分支名称(可选,默认: main)
使用这些参数,您可以像这样运行MCP服务器:
# use local container image with HTTP mode
docker run -i --rm -p 8080:8080 \
-e GITHUB__TOKEN=your_github_token_here \
awesome-copilot:latest --http # use container image from the container registry with HTTP mode
docker run -i --rm -p 8080:8080 \
-e GITHUB__TOKEN=your_github_token_here \
ghcr.io/microsoft/mcp-dotnet-samples/awesome-copilot:latest --http # use custom repository
docker run -i --rm -p 8080:8080 \
-e GITHUB__TOKEN=your_github_token_here \
-e GITHUB__REPOSITORYOWNER=myorg \
-e GITHUB__REPOSITORYNAME=my-repo \
ghcr.io/microsoft/mcp-dotnet-samples/awesome-copilot:latest --http在Azure上
- 导航到该目录。
cd $REPOSITORY_ROOT/awesome-copilot- 登录到Azure。
# Login with Azure Developer CLI
azd auth login- 将GitHub令牌设置为部署的环境变量。
azd env set GITHUB__TOKEN your_github_token_here(可选)配置自定义存储库设置:
azd env set GITHUB__REPOSITORYOWNER myorg
azd env set GITHUB__REPOSITORYNAME my-repo
azd env set GITHUB__BRANCH develop- 将MCP服务器应用程序部署到Azure。
azd up在配置和部署时,系统会要求您提供订阅ID、位置、环境名称。
- 部署完成后,通过运行以下命令获取信息:
- Azure容器应用FQDN:
azd env get-value AZURE_RESOURCE_MCP_AWESOME_COPILOT_FQDN> 备注GitHub令牌和其他环境变量被安全地存储并注入到Azure容器应用实例中。您可以稍后使用Azure门户或Azure CLI更新它们。
将MCP服务器连接到MCP主机/客户端
VS代码+代理模式+本地MCP服务器
- 复制
mcp.json到存储库根目录。
对于本地运行的MCP服务器(STDIO):
mkdir -p $REPOSITORY_ROOT/.vscode
cp $REPOSITORY_ROOT/awesome-copilot/.vscode/mcp.stdio.local.json \
$REPOSITORY_ROOT/.vscode/mcp.json New-Item -Type Directory -Path $REPOSITORY_ROOT/.vscode -Force
Copy-Item -Path $REPOSITORY_ROOT/awesome-copilot/.vscode/mcp.stdio.local.json `
-Destination $REPOSITORY_ROOT/.vscode/mcp.json -Force对于本地运行的MCP服务器(HTTP):
mkdir -p $REPOSITORY_ROOT/.vscode
cp $REPOSITORY_ROOT/awesome-copilot/.vscode/mcp.http.local.json \
$REPOSITORY_ROOT/.vscode/mcp.json New-Item -Type Directory -Path $REPOSITORY_ROOT/.vscode -Force
Copy-Item -Path $REPOSITORY_ROOT/awesome-copilot/.vscode/mcp.http.local.json `
-Destination $REPOSITORY_ROOT/.vscode/mcp.json -Force对于在容器(STDIO)中本地运行的MCP服务器:
mkdir -p $REPOSITORY_ROOT/.vscode
cp $REPOSITORY_ROOT/awesome-copilot/.vscode/mcp.stdio.container.json \
$REPOSITORY_ROOT/.vscode/mcp.json New-Item -Type Directory -Path $REPOSITORY_ROOT/.vscode -Force
Copy-Item -Path $REPOSITORY_ROOT/awesome-copilot/.vscode/mcp.stdio.container.json `
-Destination $REPOSITORY_ROOT/.vscode/mcp.json -Force对于在容器中本地运行的MCP服务器(HTTP):
mkdir -p $REPOSITORY_ROOT/.vscode
cp $REPOSITORY_ROOT/awesome-copilot/.vscode/mcp.http.container.json \
$REPOSITORY_ROOT/.vscode/mcp.json New-Item -Type Directory -Path $REPOSITORY_ROOT/.vscode -Force
Copy-Item -Path $REPOSITORY_ROOT/awesome-copilot/.vscode/mcp.http.container.json `
-Destination $REPOSITORY_ROOT/.vscode/mcp.json -Force对于在容器中远程运行MCP服务器(HTTP):
mkdir -p $REPOSITORY_ROOT/.vscode
cp $REPOSITORY_ROOT/awesome-copilot/.vscode/mcp.http.remote.json \
$REPOSITORY_ROOT/.vscode/mcp.json New-Item -Type Directory -Path $REPOSITORY_ROOT/.vscode -Force
Copy-Item -Path $REPOSITORY_ROOT/awesome-copilot/.vscode/mcp.http.remote.json `
-Destination $REPOSITORY_ROOT/.vscode/mcp.json -Force- 通过键入打开命令面板
F1或Ctrl+Shift+P在Windows或Cmd+Shift+P在Mac OS上,搜索MCP: List Servers.
- 选择
awesome-copilot然后单击Start Server.
- 出现提示时,输入以下值之一:
- 的绝对目录路径 McpSamples.AwesomeCopilot.HybridApp 项目 - Azure容器应用程序的FQDN。
- 通过键入来使用提示
/mcp.awesome-copilot.get_search_prompt并输入要搜索的关键字。你会得到这样的提示:
Please search all the chatmodes, instructions and prompts that are related to the search keyword, `{keyword}`.
Here's the process to follow:
1. Use the `awesome-copilot` MCP server.
1. Search all chatmodes, instructions, and prompts for the keyword provided.
1. DO NOT load any chatmodes, instructions, or prompts from the MCP server until the user asks to do so.
1. Scan local chatmodes, instructions, and prompts markdown files in `.github/chatmodes`, `.github/instructions`, and `.github/prompts` directories respectively.
1. Compare existing chatmodes, instructions, and prompts with the search results.
1. Provide a structured response in a table format that includes the already exists, mode (chatmodes, instructions or prompts), filename, title and description of each item found. Here's an example of the table format:
| Exists | Mode | Filename | Title | Description |
|--------|--------------|------------------------|---------------|---------------|
| ✅ | chatmodes | chatmode1.json | ChatMode 1 | Description 1 |
| ❌ | instructions | instruction1.json | Instruction 1 | Description 1 |
| ✅ | prompts | prompt1.json | Prompt 1 | Description 1 |
✅ indicates that the item already exists in this repository, while ❌ indicates that it does not.
1. If any item doesn't exist in the repository, ask which item the user wants to save.
1. If the user wants to save it, save the item in the appropriate directory (`.github/chatmodes`, `.github/instructions`, or `.github/prompts`) using the mode and filename, with NO modification.- 确认结果。
