Vigie
Definitions

Tools

defineTool adds an MCP tool of your own, with read or write scope.
definitions/tools/acme.ts
import { defineTool } from 'vigie/sdk'

export const blockedShipments = defineTool({
  name: 'parcelo_blocked',
  description: 'Shipments to Parcelo that have not succeeded yet, with the reason.',
  scope: 'read',
  run: ({ sql }) =>
    sql(`SELECT LogAttributes['task.key'] AS order, argMax(LogAttributes['taskOutcome.reason'], Timestamp) AS code, max(Timestamp) AS last, countIf(Outcome = 'succeeded') AS ok
         FROM logs WHERE $__timeFilter(Timestamp) AND Environment = $__env AND TaskKind = 'parcelo.ship'
         GROUP BY order HAVING ok = 0 ORDER BY last DESC LIMIT 50`),
})

run receives sql, which runs a read-only query with the same macros as pages, and env. input takes a JSON schema for the tool's arguments. A write tool is only offered to write tokens.

Copyright © 2026