This is an implementation of a gRPC Proxying Server in Golang, based on grpc-go. Features:
StreamDirector routing based on context.Context of the Stream, allowing users to return
a grpc.ClientConn after dialing the backend of choice based on:authorization header
director := func(ctx context.Context) (*grpc.ClientConn, error) {
if err := CheckBearerToken(ctx); err != nil {
return nil, grpc.Errorf(codes.PermissionDenied, "unauthorized access: %v", err)
}
stream, _ := transport.StreamFromContext(ctx)
backend, found := PreDialledBackends[stream.Method()];
if !found {
return nil, grpc.Errorf(codes.Unimplemented, "the service %v is not implemented", stream.Method)
}
return backend, nil
}
proxy := grpcproxy.NewProxy(director)
proxy.Server(boundListener)
This is alpha software, written as a proof of concept. It has been integration-tested, but please expect bugs.
The current implementation depends on a public interface to ClientConn.Picker(), which hopefully will be upstreamed in grpc-go#397.
Names in no particular order:
grpc-proxy is released under the Apache 2.0 license. See LICENSE.txt.
Part of the main server loop are lifted from the grpc-go Server, which is copyrighted Google Inc. and licensed under MIT license.
$ claude mcp add grpc-proxy \
-- python -m otcore.mcp_server <graph>