Skip to main content
All schemas are exported from @toolshed/shared.

ToolDefinitionSchema

z.object({
  path: z.string().regex(/^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$/),
  name: z.string(),
  description: z.string(),
  inputSchema: z.record(z.unknown()),        // JSON Schema object
  outputSchema: z.record(z.unknown()).optional(),
  destructive: z.boolean().default(false),
  authProvider: z.string().optional(),
  serviceAccountAllowed: z.boolean().default(false),
  metadata: z.object({
    httpMethod: z.string().optional(),
    operationType: z.enum(["query", "mutation"]).optional(),
    mcpAnnotations: z.record(z.unknown()).optional(),
  }).optional(),
})

RoleSchema

z.object({
  id: z.string(),
  name: z.string(),
  patterns: z.array(z.string()),
})

AuditEntrySchema

z.object({
  id: z.string(),
  userId: z.string(),
  roleId: z.string(),
  toolPath: z.string(),
  args: z.record(z.unknown()).optional(),
  resultStatus: z.enum(["success", "error", "denied", "elicited"]),
  elicitTrail: z.array(z.string()).optional(),
  timestamp: z.string().datetime(),
})

ElicitationRequestSchema

z.object({
  executionId: z.string(),
  toolPath: z.string(),
  message: z.string(),
  args: z.record(z.unknown()).optional(),
  type: z.enum(["approval", "form"]).default("approval"),
})

ElicitationResponseSchema

z.object({
  executionId: z.string(),
  approved: z.boolean(),
  data: z.record(z.unknown()).optional(),
})
The response uses an approved boolean field, not a status string. This is the canonical shape for resolved elicitations.

SerializedCatalogSchema

z.object({
  version: z.literal("v1"),
  types: z.record(JsonSchemaSchema),
  tools: z.array(ToolRegistrationSchema),
  sources: z.array(SourceRegistrationSchema),
})

ToolRegistrationSchema

z.object({
  path: z.string(),
  name: z.string(),
  description: z.string(),
  sourceId: z.string(),
  inputSchemaRef: z.string(),              // Key into the types dictionary
  outputSchemaRef: z.string().optional(),
  destructive: z.boolean(),
  authProvider: z.string().optional(),
  serviceAccountAllowed: z.boolean(),
})

SourceRegistrationSchema

z.object({
  id: z.string(),
  type: z.enum(["openapi", "mcp", "graphql", "plugin"]),
  name: z.string(),
  description: z.string(),
  toolCount: z.number().int().nonnegative(),
})

RunRequestSchema

z.object({
  script: z.string(),
  userId: z.string(),
})

SearchToolsRequestSchema

z.object({
  query: z.string(),
  limit: z.number().int().positive().default(10),
})

ReadToolRequestSchema

z.object({
  path: z.string(),
})

ResumeRequestSchema

z.object({
  executionId: z.string(),
  response: ElicitationResponseSchema,
})