Skip to content
lingo

MCP tools

Turn a field shape into a full MCP tool descriptor.

Prefer the live demos? Open this section in the interactive docs.

lingoTool() from @pascal-app/lingo/mcp builds a complete MCP tool descriptor from a lingoObject shape: a closed JSON Schema out, safeParse in, and [CODE]-prefixed errors the model can self-correct from. Bring any MCP SDK; lingo brings the schema and the validation.

import { dateField, quantityField } from "@pascal-app/lingo/ai"
import { lingoTool } from "@pascal-app/lingo/mcp"

const createShipment = lingoTool({
  name: "create_shipment",
  description: "Create a shipment; natural-language values welcome.",
  input: {
    weight: quantityField({ kind: "mass", unit: "kg", min: 0, max: 500 }),
    deliverBy: dateField({ min: "2026-01-01" }),
  },
  handler: ({ weight, deliverBy }) =>
    "Shipment logged: " + weight + " kg, deliver by " + deliverBy,
})

server.registerTool(createShipment.name, {
  description: createShipment.description,
  inputSchema: createShipment.inputSchema,
}, createShipment.callback)

With requireNow on, "tomorrow" bounces back with NOW_REQUIRED, so a queued tool call can never drift across midnight.