
一个用于从协议缓冲区规范生成 Golang 中 mcp 服务器的 protoc 插件
概览
protoc-gen-go-mcp -----------------这是一个 Topeka 插件,用于原型编译器,基于协议缓冲区定义生成模型-上下文-协议(MCP)服务器。从概念上讲,这使得 AI 模型能够使用现有的 gRPC 代码库和自然语言,从而快速实现原型设计和基于 protobuf 代码库的大型语言模型功能。 - Go 1.20或更高版本 - protoc 3.20或更高版本- protoc-gen-go-grpc 1.71或更高版本 可以查看 Makefile 里的具体命令使用。使用 make generate 从原型文件生成示例 MCP 服务器。 在2345端口以无头模式启动Delve调试器。调试文件是$GOPATH/bin/protoc-gen-go-mcp。你可以用以下launch.json配置在VSCode中连接。 将mcp-vibe服务器添加到你的MCP服务器中: 该插件利用现有的代码生成,用于协议缓冲区和 gRPC 服务器,并在基础上构建,必要时使用和重复使用部分。
概述(AI 翻译)
Protoc-Gen-go-MCP
这是一个基于协议缓冲区定义的 Topeka 插件,用于生成基于协议缓冲区定义的模型-上下文-协议(MCP)服务器。从概念上讲,这使得 AI 模型能够使用现有的 gRPC 代码库和自然语言,从而实现快速原型设计和基于 protobuf 代码库的 LLM 功能。
先决条件
- Go 1.25或更高版本(生成代码导入 官方MCP SDK的认证,需要它)
- Protoc 29.3(版本
插件会被测试;参见
Makefile和AGENTS.md) - 原始-原始-始-GO
v1.36.6 和
Protoc-Gen-go-grpc
v1.5.1(确切版本,嵌入为
tool指令)go.mod)
正在运行插件
查看 Makefile 里的具体命令使用方法。使用 make generate 从 proto 文件生成示例 MCP 服务器。
调试插件
将以无头模式启动 Delve 调试器,连接端口 2345。文件
调试将是$GOPATH/bin/protoc-gen-go-mcp。你可以在VSCode中连接到它
配置如下 launch.json。
测试这个例子
安装示例 mcp-vibe 服务器
将mcp-vibe服务器添加到你的MCP服务器中:
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
protoc-gen-go-mcp
This is a Topeka plugin for the protoc compiler that generates a model-context-protocol(MCP) server based on a protocol buffer definition. Conceptually, this allows an AI model to use existing gRPC codebases with natural language, allowing for rapid prototyping and usage of LLM capabilities for protobuf based codebases.
Prerequisites
- Go 1.25 or later (the generated code imports the official MCP SDK, which requires it)
- protoc 29.3 (the version this
plugin is tested against; see
MakefileandAGENTS.md) - protoc-gen-go
v1.36.6 and
protoc-gen-go-grpc
v1.5.1 (the exact versions pinned as
tooldirectives ingo.mod)
Running the plugin
Check out the Makefile for explicit command usage. Use make generate to generate the example MCP server from the proto file.
Debugging the plugin
make start-debugger
Will start the delve debugger in headless mode on port 2345. The file under
debug will be $GOPATH/bin/protoc-gen-go-mcp. You can connect to that in VSCode
with the following launch.json configuration.
{
"name": "Connect to protoc-gen-go-mcp plugin",
"type": "go",
"request": "attach",
"mode": "remote",
"remotePath": "${workspaceFolder}",
"port": 2345,
"host": "127.0.0.1"
}
Testing the example
Install the example mcp-vibe server
go install ./cmd/mcp-vibe
Add the mcp-vibe server to your mcp servers:
{
"mcpServers": {
"vibe": {
"command": "mcp-vibe"
}
}
}
What the plugin generates
A generated NewMCPServer wraps a gRPC client and an
*mcp.Server
from the official Go MCP SDK.
Once you’ve called RegisterDefaultTools() (or registered individual tools,
see below), serve that *mcp.Server the way any MCP server is served. The
two most common transports:
// client is a examplev1.VibeServiceClient for the backend gRPC service, e.g.
// examplev1.NewVibeServiceClient(conn) for a grpc.ClientConn.
// Over stdio, for CLI-launched MCP clients (see cmd/mcp-vibe/main.go for the
// full, runnable version of this).
stdioServer := mcp.NewServer(&mcp.Implementation{Name: "vibe", Version: "0.0.1"}, nil)
examplev1.NewVibeServiceMCPServer(client, stdioServer).RegisterDefaultTools()
if err := stdioServer.Run(ctx, &mcp.StdioTransport{}); err != nil {
panic(err)
}
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"vibe": {
"command": "mcp-vibe"
}
}
}