- Explore MCP Servers
- connect-go-mcp
Connect Go Mcp
What is Connect Go Mcp
protoc-gen-connect-go-mcp
is a Protocol Buffers compiler plugin that generates MCP (Model Context Protocol) server code from existing gRPC service definitions, creating tools that integrate seamlessly into MCP-compatible applications.
Use cases
This tool is useful for developers looking to convert their gRPC services into MCP server implementations efficiently. It is designed for applications that utilize the MCP protocol and can be integrated into various environments, including AI assistance platforms.
How to use
To use, first install the plugin via Go. Create a buf.gen.yaml
or use the protoc
command with appropriate options to generate the MCP servers. Ensure your proto files are configured correctly, and then run the buf generate
or protoc
command to generate the server code.
Key features
Key features include automatic MCP server generation from gRPC services, flexible package organization with customizable package suffixes, preservation of comments from proto files, and compatibility with Connect-Go for comprehensive gRPC support.
Where to use
The generated MCP servers can be used in applications requiring MCP functionality, such as Claude Desktop for AI assistance, any MCP-compatible clients, or custom applications that need to incorporate MCP servers.
Overview
What is Connect Go Mcp
protoc-gen-connect-go-mcp
is a Protocol Buffers compiler plugin that generates MCP (Model Context Protocol) server code from existing gRPC service definitions, creating tools that integrate seamlessly into MCP-compatible applications.
Use cases
This tool is useful for developers looking to convert their gRPC services into MCP server implementations efficiently. It is designed for applications that utilize the MCP protocol and can be integrated into various environments, including AI assistance platforms.
How to use
To use, first install the plugin via Go. Create a buf.gen.yaml
or use the protoc
command with appropriate options to generate the MCP servers. Ensure your proto files are configured correctly, and then run the buf generate
or protoc
command to generate the server code.
Key features
Key features include automatic MCP server generation from gRPC services, flexible package organization with customizable package suffixes, preservation of comments from proto files, and compatibility with Connect-Go for comprehensive gRPC support.
Where to use
The generated MCP servers can be used in applications requiring MCP functionality, such as Claude Desktop for AI assistance, any MCP-compatible clients, or custom applications that need to incorporate MCP servers.
Content
protoc-gen-connect-go-mcp
A Protocol Buffers compiler plugin that generates MCP (Model Context Protocol) server code from gRPC service definitions.
Overview
protoc-gen-connect-go-mcp
is a protoc plugin that automatically generates MCP server implementations from your existing gRPC service definitions. It creates ready-to-use MCP tools that can be integrated into MCP-compatible applications.
Features
- Automatic MCP Server Generation: Converts gRPC services to MCP server implementations
- Flexible Package Organization: Supports custom package suffixes for better code organization
- Comment Preservation: Preserves comments from proto files as tool descriptions
- Connect-Go Compatible: Works alongside
protoc-gen-connect-go
for full gRPC support
Installation
Prerequisites
- Go 1.21 or later
- Protocol Buffers compiler (
protoc
) buf
CLI tool (recommended)
Install
go install github.com/yoshihiro-shu/connect-go-mcp/cmd/protoc-gen-connect-go-mcp@latest
Usage
With buf
Create or update your buf.gen.yaml
:
version: v2
plugins:
- local: protoc-gen-go
out: gen
opt: paths=source_relative
- local: protoc-gen-connect-go
out: gen
opt: paths=source_relative
- local: protoc-gen-connect-go-mcp
out: gen
opt: paths=source_relative
Then run:
buf generate
With protoc
protoc \ --go_out=. --go_opt=paths=source_relative \ --connect-go_out=. --connect-go_opt=paths=source_relative \ --connect-go-mcp_out=. --connect-go-mcp_opt=paths=source_relative \ your_service.proto
Configuration Options
package_suffix
Controls the package naming and directory structure for generated files.
Default Behavior (no package_suffix)
plugins:
- local: protoc-gen-connect-go-mcp
out: gen
opt: paths=source_relative
Output: gen/greetv1mcp/greet.mcpserver.go
with package greetv1mcp
Custom Suffix
plugins:
- local: protoc-gen-connect-go-mcp
out: gen
opt: paths=source_relative,package_suffix=tools
Output: gen/greetv1tools/greet.mcpserver.go
with package greetv1tools
Empty Suffix (Flat Structure)
plugins:
- local: protoc-gen-connect-go-mcp
out: gen
opt: paths=source_relative,package_suffix=
Output: gen/greet.mcpserver.go
with package greetv1
Example
Input Proto File
syntax = "proto3";
package greet.v1;
option go_package = "github.com/example/gen/greet/v1;greetv1";
// Greeting service for MCP demonstration
service GreetService {
// Greet RPC
rpc Greet(GreetRequest) returns (GreetResponse);
// Ping RPC
rpc Ping(PingRequest) returns (PingResponse);
}
message GreetRequest {
// Greeting request
string name = 1;
}
message GreetResponse {
string message = 1;
}
message PingRequest {
// Ping request
string message = 1;
}
message PingResponse {
string message = 1;
}
Generated MCP Server
// Code generated by connect-go-mcp DO NOT EDIT.
package greetv1mcp
import (
"context"
"github.com/mark3labs/mcp-go/mcp"
"github.com/mark3labs/mcp-go/server"
connectgomcp "github.com/yoshihiro-shu/connect-go-mcp"
)
// NewGreetServiceMCPServer creates a configured MCP server for GreetService
func NewGreetServiceMCPServer(baseURL string, opts ...connectgomcp.ClientOption) *server.MCPServer {
server := server.NewMCPServer("GreetService", "1.0.0")
toolHandler := connectgomcp.NewToolHandler(baseURL, opts...)
server.AddTool(
mcp.NewTool("Greet RPC",
mcp.WithDescription("Greeting request"),
mcp.WithString("name"),
),
func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
return toolHandler.Handle(ctx, req, "Greet")
},
)
server.AddTool(
mcp.NewTool("Ping RPC",
mcp.WithDescription("Ping request"),
mcp.WithString("message"),
),
func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
return toolHandler.Handle(ctx, req, "Ping")
},
)
return server
}
Using the Generated Server
package main
import (
"log"
greetv1mcp "github.com/example/gen/greet/v1/greetv1mcp"
)
func main() {
// Create MCP server instance
mcpServer := greetv1mcp.NewGreetServiceMCPServer("http://localhost:8080")
// Start the MCP server
if err := mcpServer.Serve(); err != nil {
log.Fatal(err)
}
}
Generated Code Structure
The plugin generates:
- MCP Server Constructor:
New{ServiceName}MCPServer()
function - Tool Definitions: Each RPC method becomes an MCP tool
- Parameter Mapping: Proto message fields become tool parameters
- Comments: Preserved as tool descriptions
- Type Safety: Full Go type safety for all operations
Integration with MCP Ecosystem
The generated servers are compatible with:
- Claude Desktop: Add as MCP tools for AI assistance
- MCP Clients: Any client implementing the MCP protocol
- Custom Applications: Integrate MCP functionality into your apps
Development
Running Tests
cd cmd/protoc-gen-connect-go-mcp
go test -v
Test Requirements
- Protocol Buffers compiler (
protoc
) must be installed - Tests automatically skip if
protoc
is not available
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Related Projects
- mcp-go - Go implementation of MCP
- connect-go - Simple, reliable, interoperable RPC
- buf - Protocol Buffer toolkit