Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

2.1 KB
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-only
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.

// Types for the generated Carbon API operation manifest. The DATA is generated by
// `scripts/generate-mcp.ts` into the erp app's gitignored
// `routes/api+/mcp+/lib/tool-metadata.json` (its committed record is the sibling
// `tool-manifest.digest.json`); these types are the contract consumers read against.
// Keep them in sync with the generator's output shape.

export type Classification = "READ" | "WRITE" | "DESTRUCTIVE";

export type PermissionAction = "view" | "create" | "update" | "delete";

/**
 * The permission an API-key caller must hold to invoke the operation.
 * `module` is `null` for operations that gate only on a valid key of the company
 * (e.g. `account`, `shared`) rather than a specific permission module.
 */
export interface ToolPermission {
  module: string | null;
  actions: PermissionAction[];
}

/** One operation in the manifest — the successor of a `tool-metadata.json` entry. */
export interface ManifestEntry {
  name: string;
  module: string;
  classification: Classification;
  description: string;
  permission: ToolPermission;
  /** Whether the operation applies limit/offset itself. A list operation with
   *  `paginates: false` returns every row, and the MCP layer pages the response
   *  at its own boundary instead. */
  paginates: boolean;
  /** The JSON Schema for the operation's input. */
  schema: Record<string, unknown>;
  /** A service function's title: its TSDoc summary line. */
  title?: string;
  /** The operation's path in the ERP router (`["production", "cancelJob"]`).
   *  Its HTTP path is the path joined by `/`. */
  serviceFn: { path: string[] };
  /** The JSON Schema for the operation's RESPONSE `data`, reflected from the
   *  service function's TypeScript return type — absent when nothing useful could
   *  be derived (an `any`, a void, or an opaque shape). */
  responseSchema?: Record<string, unknown>;
}