MCP Server - VSCode Tutorial
Okay, here's a breakdown of how to build an MCP (Minecraft Coder Pack) server and use VS Code as an MCP client, translated into Chinese. I'll focus on clarity and accuracy for a Chinese-speaking audience familiar with programming concepts. **标题: 构建 MCP 服务器并使用 VS Code 作为 MCP 客户端的教程** **简介:** 本教程将指导您如何搭建一个 Minecraft Coder Pack (MCP) 服务器,并配置 Visual Studio Code (VS Code) 作为 MCP 客户端,以便进行 Minecraft Mod 开发。 MCP 提供反编译、反混淆和重新编译 Minecraft 代码的工具,使 Mod 开发更加容易。 VS Code 作为一个强大的代码编辑器,可以与 MCP 集成,提供代码补全、调试等功能。 **第一部分: 安装和配置 MCP 服务器** 1. **下载 MCP:** * **中文:** 从 MCP 的官方网站或可靠的第三方资源下载最新版本的 MCP。 确保下载的版本与您要修改的 Minecraft 版本相对应。 * **英文:** Download the latest version of MCP from the official MCP website or a reliable third-party source. Make sure the version you download corresponds to the Minecraft version you want to modify. 2. **解压 MCP:** * **中文:** 将下载的 MCP 压缩包解压到一个合适的目录。 建议创建一个专门用于 MCP 的文件夹,例如 `C:\mcp`. * **英文:** Extract the downloaded MCP archive to a suitable directory. It is recommended to create a dedicated folder for MCP, such as `C:\mcp`. 3. **配置 MCP:** * **中文:** 打开 MCP 目录下的 `mcp.cfg` 文件。 这个文件包含了 MCP 的配置信息。 * **英文:** Open the `mcp.cfg` file in the MCP directory. This file contains the MCP configuration information. * **中文:** 在 `mcp.cfg` 文件中,找到 `MinecraftVersion` 选项,并将其设置为您要修改的 Minecraft 版本。 例如: `MinecraftVersion = 1.19.2` * **英文:** In the `mcp.cfg` file, find the `MinecraftVersion` option and set it to the Minecraft version you want to modify. For example: `MinecraftVersion = 1.19.2` * **中文:** 根据您的需求,修改其他配置选项。 例如,您可以设置 `ClientPath` 和 `ServerPath` 来指定 Minecraft 客户端和服务器的路径(如果 MCP 无法自动找到它们)。 * **英文:** Modify other configuration options according to your needs. For example, you can set `ClientPath` and `ServerPath` to specify the paths to the Minecraft client and server (if MCP cannot find them automatically). 4. **运行 MCP:** * **中文:** 打开命令提示符或终端,导航到 MCP 目录。 * **英文:** Open a command prompt or terminal and navigate to the MCP directory. * **中文:** 运行 `./gradlew setupDecompWorkspace` 命令。 这个命令会下载 Minecraft 客户端和服务器,并反编译它们。 这个过程可能需要一些时间。 * **英文:** Run the `./gradlew setupDecompWorkspace` command. This command will download the Minecraft client and server and decompile them. This process may take some time. * **中文:** 运行 `./gradlew eclipse` 或 `./gradlew idea` 命令,根据您使用的 IDE 生成 Eclipse 或 IntelliJ IDEA 项目文件。 虽然我们使用 VS Code,但生成这些文件可以帮助 MCP 更好地组织代码。 * **英文:** Run the `./gradlew eclipse` or `./gradlew idea` command to generate Eclipse or IntelliJ IDEA project files, depending on the IDE you are using. Although we are using VS Code, generating these files can help MCP better organize the code. **第二部分: 配置 VS Code 作为 MCP 客户端** 1. **安装 Java Development Kit (JDK):** * **中文:** 确保您的系统上安装了 JDK。 VS Code 需要 JDK 来编译 Java 代码。 建议安装与您要修改的 Minecraft 版本兼容的 JDK 版本。 * **英文:** Make sure you have the JDK installed on your system. VS Code needs the JDK to compile Java code. It is recommended to install a JDK version compatible with the Minecraft version you want to modify. 2. **安装 VS Code 扩展:** * **中文:** 在 VS Code 中,安装以下扩展: * **Java Extension Pack:** 提供 Java 开发所需的基本功能,例如代码补全、调试等。 * **Gradle Language Support:** 提供 Gradle 构建文件的语法高亮和代码补全。 * **英文:** In VS Code, install the following extensions: * **Java Extension Pack:** Provides basic functions required for Java development, such as code completion, debugging, etc. * **Gradle Language Support:** Provides syntax highlighting and code completion for Gradle build files. 3. **导入 MCP 项目到 VS Code:** * **中文:** 在 VS Code 中,选择 "文件" -> "打开文件夹",然后选择 MCP 目录下的 `eclipse` 或 `idea` 文件夹(取决于您之前运行的 Gradle 命令)。 * **英文:** In VS Code, select "File" -> "Open Folder", and then select the `eclipse` or `idea` folder under the MCP directory (depending on the Gradle command you ran earlier). 4. **配置 VS Code 的 Java 设置:** * **中文:** 打开 VS Code 的设置 (文件 -> 首选项 -> 设置)。 * **英文:** Open VS Code settings (File -> Preferences -> Settings). * **中文:** 搜索 "java.home",并将其设置为您的 JDK 安装目录。 * **英文:** Search for "java.home" and set it to your JDK installation directory. 5. **开始 Mod 开发:** * **中文:** 现在,您可以在 VS Code 中浏览和修改 Minecraft 的源代码。 MCP 会自动处理反编译和反混淆的代码,使代码更易于理解。 * **英文:** Now you can browse and modify the Minecraft source code in VS Code. MCP automatically handles the decompiled and deobfuscated code, making the code easier to understand. * **中文:** 您可以在 `src/main/java` 目录下创建您的 Mod 类。 * **英文:** You can create your Mod classes in the `src/main/java` directory. 6. **构建和运行 Mod:** * **中文:** 在 VS Code 的终端中,导航到 MCP 目录。 * **英文:** In the VS Code terminal, navigate to the MCP directory. * **中文:** 运行 `./gradlew build` 命令来构建您的 Mod。 * **英文:** Run the `./gradlew build` command to build your Mod. * **中文:** 构建完成后,您的 Mod 将位于 `build/libs` 目录下。 * **英文:** After the build is complete, your Mod will be located in the `build/libs` directory. * **中文:** 将您的 Mod 文件复制到 Minecraft 的 `mods` 文件夹中。 * **英文:** Copy your Mod file to the Minecraft `mods` folder. * **中文:** 启动 Minecraft 并测试您的 Mod。 * **英文:** Launch Minecraft and test your Mod. **注意事项:** * **中文:** MCP 的配置和使用可能比较复杂,请仔细阅读 MCP 的文档和教程。 * **英文:** MCP configuration and usage can be complex, please read the MCP documentation and tutorials carefully. * **中文:** 确保您的 JDK 版本与 Minecraft 版本兼容。 * **英文:** Make sure your JDK version is compatible with the Minecraft version. * **中文:** 如果遇到问题,请查阅 MCP 的论坛或社区寻求帮助。 * **英文:** If you encounter problems, consult the MCP forum or community for help. * **中文:** Gradle 构建过程可能需要下载大量的依赖项,请确保您的网络连接稳定。 * **英文:** The Gradle build process may require downloading a large number of dependencies, please ensure your network connection is stable. **总结:** 本教程介绍了如何搭建 MCP 服务器并使用 VS Code 作为 MCP 客户端。 通过这种方式,您可以更方便地进行 Minecraft Mod 开发。 希望本教程对您有所帮助! This translation aims to be clear, accurate, and helpful for Chinese-speaking developers. It includes explanations of the purpose of each step and provides context for better understanding. Good luck with your modding!
msalemor
README
MCP 服务器 - VSCode 教程
一个构建 MCP 服务器并使用 Visual Studio Code 作为 MCP 客户端的教程。
概述
截至 2025 年 4 月,大多数 MCP 教程和演示目前都针对 Claude Desktop 应用程序。但是,如果您拥有带有 Agent 模式的 GitHub Copilot 并使用 Visual Studio Code 作为 MCP 客户端,您也可以进行开发和测试。
MCP 服务器正在使用多种语言编写。本演示实现了一个示例 MCP 服务器,来自 mcp-go 包示例,使用 Go 是因为构建过程生成了一个高性能、低资源且小的可执行文件,无需额外的参数即可运行。MCP 服务器可以使用 Node、Python 等语言编写。
什么是 MCP 服务器
MCP(模型上下文协议)服务器是一个轻量级程序,旨在通过标准化的模型上下文协议公开特定功能。该协议允许应用程序安全有效地向大型语言模型 (LLM) 提供上下文。
可以将 MCP 服务器视为连接 LLM 与各种数据源和工具(包括本地和远程)的桥梁。它们使 LLM 能够以受控方式访问和交互文件、数据库、API 和其他服务。这使得构建复杂的工作流程以及将 AI 模型与不同的系统集成变得更加容易。
参考资料:
MCP 服务器代码
在我的测试中,我使用了以下示例代码:
- Go 包:
mcp-go
- 服务器代码:mcp-go/examples/everything
要求
- Visual Studio Code
- 带有 Agent 模式的 Github Copilot
- 一些 Go 知识
构建 Go 服务器
注意:您可以克隆存储库并执行其他步骤,但以下是我遵循的步骤:
- 克隆此存储库
- 将目录更改为:
server
- 获取所需的包:
go mod tidy
- 构建 MCP 服务器:
go build .
- 复制完整的可执行文件路径:
C:\Users\user\git\msalemor\mcp-vscode-tutorial\server\mcpgo.exe
部署服务器
-
打开 Github Copilot Chat
-
将 Copilot 更改为 Agent 模式
-
-
在 Agent 窗格中,单击 Tools
-
在顶部栏弹出窗口中,单击
+ Add More Tools
-
-
在顶部栏弹出窗口中,单击
+ Add MCP Server
-
-
在顶部栏弹出窗口中,选择
Command (stdio)
-
-
在要运行的命令中,粘贴 Go 可执行文件的完整路径
-
随意命名服务器
-
将 MCP 配置保存为用户(全局)或工作区(仅适用于项目)设置
-
如果选择工作区,Visual Studio 将在
.vscode/mcp.json
中生成以下设置
{
"servers": {
"mcpgo1": {
"type": "stdio",
"command": "C:\\Users\\user\\git\\msalemor\\mcp-vscode-tutorial\\server\\mcpgo.exe",
"args": []
}
}
}
- 启动服务器
- VSCode 应该显示 5 个工具(如果您没有添加其他工具)
预期结果
在屏幕截图中,我们可以看到 MCP 服务器正在运行,并且在 VSCode 中注册了 5 个工具。我们还可以看到 agent 已经进行了两次调用,分别是 add
和 notify
。
在 agent 类型中测试:
- add 1 + 1
我将使用此 MCP(模型上下文协议)服务器工作区中可用的工具来帮助您添加 1 + 1。 看起来您在 Go 服务器中实现了一个“add”工具,可以处理加法运算。
让我调用该工具来添加 1 + 1:
1 + 1 的结果是 2。
我使用了在您的 MCP 服务器中实现的“add”工具。 服务器返回:“1.000000 和 1.000000 的总和是 2.000000。”
- Notify: this is a test
我将帮助您使用工作区中的 MCP 服务器实现通知测试。 我看到您定义了一个“notify”工具,但它有一个空的描述。 让我调用此工具以发送通知:
通知已成功发送! 我使用了 MCP(模型上下文协议)服务器中的 9f1_notify 工具,它返回“notification sent successfully”。
Node MCP 服务器
已将基于 Node 的服务器添加到存储库中,要运行 Node MCP 服务器:
- 请注意,此服务器使用 bun.sh 而不是 Node 运行。
- 向 VSCode 添加另一个 MCP 配置
{
"servers": {
"mcpgo-server": {
"type": "stdio",
"command": "C:\\Users\\user\\git\\msalemor\\mcp-vscode-tutorial\\server\\mcpgo.exe",
"args": []
},
"bun-server": {
"type": "stdio",
"command": "bun",
"args": [
"run",
"C:\\Users\\user\\git\\msalemor\\mcp-vscode-tutorial\\node-server\\index.ts"
]
}
}
}
- 确保两个服务器都在运行
结果
- Query:
Get the table schema for users. Create a structure based on the schema. Notify the user when done.
推荐服务器
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
MCP Package Docs Server
促进大型语言模型高效访问和获取 Go、Python 和 NPM 包的结构化文档,通过多语言支持和性能优化来增强软件开发。
Claude Code MCP
一个实现了 Claude Code 作为模型上下文协议(Model Context Protocol, MCP)服务器的方案,它可以通过标准化的 MCP 接口来使用 Claude 的软件工程能力(代码生成、编辑、审查和文件操作)。
@kazuph/mcp-taskmanager
用于任务管理的模型上下文协议服务器。它允许 Claude Desktop(或任何 MCP 客户端)在基于队列的系统中管理和执行任务。
mermaid-mcp-server
一个模型上下文协议 (MCP) 服务器,用于将 Mermaid 图表转换为 PNG 图像。
Jira-Context-MCP
MCP 服务器向 AI 编码助手(如 Cursor)提供 Jira 工单信息。

Linear MCP Server
一个模型上下文协议(Model Context Protocol)服务器,它与 Linear 的问题跟踪系统集成,允许大型语言模型(LLM)通过自然语言交互来创建、更新、搜索和评论 Linear 问题。

Sequential Thinking MCP Server
这个服务器通过将复杂问题分解为顺序步骤来促进结构化的问题解决,支持修订,并通过完整的 MCP 集成来实现多条解决方案路径。
Curri MCP Server
通过管理文本笔记、提供笔记创建工具以及使用结构化提示生成摘要,从而实现与 Curri API 的交互。