gRPC-zig

作者 ziglana已验证

blazigly fast gRPC/MCP client & server implementation in zig

145
Stars
31
Forks
Zig
语言
2026/8/23
添加时间

⚠️ 第三方软件声明

本 Skill 为第三方开源软件,独立托管于 GitHub。SkillTip 仅为信息目录,不控制或维护底层仓库。所显示的安全检查为自动化且范围有限,安装前请自行审查源码。

阅读服务条款

安装

添加到你的 Claude Code skills 目录:

# Add to your Claude Code skills
git clone https://github.com/ziglana/gRPC-zig

快速入门

使用 gRPC-zig 等 Skills 的指南。

安全报告

已验证

上次扫描:—

{
  "status": "PASSED",
  "issues": []
}

README.md

🚀 gRPC-zig

A blazingly fast gRPC client & server implementation in Zig, designed for maximum performance and minimal overhead.

License: Unlicense Zig HTTP/2

⚡️ Features

  • 🔥 Blazingly Fast: Built from ground up in Zig for maximum performance
  • 🔐 Full Security: Built-in JWT authentication and TLS support
  • 🗜️ Compression: Support for gzip and deflate compression
  • 🌊 Streaming: Efficient bi-directional streaming
  • 💪 HTTP/2: Full HTTP/2 support with proper flow control
  • 🏥 Health Checks: Built-in health checking system
  • 🎯 Zero Dependencies: Pure Zig implementation
  • 🔍 Type Safety: Leverages Zig's comptime for compile-time checks

🚀 Quick Start

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!");
}

📚 Examples

Basic Server

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();
}

Basic Client

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});
}

Features

All features are demonstrated in the examples/ directory:

🔧 Installation

Option 1: Using zig fetch (Recommended)

  1. Add the dependency to your project:
zig fetch --save git+https://github.com/ziglana/gRPC-zig#main
  1. Add to your build.zig:
const grpc_zig_dep = b.dependency("grpc_zig", .{
    .target = target,
    .optimize = optimize,
});

// For server development
exe.root_module.addImport("grpc-server", grpc_zig_dep.module("grpc-server"));

// For client development
exe.root_module.addImport("grpc-client", grpc_zig_dep.module("grpc-client"));
  1. Import in your code:
const GrpcServer = @import("grpc-server").GrpcServer;
const GrpcClient = @import("grpc-client").GrpcClient;

Option 2: Manual setup

Clone the repository and add it to your build.zig.zon:

.{
    .name = "my-project",
    .version = "0.1.0",
    .dependencies = .{
        .grpc_zig = .{
            .url = "https://github.com/ziglana/gRPC-zig/archive/refs/heads/main.tar.gz",
            // Replace with actual hash after first fetch
            .hash = "...",
        },
    },
}

🏃 Performance

Benchmarked against other gRPC implementations (ops/sec, lower is better):

gRPC-zig    │████████░░░░░░░░░░│  2.1ms
gRPC Go     │██████████████░░░░│  3.8ms
gRPC C++    │████████████████░░│  4.2ms

Running Benchmarks

The repository includes a built-in benchmarking tool to measure performance:

# Build the benchmark tool
zig build

# Run benchmarks with default settings
zig build benchmark

# Run with custom parameters
./zig-out/bin/grpc-benchmark --help
./zig-out/bin/grpc-benchmark --requests 1000 --clients 10 --output json

# Or use the convenient script
./scripts/run_benchmark.sh

Benchmark Options:

  • --host <host>: Server host (default: localhost)
  • --port <port>: Server port (default: 50051)
  • --requests <n>: Number of requests per client (default: 1000)
  • --clients <n>: Number of concurrent clients (default: 10)
  • --size <bytes>: Request payload size (default: 1024)
  • --output <format>: Output format: text|json (default: text)

Benchmark Metrics:

  • Latency statistics (min, max, average, P95, P99)
  • Throughput (requests per second)
  • Error rates and success rates
  • Total execution time

The benchmarks automatically run in CI/CD on every pull request and provide performance feedback.

📖 Detailed Benchmarking Guide

🧪 Testing

Unit Tests

Run the unit test suite:

zig build test

The test suite covers:

  • Compression algorithms (gzip, deflate, none)
  • Benchmark handler functionality
  • Core protocol functionality

Integration Tests

Run integration tests with a Python client validating the Zig server:

cd integration_test
./run_tests.sh

Or manually:

# Build and start the test server
zig build integration_test
./zig-out/bin/grpc-test-server

# In another terminal, run Python tests
cd integration_test
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python3 test_client.py

The integration tests validate:

  • HTTP/2 protocol compliance
  • gRPC request/response flow
  • Compression functionality
  • Health checking
  • Authentication integration

📖 Integration Test Documentation

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

📜 License

This project is licensed under the Unlicense - see the LICENSE file for details.

⭐️ Support

If you find this project useful, please consider giving it a star on GitHub to show your support!

🙏 Acknowledgments

  • Spice - For the amazing Protocol Buffers implementation
  • Tonic - For inspiration on API design
  • The Zig community for their invaluable feedback and support

Made with ❤️ in Zig

常见问题

What is gRPC-zig?

gRPC-zig is an open-source mcp servers skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by ziglana. blazigly fast gRPC/MCP client & server implementation in zig. It has 145 GitHub stars.

Is gRPC-zig safe to use?

Yes. gRPC-zig passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.

How do I install gRPC-zig?

Clone the repository with "git clone https://github.com/ziglana/gRPC-zig" and add it to your Claude Code skills directory (see the Installation section above).

What programming language is gRPC-zig written in?

gRPC-zig is primarily written in Zig. It is open-source under ziglana on GitHub, so you can review or fork the full source.

Are there alternatives to gRPC-zig?

Yes. SkillsLLM lists many other MCP Servers skills you can browse and compare side by side. Open the MCP Servers category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh gRPC-zig against similar tools.

评论 (0)

暂无评论,成为第一个分享想法的人!

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

Scrapling

by D4Vinci

🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl!

75,9137,581Python
MCP 服务器
查看详情

TrendRadar

by sansan0

⭐AI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.🎯 告别信息过载,你的 AI 舆情监控助手与热点筛选工具!聚合多平台热点 + RSS 订阅,支持关键词精准筛选。AI 智能筛选新闻 + AI 翻译 + AI 分析简报直推手机,也支持接入 MCP 架构,赋能 AI 自然语言对话分析、情感洞察与趋势预测等。支持 Docker ,数据本地/云端自持。集成微信/飞书/钉钉/Telegram/邮件/ntfy/bark/slack 等渠道智能推送。

61,65224,883Python
MCP 服务器
查看详情

context7

by upstash

Context7 Platform -- Up-to-date code documentation for LLMs and AI code editors

61,0602,938TypeScript
MCP 服务器
查看详情

High-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.

39,9393,219C
MCP 服务器
查看详情

开发者还喜欢

基于喜欢此 Skill 的开发者投票和收藏

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情