Installation
Prerequisites
vgi-rpc-typescript requires Bun runtime.
Install the package
bun add vgi-rpc-typescriptOptional: Python CLI
The vgi-rpc CLI is useful for testing and introspecting your servers:
pip install vgi-rpc[cli]The CLI can describe services, call unary methods, and interact with streaming methods from the command line.
Verify installation
Create a minimal server to verify everything works:
import { Protocol, VgiRpcServer, str } from "vgi-rpc-typescript";
const protocol = new Protocol("Hello");
protocol.unary("hello", { params: { name: str }, result: { greeting: str }, handler: async ({ name }) => ({ greeting: `Hello, ${name}!` }),});
const server = new VgiRpcServer(protocol, { enableDescribe: true });server.run();Save this as server.ts and test with:
vgi-rpc --cmd "bun run server.ts" call hello name=World# {"greeting": "Hello, World!"}