Skip to content

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 ParameterDescription
TRouter extends RouterMapThe router map (use InferRouter<typeof registry>)

Parameters

ParameterTypeDescription
transportVurbTransportThe MCP transport layer
options?VurbClientOptionsClient 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;
        },
    ],
});