MCP · Tools

MCP0013Give h3-mcp tools a schema it can turn into JSON Schema

Report h3-mcp and nitro-mcp-toolkit tools whose `inputSchema` or `outputSchema` is a Zod, Valibot, or ArkType schema that the installed version can't turn into JSON Schema.

Why it happens

h3-mcp (okmcp) converts a schema to JSON Schema only through Standard JSON Schema (~standard.jsonSchema), which Zod adds in 4.2 and ArkType in 2.1.28, and Valibot doesn't have. Any other schema object goes into tools/list as it is, so the client gets the library's internals, such as { kind, entries } or _def, with no type: "object", and MCP SDK clients reject that list. A Valibot object() does have type: "object", but clients see none of its fields.

Fix

Upgrade the schema library to a version with Standard JSON Schema, or pass the JSON Schema the library generates.

Example

Pass JSON Schema for a Valibot schema

Before

import { defineTool } from 'h3-mcp'
import * as v from 'valibot'

defineTool({
  name: 'get_order',
  inputSchema: v.object({ id: v.string() }),
  handler: ({ id }) => getOrder(id),
})

After

import { defineTool } from 'h3-mcp'
import { toJsonSchema } from '@valibot/to-json-schema'
import * as v from 'valibot'

defineTool({
  name: 'get_order',
  inputSchema: toJsonSchema(v.object({ id: v.string() })),
  handler: ({ id }) => getOrder(id),
})

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

pnpm vite-doctor . --rules mcp/tools/no-raw-standard-schema
Copyright © 2026