Skip to content

redpanda-data/protoc-gen-go-mcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

✨ Features

  • 🚀 Auto-generates MCP handlers from your .proto services
  • 📦 Outputs JSON Schema for method inputs
  • 🔄 Wire up to gRPC or ConnectRPC servers/clients
  • 🧩 Easy integration with buf

🔧 Usage

Generate code

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

Wiring Up MCP with gRPC server (in-process)

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.

Wiring up with grpc and connectrpc client

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.

⚠️ Limitations

  • No interceptor support (yet). Registering with a gRPC server bypasses interceptors.
  • Tool name mangling for long RPC names: If the full RPC name exceeds 64 characters (Claude desktop limit), the head of the tool name is mangled to fit.

🗺️ Roadmap

  • Reflection/proxy mode
  • Interceptor middleware support in gRPC server mode
  • Support for the official Go MCP SDK (once published)

💬 Feedback

We'd love feedback, bug reports, or PRs! Join the discussion and help shape the future of Go and Protobuf MCP tooling.

About

Go protobuf compiler extension to turn any gRPC service into an MCP server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages