Function: createVurbClient()
ts
function createVurbClient<TRouter>(transport, options?): VurbClient<TRouter>;Defined in: packages/core/src/client/VurbClient.ts:449
Create a type-safe MCP client.
The client provides full autocomplete for action names and compile-time validation for arguments based on the server's router type.
Type Parameters
| Type Parameter | Description |
|---|---|
TRouter extends RouterMap | The router map (use InferRouter<typeof registry>) |
Parameters
| Parameter | Type | Description |
|---|---|---|
transport | VurbTransport | The MCP transport layer |
options? | VurbClientOptions | Client options (middleware, error handling) |
Returns
VurbClient<TRouter>
A typed VurbClient
Examples
typescript
import type { AppRouter } from './mcp-server';
const client = createVurbClient<AppRouter>(transport);
// Full autocomplete + type validation:
await client.execute('projects.create', { name: 'Vinkius V2' });
// TS error: 'projects.nonexistent' is not a valid action
await client.execute('projects.nonexistent', {});
// TS error: missing required arg 'name'
await client.execute('projects.create', {});typescript
// With client middleware and throwOnError
const client = createVurbClient<AppRouter>(transport, {
throwOnError: true,
middleware: [
async (action, args, next) => {
console.log(`[Client] calling ${action}`);
const result = await next(action, args);
console.log(`[Client] ${action} done`);
return result;
},
],
});