Turbine seu Copilot 在 VS Code 中使用 MCP(模型上下文协议)
GitHub Copilot可以用来改造你的设备吗?那么,您是否可以通过以下方式获得更多信息、书籍和文献?通过模型上下文协议 (MCP)的协议,我们可以将前沿技术与 Copilot 集成,并与测试人员进行交互。
接下来,您将了解 MCP 的迷雾,并通过配置 VS Code 进行配置,并帮助 IA 进行改造,以实现项目的开发。
什么是模型上下文协议 (MCP)?
Pense 没有 MCP como uma“ponte”通用。允许与 IA 模型、副驾驶、通信方式和外部环境进行交流。
Sem MCP: O Copilot sabe sobre código, pois foi treinado em bilhões de linhas。没有任何问题,因为使用 CLI 做 seu 框架更喜欢使用 UI 库中的组件。
Com MCP:请使用副驾驶“ensinar”声音。调用 MCP 服务的本地命令可以执行命令(npx例如)或连接到网络上的公共汽车信息。
总结一下,MCP 与副驾驶的操作和真实节奏相关,允许您以自己的名义执行复杂的任务,或者附加组件,然后按照特定的逻辑或外部文档进行修改。
Como Configurar o MCP 无 VS 代码
无需任何配置即可进行配置settings.json。按下 VS Code 压缩Ctrl + Shift + P和数字按钮Preferences: Open User Settings (JSON)。
接下来,我们将分析整个配置块,并对其进行详细说明。
1. 副驾驶代理人的 MCP 资格
最初,precisamos ativar os recursos Experimentais no settings.json。
{ "chat.mcp.enabled": true, "chat.mcp.discovery.enabled": true, "chat.agent.enabled": true, "github.copilot.chat.agent.runTasks": true, "github.copilot.chat.agent.autoFix": true }
"chat.mcp.enabled": true:Ativa 支持模型上下文协议,无需与 VS Code 聊天。
"chat.mcp.discovery.enabled": true:允许 VS Code 自动运行 MCP 服务。
"chat.agent.enabled": true:副驾驶“代理”的能力,可以是执行任务的主动能力。
"github.copilot.chat.agent.runTasks": truee "autoFix": true: 承认执行命令的代理许可,并自动进行相应的处理。
2. 配置 MCP 服务器
这是主要的关于副驾驶操作的定义。整体mcp.servers定义了与副驾驶执行操作的操作方式。
{ "mcp": { "servers": { "shadcn": { "command": "npx", "args": [ "-y", "shadcn@canary", "registry:mcp" ], "env": { "REGISTRY_URL": "https://alpine-registry.vercel.app//r/registry.json" } }, "sequentialthinking": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-sequential-thinking" ] }, "context7": { "type": "http", "url": "https://mcp.context7.com/mcp" } } } }
Vamos detalhar os servidores que você configurou:
shadcn:
O que faz?连接到 Copilot à CLI do shadcn/ui,这是 React 中最流行的 UI 组件的参考文献。
科莫?全部声音调用@shadcn,或副驾驶执行或指挥npx shadcn@canary registry:mcp。允许使用 Copilot interaja com 或注册 shadcn/ui 组件。
使用示例:没有聊天:@shadcn adicione um componente Button ao meu projeto。
sequentialthinking:
O que faz? Carrega 是一名服务人员,他是副驾驶的“pensar em voz alta”,将复杂的问题分为以下几个步骤,提出解决方案。
怎么回事?执行或打包npx @modelcontextprotocol/server-sequential-thinking。
使用示例:@sequentialthinking me ajude a criar um plano para refatorar minha API do Express para usar rotas modulares。
context7:
O que faz?这是远程服务器的范例。副驾驶与外部的连接 ( context7.com),是文档总线服务或连接的基础。
科莫?不同的是,在本地命令中不执行 ( npx)。 Em vez disso, ele se conecta a uma urlvia HTTP。
使用示例:@context7 quais as principais mudanças na última versão do React?
Colocando em Prática:Como Usar no Chat do Copilot
Depois de salvar seu settings.json(pode ser necessário reiniciar o VS Code), usar seus novos superpoderes é muito simples.
Abra 是 GitHub Copilot 聊天的可视化 ( Ctrl + Alt + I)。
Comece seu 提示 usando @para invocar a ferramenta desejada。
描述一个你想要实现的目标。
提示示例:
@shadcn精确的登录公式。卡、标签、输入和按钮的其他组件。@sequentialthinking我详细介绍了 Node.js 和 PostgreSQL 银行以及 Prisma 的应用。@context7我是一个 API de 的简历Intersection Observer。

