Go protobuf compiler extension to turn any gRPC service into an MCP server
protoc-gen-go-mcp
protoc-gen-go-mcp
is a Protocol Buffers compiler plugin that generates Model Context Protocol (MCP) servers for your gRPC
or ConnectRPC
APIs.
It generates *.pb.mcp.go
files for each protobuf service, enabling you to delegate handlers directly to gRPC servers or clients. Under the hood, MCP uses JSON Schema for tool inputsโprotoc-gen-go-mcp
auto-generates these schemas from your method input descriptors.
โ ๏ธ Currently supports mark3labs/mcp-go as the MCP server runtime. Future support is planned for official Go SDKs and additional runtimes.
.proto
servicesbuf
Add entry to your buf.gen.yaml
:
...
plugins:
- local:
- go
- run
- github.com/redpanda-data/protoc-gen-go-mcp/cmd/protoc-gen-go-mcp@latest
out: ./gen/go
opt: paths=source_relative
You need to generate the standard *.pb.go
files as well. protoc-gen-go-mcp
by defaults uses a separate subfolder {$servicename}mcp
, and imports the *pb.go
files - similar to connectrpc-go.
See here for a complete example.
After running buf generate
, you will see a new folder for each package with protobuf Service definitions:
tree example/gen/
gen
โโโ go
โโโ proto
โโโ example
โโโ v1
โโโ example.pb.go
โโโ examplev1mcp
โโโ example.pb.mcp.go
Example for in-process registration:
srv := exampleServer{} // your gRPC implementation
// Register all RPC methods as tools on the MCP server
examplev1mcp.RegisterExampleServiceHandler(mcpServer, &srv)
Each RPC method in your protobuf service becomes an MCP tool.
โก๏ธ See the full example for details.
It is also possible to directly forward MCP tool calls to gRPC clients.
examplev1mcp.ForwardToExampleServiceClient(mcpServer, myGrpcClient)
Same for connectrpc:
examplev1mcp.ForwardToConnectExampleServiceClient(mcpServer, myConnectClient)
This directly connects the MCP handler to the connectrpc client, requiring zero boilerplate.
OpenAI imposes some limitations, because it does not support JSON Schema features like additionalProperties, anyOf, oneOf.
Use the protoc opt openai_compat=true
(false by default) to make the generator emit OpenAI compatible schemas.
We'd love feedback, bug reports, or PRs! Join the discussion and help shape the future of Go and Protobuf MCP tooling.
{ "mcpServers": { "protoc-gen-go-mcp": { "command": "buf", "args": [ "generate" ] } } }
Related projects feature coming soon
Will recommend related projects based on sub-categories