# @tmcp/adapter-valibot

> Valibot adapter for TMCP JSON Schema conversion

Latest version **0.1.6** (published 2026-05-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tmcp/adapter-valibot
pnpm add @tmcp/adapter-valibot
yarn add @tmcp/adapter-valibot
bun add @tmcp/adapter-valibot
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; high maintenance score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2026-05-14 |
| First published | 2025-07-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 203 |
| Maintainers | pablopang |
| Keywords | tmcp, valibot, jsonschema, adapter |

## Links

- npm: https://www.npmjs.com/package/@tmcp/adapter-valibot
- Repository: https://github.com/paoloricciuti/tmcp
- Homepage: https://github.com/paoloricciuti/tmcp#readme
- Issues: https://github.com/paoloricciuti/tmcp/issues
- npm.io page: https://npm.io/package/@tmcp/adapter-valibot

## Dependencies (3)

- [valibot](https://npm.io/package/valibot.md) ^1.1.0
- [@standard-schema/spec](https://npm.io/package/@standard-schema/spec.md) ^1.0.0
- [@valibot/to-json-schema](https://npm.io/package/@valibot/to-json-schema.md) ^1.3.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.1.6 (latest) — 2026-05-14
- 0.1.5 — 2025-11-12
- 0.1.4 — 2025-08-02
- 0.1.3 — 2025-07-22
- 0.1.2 — 2025-07-15

## README

# @tmcp/adapter-valibot

Valibot adapter for TMCP JSON Schema conversion.

## Installation

```bash
pnpm add @tmcp/adapter-valibot valibot tmcp
```

## Usage

```javascript
import { ValibotJsonSchemaAdapter } from '@tmcp/adapter-valibot';
import * as v from 'valibot';

const adapter = new ValibotJsonSchemaAdapter();

// Define a Valibot schema
const userSchema = v.object({
	name: v.string(),
	age: v.number(),
	email: v.pipe(v.string(), v.email()),
});

// Convert to JSON Schema
const jsonSchema = await adapter.toJsonSchema(userSchema);
console.log(jsonSchema);
```

## Usage with TMCP Server

```javascript
import { McpServer } from 'tmcp';
import { ValibotJsonSchemaAdapter } from '@tmcp/adapter-valibot';
import * as v from 'valibot';

const adapter = new ValibotJsonSchemaAdapter();
const server = new McpServer(
	{
		name: 'my-server',
		version: '1.0.0',
		description: 'Server with Valibot schemas',
	},
	{
		adapter,
		capabilities: {
			tools: { listChanged: true },
		},
	},
);

// Define a tool with Valibot schema
server.tool(
	{
		name: 'create_user',
		description: 'Create a new user',
		schema: v.object({
			name: v.string(),
			age: v.pipe(v.number(), v.minValue(0)),
			email: v.pipe(v.string(), v.email()),
		}),
	},
	async ({ name, age, email }) => {
		return {
			content: [
				{
					type: 'text',
					text: `Created user: ${name}, age ${age}, email ${email}`,
				},
			],
		};
	},
);
```

## Advanced Usage

### Custom Validation and Metadata

```javascript
import { ValibotJsonSchemaAdapter } from '@tmcp/adapter-valibot';
import * as v from 'valibot';

const adapter = new ValibotJsonSchemaAdapter();

// Schema with custom descriptions and metadata
const userSchema = v.object({
	name: v.pipe(v.string(), v.minLength(1), v.maxLength(100)),
	age: v.pipe(v.number(), v.minValue(0), v.maxValue(150)),
	email: v.pipe(v.string(), v.email()),
	preferences: v.optional(
		v.object({
			theme: v.picklist(['light', 'dark']),
			notifications: v.boolean(),
		}),
	),
});

const jsonSchema = await adapter.toJsonSchema(userSchema);
```

### Complex Schemas

```javascript
import * as v from 'valibot';

// Union types
const contactSchema = v.union([
	v.object({
		type: v.literal('email'),
		value: v.pipe(v.string(), v.email()),
	}),
	v.object({
		type: v.literal('phone'),
		value: v.pipe(v.string(), v.regex(/^\+?\d+$/)),
	}),
]);

// Arrays and nested objects
const companySchema = v.object({
	name: v.string(),
	employees: v.array(userSchema),
	contacts: v.array(contactSchema),
	founded: v.pipe(
		v.date(),
		v.transform((date) => date.toISOString()),
	),
});
```

## API

### `ValibotJsonSchemaAdapter`

A class that extends the base `JsonSchemaAdapter` from TMCP and provides Valibot-specific schema conversion.

#### Methods

- `toJsonSchema(schema)` - Converts a Valibot schema to JSON Schema format

## Dependencies

- `valibot` - Peer dependency for schema validation (^1.1.0)
- `tmcp` - Peer dependency for the base adapter
- `@valibot/to-json-schema` - For schema conversion

## Features

- **Full Valibot support** - Supports all Valibot schema types and validations
- **Type safety** - Full TypeScript support with proper type inference
- **Rich validation** - Preserves validation rules and transformations
- **Easy integration** - Drop-in replacement for other TMCP adapters
- **Performance** - Efficient schema conversion using Valibot's built-in utilities

## Acknowledgments

Huge thanks to Sean O'Bannon that provided us with the `@tmcp` scope on npm.

---
_Source: https://npm.io/package/@tmcp/adapter-valibot · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
