by ziglana
blazigly fast gRPC/MCP client & server implementation in zig
# Add to your Claude Code skills
git clone https://github.com/ziglana/gRPC-zigA blazingly fast gRPC client & server implementation in Zig, designed for maximum performance and minimal overhead.
const std = @import("std");
const GrpcServer = @import("grpc-server").GrpcServer;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
// Create and configure server
var server = try GrpcServer.init(allocator, 50051, "secret-key");
defer server.deinit();
// Register handlers
try server.handlers.append(allocator, .{
.name = "SayHello",
.handler_fn = sayHello,
});
// Start server
try server.start();
}
fn sayHello(request: []const u8, allocator: std.mem.Allocator) ![]u8 {
_ = request;
return allocator.dupe(u8, "Hello from gRPC-zig!");
}
See examples/basic_server.zig for a complete example.
const std = @import("std");
const GrpcServer = @import("grpc-server").GrpcServer;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
var server = try GrpcServer.init(allocator, 50051, "secret-key");
defer server.deinit();
try server.start();
}
See examples/basic_client.zig for a complete example.
const std = @import("std");
const GrpcClient = @import("grpc-client").GrpcClient;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
var client = try GrpcClient.init(allocator, "localhost", 50051);
defer client.deinit();
const response = try client.call("SayHello", "World", .none);
defer allocator.free(response);
std.debug.print("Response: {s}\n", .{response});
}
All features are demonstrated in the examples/ directory: