欢迎来到 Hello MCP Go 仓库!🚀 这个项目展示了如何使用Go语言构建一个MCP(模型上下文协议)服务器。无论您是Go语言爱好者还是对MCP感兴趣,您都来对地方了!🛠️
<div> <img src="./gopher.jpeg" alt="背景中胡萝卜田里的Gopher" width="600"> </div>这个仓库展示了:
克隆仓库:
git clone https://github.com/your-username/hello-mcp-go.git
cd hello-mcp
安装依赖项:
go mod tidy
构建项目:
go build -ldflags="-s -w" -o server.exe main.go
或对于Linux:
go build -ldflags="-s -w" -o server main.go
您将在稍后从Visual Studio Code中使用它时用到此步骤。
运行服务器:
./server
将自己置于mcp.json中,确保服务器已经构建(现在已调整)。
调整"command"以指向您的可执行文件的绝对路径。
{
"servers": {
"my-mcp-server-d73c20f3": {
"type": "stdio",
"command": "/path/to/your/executable"
}
}
}
打开Copilot并选择下拉菜单中的Agent。
选择播放图标。
您应该看到显示两个工具的工具图标。
使用类似“calculate 2 and 4”的短语测试它。这应该呈现一个按钮,该按钮调用服务器上的工具。

这个项目旨在学习和享受乐趣。请随意实验、尝试破坏事物,并创造一些令人惊叹的东西!🌈
祝编程愉快!💻