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.

MCP (#644)

Brad Barbinb33c6ee62d71
diff --git a/apps/erp/app/routes/api+/mcp+/_index.ts b/apps/erp/app/routes/api+/mcp+/_index.ts
new file mode 100644
index 0000000000..f3631eb96a
--- /dev/null
+++ b/apps/erp/app/routes/api+/mcp+/_index.ts
@@ -0,0 +1,42 @@
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
+import type { ActionFunctionArgs } from "react-router";
+import { createMcpServer } from "./lib/server";
+
+export async function action({ request }: ActionFunctionArgs) {
+ const authHeader = request.headers.get("Authorization");
+ const hasCarbonKey = request.headers.has("carbon-key");
+
+ if (authHeader?.startsWith("Bearer ") && !hasCarbonKey) {
+ const token = authHeader.slice(7);
+ const headers = new Headers(request.headers);
+ headers.set("carbon-key", token);
+ request = new Request(request, { headers });
+ }
+
+ const { client, companyId, userId } = await requirePermissions(request, {});
+
+ const server = createMcpServer({ client, companyId, userId });
+ const transport = new WebStandardStreamableHTTPServerTransport({
+ sessionIdGenerator: undefined,
+ enableJsonResponse: true
+ });
+
+ await server.connect(transport);
+
+ return transport.handleRequest(request);
+}
+
+export async function loader() {
+ return new Response(
+ JSON.stringify({
+ jsonrpc: "2.0",
+ error: { code: -32000, message: "Method not allowed. Use POST." },
+ id: null
+ }),
+ {
+ status: 405,
+ headers: { "Content-Type": "application/json" }
+ }
+ );
+}
diff --git a/apps/erp/app/routes/api+/mcp+/lib/server.ts b/apps/erp/app/routes/api+/mcp+/lib/server.ts
new file mode 100644
index 0000000000..4e6667e96f
--- /dev/null
+++ b/apps/erp/app/routes/api+/mcp+/lib/server.ts
@@ -0,0 +1,87 @@
+// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
+import {
+ registerAccountingTools,
+ registerAccountTools,
+ registerDocumentsTools,
+ registerInventoryTools,
+ registerInvoicingTools,
+ registerItemsTools,
+ registerPeopleTools,
+ registerProductionTools,
+ registerPurchasingTools,
+ registerQualityTools,
+ registerResourcesTools,
+ registerSalesTools,
+ registerSettingsTools,
+ registerSharedTools,
+ registerUsersTools
+} from "./tools";
+import type { McpContext } from "./types";
+
+function getServerInstructions(): string {
+ const today = new Date().toISOString().split("T")[0];
+
+ return `Carbon ERP is a manufacturing system. This MCP server provides access to ERP data including sales, purchasing, inventory, production, quality, and more.
+
+## Current Date
+Today is ${today}.
+
+## Tool Organization
+Tools are namespaced by module — use the prefix to discover related tools:
+- account_* — 6 read, 3 write, 1 delete tools
+- accounting_* — 27 read, 8 write, 4 delete tools
+- documents_* — 4 read, 7 write, 3 delete tools
+- inventory_* — 45 read, 15 write, 12 delete tools
+- invoicing_* — 11 read, 13 write, 4 delete tools
+- items_* — 75 read, 44 write, 17 delete tools
+- people_* — 24 read, 14 write, 6 delete tools
+- production_* — 62 read, 44 write, 22 delete tools
+- purchasing_* — 51 read, 34 write, 11 delete tools
+- quality_* — 38 read, 19 write, 11 delete tools
+- resources_* — 47 read, 27 write, 20 delete tools
+- sales_* — 78 read, 54 write, 18 delete tools
+- settings_* — 26 read, 40 write, 2 delete tools
+- shared_* — 20 read, 20 write, 4 delete tools
+- users_* — 17 read, 6 write, 2 delete tools
+
+## Key Patterns
+- All monetary amounts use the company's base currency unless specified.
+- Date parameters use ISO 8601 format (YYYY-MM-DD).
+- List tools support pagination via limit/offset (GenericQueryFilters).
+- companyId and userId are auto-filled from the authenticated context — do not provide them.
+- Most get/list tools return { data, error, count? } — check error before using data.
+- Tool errors return isError: true with a text explanation.
+`;
+}
+
+export function createMcpServer(ctx: McpContext): McpServer {
+ const server = new McpServer(
+ {
+ name: "carbon-erp",
+ version: process.env.VERCEL_GIT_COMMIT_SHA?.slice(0, 7) ?? "1.0.0"
+ },
+ {
+ instructions: getServerInstructions()
+ }
+ );
+
+ registerAccountTools(server, ctx);
+ registerAccountingTools(server, ctx);
+ registerDocumentsTools(server, ctx);
+ registerInventoryTools(server, ctx);
+ registerInvoicingTools(server, ctx);
+ registerItemsTools(server, ctx);
+ registerPeopleTools(server, ctx);
+ registerProductionTools(server, ctx);
+ registerPurchasingTools(server, ctx);
+ registerQualityTools(server, ctx);
+ registerResourcesTools(server, ctx);
+ registerSalesTools(server, ctx);
+ registerSettingsTools(server, ctx);
+ registerSharedTools(server, ctx);
+ registerUsersTools(server, ctx);
+
+ return server;
+}
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tools/account.ts b/apps/erp/app/routes/api+/mcp+/lib/tools/account.ts
new file mode 100644
index 0000000000..4c57aa4530
--- /dev/null
+++ b/apps/erp/app/routes/api+/mcp+/lib/tools/account.ts
@@ -0,0 +1,215 @@
+// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+import { z } from "zod";
+import {
+ deleteUserAttributeValue,
+ getAccount,
+ getAllAttributeCategories,
+ getAttributeCategoryWithValues,
+ getAttributes,
+ getPrivateAttributes,
+ getPublicAttributes,
+ updateAvatar,
+ updatePublicAccount,
+ upsertUserAttributeValue
+} from "~/modules/account/account.service";
+import type { RegisterTools } from "../types";
+import {
+ DESTRUCTIVE_ANNOTATIONS,
+ READ_ONLY_ANNOTATIONS,
+ toMcpResult,
+ WRITE_ANNOTATIONS,
+ withErrorHandling
+} from "../types";
+
+export const registerAccountTools: RegisterTools = (server, ctx) => {
+ server.registerTool(
+ "account_deleteUserAttributeValue",
+ {
+ description: "delete user attribute value",
+ inputSchema: {
+ args: z.object({
+ userAttributeId: z.string(),
+ userAttributeValueId: z.string()
+ })
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteUserAttributeValue(ctx.client, {
+ ...params.args,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: account_deleteUserAttributeValue")
+ );
+
+ server.registerTool(
+ "account_getAccount",
+ {
+ description: "get account",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAccount(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: account_getAccount")
+ );
+
+ server.registerTool(
+ "account_getAttributes",
+ {
+ description: "get attributes",
+ inputSchema: {
+ isPublic: z.boolean()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAttributes(
+ ctx.client,
+ ctx.userId,
+ ctx.companyId,
+ params.isPublic
+ );
+ return toMcpResult(result);
+ }, "Failed: account_getAttributes")
+ );
+
+ server.registerTool(
+ "account_getPrivateAttributes",
+ {
+ description: "get private attributes",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPrivateAttributes(
+ ctx.client,
+ ctx.userId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: account_getPrivateAttributes")
+ );
+
+ server.registerTool(
+ "account_getPublicAttributes",
+ {
+ description: "get public attributes",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPublicAttributes(
+ ctx.client,
+ ctx.userId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: account_getPublicAttributes")
+ );
+
+ server.registerTool(
+ "account_getAllAttributeCategories",
+ {
+ description: "get all attribute categories",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAllAttributeCategories(
+ ctx.client,
+ ctx.userId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: account_getAllAttributeCategories")
+ );
+
+ server.registerTool(
+ "account_getAttributeCategoryWithValues",
+ {
+ description: "get attribute category with values",
+ inputSchema: {
+ categoryId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAttributeCategoryWithValues(
+ ctx.client,
+ params.categoryId,
+ ctx.userId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: account_getAttributeCategoryWithValues")
+ );
+
+ server.registerTool(
+ "account_updateAvatar",
+ {
+ description: "update avatar",
+ inputSchema: {
+ avatarUrl: z.string().nullable()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateAvatar(
+ ctx.client,
+ ctx.userId,
+ params.avatarUrl
+ );
+ return toMcpResult(result);
+ }, "Failed: account_updateAvatar")
+ );
+
+ server.registerTool(
+ "account_updatePublicAccount",
+ {
+ description: "update public account",
+ inputSchema: {
+ account: z.object({
+ id: z.string(),
+ firstName: z.string(),
+ lastName: z.string(),
+ about: z.string().optional()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updatePublicAccount(ctx.client, params.account);
+ return toMcpResult(result);
+ }, "Failed: account_updatePublicAccount")
+ );
+
+ server.registerTool(
+ "account_upsertUserAttributeValue",
+ {
+ description: "upsert user attribute value",
+ inputSchema: {
+ update: z.object({
+ userAttributeValueId: z.any().optional(),
+ userAttributeId: z.string(),
+ value: z.any(),
+ type: z.string()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertUserAttributeValue(ctx.client, {
+ ...params.update,
+ userId: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: account_upsertUserAttributeValue")
+ );
+};
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tools/accounting.ts b/apps/erp/app/routes/api+/mcp+/lib/tools/accounting.ts
new file mode 100644
index 0000000000..35e20046ce
--- /dev/null
+++ b/apps/erp/app/routes/api+/mcp+/lib/tools/accounting.ts
@@ -0,0 +1,793 @@
+// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+import { z } from "zod";
+import {
+ accountCategoryValidator,
+ accountSubcategoryValidator,
+ accountValidator,
+ currencyValidator,
+ defaultBalanceSheetAccountValidator,
+ defaultIncomeAcountValidator,
+ fiscalYearSettingsValidator,
+ paymentTermValidator
+} from "~/modules/accounting/accounting.models";
+import {
+ deleteAccount,
+ deleteAccountCategory,
+ deleteAccountSubcategory,
+ deletePaymentTerm,
+ getAccount,
+ getAccountCategories,
+ getAccountCategoriesList,
+ getAccountCategory,
+ getAccountSubcategories,
+ getAccountSubcategoriesByCategory,
+ getAccountSubcategory,
+ getAccounts,
+ getAccountsList,
+ getBaseCurrency,
+ getChartOfAccounts,
+ getCurrencies,
+ getCurrenciesList,
+ getCurrency,
+ getCurrencyByCode,
+ getCurrentAccountingPeriod,
+ getDefaultAccounts,
+ getFiscalYearSettings,
+ getInventoryPostingGroup,
+ getInventoryPostingGroups,
+ getPaymentTerm,
+ getPaymentTerms,
+ getPaymentTermsList,
+ getPurchasingPostingGroup,
+ getPurchasingPostingGroups,
+ getPurchasingSalesGroup,
+ getSalesPostingGroups,
+ updateDefaultBalanceSheetAccounts,
+ updateDefaultIncomeAccounts,
+ updateFiscalYearSettings,
+ upsertAccount,
+ upsertAccountCategory,
+ upsertAccountSubcategory,
+ upsertCurrency,
+ upsertPaymentTerm
+} from "~/modules/accounting/accounting.service";
+import type { RegisterTools } from "../types";
+import {
+ DESTRUCTIVE_ANNOTATIONS,
+ READ_ONLY_ANNOTATIONS,
+ toMcpResult,
+ WRITE_ANNOTATIONS,
+ withErrorHandling
+} from "../types";
+
+export const registerAccountingTools: RegisterTools = (server, ctx) => {
+ server.registerTool(
+ "accounting_deleteAccount",
+ {
+ description: "delete account",
+ inputSchema: {
+ accountId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteAccount(ctx.client, params.accountId);
+ return toMcpResult(result);
+ }, "Failed: accounting_deleteAccount")
+ );
+
+ server.registerTool(
+ "accounting_deleteAccountCategory",
+ {
+ description: "delete account category",
+ inputSchema: {
+ accountCategoryId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteAccountCategory(
+ ctx.client,
+ params.accountCategoryId
+ );
+ return toMcpResult(result);
+ }, "Failed: accounting_deleteAccountCategory")
+ );
+
+ server.registerTool(
+ "accounting_deleteAccountSubcategory",
+ {
+ description: "delete account subcategory",
+ inputSchema: {
+ accountSubcategoryId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteAccountSubcategory(
+ ctx.client,
+ params.accountSubcategoryId
+ );
+ return toMcpResult(result);
+ }, "Failed: accounting_deleteAccountSubcategory")
+ );
+
+ server.registerTool(
+ "accounting_deletePaymentTerm",
+ {
+ description: "delete payment term",
+ inputSchema: {
+ paymentTermId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deletePaymentTerm(ctx.client, params.paymentTermId);
+ return toMcpResult(result);
+ }, "Failed: accounting_deletePaymentTerm")
+ );
+
+ server.registerTool(
+ "accounting_getAccount",
+ {
+ description: "get account",
+ inputSchema: {
+ accountId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAccount(ctx.client, params.accountId);
+ return toMcpResult(result);
+ }, "Failed: accounting_getAccount")
+ );
+
+ server.registerTool(
+ "accounting_getAccounts",
+ {
+ description: "get accounts",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAccounts(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: accounting_getAccounts")
+ );
+
+ server.registerTool(
+ "accounting_getAccountsList",
+ {
+ description: "get accounts list",
+ inputSchema: {
+ args: z
+ .object({
+ type: z.any().optional(),
+ incomeBalance: z.any().optional(),
+ classes: z.array(z.any()).optional()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAccountsList(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: accounting_getAccountsList")
+ );
+
+ server.registerTool(
+ "accounting_getAccountCategories",
+ {
+ description: "get account categories",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAccountCategories(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: accounting_getAccountCategories")
+ );
+
+ server.registerTool(
+ "accounting_getAccountCategoriesList",
+ {
+ description: "get account categories list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAccountCategoriesList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: accounting_getAccountCategoriesList")
+ );
+
+ server.registerTool(
+ "accounting_getAccountCategory",
+ {
+ description: "get account category",
+ inputSchema: {
+ accountCategoryId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAccountCategory(
+ ctx.client,
+ params.accountCategoryId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: accounting_getAccountCategory")
+ );
+
+ server.registerTool(
+ "accounting_getAccountSubcategories",
+ {
+ description: "get account subcategories",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAccountSubcategories(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: accounting_getAccountSubcategories")
+ );
+
+ server.registerTool(
+ "accounting_getAccountSubcategoriesByCategory",
+ {
+ description: "get account subcategories by category",
+ inputSchema: {
+ accountCategoryId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAccountSubcategoriesByCategory(
+ ctx.client,
+ params.accountCategoryId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: accounting_getAccountSubcategoriesByCategory")
+ );
+
+ server.registerTool(
+ "accounting_getAccountSubcategory",
+ {
+ description: "get account subcategory",
+ inputSchema: {
+ accountSubcategoryId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAccountSubcategory(
+ ctx.client,
+ params.accountSubcategoryId
+ );
+ return toMcpResult(result);
+ }, "Failed: accounting_getAccountSubcategory")
+ );
+
+ server.registerTool(
+ "accounting_getBaseCurrency",
+ {
+ description: "get base currency",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getBaseCurrency(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: accounting_getBaseCurrency")
+ );
+
+ server.registerTool(
+ "accounting_getChartOfAccounts",
+ {
+ description: "get chart of accounts",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ name: z.string().nullable(),
+ incomeBalance: z.enum(["Income Statement", "Balance Sheet", "null"]),
+ startDate: z.string().nullable(),
+ endDate: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getChartOfAccounts(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: accounting_getChartOfAccounts")
+ );
+
+ server.registerTool(
+ "accounting_getCurrency",
+ {
+ description: "get currency",
+ inputSchema: {
+ currencyId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCurrency(ctx.client, params.currencyId);
+ return toMcpResult(result);
+ }, "Failed: accounting_getCurrency")
+ );
+
+ server.registerTool(
+ "accounting_getCurrencyByCode",
+ {
+ description: "get currency by code",
+ inputSchema: {
+ currencyCode: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCurrencyByCode(
+ ctx.client,
+ ctx.companyId,
+ params.currencyCode
+ );
+ return toMcpResult(result);
+ }, "Failed: accounting_getCurrencyByCode")
+ );
+
+ server.registerTool(
+ "accounting_getCurrencies",
+ {
+ description: "get currencies",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCurrencies(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: accounting_getCurrencies")
+ );
+
+ server.registerTool(
+ "accounting_getCurrenciesList",
+ {
+ description: "get currencies list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCurrenciesList(ctx.client);
+ return toMcpResult(result);
+ }, "Failed: accounting_getCurrenciesList")
+ );
+
+ server.registerTool(
+ "accounting_getCurrentAccountingPeriod",
+ {
+ description: "get current accounting period",
+ inputSchema: {
+ date: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCurrentAccountingPeriod(
+ ctx.client,
+ ctx.companyId,
+ params.date
+ );
+ return toMcpResult(result);
+ }, "Failed: accounting_getCurrentAccountingPeriod")
+ );
+
+ server.registerTool(
+ "accounting_getDefaultAccounts",
+ {
+ description: "get default accounts",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getDefaultAccounts(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: accounting_getDefaultAccounts")
+ );
+
+ server.registerTool(
+ "accounting_getFiscalYearSettings",
+ {
+ description: "get fiscal year settings",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getFiscalYearSettings(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: accounting_getFiscalYearSettings")
+ );
+
+ server.registerTool(
+ "accounting_getInventoryPostingGroup",
+ {
+ description: "get inventory posting group",
+ inputSchema: {
+ args: z.object({
+ itemPostingGroupId: z.string().nullable(),
+ locationId: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getInventoryPostingGroup(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: accounting_getInventoryPostingGroup")
+ );
+
+ server.registerTool(
+ "accounting_getInventoryPostingGroups",
+ {
+ description: "get inventory posting groups",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0)
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getInventoryPostingGroups(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: accounting_getInventoryPostingGroups")
+ );
+
+ server.registerTool(
+ "accounting_getPaymentTerm",
+ {
+ description: "get payment term",
+ inputSchema: {
+ paymentTermId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPaymentTerm(ctx.client, params.paymentTermId);
+ return toMcpResult(result);
+ }, "Failed: accounting_getPaymentTerm")
+ );
+
+ server.registerTool(
+ "accounting_getPaymentTerms",
+ {
+ description: "get payment terms",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPaymentTerms(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: accounting_getPaymentTerms")
+ );
+
+ server.registerTool(
+ "accounting_getPaymentTermsList",
+ {
+ description: "get payment terms list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPaymentTermsList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: accounting_getPaymentTermsList")
+ );
+
+ server.registerTool(
+ "accounting_getPurchasingPostingGroup",
+ {
+ description: "get purchasing posting group",
+ inputSchema: {
+ args: z.object({
+ itemPostingGroupId: z.string().nullable(),
+ supplierTypeId: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchasingPostingGroup(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: accounting_getPurchasingPostingGroup")
+ );
+
+ server.registerTool(
+ "accounting_getPurchasingPostingGroups",
+ {
+ description: "get purchasing posting groups",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0)
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchasingPostingGroups(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: accounting_getPurchasingPostingGroups")
+ );
+
+ server.registerTool(
+ "accounting_getPurchasingSalesGroup",
+ {
+ description: "get purchasing sales group",
+ inputSchema: {
+ args: z.object({
+ itemPostingGroupId: z.string().nullable(),
+ customerTypeId: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchasingSalesGroup(ctx.client, params.args);
+ return toMcpResult(result);
+ }, "Failed: accounting_getPurchasingSalesGroup")
+ );
+
+ server.registerTool(
+ "accounting_getSalesPostingGroups",
+ {
+ description: "get sales posting groups",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0)
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesPostingGroups(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: accounting_getSalesPostingGroups")
+ );
+
+ server.registerTool(
+ "accounting_updateDefaultBalanceSheetAccounts",
+ {
+ description: "update default balance sheet accounts",
+ inputSchema: {
+ defaultAccounts: defaultBalanceSheetAccountValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateDefaultBalanceSheetAccounts(ctx.client, {
+ ...params.defaultAccounts,
+ companyId: ctx.companyId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: accounting_updateDefaultBalanceSheetAccounts")
+ );
+
+ server.registerTool(
+ "accounting_updateDefaultIncomeAccounts",
+ {
+ description: "update default income accounts",
+ inputSchema: {
+ defaultAccounts: defaultIncomeAcountValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateDefaultIncomeAccounts(ctx.client, {
+ ...params.defaultAccounts,
+ companyId: ctx.companyId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: accounting_updateDefaultIncomeAccounts")
+ );
+
+ server.registerTool(
+ "accounting_updateFiscalYearSettings",
+ {
+ description: "update fiscal year settings",
+ inputSchema: {
+ fiscalYearSettings: fiscalYearSettingsValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateFiscalYearSettings(ctx.client, {
+ ...params.fiscalYearSettings,
+ companyId: ctx.companyId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: accounting_updateFiscalYearSettings")
+ );
+
+ server.registerTool(
+ "accounting_upsertAccount",
+ {
+ description: "upsert account",
+ inputSchema: {
+ account: accountValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertAccount(ctx.client, {
+ ...params.account,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: accounting_upsertAccount")
+ );
+
+ server.registerTool(
+ "accounting_upsertAccountCategory",
+ {
+ description: "upsert account category",
+ inputSchema: {
+ accountCategory: accountCategoryValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertAccountCategory(ctx.client, {
+ ...params.accountCategory,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: accounting_upsertAccountCategory")
+ );
+
+ server.registerTool(
+ "accounting_upsertAccountSubcategory",
+ {
+ description: "upsert account subcategory",
+ inputSchema: {
+ accountSubcategory: accountSubcategoryValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertAccountSubcategory(ctx.client, {
+ ...params.accountSubcategory,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: accounting_upsertAccountSubcategory")
+ );
+
+ server.registerTool(
+ "accounting_upsertCurrency",
+ {
+ description: "upsert currency",
+ inputSchema: {
+ currency: currencyValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertCurrency(ctx.client, {
+ ...params.currency,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: accounting_upsertCurrency")
+ );
+
+ server.registerTool(
+ "accounting_upsertPaymentTerm",
+ {
+ description: "upsert payment term",
+ inputSchema: {
+ paymentTerm: paymentTermValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertPaymentTerm(ctx.client, {
+ ...params.paymentTerm,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: accounting_upsertPaymentTerm")
+ );
+};
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tools/documents.ts b/apps/erp/app/routes/api+/mcp+/lib/tools/documents.ts
new file mode 100644
index 0000000000..3599376283
--- /dev/null
+++ b/apps/erp/app/routes/api+/mcp+/lib/tools/documents.ts
@@ -0,0 +1,287 @@
+// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+import { z } from "zod";
+import {
+ documentLabelsValidator,
+ documentValidator
+} from "~/modules/documents/documents.models";
+import {
+ deleteDocument,
+ deleteDocumentFavorite,
+ deleteDocumentLabel,
+ getDocument,
+ getDocumentExtensions,
+ getDocumentLabels,
+ getDocuments,
+ insertDocumentFavorite,
+ insertDocumentLabel,
+ moveDocumentToTrash,
+ restoreDocument,
+ updateDocumentFavorite,
+ updateDocumentLabels,
+ upsertDocument
+} from "~/modules/documents/documents.service";
+import type { RegisterTools } from "../types";
+import {
+ DESTRUCTIVE_ANNOTATIONS,
+ READ_ONLY_ANNOTATIONS,
+ toMcpResult,
+ WRITE_ANNOTATIONS,
+ withErrorHandling
+} from "../types";
+
+export const registerDocumentsTools: RegisterTools = (server, ctx) => {
+ server.registerTool(
+ "documents_deleteDocument",
+ {
+ description: "delete document",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteDocument(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: documents_deleteDocument")
+ );
+
+ server.registerTool(
+ "documents_deleteDocumentFavorite",
+ {
+ description: "delete document favorite",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteDocumentFavorite(
+ ctx.client,
+ params.id,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: documents_deleteDocumentFavorite")
+ );
+
+ server.registerTool(
+ "documents_deleteDocumentLabel",
+ {
+ description: "delete document label",
+ inputSchema: {
+ id: z.string(),
+ label: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteDocumentLabel(
+ ctx.client,
+ params.id,
+ params.label
+ );
+ return toMcpResult(result);
+ }, "Failed: documents_deleteDocumentLabel")
+ );
+
+ server.registerTool(
+ "documents_getDocument",
+ {
+ description: "get document",
+ inputSchema: {
+ documentId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getDocument(ctx.client, params.documentId);
+ return toMcpResult(result);
+ }, "Failed: documents_getDocument")
+ );
+
+ server.registerTool(
+ "documents_getDocuments",
+ {
+ description: "get documents",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ favorite: z.boolean().optional(),
+ recent: z.boolean().optional(),
+ active: z.boolean()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getDocuments(ctx.client, ctx.companyId, {
+ ...params.args,
+ createdBy: ctx.userId,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: documents_getDocuments")
+ );
+
+ server.registerTool(
+ "documents_getDocumentExtensions",
+ {
+ description: "get document extensions",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getDocumentExtensions(ctx.client);
+ return toMcpResult(result);
+ }, "Failed: documents_getDocumentExtensions")
+ );
+
+ server.registerTool(
+ "documents_getDocumentLabels",
+ {
+ description: "get document labels",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getDocumentLabels(ctx.client, ctx.userId);
+ return toMcpResult(result);
+ }, "Failed: documents_getDocumentLabels")
+ );
+
+ server.registerTool(
+ "documents_insertDocumentFavorite",
+ {
+ description: "insert document favorite",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertDocumentFavorite(
+ ctx.client,
+ params.id,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: documents_insertDocumentFavorite")
+ );
+
+ server.registerTool(
+ "documents_insertDocumentLabel",
+ {
+ description: "insert document label",
+ inputSchema: {
+ id: z.string(),
+ label: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertDocumentLabel(
+ ctx.client,
+ params.id,
+ params.label,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: documents_insertDocumentLabel")
+ );
+
+ server.registerTool(
+ "documents_moveDocumentToTrash",
+ {
+ description: "move document to trash",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await moveDocumentToTrash(
+ ctx.client,
+ params.id,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: documents_moveDocumentToTrash")
+ );
+
+ server.registerTool(
+ "documents_restoreDocument",
+ {
+ description: "restore document",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await restoreDocument(ctx.client, params.id, ctx.userId);
+ return toMcpResult(result);
+ }, "Failed: documents_restoreDocument")
+ );
+
+ server.registerTool(
+ "documents_upsertDocument",
+ {
+ description: "upsert document",
+ inputSchema: {
+ document: documentValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertDocument(ctx.client, {
+ ...params.document,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: documents_upsertDocument")
+ );
+
+ server.registerTool(
+ "documents_updateDocumentFavorite",
+ {
+ description: "update document favorite",
+ inputSchema: {
+ args: z.object({
+ id: z.string(),
+ favorite: z.boolean()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateDocumentFavorite(ctx.client, {
+ ...params.args,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: documents_updateDocumentFavorite")
+ );
+
+ server.registerTool(
+ "documents_updateDocumentLabels",
+ {
+ description: "update document labels",
+ inputSchema: {
+ document: documentLabelsValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateDocumentLabels(ctx.client, {
+ ...params.document,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: documents_updateDocumentLabels")
+ );
+};
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tools/index.ts b/apps/erp/app/routes/api+/mcp+/lib/tools/index.ts
new file mode 100644
index 0000000000..7d88aae62a
--- /dev/null
+++ b/apps/erp/app/routes/api+/mcp+/lib/tools/index.ts
@@ -0,0 +1,17 @@
+// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+export { registerAccountTools } from "./account";
+export { registerAccountingTools } from "./accounting";
+export { registerDocumentsTools } from "./documents";
+export { registerInventoryTools } from "./inventory";
+export { registerInvoicingTools } from "./invoicing";
+export { registerItemsTools } from "./items";
+export { registerPeopleTools } from "./people";
+export { registerProductionTools } from "./production";
+export { registerPurchasingTools } from "./purchasing";
+export { registerQualityTools } from "./quality";
+export { registerResourcesTools } from "./resources";
+export { registerSalesTools } from "./sales";
+export { registerSettingsTools } from "./settings";
+export { registerSharedTools } from "./shared";
+export { registerUsersTools } from "./users";
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tools/inventory.ts b/apps/erp/app/routes/api+/mcp+/lib/tools/inventory.ts
new file mode 100644
index 0000000000..639a9d7830
--- /dev/null
+++ b/apps/erp/app/routes/api+/mcp+/lib/tools/inventory.ts
@@ -0,0 +1,1442 @@
+// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+import { z } from "zod";
+import {
+ batchPropertyOrderValidator,
+ batchPropertyValidator,
+ inventoryAdjustmentValidator,
+ kanbanValidator,
+ receiptValidator,
+ shelfValidator,
+ shipmentValidator,
+ shippingMethodValidator,
+ stockTransferLineValidator,
+ stockTransferValidator,
+ warehouseTransferValidator
+} from "~/modules/inventory/inventory.models";
+import {
+ deleteBatchProperty,
+ deleteKanban,
+ deleteReceipt,
+ deleteReceiptLine,
+ deleteShelf,
+ deleteShipment,
+ deleteShipmentLine,
+ deleteShippingMethod,
+ deleteStockTransfer,
+ deleteStockTransferLine,
+ deleteWarehouseTransfer,
+ deleteWarehouseTransferLine,
+ getBatchNumbersForItem,
+ getBatchProperties,
+ getDefaultShelfForJob,
+ getDefaultShelfOrShelfWithHighestQuantity,
+ getInventoryItems,
+ getInventoryItemsCount,
+ getItemLedgerPage,
+ getKanban,
+ getKanbans,
+ getReceipt,
+ getReceiptFiles,
+ getReceiptLines,
+ getReceiptLineTracking,
+ getReceipts,
+ getReceiptTracking,
+ getSerialNumbersForItem,
+ getShelf,
+ getShelves,
+ getShelvesList,
+ getShelvesListForLocation,
+ getShipment,
+ getShipmentFiles,
+ getShipmentLines,
+ getShipmentLinesWithDetails,
+ getShipmentLineTracking,
+ getShipmentRelatedItems,
+ getShipments,
+ getShipmentTracking,
+ getShippingMethod,
+ getShippingMethods,
+ getShippingMethodsList,
+ getShippingTermsList,
+ getStockTransfer,
+ getStockTransferLine,
+ getStockTransferLines,
+ getStockTransfers,
+ getStockTransferTracking,
+ getTrackedEntities,
+ getTrackedEntitiesByMakeMethodId,
+ getTrackedEntitiesByOperationId,
+ getTrackedEntity,
+ getWarehouseTransfer,
+ getWarehouseTransferLine,
+ getWarehouseTransferLines,
+ getWarehouseTransfers,
+ insertManualInventoryAdjustment,
+ updateBatchPropertyOrder,
+ updateStockTransferStatus,
+ updateWarehouseTransferStatus,
+ upsertBatchProperty,
+ upsertKanban,
+ upsertReceipt,
+ upsertShelf,
+ upsertShipment,
+ upsertShippingMethod,
+ upsertStockTransfer,
+ upsertStockTransferLine,
+ upsertStockTransferLines,
+ upsertWarehouseTransfer,
+ upsertWarehouseTransferLine
+} from "~/modules/inventory/inventory.service";
+import type { RegisterTools } from "../types";
+import {
+ DESTRUCTIVE_ANNOTATIONS,
+ READ_ONLY_ANNOTATIONS,
+ toMcpResult,
+ WRITE_ANNOTATIONS,
+ withErrorHandling
+} from "../types";
+
+export const registerInventoryTools: RegisterTools = (server, ctx) => {
+ server.registerTool(
+ "inventory_deleteBatchProperty",
+ {
+ description: "delete batch property",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteBatchProperty(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: inventory_deleteBatchProperty")
+ );
+
+ server.registerTool(
+ "inventory_deleteKanban",
+ {
+ description: "delete kanban",
+ inputSchema: {
+ kanbanId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteKanban(ctx.client, params.kanbanId);
+ return toMcpResult(result);
+ }, "Failed: inventory_deleteKanban")
+ );
+
+ server.registerTool(
+ "inventory_deleteReceipt",
+ {
+ description: "delete receipt",
+ inputSchema: {
+ receiptId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteReceipt(ctx.client, params.receiptId);
+ return toMcpResult(result);
+ }, "Failed: inventory_deleteReceipt")
+ );
+
+ server.registerTool(
+ "inventory_deleteReceiptLine",
+ {
+ description: "delete receipt line",
+ inputSchema: {
+ receiptLineId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteReceiptLine(ctx.client, params.receiptLineId);
+ return toMcpResult(result);
+ }, "Failed: inventory_deleteReceiptLine")
+ );
+
+ server.registerTool(
+ "inventory_deleteShelf",
+ {
+ description: "delete shelf",
+ inputSchema: {
+ shelfId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteShelf(ctx.client, params.shelfId);
+ return toMcpResult(result);
+ }, "Failed: inventory_deleteShelf")
+ );
+
+ server.registerTool(
+ "inventory_deleteShipment",
+ {
+ description: "delete shipment",
+ inputSchema: {
+ shipmentId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteShipment(ctx.client, params.shipmentId);
+ return toMcpResult(result);
+ }, "Failed: inventory_deleteShipment")
+ );
+
+ server.registerTool(
+ "inventory_deleteShipmentLine",
+ {
+ description: "delete shipment line",
+ inputSchema: {
+ shipmentLineId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteShipmentLine(
+ ctx.client,
+ params.shipmentLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_deleteShipmentLine")
+ );
+
+ server.registerTool(
+ "inventory_deleteShippingMethod",
+ {
+ description: "delete shipping method",
+ inputSchema: {
+ shippingMethodId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteShippingMethod(
+ ctx.client,
+ params.shippingMethodId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_deleteShippingMethod")
+ );
+
+ server.registerTool(
+ "inventory_deleteStockTransfer",
+ {
+ description: "delete stock transfer",
+ inputSchema: {
+ stockTransferId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteStockTransfer(
+ ctx.client,
+ params.stockTransferId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_deleteStockTransfer")
+ );
+
+ server.registerTool(
+ "inventory_deleteStockTransferLine",
+ {
+ description: "delete stock transfer line",
+ inputSchema: {
+ stockTransferLineId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteStockTransferLine(
+ ctx.client,
+ params.stockTransferLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_deleteStockTransferLine")
+ );
+
+ server.registerTool(
+ "inventory_deleteWarehouseTransfer",
+ {
+ description: "delete warehouse transfer",
+ inputSchema: {
+ transferId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteWarehouseTransfer(
+ ctx.client,
+ params.transferId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_deleteWarehouseTransfer")
+ );
+
+ server.registerTool(
+ "inventory_deleteWarehouseTransferLine",
+ {
+ description: "delete warehouse transfer line",
+ inputSchema: {
+ transferLineId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteWarehouseTransferLine(
+ ctx.client,
+ params.transferLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_deleteWarehouseTransferLine")
+ );
+
+ server.registerTool(
+ "inventory_getItemLedgerPage",
+ {
+ description: "get item ledger page",
+ inputSchema: {
+ itemId: z.string(),
+ locationId: z.string(),
+ sortDescending: z.boolean().optional(),
+ page: z.number().optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getItemLedgerPage(
+ ctx.client,
+ params.itemId,
+ ctx.companyId,
+ params.locationId,
+ params.sortDescending,
+ params.page
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getItemLedgerPage")
+ );
+
+ server.registerTool(
+ "inventory_getBatchProperties",
+ {
+ description: "get batch properties",
+ inputSchema: {
+ itemIds: z.array(z.string())
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getBatchProperties(
+ ctx.client,
+ params.itemIds,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getBatchProperties")
+ );
+
+ server.registerTool(
+ "inventory_getInventoryItems",
+ {
+ description: "get inventory items",
+ inputSchema: {
+ locationId: z.string(),
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getInventoryItems(
+ ctx.client,
+ params.locationId,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getInventoryItems")
+ );
+
+ server.registerTool(
+ "inventory_getInventoryItemsCount",
+ {
+ description: "get inventory items count",
+ inputSchema: {
+ locationId: z.string(),
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getInventoryItemsCount(
+ ctx.client,
+ params.locationId,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getInventoryItemsCount")
+ );
+
+ server.registerTool(
+ "inventory_getKanbans",
+ {
+ description: "get kanbans",
+ inputSchema: {
+ locationId: z.string(),
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getKanbans(
+ ctx.client,
+ params.locationId,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getKanbans")
+ );
+
+ server.registerTool(
+ "inventory_getKanban",
+ {
+ description: "get kanban",
+ inputSchema: {
+ kanbanId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getKanban(ctx.client, params.kanbanId);
+ return toMcpResult(result);
+ }, "Failed: inventory_getKanban")
+ );
+
+ server.registerTool(
+ "inventory_getStockTransfer",
+ {
+ description: "get stock transfer",
+ inputSchema: {
+ stockTransferId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getStockTransfer(ctx.client, params.stockTransferId);
+ return toMcpResult(result);
+ }, "Failed: inventory_getStockTransfer")
+ );
+
+ server.registerTool(
+ "inventory_getStockTransferLine",
+ {
+ description: "get stock transfer line",
+ inputSchema: {
+ stockTransferLineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getStockTransferLine(
+ ctx.client,
+ params.stockTransferLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getStockTransferLine")
+ );
+
+ server.registerTool(
+ "inventory_getStockTransferLines",
+ {
+ description: "get stock transfer lines",
+ inputSchema: {
+ stockTransferId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getStockTransferLines(
+ ctx.client,
+ params.stockTransferId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getStockTransferLines")
+ );
+
+ server.registerTool(
+ "inventory_getStockTransferTracking",
+ {
+ description: "get stock transfer tracking",
+ inputSchema: {
+ stockTransferId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getStockTransferTracking(
+ ctx.client,
+ params.stockTransferId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getStockTransferTracking")
+ );
+
+ server.registerTool(
+ "inventory_getStockTransfers",
+ {
+ description: "get stock transfers",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ locationId: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getStockTransfers(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getStockTransfers")
+ );
+
+ server.registerTool(
+ "inventory_getDefaultShelfOrShelfWithHighestQuantity",
+ {
+ description: "get default shelf or shelf with highest quantity",
+ inputSchema: {
+ itemId: z.string(),
+ locationId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getDefaultShelfOrShelfWithHighestQuantity(
+ ctx.client,
+ params.itemId,
+ params.locationId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getDefaultShelfOrShelfWithHighestQuantity")
+ );
+
+ server.registerTool(
+ "inventory_getReceipts",
+ {
+ description: "get receipts",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getReceipts(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: inventory_getReceipts")
+ );
+
+ server.registerTool(
+ "inventory_getReceipt",
+ {
+ description: "get receipt",
+ inputSchema: {
+ receiptId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getReceipt(ctx.client, params.receiptId);
+ return toMcpResult(result);
+ }, "Failed: inventory_getReceipt")
+ );
+
+ server.registerTool(
+ "inventory_getReceiptLines",
+ {
+ description: "get receipt lines",
+ inputSchema: {
+ receiptId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getReceiptLines(ctx.client, params.receiptId);
+ return toMcpResult(result);
+ }, "Failed: inventory_getReceiptLines")
+ );
+
+ server.registerTool(
+ "inventory_getReceiptTracking",
+ {
+ description: "get receipt tracking",
+ inputSchema: {
+ receiptId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getReceiptTracking(
+ ctx.client,
+ params.receiptId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getReceiptTracking")
+ );
+
+ server.registerTool(
+ "inventory_getReceiptLineTracking",
+ {
+ description: "get receipt line tracking",
+ inputSchema: {
+ receiptLineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getReceiptLineTracking(
+ ctx.client,
+ params.receiptLineId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getReceiptLineTracking")
+ );
+
+ server.registerTool(
+ "inventory_getReceiptFiles",
+ {
+ description: "get receipt files",
+ inputSchema: {
+ lineIds: z.array(z.string())
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getReceiptFiles(
+ ctx.client,
+ ctx.companyId,
+ params.lineIds
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getReceiptFiles")
+ );
+
+ server.registerTool(
+ "inventory_getSerialNumbersForItem",
+ {
+ description: "get serial numbers for item",
+ inputSchema: {
+ args: z.object({
+ itemId: z.string()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSerialNumbersForItem(ctx.client, {
+ ...params.args,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: inventory_getSerialNumbersForItem")
+ );
+
+ server.registerTool(
+ "inventory_getBatchNumbersForItem",
+ {
+ description: "get batch numbers for item",
+ inputSchema: {
+ args: z.object({
+ itemId: z.string(),
+ isReadOnly: z.boolean().optional()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getBatchNumbersForItem(ctx.client, {
+ ...params.args,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: inventory_getBatchNumbersForItem")
+ );
+
+ server.registerTool(
+ "inventory_getShelvesList",
+ {
+ description: "get shelves list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getShelvesList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: inventory_getShelvesList")
+ );
+
+ server.registerTool(
+ "inventory_getShelvesListForLocation",
+ {
+ description: "get shelves list for location",
+ inputSchema: {
+ locationId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getShelvesListForLocation(
+ ctx.client,
+ ctx.companyId,
+ params.locationId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getShelvesListForLocation")
+ );
+
+ server.registerTool(
+ "inventory_getShelves",
+ {
+ description: "get shelves",
+ inputSchema: {
+ locationId: z.string(),
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getShelves(
+ ctx.client,
+ params.locationId,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getShelves")
+ );
+
+ server.registerTool(
+ "inventory_getShelf",
+ {
+ description: "get shelf",
+ inputSchema: {
+ shelfId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getShelf(ctx.client, params.shelfId);
+ return toMcpResult(result);
+ }, "Failed: inventory_getShelf")
+ );
+
+ server.registerTool(
+ "inventory_getShipments",
+ {
+ description: "get shipments",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getShipments(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: inventory_getShipments")
+ );
+
+ server.registerTool(
+ "inventory_getShipment",
+ {
+ description: "get shipment",
+ inputSchema: {
+ shipmentId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getShipment(ctx.client, params.shipmentId);
+ return toMcpResult(result);
+ }, "Failed: inventory_getShipment")
+ );
+
+ server.registerTool(
+ "inventory_getShipmentLines",
+ {
+ description: "get shipment lines",
+ inputSchema: {
+ shipmentId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getShipmentLines(ctx.client, params.shipmentId);
+ return toMcpResult(result);
+ }, "Failed: inventory_getShipmentLines")
+ );
+
+ server.registerTool(
+ "inventory_getShipmentLinesWithDetails",
+ {
+ description: "get shipment lines with details",
+ inputSchema: {
+ shipmentId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getShipmentLinesWithDetails(
+ ctx.client,
+ params.shipmentId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getShipmentLinesWithDetails")
+ );
+
+ server.registerTool(
+ "inventory_getShipmentFiles",
+ {
+ description: "get shipment files",
+ inputSchema: {
+ lineIds: z.array(z.string())
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getShipmentFiles(
+ ctx.client,
+ ctx.companyId,
+ params.lineIds
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getShipmentFiles")
+ );
+
+ server.registerTool(
+ "inventory_getShipmentRelatedItems",
+ {
+ description: "get shipment related items",
+ inputSchema: {
+ shipmentId: z.string(),
+ sourceDocumentId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getShipmentRelatedItems(
+ ctx.client,
+ params.shipmentId,
+ params.sourceDocumentId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getShipmentRelatedItems")
+ );
+
+ server.registerTool(
+ "inventory_getShipmentTracking",
+ {
+ description: "get shipment tracking",
+ inputSchema: {
+ shipmentId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getShipmentTracking(
+ ctx.client,
+ params.shipmentId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getShipmentTracking")
+ );
+
+ server.registerTool(
+ "inventory_getShipmentLineTracking",
+ {
+ description: "get shipment line tracking",
+ inputSchema: {
+ shipmentLineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getShipmentLineTracking(
+ ctx.client,
+ params.shipmentLineId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getShipmentLineTracking")
+ );
+
+ server.registerTool(
+ "inventory_getShippingMethod",
+ {
+ description: "get shipping method",
+ inputSchema: {
+ shippingMethodId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getShippingMethod(
+ ctx.client,
+ params.shippingMethodId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getShippingMethod")
+ );
+
+ server.registerTool(
+ "inventory_getShippingMethods",
+ {
+ description: "get shipping methods",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getShippingMethods(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getShippingMethods")
+ );
+
+ server.registerTool(
+ "inventory_getShippingMethodsList",
+ {
+ description: "get shipping methods list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getShippingMethodsList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: inventory_getShippingMethodsList")
+ );
+
+ server.registerTool(
+ "inventory_getShippingTermsList",
+ {
+ description: "get shipping terms list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getShippingTermsList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: inventory_getShippingTermsList")
+ );
+
+ server.registerTool(
+ "inventory_getTrackedEntities",
+ {
+ description: "get tracked entities",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTrackedEntities(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getTrackedEntities")
+ );
+
+ server.registerTool(
+ "inventory_getTrackedEntitiesByMakeMethodId",
+ {
+ description: "get tracked entities by make method id",
+ inputSchema: {
+ jobMakeMethodId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTrackedEntitiesByMakeMethodId(
+ ctx.client,
+ params.jobMakeMethodId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getTrackedEntitiesByMakeMethodId")
+ );
+
+ server.registerTool(
+ "inventory_getTrackedEntity",
+ {
+ description: "get tracked entity",
+ inputSchema: {
+ trackedEntityId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTrackedEntity(ctx.client, params.trackedEntityId);
+ return toMcpResult(result);
+ }, "Failed: inventory_getTrackedEntity")
+ );
+
+ server.registerTool(
+ "inventory_getTrackedEntitiesByOperationId",
+ {
+ description: "get tracked entities by operation id",
+ inputSchema: {
+ operationId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTrackedEntitiesByOperationId(
+ ctx.client,
+ params.operationId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getTrackedEntitiesByOperationId")
+ );
+
+ server.registerTool(
+ "inventory_getWarehouseTransfers",
+ {
+ description: "get warehouse transfers",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getWarehouseTransfers(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getWarehouseTransfers")
+ );
+
+ server.registerTool(
+ "inventory_getWarehouseTransfer",
+ {
+ description: "get warehouse transfer",
+ inputSchema: {
+ transferId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getWarehouseTransfer(ctx.client, params.transferId);
+ return toMcpResult(result);
+ }, "Failed: inventory_getWarehouseTransfer")
+ );
+
+ server.registerTool(
+ "inventory_getWarehouseTransferLine",
+ {
+ description: "get warehouse transfer line",
+ inputSchema: {
+ transferId: z.string(),
+ lineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getWarehouseTransferLine(
+ ctx.client,
+ params.transferId,
+ params.lineId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getWarehouseTransferLine")
+ );
+
+ server.registerTool(
+ "inventory_getWarehouseTransferLines",
+ {
+ description: "get warehouse transfer lines",
+ inputSchema: {
+ transferId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getWarehouseTransferLines(
+ ctx.client,
+ params.transferId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getWarehouseTransferLines")
+ );
+
+ server.registerTool(
+ "inventory_insertManualInventoryAdjustment",
+ {
+ description: "insert manual inventory adjustment",
+ inputSchema: {
+ inventoryAdjustment: inventoryAdjustmentValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertManualInventoryAdjustment(ctx.client, {
+ ...params.inventoryAdjustment,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: inventory_insertManualInventoryAdjustment")
+ );
+
+ server.registerTool(
+ "inventory_updateBatchPropertyOrder",
+ {
+ description: "update batch property order",
+ inputSchema: {
+ data: batchPropertyOrderValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateBatchPropertyOrder(ctx.client, {
+ ...params.data,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: inventory_updateBatchPropertyOrder")
+ );
+
+ server.registerTool(
+ "inventory_updateStockTransferStatus",
+ {
+ description: "update stock transfer status",
+ inputSchema: {
+ args: z.object({
+ id: z.string(),
+ status: z.any(),
+ assignee: z.string().nullable().optional(),
+ completedAt: z.string().nullable()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateStockTransferStatus(ctx.client, {
+ ...params.args,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: inventory_updateStockTransferStatus")
+ );
+
+ server.registerTool(
+ "inventory_upsertBatchProperty",
+ {
+ description: "upsert batch property",
+ inputSchema: {
+ batchProperty: batchPropertyValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertBatchProperty(ctx.client, {
+ ...params.batchProperty,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: inventory_upsertBatchProperty")
+ );
+
+ server.registerTool(
+ "inventory_upsertKanban",
+ {
+ description: "upsert kanban",
+ inputSchema: {
+ kanban: kanbanValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertKanban(ctx.client, {
+ ...params.kanban,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: inventory_upsertKanban")
+ );
+
+ server.registerTool(
+ "inventory_upsertReceipt",
+ {
+ description: "upsert receipt",
+ inputSchema: {
+ receipt: receiptValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertReceipt(ctx.client, {
+ ...params.receipt,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: inventory_upsertReceipt")
+ );
+
+ server.registerTool(
+ "inventory_upsertShelf",
+ {
+ description: "upsert shelf",
+ inputSchema: {
+ shelf: shelfValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertShelf(ctx.client, {
+ ...params.shelf,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: inventory_upsertShelf")
+ );
+
+ server.registerTool(
+ "inventory_upsertShippingMethod",
+ {
+ description: "upsert shipping method",
+ inputSchema: {
+ shippingMethod: shippingMethodValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertShippingMethod(ctx.client, {
+ ...params.shippingMethod,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: inventory_upsertShippingMethod")
+ );
+
+ server.registerTool(
+ "inventory_upsertShipment",
+ {
+ description: "upsert shipment",
+ inputSchema: {
+ shipment: shipmentValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertShipment(ctx.client, {
+ ...params.shipment,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: inventory_upsertShipment")
+ );
+
+ server.registerTool(
+ "inventory_upsertStockTransfer",
+ {
+ description: "upsert stock transfer",
+ inputSchema: {
+ stockTransfer: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertStockTransfer(ctx.client, {
+ ...params.stockTransfer,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: inventory_upsertStockTransfer")
+ );
+
+ server.registerTool(
+ "inventory_upsertStockTransferLine",
+ {
+ description: "upsert stock transfer line",
+ inputSchema: {
+ stockTransferLine: stockTransferLineValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertStockTransferLine(ctx.client, {
+ ...params.stockTransferLine,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: inventory_upsertStockTransferLine")
+ );
+
+ server.registerTool(
+ "inventory_upsertStockTransferLines",
+ {
+ description: "upsert stock transfer lines",
+ inputSchema: {
+ args: stockTransferValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertStockTransferLines(ctx.client, {
+ ...params.args,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: inventory_upsertStockTransferLines")
+ );
+
+ server.registerTool(
+ "inventory_upsertWarehouseTransfer",
+ {
+ description: "upsert warehouse transfer",
+ inputSchema: {
+ transfer: warehouseTransferValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertWarehouseTransfer(ctx.client, {
+ ...params.transfer,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: inventory_upsertWarehouseTransfer")
+ );
+
+ server.registerTool(
+ "inventory_updateWarehouseTransferStatus",
+ {
+ description: "update warehouse transfer status",
+ inputSchema: {
+ transferId: z.string(),
+ status: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateWarehouseTransferStatus(
+ ctx.client,
+ params.transferId,
+ params.status,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_updateWarehouseTransferStatus")
+ );
+
+ server.registerTool(
+ "inventory_upsertWarehouseTransferLine",
+ {
+ description: "upsert warehouse transfer line",
+ inputSchema: {
+ line: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertWarehouseTransferLine(ctx.client, params.line);
+ return toMcpResult(result);
+ }, "Failed: inventory_upsertWarehouseTransferLine")
+ );
+
+ server.registerTool(
+ "inventory_getDefaultShelfForJob",
+ {
+ description: "get default shelf for job",
+ inputSchema: {
+ itemId: z.string(),
+ locationId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getDefaultShelfForJob(
+ ctx.client,
+ params.itemId,
+ params.locationId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: inventory_getDefaultShelfForJob")
+ );
+};
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tools/invoicing.ts b/apps/erp/app/routes/api+/mcp+/lib/tools/invoicing.ts
new file mode 100644
index 0000000000..695d2fd43f
--- /dev/null
+++ b/apps/erp/app/routes/api+/mcp+/lib/tools/invoicing.ts
@@ -0,0 +1,596 @@
+// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+import { z } from "zod";
+import {
+ purchaseInvoiceDeliveryValidator,
+ purchaseInvoiceLineValidator,
+ purchaseInvoiceValidator,
+ salesInvoiceLineValidator,
+ salesInvoiceShipmentValidator,
+ salesInvoiceValidator
+} from "~/modules/invoicing/invoicing.models";
+import {
+ createPurchaseInvoiceFromPurchaseOrder,
+ createSalesInvoiceFromSalesOrder,
+ createSalesInvoiceFromShipment,
+ deletePurchaseInvoice,
+ deletePurchaseInvoiceLine,
+ deleteSalesInvoice,
+ deleteSalesInvoiceLine,
+ getPurchaseInvoice,
+ getPurchaseInvoiceDelivery,
+ getPurchaseInvoiceLine,
+ getPurchaseInvoiceLines,
+ getPurchaseInvoices,
+ getSalesInvoice,
+ getSalesInvoiceCustomerDetails,
+ getSalesInvoiceLine,
+ getSalesInvoiceLines,
+ getSalesInvoiceShipment,
+ getSalesInvoices,
+ updatePurchaseInvoiceExchangeRate,
+ updatePurchaseInvoiceStatus,
+ updateSalesInvoiceExchangeRate,
+ updateSalesInvoiceStatus,
+ upsertPurchaseInvoice,
+ upsertPurchaseInvoiceDelivery,
+ upsertPurchaseInvoiceLine,
+ upsertSalesInvoice,
+ upsertSalesInvoiceLine,
+ upsertSalesInvoiceShipment
+} from "~/modules/invoicing/invoicing.service";
+import type { RegisterTools } from "../types";
+import {
+ DESTRUCTIVE_ANNOTATIONS,
+ READ_ONLY_ANNOTATIONS,
+ toMcpResult,
+ WRITE_ANNOTATIONS,
+ withErrorHandling
+} from "../types";
+
+export const registerInvoicingTools: RegisterTools = (server, ctx) => {
+ server.registerTool(
+ "invoicing_createPurchaseInvoiceFromPurchaseOrder",
+ {
+ description: "create purchase invoice from purchase order",
+ inputSchema: {
+ purchaseOrderId: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await createPurchaseInvoiceFromPurchaseOrder(
+ ctx.client,
+ params.purchaseOrderId,
+ ctx.companyId,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: invoicing_createPurchaseInvoiceFromPurchaseOrder")
+ );
+
+ server.registerTool(
+ "invoicing_createSalesInvoiceFromSalesOrder",
+ {
+ description: "create sales invoice from sales order",
+ inputSchema: {
+ salesOrderId: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await createSalesInvoiceFromSalesOrder(
+ ctx.client,
+ params.salesOrderId,
+ ctx.companyId,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: invoicing_createSalesInvoiceFromSalesOrder")
+ );
+
+ server.registerTool(
+ "invoicing_createSalesInvoiceFromShipment",
+ {
+ description: "create sales invoice from shipment",
+ inputSchema: {
+ shipmentId: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await createSalesInvoiceFromShipment(
+ ctx.client,
+ params.shipmentId,
+ ctx.companyId,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: invoicing_createSalesInvoiceFromShipment")
+ );
+
+ server.registerTool(
+ "invoicing_deletePurchaseInvoice",
+ {
+ description: "delete purchase invoice",
+ inputSchema: {
+ purchaseInvoiceId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deletePurchaseInvoice(
+ ctx.client,
+ params.purchaseInvoiceId
+ );
+ return toMcpResult(result);
+ }, "Failed: invoicing_deletePurchaseInvoice")
+ );
+
+ server.registerTool(
+ "invoicing_deletePurchaseInvoiceLine",
+ {
+ description: "delete purchase invoice line",
+ inputSchema: {
+ purchaseInvoiceLineId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deletePurchaseInvoiceLine(
+ ctx.client,
+ params.purchaseInvoiceLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: invoicing_deletePurchaseInvoiceLine")
+ );
+
+ server.registerTool(
+ "invoicing_deleteSalesInvoice",
+ {
+ description: "delete sales invoice",
+ inputSchema: {
+ salesInvoiceId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteSalesInvoice(
+ ctx.client,
+ params.salesInvoiceId
+ );
+ return toMcpResult(result);
+ }, "Failed: invoicing_deleteSalesInvoice")
+ );
+
+ server.registerTool(
+ "invoicing_deleteSalesInvoiceLine",
+ {
+ description: "delete sales invoice line",
+ inputSchema: {
+ salesInvoiceLineId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteSalesInvoiceLine(
+ ctx.client,
+ params.salesInvoiceLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: invoicing_deleteSalesInvoiceLine")
+ );
+
+ server.registerTool(
+ "invoicing_getPurchaseInvoice",
+ {
+ description: "get purchase invoice",
+ inputSchema: {
+ purchaseInvoiceId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchaseInvoice(
+ ctx.client,
+ params.purchaseInvoiceId
+ );
+ return toMcpResult(result);
+ }, "Failed: invoicing_getPurchaseInvoice")
+ );
+
+ server.registerTool(
+ "invoicing_getPurchaseInvoices",
+ {
+ description: "get purchase invoices",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ supplierId: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchaseInvoices(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: invoicing_getPurchaseInvoices")
+ );
+
+ server.registerTool(
+ "invoicing_getPurchaseInvoiceDelivery",
+ {
+ description: "get purchase invoice delivery",
+ inputSchema: {
+ purchaseInvoiceId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchaseInvoiceDelivery(
+ ctx.client,
+ params.purchaseInvoiceId
+ );
+ return toMcpResult(result);
+ }, "Failed: invoicing_getPurchaseInvoiceDelivery")
+ );
+
+ server.registerTool(
+ "invoicing_getPurchaseInvoiceLines",
+ {
+ description: "get purchase invoice lines",
+ inputSchema: {
+ purchaseInvoiceId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchaseInvoiceLines(
+ ctx.client,
+ params.purchaseInvoiceId
+ );
+ return toMcpResult(result);
+ }, "Failed: invoicing_getPurchaseInvoiceLines")
+ );
+
+ server.registerTool(
+ "invoicing_getPurchaseInvoiceLine",
+ {
+ description: "get purchase invoice line",
+ inputSchema: {
+ purchaseInvoiceLineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchaseInvoiceLine(
+ ctx.client,
+ params.purchaseInvoiceLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: invoicing_getPurchaseInvoiceLine")
+ );
+
+ server.registerTool(
+ "invoicing_getSalesInvoice",
+ {
+ description: "get sales invoice",
+ inputSchema: {
+ salesInvoiceId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesInvoice(ctx.client, params.salesInvoiceId);
+ return toMcpResult(result);
+ }, "Failed: invoicing_getSalesInvoice")
+ );
+
+ server.registerTool(
+ "invoicing_getSalesInvoiceCustomerDetails",
+ {
+ description: "get sales invoice customer details",
+ inputSchema: {
+ salesInvoiceId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesInvoiceCustomerDetails(
+ ctx.client,
+ params.salesInvoiceId
+ );
+ return toMcpResult(result);
+ }, "Failed: invoicing_getSalesInvoiceCustomerDetails")
+ );
+
+ server.registerTool(
+ "invoicing_getSalesInvoices",
+ {
+ description: "get sales invoices",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ customerId: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesInvoices(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: invoicing_getSalesInvoices")
+ );
+
+ server.registerTool(
+ "invoicing_getSalesInvoiceShipment",
+ {
+ description: "get sales invoice shipment",
+ inputSchema: {
+ salesInvoiceId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesInvoiceShipment(
+ ctx.client,
+ params.salesInvoiceId
+ );
+ return toMcpResult(result);
+ }, "Failed: invoicing_getSalesInvoiceShipment")
+ );
+
+ server.registerTool(
+ "invoicing_getSalesInvoiceLines",
+ {
+ description: "get sales invoice lines",
+ inputSchema: {
+ salesInvoiceId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesInvoiceLines(
+ ctx.client,
+ params.salesInvoiceId
+ );
+ return toMcpResult(result);
+ }, "Failed: invoicing_getSalesInvoiceLines")
+ );
+
+ server.registerTool(
+ "invoicing_getSalesInvoiceLine",
+ {
+ description: "get sales invoice line",
+ inputSchema: {
+ salesInvoiceLineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesInvoiceLine(
+ ctx.client,
+ params.salesInvoiceLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: invoicing_getSalesInvoiceLine")
+ );
+
+ server.registerTool(
+ "invoicing_updatePurchaseInvoiceExchangeRate",
+ {
+ description: "update purchase invoice exchange rate",
+ inputSchema: {
+ data: z.object({
+ id: z.string(),
+ exchangeRate: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updatePurchaseInvoiceExchangeRate(
+ ctx.client,
+ params.data
+ );
+ return toMcpResult(result);
+ }, "Failed: invoicing_updatePurchaseInvoiceExchangeRate")
+ );
+
+ server.registerTool(
+ "invoicing_updatePurchaseInvoiceStatus",
+ {
+ description: "update purchase invoice status",
+ inputSchema: {
+ update: z.object({
+ id: z.string(),
+ status: z.any(),
+ assignee: z.any()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updatePurchaseInvoiceStatus(ctx.client, {
+ ...params.update,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: invoicing_updatePurchaseInvoiceStatus")
+ );
+
+ server.registerTool(
+ "invoicing_updateSalesInvoiceExchangeRate",
+ {
+ description: "update sales invoice exchange rate",
+ inputSchema: {
+ data: z.object({
+ id: z.string(),
+ exchangeRate: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSalesInvoiceExchangeRate(
+ ctx.client,
+ params.data
+ );
+ return toMcpResult(result);
+ }, "Failed: invoicing_updateSalesInvoiceExchangeRate")
+ );
+
+ server.registerTool(
+ "invoicing_updateSalesInvoiceStatus",
+ {
+ description: "update sales invoice status",
+ inputSchema: {
+ update: z.object({
+ id: z.string(),
+ status: z.any(),
+ assignee: z.any()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSalesInvoiceStatus(ctx.client, {
+ ...params.update,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: invoicing_updateSalesInvoiceStatus")
+ );
+
+ server.registerTool(
+ "invoicing_upsertPurchaseInvoice",
+ {
+ description: "upsert purchase invoice",
+ inputSchema: {
+ purchaseInvoice: purchaseInvoiceValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertPurchaseInvoice(ctx.client, {
+ ...params.purchaseInvoice,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: invoicing_upsertPurchaseInvoice")
+ );
+
+ server.registerTool(
+ "invoicing_upsertPurchaseInvoiceDelivery",
+ {
+ description: "upsert purchase invoice delivery",
+ inputSchema: {
+ purchaseInvoiceDelivery: purchaseInvoiceDeliveryValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertPurchaseInvoiceDelivery(ctx.client, {
+ ...params.purchaseInvoiceDelivery,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: invoicing_upsertPurchaseInvoiceDelivery")
+ );
+
+ server.registerTool(
+ "invoicing_upsertPurchaseInvoiceLine",
+ {
+ description: "upsert purchase invoice line",
+ inputSchema: {
+ purchaseInvoiceLine: purchaseInvoiceLineValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertPurchaseInvoiceLine(ctx.client, {
+ ...params.purchaseInvoiceLine,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: invoicing_upsertPurchaseInvoiceLine")
+ );
+
+ server.registerTool(
+ "invoicing_upsertSalesInvoice",
+ {
+ description: "upsert sales invoice",
+ inputSchema: {
+ salesInvoice: salesInvoiceValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertSalesInvoice(ctx.client, {
+ ...params.salesInvoice,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: invoicing_upsertSalesInvoice")
+ );
+
+ server.registerTool(
+ "invoicing_upsertSalesInvoiceShipment",
+ {
+ description: "upsert sales invoice shipment",
+ inputSchema: {
+ salesInvoiceShipment: salesInvoiceShipmentValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertSalesInvoiceShipment(ctx.client, {
+ ...params.salesInvoiceShipment,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: invoicing_upsertSalesInvoiceShipment")
+ );
+
+ server.registerTool(
+ "invoicing_upsertSalesInvoiceLine",
+ {
+ description: "upsert sales invoice line",
+ inputSchema: {
+ salesInvoiceLine: salesInvoiceLineValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertSalesInvoiceLine(ctx.client, {
+ ...params.salesInvoiceLine,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: invoicing_upsertSalesInvoiceLine")
+ );
+};
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tools/items.ts b/apps/erp/app/routes/api+/mcp+/lib/tools/items.ts
new file mode 100644
index 0000000000..d9eb2b2882
--- /dev/null
+++ b/apps/erp/app/routes/api+/mcp+/lib/tools/items.ts
@@ -0,0 +1,2720 @@
+// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+import { z } from "zod";
+import {
+ configurationParameterGroupOrderValidator,
+ configurationParameterOrderValidator,
+ configurationParameterValidator,
+ configurationRuleValidator,
+ consumableValidator,
+ customerPartValidator,
+ getMethodValidator,
+ itemCostValidator,
+ itemManufacturingValidator,
+ itemPlanningValidator,
+ itemPostingGroupValidator,
+ itemPurchasingValidator,
+ itemUnitSalePriceValidator,
+ itemValidator,
+ makeMethodVersionValidator,
+ materialDimensionValidator,
+ materialFinishValidator,
+ materialFormValidator,
+ materialGradeValidator,
+ materialSubstanceValidator,
+ materialTypeValidator,
+ materialValidator,
+ methodMaterialValidator,
+ methodOperationValidator,
+ partValidator,
+ pickMethodValidator,
+ serviceValidator,
+ supplierPartValidator,
+ toolValidator,
+ unitOfMeasureValidator
+} from "~/modules/items/items.models";
+import {
+ activateMethodVersion,
+ assertMethodOperationIsDraft,
+ copyItem,
+ copyMakeMethod,
+ createRevision,
+ deleteConfigurationParameter,
+ deleteConfigurationParameterGroup,
+ deleteConfigurationRule,
+ deleteItem,
+ deleteItemCustomerPart,
+ deleteItemPostingGroup,
+ deleteMaterialDimension,
+ deleteMaterialFinish,
+ deleteMaterialForm,
+ deleteMaterialGrade,
+ deleteMaterialSubstance,
+ deleteMaterialType,
+ deleteMethodMaterial,
+ deleteMethodOperationParameter,
+ deleteMethodOperationStep,
+ deleteMethodOperationTool,
+ deleteUnitOfMeasure,
+ getConfigurationParameters,
+ getConfigurationRules,
+ getConsumable,
+ getConsumables,
+ getConsumablesList,
+ getItem,
+ getItemCost,
+ getItemCostHistory,
+ getItemCustomerPart,
+ getItemCustomerParts,
+ getItemDemand,
+ getItemFiles,
+ getItemManufacturing,
+ getItemPlanning,
+ getItemPostingGroup,
+ getItemPostingGroups,
+ getItemPostingGroupsList,
+ getItemQuantities,
+ getItemReplenishment,
+ getItemShelfQuantities,
+ getItemSupply,
+ getItemUnitSalePrice,
+ getMakeMethodById,
+ getMakeMethods,
+ getMaterial,
+ getMaterialDimension,
+ getMaterialDimensionList,
+ getMaterialDimensions,
+ getMaterialFinish,
+ getMaterialFinishes,
+ getMaterialFinishList,
+ getMaterialForm,
+ getMaterialForms,
+ getMaterialFormsList,
+ getMaterialGrade,
+ getMaterialGradeList,
+ getMaterialGrades,
+ getMaterialSubstance,
+ getMaterialSubstances,
+ getMaterialSubstancesList,
+ getMaterials,
+ getMaterialsList,
+ getMaterialType,
+ getMaterialTypeList,
+ getMaterialTypes,
+ getMaterialUsedIn,
+ getMethodMaterial,
+ getMethodMaterials,
+ getMethodMaterialsByMakeMethod,
+ getMethodOperations,
+ getMethodOperationsByMakeMethodId,
+ getMethodTree,
+ getMethodTreeArray,
+ getOpenJobMaterials,
+ getOpenProductionOrders,
+ getOpenPurchaseOrderLines,
+ getOpenSalesOrderLines,
+ getPart,
+ getParts,
+ getPartsList,
+ getPartUsedIn,
+ getPickMethod,
+ getPickMethods,
+ getService,
+ getServices,
+ getServicesList,
+ getSupplierPartPriceBreaks,
+ getSupplierParts,
+ getSupplierPriceBreaksForItems,
+ getTool,
+ getTools,
+ getToolsList,
+ getUnitOfMeasure,
+ getUnitOfMeasures,
+ getUnitOfMeasuresList,
+ lookupBuyPrice,
+ updateConfigurationParameterGroupOrder,
+ updateConfigurationParameterOrder,
+ updateDefaultRevision,
+ updateItem,
+ updateItemCost,
+ updateMaterialOrder,
+ updateOperationOrder,
+ updateRevision,
+ upsertConfigurationParameter,
+ upsertConfigurationParameterGroup,
+ upsertConfigurationRule,
+ upsertConsumable,
+ upsertItemCost,
+ upsertItemCustomerPart,
+ upsertItemManufacturing,
+ upsertItemPlanning,
+ upsertItemPostingGroup,
+ upsertItemPurchasing,
+ upsertItemUnitSalePrice,
+ upsertMakeMethodVersion,
+ upsertMaterial,
+ upsertMaterialDimension,
+ upsertMaterialFinish,
+ upsertMaterialForm,
+ upsertMaterialGrade,
+ upsertMaterialSubstance,
+ upsertMaterialType,
+ upsertMethodMaterial,
+ upsertMethodOperation,
+ upsertMethodOperationParameter,
+ upsertMethodOperationStep,
+ upsertMethodOperationTool,
+ upsertPart,
+ upsertPickMethod,
+ upsertService,
+ upsertSupplierPart,
+ upsertTool,
+ upsertUnitOfMeasure
+} from "~/modules/items/items.service";
+import {
+ operationParameterValidator,
+ operationStepValidator,
+ operationToolValidator
+} from "~/modules/shared";
+import type { RegisterTools } from "../types";
+import {
+ DESTRUCTIVE_ANNOTATIONS,
+ READ_ONLY_ANNOTATIONS,
+ toMcpResult,
+ WRITE_ANNOTATIONS,
+ withErrorHandling
+} from "../types";
+
+export const registerItemsTools: RegisterTools = (server, ctx) => {
+ server.registerTool(
+ "items_activateMethodVersion",
+ {
+ description: "activate method version",
+ inputSchema: {
+ payload: z.object({
+ id: z.string()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await activateMethodVersion(ctx.client, {
+ ...params.payload,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_activateMethodVersion")
+ );
+
+ server.registerTool(
+ "items_copyItem",
+ {
+ description: "copy item",
+ inputSchema: {
+ args: getMethodValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await copyItem(ctx.client, {
+ ...params.args,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_copyItem")
+ );
+
+ server.registerTool(
+ "items_copyMakeMethod",
+ {
+ description: "copy make method",
+ inputSchema: {
+ args: getMethodValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await copyMakeMethod(ctx.client, {
+ ...params.args,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_copyMakeMethod")
+ );
+
+ server.registerTool(
+ "items_createRevision",
+ {
+ description: "create revision",
+ inputSchema: {
+ args: z.object({
+ item: z.any(),
+ revision: z.string()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await createRevision(ctx.client, {
+ ...params.args,
+ createdBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_createRevision")
+ );
+
+ server.registerTool(
+ "items_deleteConfigurationParameter",
+ {
+ description: "delete configuration parameter",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteConfigurationParameter(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_deleteConfigurationParameter")
+ );
+
+ server.registerTool(
+ "items_deleteConfigurationRule",
+ {
+ description: "delete configuration rule",
+ inputSchema: {
+ field: z.string(),
+ itemId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteConfigurationRule(
+ ctx.client,
+ params.field,
+ params.itemId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_deleteConfigurationRule")
+ );
+
+ server.registerTool(
+ "items_deleteItemCustomerPart",
+ {
+ description: "delete item customer part",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteItemCustomerPart(
+ ctx.client,
+ params.id,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_deleteItemCustomerPart")
+ );
+
+ server.registerTool(
+ "items_deleteConfigurationParameterGroup",
+ {
+ description: "delete configuration parameter group",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteConfigurationParameterGroup(
+ ctx.client,
+ params.id
+ );
+ return toMcpResult(result);
+ }, "Failed: items_deleteConfigurationParameterGroup")
+ );
+
+ server.registerTool(
+ "items_deleteItem",
+ {
+ description: "delete item",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteItem(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_deleteItem")
+ );
+
+ server.registerTool(
+ "items_deleteItemPostingGroup",
+ {
+ description: "delete item posting group",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteItemPostingGroup(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_deleteItemPostingGroup")
+ );
+
+ server.registerTool(
+ "items_deleteMaterialDimension",
+ {
+ description: "delete material dimension",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaterialDimension(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_deleteMaterialDimension")
+ );
+
+ server.registerTool(
+ "items_deleteMaterialFinish",
+ {
+ description: "delete material finish",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaterialFinish(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_deleteMaterialFinish")
+ );
+
+ server.registerTool(
+ "items_deleteMaterialForm",
+ {
+ description: "delete material form",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaterialForm(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_deleteMaterialForm")
+ );
+
+ server.registerTool(
+ "items_deleteMaterialGrade",
+ {
+ description: "delete material grade",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaterialGrade(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_deleteMaterialGrade")
+ );
+
+ server.registerTool(
+ "items_deleteMaterialSubstance",
+ {
+ description: "delete material substance",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaterialSubstance(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_deleteMaterialSubstance")
+ );
+
+ server.registerTool(
+ "items_deleteMethodMaterial",
+ {
+ description: "delete method material",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMethodMaterial(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_deleteMethodMaterial")
+ );
+
+ server.registerTool(
+ "items_assertMethodOperationIsDraft",
+ {
+ description: "assert method operation is draft",
+ inputSchema: {
+ operationId: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await assertMethodOperationIsDraft(
+ ctx.client,
+ params.operationId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_assertMethodOperationIsDraft")
+ );
+
+ server.registerTool(
+ "items_deleteMethodOperationStep",
+ {
+ description: "delete method operation step",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMethodOperationStep(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_deleteMethodOperationStep")
+ );
+
+ server.registerTool(
+ "items_deleteMethodOperationParameter",
+ {
+ description: "delete method operation parameter",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMethodOperationParameter(
+ ctx.client,
+ params.id
+ );
+ return toMcpResult(result);
+ }, "Failed: items_deleteMethodOperationParameter")
+ );
+
+ server.registerTool(
+ "items_deleteMethodOperationTool",
+ {
+ description: "delete method operation tool",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMethodOperationTool(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_deleteMethodOperationTool")
+ );
+
+ server.registerTool(
+ "items_deleteUnitOfMeasure",
+ {
+ description: "delete unit of measure",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteUnitOfMeasure(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_deleteUnitOfMeasure")
+ );
+
+ server.registerTool(
+ "items_getConfigurationParameters",
+ {
+ description: "get configuration parameters",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getConfigurationParameters(
+ ctx.client,
+ params.itemId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getConfigurationParameters")
+ );
+
+ server.registerTool(
+ "items_getConfigurationRules",
+ {
+ description: "get configuration rules",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getConfigurationRules(
+ ctx.client,
+ params.itemId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getConfigurationRules")
+ );
+
+ server.registerTool(
+ "items_getConsumable",
+ {
+ description: "get consumable",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getConsumable(
+ ctx.client,
+ params.itemId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getConsumable")
+ );
+
+ server.registerTool(
+ "items_getConsumables",
+ {
+ description: "get consumables",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ supplierId: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getConsumables(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getConsumables")
+ );
+
+ server.registerTool(
+ "items_getConsumablesList",
+ {
+ description: "get consumables list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getConsumablesList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: items_getConsumablesList")
+ );
+
+ server.registerTool(
+ "items_getItem",
+ {
+ description: "get item",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getItem(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_getItem")
+ );
+
+ server.registerTool(
+ "items_getItemCost",
+ {
+ description: "get item cost",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getItemCost(
+ ctx.client,
+ params.itemId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getItemCost")
+ );
+
+ server.registerTool(
+ "items_getItemCostHistory",
+ {
+ description: "get item cost history",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getItemCostHistory(
+ ctx.client,
+ params.itemId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getItemCostHistory")
+ );
+
+ server.registerTool(
+ "items_getItemCustomerPart",
+ {
+ description: "get item customer part",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getItemCustomerPart(
+ ctx.client,
+ params.id,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getItemCustomerPart")
+ );
+
+ server.registerTool(
+ "items_getItemCustomerParts",
+ {
+ description: "get item customer parts",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getItemCustomerParts(
+ ctx.client,
+ params.itemId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getItemCustomerParts")
+ );
+
+ server.registerTool(
+ "items_getItemDemand",
+ {
+ description: "get item demand",
+ inputSchema: {
+ arg1: z.object({
+ itemId: z.string(),
+ locationId: z.string(),
+ periods: z.array(z.string())
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getItemDemand(ctx.client, {
+ ...params.arg1,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_getItemDemand")
+ );
+
+ server.registerTool(
+ "items_getItemFiles",
+ {
+ description: "get item files",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getItemFiles(
+ ctx.client,
+ params.itemId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getItemFiles")
+ );
+
+ server.registerTool(
+ "items_getItemPostingGroup",
+ {
+ description: "get item posting group",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getItemPostingGroup(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_getItemPostingGroup")
+ );
+
+ server.registerTool(
+ "items_getItemPostingGroups",
+ {
+ description: "get item posting groups",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getItemPostingGroups(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getItemPostingGroups")
+ );
+
+ server.registerTool(
+ "items_getItemPostingGroupsList",
+ {
+ description: "get item posting groups list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getItemPostingGroupsList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: items_getItemPostingGroupsList")
+ );
+
+ server.registerTool(
+ "items_getItemManufacturing",
+ {
+ description: "get item manufacturing",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getItemManufacturing(
+ ctx.client,
+ params.id,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getItemManufacturing")
+ );
+
+ server.registerTool(
+ "items_getItemPlanning",
+ {
+ description: "get item planning",
+ inputSchema: {
+ itemId: z.string(),
+ locationId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getItemPlanning(
+ ctx.client,
+ params.itemId,
+ ctx.companyId,
+ params.locationId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getItemPlanning")
+ );
+
+ server.registerTool(
+ "items_getItemQuantities",
+ {
+ description: "get item quantities",
+ inputSchema: {
+ itemId: z.string(),
+ locationId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getItemQuantities(
+ ctx.client,
+ params.itemId,
+ ctx.companyId,
+ params.locationId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getItemQuantities")
+ );
+
+ server.registerTool(
+ "items_getItemReplenishment",
+ {
+ description: "get item replenishment",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getItemReplenishment(
+ ctx.client,
+ params.itemId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getItemReplenishment")
+ );
+
+ server.registerTool(
+ "items_getItemShelfQuantities",
+ {
+ description: "get item shelf quantities",
+ inputSchema: {
+ itemId: z.string(),
+ locationId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getItemShelfQuantities(
+ ctx.client,
+ params.itemId,
+ ctx.companyId,
+ params.locationId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getItemShelfQuantities")
+ );
+
+ server.registerTool(
+ "items_getItemSupply",
+ {
+ description: "get item supply",
+ inputSchema: {
+ arg1: z.object({
+ itemId: z.string(),
+ locationId: z.string(),
+ periods: z.array(z.string())
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getItemSupply(ctx.client, {
+ ...params.arg1,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_getItemSupply")
+ );
+
+ server.registerTool(
+ "items_getItemUnitSalePrice",
+ {
+ description: "get item unit sale price",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getItemUnitSalePrice(
+ ctx.client,
+ params.id,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getItemUnitSalePrice")
+ );
+
+ server.registerTool(
+ "items_getMaterialUsedIn",
+ {
+ description: "get material used in",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialUsedIn(
+ ctx.client,
+ params.itemId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialUsedIn")
+ );
+
+ server.registerTool(
+ "items_getMakeMethods",
+ {
+ description: "get make methods",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMakeMethods(
+ ctx.client,
+ params.itemId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getMakeMethods")
+ );
+
+ server.registerTool(
+ "items_getMakeMethodById",
+ {
+ description: "get make method by id",
+ inputSchema: {
+ makeMethodId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMakeMethodById(
+ ctx.client,
+ params.makeMethodId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getMakeMethodById")
+ );
+
+ server.registerTool(
+ "items_getMaterial",
+ {
+ description: "get material",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterial(
+ ctx.client,
+ params.itemId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getMaterial")
+ );
+
+ server.registerTool(
+ "items_getMaterials",
+ {
+ description: "get materials",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ supplierId: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterials(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: items_getMaterials")
+ );
+
+ server.registerTool(
+ "items_getMaterialsList",
+ {
+ description: "get materials list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialsList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialsList")
+ );
+
+ server.registerTool(
+ "items_getMaterialDimension",
+ {
+ description: "get material dimension",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialDimension(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialDimension")
+ );
+
+ server.registerTool(
+ "items_getMaterialDimensions",
+ {
+ description: "get material dimensions",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ isMetric: z.boolean()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialDimensions(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialDimensions")
+ );
+
+ server.registerTool(
+ "items_getMaterialDimensionList",
+ {
+ description: "get material dimension list",
+ inputSchema: {
+ materialFormId: z.string(),
+ isMetric: z.boolean()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialDimensionList(
+ ctx.client,
+ params.materialFormId,
+ params.isMetric,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialDimensionList")
+ );
+
+ server.registerTool(
+ "items_getMaterialFinish",
+ {
+ description: "get material finish",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialFinish(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialFinish")
+ );
+
+ server.registerTool(
+ "items_getMaterialFinishes",
+ {
+ description: "get material finishes",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialFinishes(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialFinishes")
+ );
+
+ server.registerTool(
+ "items_getMaterialFinishList",
+ {
+ description: "get material finish list",
+ inputSchema: {
+ materialSubstanceId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialFinishList(
+ ctx.client,
+ params.materialSubstanceId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialFinishList")
+ );
+
+ server.registerTool(
+ "items_getMaterialForm",
+ {
+ description: "get material form",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialForm(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialForm")
+ );
+
+ server.registerTool(
+ "items_getMaterialForms",
+ {
+ description: "get material forms",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialForms(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialForms")
+ );
+
+ server.registerTool(
+ "items_getMaterialFormsList",
+ {
+ description: "get material forms list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialFormsList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialFormsList")
+ );
+
+ server.registerTool(
+ "items_getMaterialGrades",
+ {
+ description: "get material grades",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialGrades(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialGrades")
+ );
+
+ server.registerTool(
+ "items_getMaterialGrade",
+ {
+ description: "get material grade",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialGrade(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialGrade")
+ );
+
+ server.registerTool(
+ "items_getMaterialGradeList",
+ {
+ description: "get material grade list",
+ inputSchema: {
+ materialSubstanceId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialGradeList(
+ ctx.client,
+ params.materialSubstanceId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialGradeList")
+ );
+
+ server.registerTool(
+ "items_getMaterialSubstance",
+ {
+ description: "get material substance",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialSubstance(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialSubstance")
+ );
+
+ server.registerTool(
+ "items_getMaterialSubstances",
+ {
+ description: "get material substances",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialSubstances(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialSubstances")
+ );
+
+ server.registerTool(
+ "items_getMaterialSubstancesList",
+ {
+ description: "get material substances list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialSubstancesList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialSubstancesList")
+ );
+
+ server.registerTool(
+ "items_getMethodMaterial",
+ {
+ description: "get method material",
+ inputSchema: {
+ materialId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMethodMaterial(ctx.client, params.materialId);
+ return toMcpResult(result);
+ }, "Failed: items_getMethodMaterial")
+ );
+
+ server.registerTool(
+ "items_getMethodMaterials",
+ {
+ description: "get method materials",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMethodMaterials(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getMethodMaterials")
+ );
+
+ server.registerTool(
+ "items_getMethodMaterialsByMakeMethod",
+ {
+ description: "get method materials by make method",
+ inputSchema: {
+ makeMethodId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMethodMaterialsByMakeMethod(
+ ctx.client,
+ params.makeMethodId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getMethodMaterialsByMakeMethod")
+ );
+
+ server.registerTool(
+ "items_getMethodOperations",
+ {
+ description: "get method operations",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMethodOperations(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getMethodOperations")
+ );
+
+ server.registerTool(
+ "items_getMethodOperationsByMakeMethodId",
+ {
+ description: "get method operations by make method id",
+ inputSchema: {
+ makeMethodId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMethodOperationsByMakeMethodId(
+ ctx.client,
+ params.makeMethodId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getMethodOperationsByMakeMethodId")
+ );
+
+ server.registerTool(
+ "items_getMethodTree",
+ {
+ description: "get method tree",
+ inputSchema: {
+ makeMethodId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMethodTree(ctx.client, params.makeMethodId);
+ return toMcpResult(result);
+ }, "Failed: items_getMethodTree")
+ );
+
+ server.registerTool(
+ "items_getMethodTreeArray",
+ {
+ description: "get method tree array",
+ inputSchema: {
+ makeMethodId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMethodTreeArray(ctx.client, params.makeMethodId);
+ return toMcpResult(result);
+ }, "Failed: items_getMethodTreeArray")
+ );
+
+ server.registerTool(
+ "items_getOpenJobMaterials",
+ {
+ description: "get open job materials",
+ inputSchema: {
+ arg1: z.object({
+ itemId: z.string(),
+ locationId: z.string()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getOpenJobMaterials(ctx.client, {
+ ...params.arg1,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_getOpenJobMaterials")
+ );
+
+ server.registerTool(
+ "items_getOpenProductionOrders",
+ {
+ description: "get open production orders",
+ inputSchema: {
+ arg1: z.object({
+ itemId: z.string(),
+ locationId: z.string()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getOpenProductionOrders(ctx.client, {
+ ...params.arg1,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_getOpenProductionOrders")
+ );
+
+ server.registerTool(
+ "items_getOpenPurchaseOrderLines",
+ {
+ description: "get open purchase order lines",
+ inputSchema: {
+ arg1: z.object({
+ itemId: z.string(),
+ locationId: z.string()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getOpenPurchaseOrderLines(ctx.client, {
+ ...params.arg1,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_getOpenPurchaseOrderLines")
+ );
+
+ server.registerTool(
+ "items_getOpenSalesOrderLines",
+ {
+ description: "get open sales order lines",
+ inputSchema: {
+ arg1: z.object({
+ itemId: z.string(),
+ locationId: z.string()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getOpenSalesOrderLines(ctx.client, {
+ ...params.arg1,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_getOpenSalesOrderLines")
+ );
+
+ server.registerTool(
+ "items_getPart",
+ {
+ description: "get part",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPart(ctx.client, params.itemId, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: items_getPart")
+ );
+
+ server.registerTool(
+ "items_getParts",
+ {
+ description: "get parts",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ supplierId: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getParts(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: items_getParts")
+ );
+
+ server.registerTool(
+ "items_getPartsList",
+ {
+ description: "get parts list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPartsList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: items_getPartsList")
+ );
+
+ server.registerTool(
+ "items_getPartUsedIn",
+ {
+ description: "get part used in",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPartUsedIn(
+ ctx.client,
+ params.itemId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getPartUsedIn")
+ );
+
+ server.registerTool(
+ "items_getPickMethod",
+ {
+ description: "get pick method",
+ inputSchema: {
+ itemId: z.string(),
+ locationId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPickMethod(
+ ctx.client,
+ params.itemId,
+ ctx.companyId,
+ params.locationId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getPickMethod")
+ );
+
+ server.registerTool(
+ "items_getPickMethods",
+ {
+ description: "get pick methods",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPickMethods(
+ ctx.client,
+ params.itemId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getPickMethods")
+ );
+
+ server.registerTool(
+ "items_getServices",
+ {
+ description: "get services",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ type: z.string().nullable(),
+ group: z.string().nullable(),
+ supplierId: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getServices(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: items_getServices")
+ );
+
+ server.registerTool(
+ "items_getService",
+ {
+ description: "get service",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getService(ctx.client, params.itemId, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: items_getService")
+ );
+
+ server.registerTool(
+ "items_getServicesList",
+ {
+ description: "get services list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getServicesList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: items_getServicesList")
+ );
+
+ server.registerTool(
+ "items_getSupplierParts",
+ {
+ description: "get supplier parts",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierParts(
+ ctx.client,
+ params.id,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getSupplierParts")
+ );
+
+ server.registerTool(
+ "items_getTool",
+ {
+ description: "get tool",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTool(ctx.client, params.itemId, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: items_getTool")
+ );
+
+ server.registerTool(
+ "items_getTools",
+ {
+ description: "get tools",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ supplierId: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTools(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: items_getTools")
+ );
+
+ server.registerTool(
+ "items_getToolsList",
+ {
+ description: "get tools list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getToolsList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: items_getToolsList")
+ );
+
+ server.registerTool(
+ "items_getUnitOfMeasure",
+ {
+ description: "get unit of measure",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getUnitOfMeasure(
+ ctx.client,
+ params.id,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getUnitOfMeasure")
+ );
+
+ server.registerTool(
+ "items_getUnitOfMeasures",
+ {
+ description: "get unit of measures",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getUnitOfMeasures(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getUnitOfMeasures")
+ );
+
+ server.registerTool(
+ "items_getUnitOfMeasuresList",
+ {
+ description: "get unit of measures list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getUnitOfMeasuresList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: items_getUnitOfMeasuresList")
+ );
+
+ server.registerTool(
+ "items_updateConfigurationParameterGroupOrder",
+ {
+ description: "update configuration parameter group order",
+ inputSchema: {
+ data: configurationParameterGroupOrderValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateConfigurationParameterGroupOrder(
+ ctx.client,
+ params.data
+ );
+ return toMcpResult(result);
+ }, "Failed: items_updateConfigurationParameterGroupOrder")
+ );
+
+ server.registerTool(
+ "items_updateDefaultRevision",
+ {
+ description: "update default revision",
+ inputSchema: {
+ data: z.object({
+ id: z.string()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateDefaultRevision(ctx.client, {
+ ...params.data,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_updateDefaultRevision")
+ );
+
+ server.registerTool(
+ "items_updateConfigurationParameterOrder",
+ {
+ description: "update configuration parameter order",
+ inputSchema: {
+ data: configurationParameterOrderValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateConfigurationParameterOrder(ctx.client, {
+ ...params.data,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_updateConfigurationParameterOrder")
+ );
+
+ server.registerTool(
+ "items_updateItemCost",
+ {
+ description: "update item cost",
+ inputSchema: {
+ itemId: z.string(),
+ cost: z.object({
+ unitCost: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateItemCost(ctx.client, params.itemId, {
+ ...params.cost,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_updateItemCost")
+ );
+
+ server.registerTool(
+ "items_updateMaterialOrder",
+ {
+ description: "update material order",
+ inputSchema: {
+ updates: z.object({
+ id: z.string(),
+ order: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateMaterialOrder(ctx.client, {
+ ...params.updates,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_updateMaterialOrder")
+ );
+
+ server.registerTool(
+ "items_updateOperationOrder",
+ {
+ description: "update operation order",
+ inputSchema: {
+ updates: z.object({
+ id: z.string(),
+ order: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateOperationOrder(ctx.client, {
+ ...params.updates,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_updateOperationOrder")
+ );
+
+ server.registerTool(
+ "items_updateRevision",
+ {
+ description: "update revision",
+ inputSchema: {
+ revision: z.object({
+ id: z.string(),
+ revision: z.string()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateRevision(ctx.client, {
+ ...params.revision,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_updateRevision")
+ );
+
+ server.registerTool(
+ "items_upsertConfigurationParameter",
+ {
+ description: "upsert configuration parameter",
+ inputSchema: {
+ configurationParameter: configurationParameterValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertConfigurationParameter(ctx.client, {
+ ...params.configurationParameter,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertConfigurationParameter")
+ );
+
+ server.registerTool(
+ "items_upsertConfigurationParameterGroup",
+ {
+ description: "upsert configuration parameter group",
+ inputSchema: {
+ configurationParameterGroup: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertConfigurationParameterGroup(ctx.client, {
+ ...params.configurationParameterGroup,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertConfigurationParameterGroup")
+ );
+
+ server.registerTool(
+ "items_upsertConfigurationRule",
+ {
+ description: "upsert configuration rule",
+ inputSchema: {
+ configurationRule: configurationRuleValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertConfigurationRule(ctx.client, {
+ ...params.configurationRule,
+ companyId: ctx.companyId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertConfigurationRule")
+ );
+
+ server.registerTool(
+ "items_upsertConsumable",
+ {
+ description: "upsert consumable",
+ inputSchema: {
+ consumable: consumableValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertConsumable(ctx.client, {
+ ...params.consumable,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertConsumable")
+ );
+
+ server.registerTool(
+ "items_upsertPart",
+ {
+ description: "upsert part",
+ inputSchema: {
+ part: partValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertPart(ctx.client, {
+ ...params.part,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertPart")
+ );
+
+ server.registerTool(
+ "items_updateItem",
+ {
+ description: "update item",
+ inputSchema: {
+ item: itemValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateItem(ctx.client, {
+ ...params.item,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_updateItem")
+ );
+
+ server.registerTool(
+ "items_upsertItemCost",
+ {
+ description: "upsert item cost",
+ inputSchema: {
+ itemCost: itemCostValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertItemCost(ctx.client, {
+ ...params.itemCost,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertItemCost")
+ );
+
+ server.registerTool(
+ "items_upsertPickMethod",
+ {
+ description: "upsert pick method",
+ inputSchema: {
+ pickMethod: pickMethodValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertPickMethod(ctx.client, {
+ ...params.pickMethod,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertPickMethod")
+ );
+
+ server.registerTool(
+ "items_upsertItemManufacturing",
+ {
+ description: "upsert item manufacturing",
+ inputSchema: {
+ partManufacturing: itemManufacturingValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertItemManufacturing(ctx.client, {
+ ...params.partManufacturing,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertItemManufacturing")
+ );
+
+ server.registerTool(
+ "items_upsertItemPlanning",
+ {
+ description: "upsert item planning",
+ inputSchema: {
+ partPlanning: itemPlanningValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertItemPlanning(ctx.client, {
+ ...params.partPlanning,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertItemPlanning")
+ );
+
+ server.registerTool(
+ "items_upsertItemPurchasing",
+ {
+ description: "upsert item purchasing",
+ inputSchema: {
+ itemPurchasing: itemPurchasingValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertItemPurchasing(ctx.client, {
+ ...params.itemPurchasing,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertItemPurchasing")
+ );
+
+ server.registerTool(
+ "items_upsertItemPostingGroup",
+ {
+ description: "upsert item posting group",
+ inputSchema: {
+ itemPostingGroup: itemPostingGroupValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertItemPostingGroup(ctx.client, {
+ ...params.itemPostingGroup,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertItemPostingGroup")
+ );
+
+ server.registerTool(
+ "items_upsertSupplierPart",
+ {
+ description: "upsert supplier part",
+ inputSchema: {
+ supplierPart: supplierPartValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertSupplierPart(ctx.client, {
+ ...params.supplierPart,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertSupplierPart")
+ );
+
+ server.registerTool(
+ "items_upsertItemCustomerPart",
+ {
+ description: "upsert item customer part",
+ inputSchema: {
+ customerPart: customerPartValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertItemCustomerPart(ctx.client, {
+ ...params.customerPart,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertItemCustomerPart")
+ );
+
+ server.registerTool(
+ "items_upsertItemUnitSalePrice",
+ {
+ description: "upsert item unit sale price",
+ inputSchema: {
+ itemUnitSalePrice: itemUnitSalePriceValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertItemUnitSalePrice(ctx.client, {
+ ...params.itemUnitSalePrice,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertItemUnitSalePrice")
+ );
+
+ server.registerTool(
+ "items_upsertMakeMethodVersion",
+ {
+ description: "upsert make method version",
+ inputSchema: {
+ makeMethodVersion: makeMethodVersionValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMakeMethodVersion(ctx.client, {
+ ...params.makeMethodVersion,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertMakeMethodVersion")
+ );
+
+ server.registerTool(
+ "items_upsertMethodMaterial",
+ {
+ description: "upsert method material",
+ inputSchema: {
+ methodMaterial: methodMaterialValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMethodMaterial(ctx.client, {
+ ...params.methodMaterial,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertMethodMaterial")
+ );
+
+ server.registerTool(
+ "items_upsertMethodOperation",
+ {
+ description: "upsert method operation",
+ inputSchema: {
+ methodOperation: methodOperationValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMethodOperation(ctx.client, {
+ ...params.methodOperation,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertMethodOperation")
+ );
+
+ server.registerTool(
+ "items_upsertMethodOperationStep",
+ {
+ description: "upsert method operation step",
+ inputSchema: {
+ methodOperationStep: operationStepValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMethodOperationStep(ctx.client, {
+ ...params.methodOperationStep,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertMethodOperationStep")
+ );
+
+ server.registerTool(
+ "items_upsertMethodOperationParameter",
+ {
+ description: "upsert method operation parameter",
+ inputSchema: {
+ methodOperationParameter: operationParameterValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMethodOperationParameter(ctx.client, {
+ ...params.methodOperationParameter,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertMethodOperationParameter")
+ );
+
+ server.registerTool(
+ "items_upsertMethodOperationTool",
+ {
+ description: "upsert method operation tool",
+ inputSchema: {
+ methodOperationTool: operationToolValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMethodOperationTool(ctx.client, {
+ ...params.methodOperationTool,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertMethodOperationTool")
+ );
+
+ server.registerTool(
+ "items_upsertMaterial",
+ {
+ description: "upsert material",
+ inputSchema: {
+ material: materialValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaterial(ctx.client, {
+ ...params.material,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertMaterial")
+ );
+
+ server.registerTool(
+ "items_upsertMaterialDimension",
+ {
+ description: "upsert material dimension",
+ inputSchema: {
+ materialDimension: materialDimensionValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaterialDimension(ctx.client, {
+ ...params.materialDimension,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertMaterialDimension")
+ );
+
+ server.registerTool(
+ "items_upsertMaterialFinish",
+ {
+ description: "upsert material finish",
+ inputSchema: {
+ materialFinish: materialFinishValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaterialFinish(ctx.client, {
+ ...params.materialFinish,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertMaterialFinish")
+ );
+
+ server.registerTool(
+ "items_upsertMaterialForm",
+ {
+ description: "upsert material form",
+ inputSchema: {
+ materialForm: materialFormValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaterialForm(ctx.client, {
+ ...params.materialForm,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertMaterialForm")
+ );
+
+ server.registerTool(
+ "items_upsertMaterialGrade",
+ {
+ description: "upsert material grade",
+ inputSchema: {
+ materialGrade: materialGradeValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaterialGrade(ctx.client, {
+ ...params.materialGrade,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertMaterialGrade")
+ );
+
+ server.registerTool(
+ "items_deleteMaterialType",
+ {
+ description: "delete material type",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaterialType(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_deleteMaterialType")
+ );
+
+ server.registerTool(
+ "items_getMaterialTypes",
+ {
+ description: "get material types",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialTypes(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialTypes")
+ );
+
+ server.registerTool(
+ "items_getMaterialType",
+ {
+ description: "get material type",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialType(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialType")
+ );
+
+ server.registerTool(
+ "items_getMaterialTypeList",
+ {
+ description: "get material type list",
+ inputSchema: {
+ materialSubstanceId: z.string(),
+ materialFormId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaterialTypeList(
+ ctx.client,
+ params.materialSubstanceId,
+ params.materialFormId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getMaterialTypeList")
+ );
+
+ server.registerTool(
+ "items_upsertMaterialType",
+ {
+ description: "upsert material type",
+ inputSchema: {
+ materialType: materialTypeValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaterialType(ctx.client, {
+ ...params.materialType,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertMaterialType")
+ );
+
+ server.registerTool(
+ "items_upsertMaterialSubstance",
+ {
+ description: "upsert material substance",
+ inputSchema: {
+ materialSubstance: materialSubstanceValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaterialSubstance(ctx.client, {
+ ...params.materialSubstance,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertMaterialSubstance")
+ );
+
+ server.registerTool(
+ "items_upsertService",
+ {
+ description: "upsert service",
+ inputSchema: {
+ service: serviceValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertService(ctx.client, {
+ ...params.service,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertService")
+ );
+
+ server.registerTool(
+ "items_upsertUnitOfMeasure",
+ {
+ description: "upsert unit of measure",
+ inputSchema: {
+ unitOfMeasure: unitOfMeasureValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertUnitOfMeasure(ctx.client, {
+ ...params.unitOfMeasure,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertUnitOfMeasure")
+ );
+
+ server.registerTool(
+ "items_upsertTool",
+ {
+ description: "upsert tool",
+ inputSchema: {
+ tool: toolValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertTool(ctx.client, {
+ ...params.tool,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: items_upsertTool")
+ );
+
+ server.registerTool(
+ "items_getSupplierPriceBreaksForItems",
+ {
+ description: "get supplier price breaks for items",
+ inputSchema: {
+ itemIds: z.array(z.string())
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierPriceBreaksForItems(
+ ctx.client,
+ params.itemIds
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getSupplierPriceBreaksForItems")
+ );
+
+ server.registerTool(
+ "items_lookupBuyPrice",
+ {
+ description: "lookup buy price",
+ inputSchema: {
+ itemId: z.string(),
+ qty: z.number(),
+ fallbackCost: z.number()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await lookupBuyPrice(
+ ctx.client,
+ params.itemId,
+ params.qty,
+ params.fallbackCost
+ );
+ return toMcpResult(result);
+ }, "Failed: items_lookupBuyPrice")
+ );
+
+ server.registerTool(
+ "items_getSupplierPartPriceBreaks",
+ {
+ description: "get supplier part price breaks",
+ inputSchema: {
+ supplierPartId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierPartPriceBreaks(
+ ctx.client,
+ params.supplierPartId
+ );
+ return toMcpResult(result);
+ }, "Failed: items_getSupplierPartPriceBreaks")
+ );
+};
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tools/people.ts b/apps/erp/app/routes/api+/mcp+/lib/tools/people.ts
new file mode 100644
index 0000000000..0484deff45
--- /dev/null
+++ b/apps/erp/app/routes/api+/mcp+/lib/tools/people.ts
@@ -0,0 +1,885 @@
+// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+import { z } from "zod";
+import {
+ departmentValidator,
+ employeeJobValidator,
+ holidayValidator,
+ shiftValidator
+} from "~/modules/people/people.models";
+import {
+ clockIn,
+ clockOut,
+ createTimeCardEntry,
+ deleteAttribute,
+ deleteAttributeCategory,
+ deleteDepartment,
+ deleteHoliday,
+ deleteShift,
+ deleteTimeCardEntry,
+ getAttribute,
+ getAttributeCategories,
+ getAttributeCategory,
+ getAttributeDataTypes,
+ getClockedInEmployees,
+ getContacts,
+ getDepartment,
+ getDepartments,
+ getDepartmentsList,
+ getEmployeeJob,
+ getEmployeeSummary,
+ getHoliday,
+ getHolidays,
+ getOpenClockEntry,
+ getPeople,
+ getRecentTimecards,
+ getScheduledEmployeesToday,
+ getShift,
+ getShifts,
+ getShiftsList,
+ getTimeCardEntries,
+ getTimeCardEntry,
+ getTimecardEntries,
+ getWeeklyHoursForEmployees,
+ insertAttribute,
+ insertAttributeCategory,
+ insertEmployeeJob,
+ updateAttribute,
+ updateAttributeCategory,
+ updateAttributeSortOrder,
+ updateEmployeeJob,
+ updateTimeCardEntry,
+ upsertDepartment,
+ upsertHoliday,
+ upsertShift
+} from "~/modules/people/people.service";
+import type { RegisterTools } from "../types";
+import {
+ DESTRUCTIVE_ANNOTATIONS,
+ READ_ONLY_ANNOTATIONS,
+ toMcpResult,
+ WRITE_ANNOTATIONS,
+ withErrorHandling
+} from "../types";
+
+export const registerPeopleTools: RegisterTools = (server, ctx) => {
+ server.registerTool(
+ "people_deleteAttribute",
+ {
+ description: "delete attribute",
+ inputSchema: {
+ attributeId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteAttribute(ctx.client, params.attributeId);
+ return toMcpResult(result);
+ }, "Failed: people_deleteAttribute")
+ );
+
+ server.registerTool(
+ "people_deleteAttributeCategory",
+ {
+ description: "delete attribute category",
+ inputSchema: {
+ attributeCategoryId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteAttributeCategory(
+ ctx.client,
+ params.attributeCategoryId
+ );
+ return toMcpResult(result);
+ }, "Failed: people_deleteAttributeCategory")
+ );
+
+ server.registerTool(
+ "people_deleteDepartment",
+ {
+ description: "delete department",
+ inputSchema: {
+ departmentId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteDepartment(ctx.client, params.departmentId);
+ return toMcpResult(result);
+ }, "Failed: people_deleteDepartment")
+ );
+
+ server.registerTool(
+ "people_deleteHoliday",
+ {
+ description: "delete holiday",
+ inputSchema: {
+ holidayId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteHoliday(ctx.client, params.holidayId);
+ return toMcpResult(result);
+ }, "Failed: people_deleteHoliday")
+ );
+
+ server.registerTool(
+ "people_deleteShift",
+ {
+ description: "delete shift",
+ inputSchema: {
+ shiftId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteShift(ctx.client, params.shiftId);
+ return toMcpResult(result);
+ }, "Failed: people_deleteShift")
+ );
+
+ server.registerTool(
+ "people_getAttribute",
+ {
+ description: "get attribute",
+ inputSchema: {
+ attributeId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAttribute(ctx.client, params.attributeId);
+ return toMcpResult(result);
+ }, "Failed: people_getAttribute")
+ );
+
+ server.registerTool(
+ "people_getAttributeCategories",
+ {
+ description: "get attribute categories",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0)
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAttributeCategories(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: people_getAttributeCategories")
+ );
+
+ server.registerTool(
+ "people_getAttributeCategory",
+ {
+ description: "get attribute category",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAttributeCategory(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: people_getAttributeCategory")
+ );
+
+ server.registerTool(
+ "people_getAttributeDataTypes",
+ {
+ description: "get attribute data types",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAttributeDataTypes(ctx.client);
+ return toMcpResult(result);
+ }, "Failed: people_getAttributeDataTypes")
+ );
+
+ server.registerTool(
+ "people_getDepartment",
+ {
+ description: "get department",
+ inputSchema: {
+ departmentId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getDepartment(ctx.client, params.departmentId);
+ return toMcpResult(result);
+ }, "Failed: people_getDepartment")
+ );
+
+ server.registerTool(
+ "people_getDepartments",
+ {
+ description: "get departments",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getDepartments(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: people_getDepartments")
+ );
+
+ server.registerTool(
+ "people_getDepartmentsList",
+ {
+ description: "get departments list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getDepartmentsList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: people_getDepartmentsList")
+ );
+
+ server.registerTool(
+ "people_getEmployeeJob",
+ {
+ description: "get employee job",
+ inputSchema: {
+ employeeId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getEmployeeJob(
+ ctx.client,
+ params.employeeId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: people_getEmployeeJob")
+ );
+
+ server.registerTool(
+ "people_getEmployeeSummary",
+ {
+ description: "get employee summary",
+ inputSchema: {
+ employeeId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getEmployeeSummary(
+ ctx.client,
+ params.employeeId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: people_getEmployeeSummary")
+ );
+
+ server.registerTool(
+ "people_getHoliday",
+ {
+ description: "get holiday",
+ inputSchema: {
+ holidayId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getHoliday(ctx.client, params.holidayId);
+ return toMcpResult(result);
+ }, "Failed: people_getHoliday")
+ );
+
+ server.registerTool(
+ "people_getHolidays",
+ {
+ description: "get holidays",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getHolidays(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: people_getHolidays")
+ );
+
+ server.registerTool(
+ "people_getPeople",
+ {
+ description: "get people",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPeople(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: people_getPeople")
+ );
+
+ server.registerTool(
+ "people_getContacts",
+ {
+ description: "get contacts",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getContacts(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: people_getContacts")
+ );
+
+ server.registerTool(
+ "people_getShift",
+ {
+ description: "get shift",
+ inputSchema: {
+ shiftId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getShift(ctx.client, params.shiftId);
+ return toMcpResult(result);
+ }, "Failed: people_getShift")
+ );
+
+ server.registerTool(
+ "people_getShifts",
+ {
+ description: "get shifts",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getShifts(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: people_getShifts")
+ );
+
+ server.registerTool(
+ "people_getShiftsList",
+ {
+ description: "get shifts list",
+ inputSchema: {
+ locationId: z.string().nullable()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getShiftsList(ctx.client, params.locationId);
+ return toMcpResult(result);
+ }, "Failed: people_getShiftsList")
+ );
+
+ server.registerTool(
+ "people_insertAttribute",
+ {
+ description: "insert attribute",
+ inputSchema: {
+ attribute: z.object({
+ name: z.string(),
+ attributeDataTypeId: z.number(),
+ userAttributeCategoryId: z.string(),
+ listOptions: z.array(z.string()).optional(),
+ canSelfManage: z.boolean()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertAttribute(ctx.client, {
+ ...params.attribute,
+ createdBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: people_insertAttribute")
+ );
+
+ server.registerTool(
+ "people_insertAttributeCategory",
+ {
+ description: "insert attribute category",
+ inputSchema: {
+ attributeCategory: z.object({
+ name: z.string(),
+ emoji: z.string().optional(),
+ public: z.boolean()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertAttributeCategory(ctx.client, {
+ ...params.attributeCategory,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: people_insertAttributeCategory")
+ );
+
+ server.registerTool(
+ "people_insertEmployeeJob",
+ {
+ description: "insert employee job",
+ inputSchema: {
+ job: z.object({
+ id: z.string(),
+ locationId: z.string().optional()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertEmployeeJob(ctx.client, {
+ ...params.job,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: people_insertEmployeeJob")
+ );
+
+ server.registerTool(
+ "people_updateAttribute",
+ {
+ description: "update attribute",
+ inputSchema: {
+ attribute: z.object({
+ id: z.string().optional(),
+ name: z.string(),
+ listOptions: z.array(z.string()).optional(),
+ canSelfManage: z.boolean()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateAttribute(ctx.client, {
+ ...params.attribute,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: people_updateAttribute")
+ );
+
+ server.registerTool(
+ "people_updateAttributeCategory",
+ {
+ description: "update attribute category",
+ inputSchema: {
+ attributeCategory: z.object({
+ id: z.string(),
+ name: z.string(),
+ emoji: z.string().optional(),
+ public: z.boolean()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateAttributeCategory(ctx.client, {
+ ...params.attributeCategory,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: people_updateAttributeCategory")
+ );
+
+ server.registerTool(
+ "people_updateAttributeSortOrder",
+ {
+ description: "update attribute sort order",
+ inputSchema: {
+ updates: z.object({
+ id: z.string(),
+ sortOrder: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateAttributeSortOrder(ctx.client, {
+ ...params.updates,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: people_updateAttributeSortOrder")
+ );
+
+ server.registerTool(
+ "people_updateEmployeeJob",
+ {
+ description: "update employee job",
+ inputSchema: {
+ employeeId: z.string(),
+ employeeJob: employeeJobValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateEmployeeJob(ctx.client, params.employeeId, {
+ ...params.employeeJob,
+ companyId: ctx.companyId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: people_updateEmployeeJob")
+ );
+
+ server.registerTool(
+ "people_upsertDepartment",
+ {
+ description: "upsert department",
+ inputSchema: {
+ department: departmentValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertDepartment(ctx.client, {
+ ...params.department,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: people_upsertDepartment")
+ );
+
+ server.registerTool(
+ "people_upsertHoliday",
+ {
+ description: "upsert holiday",
+ inputSchema: {
+ holiday: holidayValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertHoliday(ctx.client, {
+ ...params.holiday,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: people_upsertHoliday")
+ );
+
+ server.registerTool(
+ "people_upsertShift",
+ {
+ description: "upsert shift",
+ inputSchema: {
+ shift: shiftValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertShift(ctx.client, {
+ ...params.shift,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: people_upsertShift")
+ );
+
+ server.registerTool(
+ "people_clockIn",
+ {
+ description: "clock in",
+ inputSchema: {
+ args: z.object({
+ employeeId: z.string()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await clockIn(ctx.client, {
+ ...params.args,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: people_clockIn")
+ );
+
+ server.registerTool(
+ "people_clockOut",
+ {
+ description: "clock out",
+ inputSchema: {
+ args: z.object({
+ employeeId: z.string(),
+ clockOut: z.string().optional(),
+ note: z.string().optional()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await clockOut(ctx.client, {
+ ...params.args,
+ companyId: ctx.companyId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: people_clockOut")
+ );
+
+ server.registerTool(
+ "people_createTimeCardEntry",
+ {
+ description: "create time card entry",
+ inputSchema: {
+ entry: z.object({
+ employeeId: z.string(),
+ clockIn: z.string(),
+ clockOut: z.string().nullable().optional(),
+ note: z.string().nullable().optional()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await createTimeCardEntry(ctx.client, {
+ ...params.entry,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: people_createTimeCardEntry")
+ );
+
+ server.registerTool(
+ "people_deleteTimeCardEntry",
+ {
+ description: "delete time card entry",
+ inputSchema: {
+ entryId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteTimeCardEntry(ctx.client, params.entryId);
+ return toMcpResult(result);
+ }, "Failed: people_deleteTimeCardEntry")
+ );
+
+ server.registerTool(
+ "people_getClockedInEmployees",
+ {
+ description: "get clocked in employees",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getClockedInEmployees(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: people_getClockedInEmployees")
+ );
+
+ server.registerTool(
+ "people_getOpenClockEntry",
+ {
+ description: "get open clock entry",
+ inputSchema: {
+ employeeId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getOpenClockEntry(
+ ctx.client,
+ params.employeeId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: people_getOpenClockEntry")
+ );
+
+ server.registerTool(
+ "people_getRecentTimecards",
+ {
+ description: "get recent timecards",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getRecentTimecards(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: people_getRecentTimecards")
+ );
+
+ server.registerTool(
+ "people_getScheduledEmployeesToday",
+ {
+ description: "get scheduled employees today",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getScheduledEmployeesToday(
+ ctx.client,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: people_getScheduledEmployeesToday")
+ );
+
+ server.registerTool(
+ "people_getTimeCardEntry",
+ {
+ description: "get time card entry",
+ inputSchema: {
+ entryId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTimeCardEntry(ctx.client, params.entryId);
+ return toMcpResult(result);
+ }, "Failed: people_getTimeCardEntry")
+ );
+
+ server.registerTool(
+ "people_getTimeCardEntries",
+ {
+ description: "get time card entries",
+ inputSchema: {
+ args: z.object({
+ employeeId: z.string(),
+ from: z.string().optional(),
+ to: z.string().optional()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTimeCardEntries(ctx.client, {
+ ...params.args,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: people_getTimeCardEntries")
+ );
+
+ server.registerTool(
+ "people_getTimecardEntries",
+ {
+ description: "get timecard entries",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTimecardEntries(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: people_getTimecardEntries")
+ );
+
+ server.registerTool(
+ "people_getWeeklyHoursForEmployees",
+ {
+ description: "get weekly hours for employees",
+ inputSchema: {
+ employeeIds: z.array(z.string())
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getWeeklyHoursForEmployees(
+ ctx.client,
+ ctx.companyId,
+ params.employeeIds
+ );
+ return toMcpResult(result);
+ }, "Failed: people_getWeeklyHoursForEmployees")
+ );
+
+ server.registerTool(
+ "people_updateTimeCardEntry",
+ {
+ description: "update time card entry",
+ inputSchema: {
+ args: z.object({
+ entryId: z.string(),
+ clockIn: z.string().optional(),
+ clockOut: z.string().nullable().optional(),
+ note: z.string().nullable().optional()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateTimeCardEntry(ctx.client, {
+ ...params.args,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: people_updateTimeCardEntry")
+ );
+};
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tools/production.ts b/apps/erp/app/routes/api+/mcp+/lib/tools/production.ts
new file mode 100644
index 0000000000..019f634041
--- /dev/null
+++ b/apps/erp/app/routes/api+/mcp+/lib/tools/production.ts
@@ -0,0 +1,2662 @@
+// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+import { z } from "zod";
+import {
+ failureModeValidator,
+ jobMaterialValidator,
+ jobOperationValidator,
+ jobValidator,
+ maintenanceDispatchCommentValidator,
+ maintenanceDispatchEventValidator,
+ maintenanceDispatchItemValidator,
+ maintenanceDispatchValidator,
+ maintenanceDispatchWorkCenterValidator,
+ maintenanceScheduleItemValidator,
+ maintenanceScheduleValidator,
+ procedureParameterValidator,
+ procedureStepValidator,
+ procedureValidator,
+ productionEventValidator,
+ productionQuantityValidator,
+ scrapReasonValidator
+} from "~/modules/production/production.models";
+import {
+ calculateJobPriority,
+ convertSalesOrderLinesToJobs,
+ deleteDemandForecasts,
+ deleteDemandProjections,
+ deleteFailureMode,
+ deleteJob,
+ deleteJobMaterial,
+ deleteJobOperation,
+ deleteJobOperationParameter,
+ deleteJobOperationStep,
+ deleteJobOperationTool,
+ deleteMaintenanceDispatch,
+ deleteMaintenanceDispatchComment,
+ deleteMaintenanceDispatchEvent,
+ deleteMaintenanceDispatchItem,
+ deleteMaintenanceDispatchWorkCenter,
+ deleteMaintenanceSchedule,
+ deleteMaintenanceScheduleItem,
+ deleteProcedure,
+ deleteProcedureParameter,
+ deleteProcedureStep,
+ deleteProductionEvent,
+ deleteProductionQuantity,
+ deleteScrapReason,
+ getActiveJobOperationByJobId,
+ getActiveJobOperationsByLocation,
+ getActiveProductionEvents,
+ getDemandForecasts,
+ getDemandProjections,
+ getFailureMode,
+ getFailureModes,
+ getFailureModesList,
+ getJob,
+ getJobByOperationId,
+ getJobDocuments,
+ getJobDocumentsWithItemId,
+ getJobMakeMethodById,
+ getJobMaterial,
+ getJobMaterialsByMethodId,
+ getJobMaterialsWithQuantityOnHand,
+ getJobMethodTree,
+ getJobMethodTreeArray,
+ getJobOperation,
+ getJobOperationAttachments,
+ getJobOperationStepRecords,
+ getJobOperations,
+ getJobOperationsAssignedToEmployee,
+ getJobOperationsByMethodId,
+ getJobOperationsList,
+ getJobPurchaseOrderLines,
+ getJobs,
+ getJobsByDateRange,
+ getJobsBySalesOrderLine,
+ getJobsList,
+ getMaintenanceDispatch,
+ getMaintenanceDispatchComments,
+ getMaintenanceDispatchEvents,
+ getMaintenanceDispatches,
+ getMaintenanceDispatchItems,
+ getMaintenanceDispatchWorkCenters,
+ getMaintenanceSchedule,
+ getMaintenanceScheduleItems,
+ getMaintenanceSchedules,
+ getOutsideOperationsByJobId,
+ getProcedure,
+ getProcedureParameters,
+ getProcedureSteps,
+ getProcedures,
+ getProceduresList,
+ getProcedureVersions,
+ getProductionDataByOperations,
+ getProductionEvent,
+ getProductionEvents,
+ getProductionEventsByOperations,
+ getProductionEventsPage,
+ getProductionPlanning,
+ getProductionProjections,
+ getProductionQuantities,
+ getProductionQuantity,
+ getRootMakeMethod,
+ getScrapReason,
+ getScrapReasons,
+ getScrapReasonsList,
+ getTrackedEntitiesByJobId,
+ getTrackedEntityByJobId,
+ getUnscheduledJobs,
+ recalculateJobMakeMethodRequirements,
+ recalculateJobOperationDependencies,
+ recalculateJobRequirements,
+ runMRP,
+ updateJobBatchNumber,
+ updateJobMaterialOrder,
+ updateJobOperationDueDate,
+ updateJobOperationOrder,
+ updateJobOperationStatus,
+ updateJobOperationStepOrder,
+ updateJobStatus,
+ updateKanbanJob,
+ updateMethodOperationStepOrder,
+ updateProcedureStepOrder,
+ updateProductionQuantity,
+ updateQuoteOperationStepOrder,
+ upsertDemandForecasts,
+ upsertDemandProjections,
+ upsertFailureMode,
+ upsertJob,
+ upsertJobMaterial,
+ upsertJobMaterialMakeMethod,
+ upsertJobMethod,
+ upsertJobOperation,
+ upsertJobOperationParameter,
+ upsertJobOperationStep,
+ upsertJobOperationTool,
+ upsertMaintenanceDispatch,
+ upsertMaintenanceDispatchComment,
+ upsertMaintenanceDispatchEvent,
+ upsertMaintenanceDispatchItem,
+ upsertMaintenanceDispatchWorkCenter,
+ upsertMaintenanceSchedule,
+ upsertMaintenanceScheduleItem,
+ upsertMakeMethodFromJob,
+ upsertMakeMethodFromJobMethod,
+ upsertProcedure,
+ upsertProcedureParameter,
+ upsertProcedureStep,
+ upsertProductionEvent,
+ upsertProductionQuantity,
+ upsertScrapReason
+} from "~/modules/production/production.service";
+import {
+ operationParameterValidator,
+ operationStepValidator,
+ operationToolValidator
+} from "~/modules/shared";
+import type { RegisterTools } from "../types";
+import {
+ DESTRUCTIVE_ANNOTATIONS,
+ READ_ONLY_ANNOTATIONS,
+ toMcpResult,
+ WRITE_ANNOTATIONS,
+ withErrorHandling
+} from "../types";
+
+export const registerProductionTools: RegisterTools = (server, ctx) => {
+ server.registerTool(
+ "production_convertSalesOrderLinesToJobs",
+ {
+ description: "convert sales order lines to jobs",
+ inputSchema: {
+ arg1: z.object({
+ orderId: z.string()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await convertSalesOrderLinesToJobs(ctx.client, {
+ ...params.arg1,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_convertSalesOrderLinesToJobs")
+ );
+
+ server.registerTool(
+ "production_calculateJobPriority",
+ {
+ description: "calculate job priority",
+ inputSchema: {
+ params: z.object({
+ jobId: z.string().optional(),
+ dueDate: z.string().nullable(),
+ deadlineType: z.any(),
+ locationId: z.string()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await calculateJobPriority(ctx.client, {
+ ...params.params,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_calculateJobPriority")
+ );
+
+ server.registerTool(
+ "production_deleteDemandForecasts",
+ {
+ description: "delete demand forecasts",
+ inputSchema: {
+ params: z.object({
+ itemId: z.string(),
+ locationId: z.string(),
+ futurePeriodIds: z.array(z.string())
+ })
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteDemandForecasts(ctx.client, {
+ ...params.params,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_deleteDemandForecasts")
+ );
+
+ server.registerTool(
+ "production_deleteDemandProjections",
+ {
+ description: "delete demand projections",
+ inputSchema: {
+ params: z.object({
+ itemId: z.string(),
+ locationId: z.string(),
+ futurePeriodIds: z.array(z.string())
+ })
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteDemandProjections(ctx.client, {
+ ...params.params,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_deleteDemandProjections")
+ );
+
+ server.registerTool(
+ "production_deleteJob",
+ {
+ description: "delete job",
+ inputSchema: {
+ jobId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteJob(ctx.client, params.jobId);
+ return toMcpResult(result);
+ }, "Failed: production_deleteJob")
+ );
+
+ server.registerTool(
+ "production_deleteJobMaterial",
+ {
+ description: "delete job material",
+ inputSchema: {
+ jobMaterialId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteJobMaterial(ctx.client, params.jobMaterialId);
+ return toMcpResult(result);
+ }, "Failed: production_deleteJobMaterial")
+ );
+
+ server.registerTool(
+ "production_deleteJobOperation",
+ {
+ description: "delete job operation",
+ inputSchema: {
+ jobOperationId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteJobOperation(
+ ctx.client,
+ params.jobOperationId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_deleteJobOperation")
+ );
+
+ server.registerTool(
+ "production_deleteJobOperationStep",
+ {
+ description: "delete job operation step",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteJobOperationStep(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: production_deleteJobOperationStep")
+ );
+
+ server.registerTool(
+ "production_deleteJobOperationParameter",
+ {
+ description: "delete job operation parameter",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteJobOperationParameter(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: production_deleteJobOperationParameter")
+ );
+
+ server.registerTool(
+ "production_deleteJobOperationTool",
+ {
+ description: "delete job operation tool",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteJobOperationTool(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: production_deleteJobOperationTool")
+ );
+
+ server.registerTool(
+ "production_deleteProcedure",
+ {
+ description: "delete procedure",
+ inputSchema: {
+ procedureId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteProcedure(ctx.client, params.procedureId);
+ return toMcpResult(result);
+ }, "Failed: production_deleteProcedure")
+ );
+
+ server.registerTool(
+ "production_deleteProcedureStep",
+ {
+ description: "delete procedure step",
+ inputSchema: {
+ procedureStepId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteProcedureStep(
+ ctx.client,
+ params.procedureStepId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_deleteProcedureStep")
+ );
+
+ server.registerTool(
+ "production_deleteProcedureParameter",
+ {
+ description: "delete procedure parameter",
+ inputSchema: {
+ procedureParameterId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteProcedureParameter(
+ ctx.client,
+ params.procedureParameterId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_deleteProcedureParameter")
+ );
+
+ server.registerTool(
+ "production_deleteProductionEvent",
+ {
+ description: "delete production event",
+ inputSchema: {
+ productionEventId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteProductionEvent(
+ ctx.client,
+ params.productionEventId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_deleteProductionEvent")
+ );
+
+ server.registerTool(
+ "production_deleteProductionQuantity",
+ {
+ description: "delete production quantity",
+ inputSchema: {
+ productionQuantityId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteProductionQuantity(
+ ctx.client,
+ params.productionQuantityId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_deleteProductionQuantity")
+ );
+
+ server.registerTool(
+ "production_getActiveJobOperationByJobId",
+ {
+ description: "get active job operation by job id",
+ inputSchema: {
+ jobId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getActiveJobOperationByJobId(
+ ctx.client,
+ params.jobId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getActiveJobOperationByJobId")
+ );
+
+ server.registerTool(
+ "production_getActiveJobOperationsByLocation",
+ {
+ description: "get active job operations by location",
+ inputSchema: {
+ locationId: z.string(),
+ workCenterIds: z.array(z.string()).optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getActiveJobOperationsByLocation(
+ ctx.client,
+ params.locationId,
+ params.workCenterIds
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getActiveJobOperationsByLocation")
+ );
+
+ server.registerTool(
+ "production_getJobsByDateRange",
+ {
+ description: "get jobs by date range",
+ inputSchema: {
+ locationId: z.string(),
+ startDate: z.string(),
+ endDate: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobsByDateRange(
+ ctx.client,
+ params.locationId,
+ params.startDate,
+ params.endDate
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getJobsByDateRange")
+ );
+
+ server.registerTool(
+ "production_getUnscheduledJobs",
+ {
+ description: "get unscheduled jobs",
+ inputSchema: {
+ locationId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getUnscheduledJobs(ctx.client, params.locationId);
+ return toMcpResult(result);
+ }, "Failed: production_getUnscheduledJobs")
+ );
+
+ server.registerTool(
+ "production_getActiveProductionEvents",
+ {
+ description: "get active production events",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getActiveProductionEvents(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: production_getActiveProductionEvents")
+ );
+
+ server.registerTool(
+ "production_deleteScrapReason",
+ {
+ description: "delete scrap reason",
+ inputSchema: {
+ scrapReasonId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteScrapReason(ctx.client, params.scrapReasonId);
+ return toMcpResult(result);
+ }, "Failed: production_deleteScrapReason")
+ );
+
+ server.registerTool(
+ "production_deleteFailureMode",
+ {
+ description: "delete failure mode",
+ inputSchema: {
+ failureModeId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteFailureMode(ctx.client, params.failureModeId);
+ return toMcpResult(result);
+ }, "Failed: production_deleteFailureMode")
+ );
+
+ server.registerTool(
+ "production_deleteMaintenanceDispatch",
+ {
+ description: "delete maintenance dispatch",
+ inputSchema: {
+ dispatchId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaintenanceDispatch(
+ ctx.client,
+ params.dispatchId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_deleteMaintenanceDispatch")
+ );
+
+ server.registerTool(
+ "production_deleteMaintenanceDispatchComment",
+ {
+ description: "delete maintenance dispatch comment",
+ inputSchema: {
+ commentId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaintenanceDispatchComment(
+ ctx.client,
+ params.commentId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_deleteMaintenanceDispatchComment")
+ );
+
+ server.registerTool(
+ "production_deleteMaintenanceDispatchEvent",
+ {
+ description: "delete maintenance dispatch event",
+ inputSchema: {
+ eventId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaintenanceDispatchEvent(
+ ctx.client,
+ params.eventId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_deleteMaintenanceDispatchEvent")
+ );
+
+ server.registerTool(
+ "production_deleteMaintenanceDispatchItem",
+ {
+ description: "delete maintenance dispatch item",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaintenanceDispatchItem(
+ ctx.client,
+ params.itemId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_deleteMaintenanceDispatchItem")
+ );
+
+ server.registerTool(
+ "production_deleteMaintenanceDispatchWorkCenter",
+ {
+ description: "delete maintenance dispatch work center",
+ inputSchema: {
+ workCenterId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaintenanceDispatchWorkCenter(
+ ctx.client,
+ params.workCenterId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_deleteMaintenanceDispatchWorkCenter")
+ );
+
+ server.registerTool(
+ "production_deleteMaintenanceSchedule",
+ {
+ description: "delete maintenance schedule",
+ inputSchema: {
+ scheduleId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaintenanceSchedule(
+ ctx.client,
+ params.scheduleId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_deleteMaintenanceSchedule")
+ );
+
+ server.registerTool(
+ "production_deleteMaintenanceScheduleItem",
+ {
+ description: "delete maintenance schedule item",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaintenanceScheduleItem(
+ ctx.client,
+ params.itemId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_deleteMaintenanceScheduleItem")
+ );
+
+ server.registerTool(
+ "production_getDemandForecasts",
+ {
+ description: "get demand forecasts",
+ inputSchema: {
+ params: z.object({
+ itemId: z.string(),
+ locationId: z.string(),
+ periodIds: z.array(z.string())
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getDemandForecasts(ctx.client, {
+ ...params.params,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_getDemandForecasts")
+ );
+
+ server.registerTool(
+ "production_getDemandProjections",
+ {
+ description: "get demand projections",
+ inputSchema: {
+ params: z.object({
+ itemId: z.string(),
+ locationId: z.string(),
+ periodIds: z.array(z.string())
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getDemandProjections(ctx.client, {
+ ...params.params,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_getDemandProjections")
+ );
+
+ server.registerTool(
+ "production_getJobDocuments",
+ {
+ description: "get job documents",
+ inputSchema: {
+ job: z.object({
+ id: z.string().nullable(),
+ salesOrderLineId: z.string().nullable().optional(),
+ quoteLineId: z.string().nullable().optional(),
+ itemId: z.string().nullable().optional()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobDocuments(
+ ctx.client,
+ ctx.companyId,
+ params.job
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getJobDocuments")
+ );
+
+ server.registerTool(
+ "production_getJobDocumentsWithItemId",
+ {
+ description: "get job documents with item id",
+ inputSchema: {
+ job: z.any(),
+ itemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobDocumentsWithItemId(
+ ctx.client,
+ ctx.companyId,
+ params.job,
+ params.itemId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getJobDocumentsWithItemId")
+ );
+
+ server.registerTool(
+ "production_getJob",
+ {
+ description: "get job",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJob(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: production_getJob")
+ );
+
+ server.registerTool(
+ "production_getJobByOperationId",
+ {
+ description: "get job by operation id",
+ inputSchema: {
+ operationId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobByOperationId(ctx.client, params.operationId);
+ return toMcpResult(result);
+ }, "Failed: production_getJobByOperationId")
+ );
+
+ server.registerTool(
+ "production_getJobPurchaseOrderLines",
+ {
+ description: "get job purchase order lines",
+ inputSchema: {
+ jobId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobPurchaseOrderLines(ctx.client, params.jobId);
+ return toMcpResult(result);
+ }, "Failed: production_getJobPurchaseOrderLines")
+ );
+
+ server.registerTool(
+ "production_getJobs",
+ {
+ description: "get jobs",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0)
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobs(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: production_getJobs")
+ );
+
+ server.registerTool(
+ "production_getJobsBySalesOrderLine",
+ {
+ description: "get jobs by sales order line",
+ inputSchema: {
+ salesOrderLineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobsBySalesOrderLine(
+ ctx.client,
+ params.salesOrderLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getJobsBySalesOrderLine")
+ );
+
+ server.registerTool(
+ "production_getJobsList",
+ {
+ description: "get jobs list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobsList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: production_getJobsList")
+ );
+
+ server.registerTool(
+ "production_getJobMakeMethodById",
+ {
+ description: "get job make method by id",
+ inputSchema: {
+ jobMakeMethodId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobMakeMethodById(
+ ctx.client,
+ params.jobMakeMethodId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getJobMakeMethodById")
+ );
+
+ server.registerTool(
+ "production_getRootMakeMethod",
+ {
+ description: "get root make method",
+ inputSchema: {
+ jobId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getRootMakeMethod(
+ ctx.client,
+ params.jobId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getRootMakeMethod")
+ );
+
+ server.registerTool(
+ "production_getJobMaterialsWithQuantityOnHand",
+ {
+ description: "get job materials with quantity on hand",
+ inputSchema: {
+ jobId: z.string(),
+ locationId: z.string(),
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0)
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobMaterialsWithQuantityOnHand(
+ ctx.client,
+ params.jobId,
+ ctx.companyId,
+ params.locationId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getJobMaterialsWithQuantityOnHand")
+ );
+
+ server.registerTool(
+ "production_getJobMethodTree",
+ {
+ description: "get job method tree",
+ inputSchema: {
+ jobId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobMethodTree(ctx.client, params.jobId);
+ return toMcpResult(result);
+ }, "Failed: production_getJobMethodTree")
+ );
+
+ server.registerTool(
+ "production_getJobMethodTreeArray",
+ {
+ description: "get job method tree array",
+ inputSchema: {
+ jobId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobMethodTreeArray(ctx.client, params.jobId);
+ return toMcpResult(result);
+ }, "Failed: production_getJobMethodTreeArray")
+ );
+
+ server.registerTool(
+ "production_getJobMaterial",
+ {
+ description: "get job material",
+ inputSchema: {
+ materialId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobMaterial(ctx.client, params.materialId);
+ return toMcpResult(result);
+ }, "Failed: production_getJobMaterial")
+ );
+
+ server.registerTool(
+ "production_getJobMaterialsByMethodId",
+ {
+ description: "get job materials by method id",
+ inputSchema: {
+ jobMakeMethodId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobMaterialsByMethodId(
+ ctx.client,
+ params.jobMakeMethodId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getJobMaterialsByMethodId")
+ );
+
+ server.registerTool(
+ "production_getJobOperation",
+ {
+ description: "get job operation",
+ inputSchema: {
+ jobOperationId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobOperation(ctx.client, params.jobOperationId);
+ return toMcpResult(result);
+ }, "Failed: production_getJobOperation")
+ );
+
+ server.registerTool(
+ "production_getJobOperations",
+ {
+ description: "get job operations",
+ inputSchema: {
+ jobId: z.string(),
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0)
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobOperations(
+ ctx.client,
+ params.jobId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getJobOperations")
+ );
+
+ server.registerTool(
+ "production_getJobOperationsAssignedToEmployee",
+ {
+ description: "get job operations assigned to employee",
+ inputSchema: {
+ employeeId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobOperationsAssignedToEmployee(
+ ctx.client,
+ params.employeeId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getJobOperationsAssignedToEmployee")
+ );
+
+ server.registerTool(
+ "production_getJobOperationAttachments",
+ {
+ description: "get job operation attachments",
+ inputSchema: {
+ jobOperationIds: z.array(z.string())
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobOperationAttachments(
+ ctx.client,
+ params.jobOperationIds
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getJobOperationAttachments")
+ );
+
+ server.registerTool(
+ "production_getJobOperationsList",
+ {
+ description: "get job operations list",
+ inputSchema: {
+ jobId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobOperationsList(ctx.client, params.jobId);
+ return toMcpResult(result);
+ }, "Failed: production_getJobOperationsList")
+ );
+
+ server.registerTool(
+ "production_getJobOperationsByMethodId",
+ {
+ description: "get job operations by method id",
+ inputSchema: {
+ jobMakeMethodId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobOperationsByMethodId(
+ ctx.client,
+ params.jobMakeMethodId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getJobOperationsByMethodId")
+ );
+
+ server.registerTool(
+ "production_getJobOperationStepRecords",
+ {
+ description: "get job operation step records",
+ inputSchema: {
+ jobId: z.string(),
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getJobOperationStepRecords(
+ ctx.client,
+ params.jobId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getJobOperationStepRecords")
+ );
+
+ server.registerTool(
+ "production_getOutsideOperationsByJobId",
+ {
+ description: "get outside operations by job id",
+ inputSchema: {
+ jobId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getOutsideOperationsByJobId(
+ ctx.client,
+ params.jobId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getOutsideOperationsByJobId")
+ );
+
+ server.registerTool(
+ "production_getProcedure",
+ {
+ description: "get procedure",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getProcedure(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: production_getProcedure")
+ );
+
+ server.registerTool(
+ "production_getProcedureSteps",
+ {
+ description: "get procedure steps",
+ inputSchema: {
+ procedureId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getProcedureSteps(ctx.client, params.procedureId);
+ return toMcpResult(result);
+ }, "Failed: production_getProcedureSteps")
+ );
+
+ server.registerTool(
+ "production_getProcedureParameters",
+ {
+ description: "get procedure parameters",
+ inputSchema: {
+ procedureId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getProcedureParameters(
+ ctx.client,
+ params.procedureId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getProcedureParameters")
+ );
+
+ server.registerTool(
+ "production_getProcedureVersions",
+ {
+ description: "get procedure versions",
+ inputSchema: {
+ procedure: z.object({
+ name: z.string(),
+ version: z.number()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getProcedureVersions(
+ ctx.client,
+ params.procedure,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getProcedureVersions")
+ );
+
+ server.registerTool(
+ "production_getProcedures",
+ {
+ description: "get procedures",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0)
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getProcedures(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getProcedures")
+ );
+
+ server.registerTool(
+ "production_getProceduresList",
+ {
+ description: "get procedures list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getProceduresList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: production_getProceduresList")
+ );
+
+ server.registerTool(
+ "production_getProductionEvent",
+ {
+ description: "get production event",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getProductionEvent(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: production_getProductionEvent")
+ );
+
+ server.registerTool(
+ "production_getProductionEvents",
+ {
+ description: "get production events",
+ inputSchema: {
+ jobOperationIds: z.array(z.string()),
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0)
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getProductionEvents(
+ ctx.client,
+ params.jobOperationIds,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getProductionEvents")
+ );
+
+ server.registerTool(
+ "production_getProductionEventsPage",
+ {
+ description: "get production events page",
+ inputSchema: {
+ jobOperationId: z.string(),
+ sortDescending: z.boolean().optional(),
+ page: z.number().optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getProductionEventsPage(
+ ctx.client,
+ params.jobOperationId,
+ ctx.companyId,
+ params.sortDescending,
+ params.page
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getProductionEventsPage")
+ );
+
+ server.registerTool(
+ "production_getProductionEventsByOperations",
+ {
+ description: "get production events by operations",
+ inputSchema: {
+ jobOperationIds: z.array(z.string())
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getProductionEventsByOperations(
+ ctx.client,
+ params.jobOperationIds
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getProductionEventsByOperations")
+ );
+
+ server.registerTool(
+ "production_getProductionPlanning",
+ {
+ description: "get production planning",
+ inputSchema: {
+ locationId: z.string(),
+ periods: z.array(z.string()),
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getProductionPlanning(
+ ctx.client,
+ params.locationId,
+ ctx.companyId,
+ params.periods,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getProductionPlanning")
+ );
+
+ server.registerTool(
+ "production_getProductionProjections",
+ {
+ description: "get production projections",
+ inputSchema: {
+ locationId: z.string(),
+ periods: z.array(z.string()),
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getProductionProjections(
+ ctx.client,
+ params.locationId,
+ params.periods,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getProductionProjections")
+ );
+
+ server.registerTool(
+ "production_getProductionQuantity",
+ {
+ description: "get production quantity",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getProductionQuantity(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: production_getProductionQuantity")
+ );
+
+ server.registerTool(
+ "production_getProductionQuantities",
+ {
+ description: "get production quantities",
+ inputSchema: {
+ jobOperationIds: z.array(z.string()),
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0)
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getProductionQuantities(
+ ctx.client,
+ params.jobOperationIds,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getProductionQuantities")
+ );
+
+ server.registerTool(
+ "production_getProductionDataByOperations",
+ {
+ description: "get production data by operations",
+ inputSchema: {
+ jobOperationIds: z.array(z.string())
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getProductionDataByOperations(
+ ctx.client,
+ params.jobOperationIds
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getProductionDataByOperations")
+ );
+
+ server.registerTool(
+ "production_getScrapReasonsList",
+ {
+ description: "get scrap reasons list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getScrapReasonsList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: production_getScrapReasonsList")
+ );
+
+ server.registerTool(
+ "production_getScrapReason",
+ {
+ description: "get scrap reason",
+ inputSchema: {
+ scrapReasonId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getScrapReason(ctx.client, params.scrapReasonId);
+ return toMcpResult(result);
+ }, "Failed: production_getScrapReason")
+ );
+
+ server.registerTool(
+ "production_getScrapReasons",
+ {
+ description: "get scrap reasons",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getScrapReasons(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getScrapReasons")
+ );
+
+ server.registerTool(
+ "production_getFailureMode",
+ {
+ description: "get failure mode",
+ inputSchema: {
+ failureModeId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getFailureMode(ctx.client, params.failureModeId);
+ return toMcpResult(result);
+ }, "Failed: production_getFailureMode")
+ );
+
+ server.registerTool(
+ "production_getFailureModes",
+ {
+ description: "get failure modes",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getFailureModes(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getFailureModes")
+ );
+
+ server.registerTool(
+ "production_getFailureModesList",
+ {
+ description: "get failure modes list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getFailureModesList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: production_getFailureModesList")
+ );
+
+ server.registerTool(
+ "production_getMaintenanceDispatch",
+ {
+ description: "get maintenance dispatch",
+ inputSchema: {
+ dispatchId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceDispatch(
+ ctx.client,
+ params.dispatchId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getMaintenanceDispatch")
+ );
+
+ server.registerTool(
+ "production_getMaintenanceDispatches",
+ {
+ description: "get maintenance dispatches",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ status: z.string().optional()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceDispatches(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getMaintenanceDispatches")
+ );
+
+ server.registerTool(
+ "production_getMaintenanceDispatchComments",
+ {
+ description: "get maintenance dispatch comments",
+ inputSchema: {
+ dispatchId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceDispatchComments(
+ ctx.client,
+ params.dispatchId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getMaintenanceDispatchComments")
+ );
+
+ server.registerTool(
+ "production_getMaintenanceDispatchEvents",
+ {
+ description: "get maintenance dispatch events",
+ inputSchema: {
+ dispatchId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceDispatchEvents(
+ ctx.client,
+ params.dispatchId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getMaintenanceDispatchEvents")
+ );
+
+ server.registerTool(
+ "production_getMaintenanceDispatchItems",
+ {
+ description: "get maintenance dispatch items",
+ inputSchema: {
+ dispatchId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceDispatchItems(
+ ctx.client,
+ params.dispatchId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getMaintenanceDispatchItems")
+ );
+
+ server.registerTool(
+ "production_getMaintenanceDispatchWorkCenters",
+ {
+ description: "get maintenance dispatch work centers",
+ inputSchema: {
+ dispatchId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceDispatchWorkCenters(
+ ctx.client,
+ params.dispatchId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getMaintenanceDispatchWorkCenters")
+ );
+
+ server.registerTool(
+ "production_getMaintenanceSchedule",
+ {
+ description: "get maintenance schedule",
+ inputSchema: {
+ scheduleId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceSchedule(
+ ctx.client,
+ params.scheduleId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getMaintenanceSchedule")
+ );
+
+ server.registerTool(
+ "production_getMaintenanceSchedules",
+ {
+ description: "get maintenance schedules",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ active: z.boolean().optional()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceSchedules(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getMaintenanceSchedules")
+ );
+
+ server.registerTool(
+ "production_getMaintenanceScheduleItems",
+ {
+ description: "get maintenance schedule items",
+ inputSchema: {
+ scheduleId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceScheduleItems(
+ ctx.client,
+ params.scheduleId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_getMaintenanceScheduleItems")
+ );
+
+ server.registerTool(
+ "production_getTrackedEntityByJobId",
+ {
+ description: "get tracked entity by job id",
+ inputSchema: {
+ jobId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTrackedEntityByJobId(ctx.client, params.jobId);
+ return toMcpResult(result);
+ }, "Failed: production_getTrackedEntityByJobId")
+ );
+
+ server.registerTool(
+ "production_getTrackedEntitiesByJobId",
+ {
+ description: "get tracked entities by job id",
+ inputSchema: {
+ jobId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTrackedEntitiesByJobId(ctx.client, params.jobId);
+ return toMcpResult(result);
+ }, "Failed: production_getTrackedEntitiesByJobId")
+ );
+
+ server.registerTool(
+ "production_recalculateJobOperationDependencies",
+ {
+ description: "recalculate job operation dependencies",
+ inputSchema: {
+ params: z.object({
+ jobId: z.string()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await recalculateJobOperationDependencies(ctx.client, {
+ ...params.params,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_recalculateJobOperationDependencies")
+ );
+
+ server.registerTool(
+ "production_recalculateJobRequirements",
+ {
+ description: "recalculate job requirements",
+ inputSchema: {
+ params: z.object({
+ id: z.string()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await recalculateJobRequirements(ctx.client, {
+ ...params.params,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_recalculateJobRequirements")
+ );
+
+ server.registerTool(
+ "production_recalculateJobMakeMethodRequirements",
+ {
+ description: "recalculate job make method requirements",
+ inputSchema: {
+ params: z.object({
+ id: z.string()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await recalculateJobMakeMethodRequirements(ctx.client, {
+ ...params.params,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_recalculateJobMakeMethodRequirements")
+ );
+
+ server.registerTool(
+ "production_runMRP",
+ {
+ description: "run m r p",
+ inputSchema: {
+ params: z.object({
+ type: z.any(),
+ id: z.string()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await runMRP(ctx.client, {
+ ...params.params,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_runMRP")
+ );
+
+ server.registerTool(
+ "production_updateJobBatchNumber",
+ {
+ description: "update job batch number",
+ inputSchema: {
+ trackedEntityId: z.string(),
+ value: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateJobBatchNumber(
+ ctx.client,
+ params.trackedEntityId,
+ params.value
+ );
+ return toMcpResult(result);
+ }, "Failed: production_updateJobBatchNumber")
+ );
+
+ server.registerTool(
+ "production_updateJobStatus",
+ {
+ description: "update job status",
+ inputSchema: {
+ params: z.object({
+ id: z.string(),
+ status: z.any(),
+ assignee: z.string().nullable().optional()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateJobStatus(ctx.client, {
+ ...params.params,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_updateJobStatus")
+ );
+
+ server.registerTool(
+ "production_updateJobMaterialOrder",
+ {
+ description: "update job material order",
+ inputSchema: {
+ updates: z.object({
+ id: z.string(),
+ order: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateJobMaterialOrder(ctx.client, {
+ ...params.updates,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_updateJobMaterialOrder")
+ );
+
+ server.registerTool(
+ "production_updateJobOperationOrder",
+ {
+ description: "update job operation order",
+ inputSchema: {
+ updates: z.object({
+ id: z.string(),
+ order: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateJobOperationOrder(ctx.client, {
+ ...params.updates,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_updateJobOperationOrder")
+ );
+
+ server.registerTool(
+ "production_updateJobOperationStepOrder",
+ {
+ description: "update job operation step order",
+ inputSchema: {
+ updates: z.object({
+ id: z.string(),
+ sortOrder: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateJobOperationStepOrder(ctx.client, {
+ ...params.updates,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_updateJobOperationStepOrder")
+ );
+
+ server.registerTool(
+ "production_updateKanbanJob",
+ {
+ description: "update kanban job",
+ inputSchema: {
+ params: z.object({
+ id: z.string(),
+ jobId: z.string().nullable()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateKanbanJob(ctx.client, {
+ ...params.params,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_updateKanbanJob")
+ );
+
+ server.registerTool(
+ "production_updateQuoteOperationStepOrder",
+ {
+ description: "update quote operation step order",
+ inputSchema: {
+ updates: z.object({
+ id: z.string(),
+ sortOrder: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateQuoteOperationStepOrder(ctx.client, {
+ ...params.updates,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_updateQuoteOperationStepOrder")
+ );
+
+ server.registerTool(
+ "production_updateMethodOperationStepOrder",
+ {
+ description: "update method operation step order",
+ inputSchema: {
+ updates: z.object({
+ id: z.string(),
+ sortOrder: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateMethodOperationStepOrder(ctx.client, {
+ ...params.updates,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_updateMethodOperationStepOrder")
+ );
+
+ server.registerTool(
+ "production_updateJobOperationStatus",
+ {
+ description: "update job operation status",
+ inputSchema: {
+ id: z.string(),
+ status: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateJobOperationStatus(
+ ctx.client,
+ params.id,
+ params.status,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_updateJobOperationStatus")
+ );
+
+ server.registerTool(
+ "production_updateJobOperationDueDate",
+ {
+ description: "update job operation due date",
+ inputSchema: {
+ id: z.string(),
+ dueDate: z.string().nullable()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateJobOperationDueDate(
+ ctx.client,
+ params.id,
+ params.dueDate,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: production_updateJobOperationDueDate")
+ );
+
+ server.registerTool(
+ "production_updateProcedureStepOrder",
+ {
+ description: "update procedure step order",
+ inputSchema: {
+ updates: z.object({
+ id: z.string(),
+ sortOrder: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateProcedureStepOrder(ctx.client, {
+ ...params.updates,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_updateProcedureStepOrder")
+ );
+
+ server.registerTool(
+ "production_upsertProductionEvent",
+ {
+ description: "upsert production event",
+ inputSchema: {
+ productionEvent: productionEventValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertProductionEvent(ctx.client, {
+ ...params.productionEvent,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertProductionEvent")
+ );
+
+ server.registerTool(
+ "production_updateProductionQuantity",
+ {
+ description: "update production quantity",
+ inputSchema: {
+ productionQuantity: productionQuantityValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateProductionQuantity(ctx.client, {
+ ...params.productionQuantity,
+ companyId: ctx.companyId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_updateProductionQuantity")
+ );
+
+ server.registerTool(
+ "production_upsertProductionQuantity",
+ {
+ description: "upsert production quantity",
+ inputSchema: {
+ productionQuantity: productionQuantityValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertProductionQuantity(ctx.client, {
+ ...params.productionQuantity,
+ companyId: ctx.companyId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertProductionQuantity")
+ );
+
+ server.registerTool(
+ "production_upsertJob",
+ {
+ description: "upsert job",
+ inputSchema: {
+ job: jobValidator,
+ status: z.any().optional()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertJob(
+ ctx.client,
+ {
+ ...params.job,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ },
+ params.status
+ );
+ return toMcpResult(result);
+ }, "Failed: production_upsertJob")
+ );
+
+ server.registerTool(
+ "production_upsertJobMaterial",
+ {
+ description: "upsert job material",
+ inputSchema: {
+ jobMaterial: jobMaterialValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertJobMaterial(ctx.client, {
+ ...params.jobMaterial,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertJobMaterial")
+ );
+
+ server.registerTool(
+ "production_upsertJobOperation",
+ {
+ description: "upsert job operation",
+ inputSchema: {
+ jobOperation: jobOperationValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertJobOperation(ctx.client, {
+ ...params.jobOperation,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertJobOperation")
+ );
+
+ server.registerTool(
+ "production_upsertJobOperationStep",
+ {
+ description: "upsert job operation step",
+ inputSchema: {
+ jobOperationStep: operationStepValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertJobOperationStep(ctx.client, {
+ ...params.jobOperationStep,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertJobOperationStep")
+ );
+
+ server.registerTool(
+ "production_upsertJobOperationParameter",
+ {
+ description: "upsert job operation parameter",
+ inputSchema: {
+ jobOperationParameter: operationParameterValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertJobOperationParameter(ctx.client, {
+ ...params.jobOperationParameter,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertJobOperationParameter")
+ );
+
+ server.registerTool(
+ "production_upsertJobOperationTool",
+ {
+ description: "upsert job operation tool",
+ inputSchema: {
+ jobOperationTool: operationToolValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertJobOperationTool(ctx.client, {
+ ...params.jobOperationTool,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertJobOperationTool")
+ );
+
+ server.registerTool(
+ "production_upsertJobMethod",
+ {
+ description: "upsert job method",
+ inputSchema: {
+ type: z.string(),
+ jobMethod: z.object({
+ sourceId: z.string(),
+ targetId: z.string(),
+ configuration: z.any().optional(),
+ parts: z.any().optional(),
+ billOfMaterial: z.boolean(),
+ billOfProcess: z.boolean(),
+ parameters: z.boolean(),
+ tools: z.boolean(),
+ steps: z.boolean(),
+ workInstructions: z.boolean()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertJobMethod(ctx.client, params.type, {
+ ...params.jobMethod,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertJobMethod")
+ );
+
+ server.registerTool(
+ "production_upsertJobMaterialMakeMethod",
+ {
+ description: "upsert job material make method",
+ inputSchema: {
+ jobMaterial: z.object({
+ sourceId: z.string(),
+ targetId: z.string(),
+ configuration: z.any().optional(),
+ parts: z.any().optional(),
+ billOfMaterial: z.boolean(),
+ billOfProcess: z.boolean(),
+ parameters: z.boolean(),
+ tools: z.boolean(),
+ steps: z.boolean(),
+ workInstructions: z.boolean()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertJobMaterialMakeMethod(ctx.client, {
+ ...params.jobMaterial,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertJobMaterialMakeMethod")
+ );
+
+ server.registerTool(
+ "production_upsertMakeMethodFromJob",
+ {
+ description: "upsert make method from job",
+ inputSchema: {
+ jobMethod: z.object({
+ sourceId: z.string(),
+ targetId: z.string(),
+ parts: z.any().optional(),
+ billOfMaterial: z.boolean(),
+ billOfProcess: z.boolean(),
+ parameters: z.boolean(),
+ tools: z.boolean(),
+ steps: z.boolean(),
+ workInstructions: z.boolean()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMakeMethodFromJob(ctx.client, {
+ ...params.jobMethod,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertMakeMethodFromJob")
+ );
+
+ server.registerTool(
+ "production_upsertMakeMethodFromJobMethod",
+ {
+ description: "upsert make method from job method",
+ inputSchema: {
+ jobMethod: z.object({
+ sourceId: z.string(),
+ targetId: z.string(),
+ parts: z.any().optional(),
+ billOfMaterial: z.boolean(),
+ billOfProcess: z.boolean(),
+ parameters: z.boolean(),
+ tools: z.boolean(),
+ steps: z.boolean(),
+ workInstructions: z.boolean()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMakeMethodFromJobMethod(ctx.client, {
+ ...params.jobMethod,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertMakeMethodFromJobMethod")
+ );
+
+ server.registerTool(
+ "production_upsertProcedure",
+ {
+ description: "upsert procedure",
+ inputSchema: {
+ procedure: procedureValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertProcedure(ctx.client, {
+ ...params.procedure,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertProcedure")
+ );
+
+ server.registerTool(
+ "production_upsertProcedureStep",
+ {
+ description: "upsert procedure step",
+ inputSchema: {
+ procedureStep: procedureStepValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertProcedureStep(ctx.client, {
+ ...params.procedureStep,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertProcedureStep")
+ );
+
+ server.registerTool(
+ "production_upsertProcedureParameter",
+ {
+ description: "upsert procedure parameter",
+ inputSchema: {
+ procedureParameter: procedureParameterValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertProcedureParameter(ctx.client, {
+ ...params.procedureParameter,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertProcedureParameter")
+ );
+
+ server.registerTool(
+ "production_upsertScrapReason",
+ {
+ description: "upsert scrap reason",
+ inputSchema: {
+ scrapReason: scrapReasonValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertScrapReason(ctx.client, {
+ ...params.scrapReason,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertScrapReason")
+ );
+
+ server.registerTool(
+ "production_upsertFailureMode",
+ {
+ description: "upsert failure mode",
+ inputSchema: {
+ failureMode: failureModeValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertFailureMode(ctx.client, {
+ ...params.failureMode,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertFailureMode")
+ );
+
+ server.registerTool(
+ "production_upsertMaintenanceDispatch",
+ {
+ description: "upsert maintenance dispatch",
+ inputSchema: {
+ dispatch: maintenanceDispatchValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaintenanceDispatch(ctx.client, {
+ ...params.dispatch,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertMaintenanceDispatch")
+ );
+
+ server.registerTool(
+ "production_upsertMaintenanceDispatchComment",
+ {
+ description: "upsert maintenance dispatch comment",
+ inputSchema: {
+ comment: maintenanceDispatchCommentValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaintenanceDispatchComment(ctx.client, {
+ ...params.comment,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertMaintenanceDispatchComment")
+ );
+
+ server.registerTool(
+ "production_upsertMaintenanceDispatchEvent",
+ {
+ description: "upsert maintenance dispatch event",
+ inputSchema: {
+ event: maintenanceDispatchEventValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaintenanceDispatchEvent(ctx.client, {
+ ...params.event,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertMaintenanceDispatchEvent")
+ );
+
+ server.registerTool(
+ "production_upsertMaintenanceDispatchItem",
+ {
+ description: "upsert maintenance dispatch item",
+ inputSchema: {
+ item: maintenanceDispatchItemValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaintenanceDispatchItem(ctx.client, {
+ ...params.item,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertMaintenanceDispatchItem")
+ );
+
+ server.registerTool(
+ "production_upsertMaintenanceDispatchWorkCenter",
+ {
+ description: "upsert maintenance dispatch work center",
+ inputSchema: {
+ workCenter: maintenanceDispatchWorkCenterValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaintenanceDispatchWorkCenter(ctx.client, {
+ ...params.workCenter,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertMaintenanceDispatchWorkCenter")
+ );
+
+ server.registerTool(
+ "production_upsertMaintenanceSchedule",
+ {
+ description: "upsert maintenance schedule",
+ inputSchema: {
+ schedule: maintenanceScheduleValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaintenanceSchedule(ctx.client, {
+ ...params.schedule,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertMaintenanceSchedule")
+ );
+
+ server.registerTool(
+ "production_upsertMaintenanceScheduleItem",
+ {
+ description: "upsert maintenance schedule item",
+ inputSchema: {
+ item: maintenanceScheduleItemValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaintenanceScheduleItem(ctx.client, {
+ ...params.item,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertMaintenanceScheduleItem")
+ );
+
+ server.registerTool(
+ "production_upsertDemandForecasts",
+ {
+ description: "upsert demand forecasts",
+ inputSchema: {
+ forecasts: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertDemandForecasts(ctx.client, {
+ ...params.forecasts,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertDemandForecasts")
+ );
+
+ server.registerTool(
+ "production_upsertDemandProjections",
+ {
+ description: "upsert demand projections",
+ inputSchema: {
+ forecasts: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertDemandProjections(ctx.client, {
+ ...params.forecasts,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: production_upsertDemandProjections")
+ );
+};
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tools/purchasing.ts b/apps/erp/app/routes/api+/mcp+/lib/tools/purchasing.ts
new file mode 100644
index 0000000000..2713f7afaf
--- /dev/null
+++ b/apps/erp/app/routes/api+/mcp+/lib/tools/purchasing.ts
@@ -0,0 +1,1934 @@
+// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+import { z } from "zod";
+import {
+ purchaseOrderDeliveryValidator,
+ purchaseOrderLineValidator,
+ purchaseOrderPaymentValidator,
+ purchaseOrderValidator,
+ selectedLinesValidator,
+ supplierAccountingValidator,
+ supplierContactValidator,
+ supplierPaymentValidator,
+ supplierProcessValidator,
+ supplierQuoteLineValidator,
+ supplierQuoteValidator,
+ supplierShippingValidator,
+ supplierTypeValidator,
+ supplierValidator
+} from "~/modules/purchasing/purchasing.models";
+import {
+ closePurchaseOrder,
+ convertSupplierQuoteToOrder,
+ deletePurchaseOrder,
+ deletePurchaseOrderLine,
+ deletePurchasingRFQ,
+ deletePurchasingRFQLine,
+ deleteSupplier,
+ deleteSupplierContact,
+ deleteSupplierLocation,
+ deleteSupplierProcess,
+ deleteSupplierQuote,
+ deleteSupplierQuoteLine,
+ deleteSupplierType,
+ finalizePurchaseOrder,
+ finalizeSupplierQuote,
+ getLinkedPurchasingRfqs,
+ getLinkedPurchasingRfqsForInteraction,
+ getLinkedPurchasingRfqsForOrder,
+ getLinkedSupplierQuotes,
+ getPurchaseOrder,
+ getPurchaseOrderDelivery,
+ getPurchaseOrderLine,
+ getPurchaseOrderLines,
+ getPurchaseOrderLocations,
+ getPurchaseOrderPayment,
+ getPurchaseOrderSuppliers,
+ getPurchaseOrders,
+ getPurchasingDocumentsAssignedToMe,
+ getPurchasingPlanning,
+ getPurchasingRFQ,
+ getPurchasingRFQLine,
+ getPurchasingRFQLines,
+ getPurchasingRFQSuppliers,
+ getPurchasingRFQSuppliersWithLinks,
+ getPurchasingRFQs,
+ getPurchasingTerms,
+ getSiblingQuotesForQuote,
+ getSupplier,
+ getSupplierApprovalContext,
+ getSupplierContact,
+ getSupplierContacts,
+ getSupplierInteraction,
+ getSupplierInteractionDocuments,
+ getSupplierInteractionLineDocuments,
+ getSupplierLocation,
+ getSupplierLocations,
+ getSupplierPayment,
+ getSupplierProcessById,
+ getSupplierProcessesByProcess,
+ getSupplierProcessesBySupplier,
+ getSupplierQuote,
+ getSupplierQuoteByExternalLinkId,
+ getSupplierQuoteByInteractionId,
+ getSupplierQuoteLine,
+ getSupplierQuoteLinePrices,
+ getSupplierQuoteLinePricesByQuoteId,
+ getSupplierQuoteLines,
+ getSupplierQuotes,
+ getSupplierQuotesForComparison,
+ getSupplierQuotesList,
+ getSupplierShipping,
+ getSuppliers,
+ getSuppliersList,
+ getSupplierType,
+ getSupplierTypes,
+ getSupplierTypesList,
+ insertSupplier,
+ insertSupplierContact,
+ insertSupplierInteraction,
+ insertSupplierLocation,
+ sendSupplierQuote,
+ updatePurchaseOrder,
+ updatePurchaseOrderExchangeRate,
+ updatePurchaseOrderFavorite,
+ updatePurchaseOrderStatus,
+ updatePurchasingRFQStatus,
+ updateSupplierAccounting,
+ updateSupplierContact,
+ updateSupplierLocation,
+ updateSupplierPayment,
+ updateSupplierQuoteExchangeRate,
+ updateSupplierQuoteFavorite,
+ updateSupplierQuoteStatus,
+ updateSupplierShipping,
+ upsertPurchaseOrder,
+ upsertPurchaseOrderDelivery,
+ upsertPurchaseOrderLine,
+ upsertPurchaseOrderPayment,
+ upsertPurchasingRFQ,
+ upsertPurchasingRFQLine,
+ upsertPurchasingRFQSuppliers,
+ upsertSupplier,
+ upsertSupplierProcess,
+ upsertSupplierQuote,
+ upsertSupplierQuoteLine,
+ upsertSupplierType
+} from "~/modules/purchasing/purchasing.service";
+import type { RegisterTools } from "../types";
+import {
+ DESTRUCTIVE_ANNOTATIONS,
+ READ_ONLY_ANNOTATIONS,
+ toMcpResult,
+ WRITE_ANNOTATIONS,
+ withErrorHandling
+} from "../types";
+
+export const registerPurchasingTools: RegisterTools = (server, ctx) => {
+ server.registerTool(
+ "purchasing_closePurchaseOrder",
+ {
+ description: "close purchase order",
+ inputSchema: {
+ purchaseOrderId: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await closePurchaseOrder(
+ ctx.client,
+ params.purchaseOrderId,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_closePurchaseOrder")
+ );
+
+ server.registerTool(
+ "purchasing_convertSupplierQuoteToOrder",
+ {
+ description: "convert supplier quote to order",
+ inputSchema: {
+ payload: selectedLinesValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await convertSupplierQuoteToOrder(ctx.client, {
+ ...params.payload,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_convertSupplierQuoteToOrder")
+ );
+
+ server.registerTool(
+ "purchasing_deletePurchaseOrder",
+ {
+ description: "delete purchase order",
+ inputSchema: {
+ purchaseOrderId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deletePurchaseOrder(
+ ctx.client,
+ params.purchaseOrderId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_deletePurchaseOrder")
+ );
+
+ server.registerTool(
+ "purchasing_deletePurchaseOrderLine",
+ {
+ description: "delete purchase order line",
+ inputSchema: {
+ purchaseOrderLineId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deletePurchaseOrderLine(
+ ctx.client,
+ params.purchaseOrderLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_deletePurchaseOrderLine")
+ );
+
+ server.registerTool(
+ "purchasing_deleteSupplier",
+ {
+ description: "delete supplier",
+ inputSchema: {
+ supplierId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteSupplier(ctx.client, params.supplierId);
+ return toMcpResult(result);
+ }, "Failed: purchasing_deleteSupplier")
+ );
+
+ server.registerTool(
+ "purchasing_deleteSupplierContact",
+ {
+ description: "delete supplier contact",
+ inputSchema: {
+ supplierId: z.string(),
+ supplierContactId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteSupplierContact(
+ ctx.client,
+ params.supplierId,
+ params.supplierContactId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_deleteSupplierContact")
+ );
+
+ server.registerTool(
+ "purchasing_deleteSupplierLocation",
+ {
+ description: "delete supplier location",
+ inputSchema: {
+ supplierId: z.string(),
+ supplierLocationId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteSupplierLocation(
+ ctx.client,
+ params.supplierId,
+ params.supplierLocationId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_deleteSupplierLocation")
+ );
+
+ server.registerTool(
+ "purchasing_deleteSupplierProcess",
+ {
+ description: "delete supplier process",
+ inputSchema: {
+ supplierProcessId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteSupplierProcess(
+ ctx.client,
+ params.supplierProcessId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_deleteSupplierProcess")
+ );
+
+ server.registerTool(
+ "purchasing_deleteSupplierQuote",
+ {
+ description: "delete supplier quote",
+ inputSchema: {
+ supplierQuoteId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteSupplierQuote(
+ ctx.client,
+ params.supplierQuoteId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_deleteSupplierQuote")
+ );
+
+ server.registerTool(
+ "purchasing_deleteSupplierQuoteLine",
+ {
+ description: "delete supplier quote line",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteSupplierQuoteLine(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: purchasing_deleteSupplierQuoteLine")
+ );
+
+ server.registerTool(
+ "purchasing_deleteSupplierType",
+ {
+ description: "delete supplier type",
+ inputSchema: {
+ supplierTypeId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteSupplierType(
+ ctx.client,
+ params.supplierTypeId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_deleteSupplierType")
+ );
+
+ server.registerTool(
+ "purchasing_getPurchaseOrder",
+ {
+ description: "get purchase order",
+ inputSchema: {
+ purchaseOrderId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchaseOrder(ctx.client, params.purchaseOrderId);
+ return toMcpResult(result);
+ }, "Failed: purchasing_getPurchaseOrder")
+ );
+
+ server.registerTool(
+ "purchasing_finalizeSupplierQuote",
+ {
+ description: "finalize supplier quote",
+ inputSchema: {
+ supplierQuoteId: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await finalizeSupplierQuote(
+ ctx.client,
+ params.supplierQuoteId,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_finalizeSupplierQuote")
+ );
+
+ server.registerTool(
+ "purchasing_getPurchaseOrders",
+ {
+ description: "get purchase orders",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ status: z.string().nullable(),
+ supplierId: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchaseOrders(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getPurchaseOrders")
+ );
+
+ server.registerTool(
+ "purchasing_getPurchaseOrderDelivery",
+ {
+ description: "get purchase order delivery",
+ inputSchema: {
+ purchaseOrderId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchaseOrderDelivery(
+ ctx.client,
+ params.purchaseOrderId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getPurchaseOrderDelivery")
+ );
+
+ server.registerTool(
+ "purchasing_getPurchaseOrderLocations",
+ {
+ description: "get purchase order locations",
+ inputSchema: {
+ purchaseOrderId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchaseOrderLocations(
+ ctx.client,
+ params.purchaseOrderId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getPurchaseOrderLocations")
+ );
+
+ server.registerTool(
+ "purchasing_getPurchaseOrderPayment",
+ {
+ description: "get purchase order payment",
+ inputSchema: {
+ purchaseOrderId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchaseOrderPayment(
+ ctx.client,
+ params.purchaseOrderId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getPurchaseOrderPayment")
+ );
+
+ server.registerTool(
+ "purchasing_getPurchaseOrderLines",
+ {
+ description: "get purchase order lines",
+ inputSchema: {
+ purchaseOrderId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchaseOrderLines(
+ ctx.client,
+ params.purchaseOrderId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getPurchaseOrderLines")
+ );
+
+ server.registerTool(
+ "purchasing_getPurchaseOrderLine",
+ {
+ description: "get purchase order line",
+ inputSchema: {
+ purchaseOrderLineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchaseOrderLine(
+ ctx.client,
+ params.purchaseOrderLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getPurchaseOrderLine")
+ );
+
+ server.registerTool(
+ "purchasing_getPurchaseOrderSuppliers",
+ {
+ description: "get purchase order suppliers",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchaseOrderSuppliers(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: purchasing_getPurchaseOrderSuppliers")
+ );
+
+ server.registerTool(
+ "purchasing_getPurchasingDocumentsAssignedToMe",
+ {
+ description: "get purchasing documents assigned to me",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchasingDocumentsAssignedToMe(
+ ctx.client,
+ ctx.userId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getPurchasingDocumentsAssignedToMe")
+ );
+
+ server.registerTool(
+ "purchasing_getPurchasingPlanning",
+ {
+ description: "get purchasing planning",
+ inputSchema: {
+ locationId: z.string(),
+ periods: z.array(z.string()),
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchasingPlanning(
+ ctx.client,
+ params.locationId,
+ ctx.companyId,
+ params.periods,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getPurchasingPlanning")
+ );
+
+ server.registerTool(
+ "purchasing_getPurchasingTerms",
+ {
+ description: "get purchasing terms",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchasingTerms(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: purchasing_getPurchasingTerms")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplier",
+ {
+ description: "get supplier",
+ inputSchema: {
+ supplierId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplier(ctx.client, params.supplierId);
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplier")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierApprovalContext",
+ {
+ description: "get supplier approval context",
+ inputSchema: {
+ supplierId: z.string(),
+ status: z.string().nullable()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierApprovalContext(
+ ctx.client,
+ params.supplierId,
+ params.status,
+ ctx.companyId,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierApprovalContext")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierContact",
+ {
+ description: "get supplier contact",
+ inputSchema: {
+ supplierContactId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierContact(
+ ctx.client,
+ params.supplierContactId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierContact")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierContacts",
+ {
+ description: "get supplier contacts",
+ inputSchema: {
+ supplierId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierContacts(ctx.client, params.supplierId);
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierContacts")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierInteraction",
+ {
+ description: "get supplier interaction",
+ inputSchema: {
+ opportunityId: z.string().nullable()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierInteraction(
+ ctx.client,
+ params.opportunityId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierInteraction")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierInteractionDocuments",
+ {
+ description: "get supplier interaction documents",
+ inputSchema: {
+ interactionId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierInteractionDocuments(
+ ctx.client,
+ ctx.companyId,
+ params.interactionId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierInteractionDocuments")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierInteractionLineDocuments",
+ {
+ description: "get supplier interaction line documents",
+ inputSchema: {
+ lineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierInteractionLineDocuments(
+ ctx.client,
+ ctx.companyId,
+ params.lineId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierInteractionLineDocuments")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierLocations",
+ {
+ description: "get supplier locations",
+ inputSchema: {
+ supplierId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierLocations(ctx.client, params.supplierId);
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierLocations")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierLocation",
+ {
+ description: "get supplier location",
+ inputSchema: {
+ supplierContactId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierLocation(
+ ctx.client,
+ params.supplierContactId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierLocation")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierPayment",
+ {
+ description: "get supplier payment",
+ inputSchema: {
+ supplierId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierPayment(ctx.client, params.supplierId);
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierPayment")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierProcessById",
+ {
+ description: "get supplier process by id",
+ inputSchema: {
+ supplierProcessId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierProcessById(
+ ctx.client,
+ params.supplierProcessId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierProcessById")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierProcessesByProcess",
+ {
+ description: "get supplier processes by process",
+ inputSchema: {
+ processId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierProcessesByProcess(
+ ctx.client,
+ params.processId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierProcessesByProcess")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierProcessesBySupplier",
+ {
+ description: "get supplier processes by supplier",
+ inputSchema: {
+ supplierId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierProcessesBySupplier(
+ ctx.client,
+ params.supplierId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierProcessesBySupplier")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierQuote",
+ {
+ description: "get supplier quote",
+ inputSchema: {
+ supplierQuoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierQuote(ctx.client, params.supplierQuoteId);
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierQuote")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierQuoteByInteractionId",
+ {
+ description: "get supplier quote by interaction id",
+ inputSchema: {
+ interactionId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierQuoteByInteractionId(
+ ctx.client,
+ params.interactionId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierQuoteByInteractionId")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierQuoteByExternalLinkId",
+ {
+ description: "get supplier quote by external link id",
+ inputSchema: {
+ externalLinkId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierQuoteByExternalLinkId(
+ ctx.client,
+ params.externalLinkId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierQuoteByExternalLinkId")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierQuotes",
+ {
+ description: "get supplier quotes",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierQuotes(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierQuotes")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierQuoteLine",
+ {
+ description: "get supplier quote line",
+ inputSchema: {
+ supplierQuoteLineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierQuoteLine(
+ ctx.client,
+ params.supplierQuoteLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierQuoteLine")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierQuoteLines",
+ {
+ description: "get supplier quote lines",
+ inputSchema: {
+ supplierQuoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierQuoteLines(
+ ctx.client,
+ params.supplierQuoteId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierQuoteLines")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierQuoteLinePrices",
+ {
+ description: "get supplier quote line prices",
+ inputSchema: {
+ supplierQuoteLineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierQuoteLinePrices(
+ ctx.client,
+ params.supplierQuoteLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierQuoteLinePrices")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierQuoteLinePricesByQuoteId",
+ {
+ description: "get supplier quote line prices by quote id",
+ inputSchema: {
+ supplierQuoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierQuoteLinePricesByQuoteId(
+ ctx.client,
+ params.supplierQuoteId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierQuoteLinePricesByQuoteId")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierQuotesList",
+ {
+ description: "get supplier quotes list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierQuotesList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierQuotesList")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierShipping",
+ {
+ description: "get supplier shipping",
+ inputSchema: {
+ supplierId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierShipping(ctx.client, params.supplierId);
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierShipping")
+ );
+
+ server.registerTool(
+ "purchasing_getSuppliers",
+ {
+ description: "get suppliers",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ type: z.string().nullable(),
+ status: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSuppliers(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSuppliers")
+ );
+
+ server.registerTool(
+ "purchasing_getSuppliersList",
+ {
+ description: "get suppliers list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSuppliersList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSuppliersList")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierType",
+ {
+ description: "get supplier type",
+ inputSchema: {
+ supplierTypeId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierType(ctx.client, params.supplierTypeId);
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierType")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierTypes",
+ {
+ description: "get supplier types",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierTypes(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierTypes")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierTypesList",
+ {
+ description: "get supplier types list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierTypesList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierTypesList")
+ );
+
+ server.registerTool(
+ "purchasing_insertSupplier",
+ {
+ description: "insert supplier",
+ inputSchema: {
+ supplier: supplierValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertSupplier(ctx.client, {
+ ...params.supplier,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_insertSupplier")
+ );
+
+ server.registerTool(
+ "purchasing_insertSupplierContact",
+ {
+ description: "insert supplier contact",
+ inputSchema: {
+ supplierContact: supplierContactValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertSupplierContact(ctx.client, {
+ ...params.supplierContact,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_insertSupplierContact")
+ );
+
+ server.registerTool(
+ "purchasing_insertSupplierInteraction",
+ {
+ description: "insert supplier interaction",
+ inputSchema: {
+ supplierId: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertSupplierInteraction(
+ ctx.client,
+ ctx.companyId,
+ params.supplierId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_insertSupplierInteraction")
+ );
+
+ server.registerTool(
+ "purchasing_insertSupplierLocation",
+ {
+ description: "insert supplier location",
+ inputSchema: {
+ supplierLocation: z.object({
+ supplierId: z.string(),
+ name: z.string(),
+ address: z.any(),
+ addressLine1: z.string().optional(),
+ addressLine2: z.string().optional(),
+ city: z.string().optional(),
+ stateProvince: z.string().optional(),
+ postalCode: z.string().optional(),
+ countryCode: z.string().optional(),
+ customFields: z.any().optional()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertSupplierLocation(ctx.client, {
+ ...params.supplierLocation,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_insertSupplierLocation")
+ );
+
+ server.registerTool(
+ "purchasing_finalizePurchaseOrder",
+ {
+ description: "finalize purchase order",
+ inputSchema: {
+ purchaseOrderId: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await finalizePurchaseOrder(
+ ctx.client,
+ params.purchaseOrderId,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_finalizePurchaseOrder")
+ );
+
+ server.registerTool(
+ "purchasing_sendSupplierQuote",
+ {
+ description: "send supplier quote",
+ inputSchema: {
+ supplierQuoteId: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await sendSupplierQuote(
+ ctx.client,
+ params.supplierQuoteId,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_sendSupplierQuote")
+ );
+
+ server.registerTool(
+ "purchasing_updatePurchaseOrder",
+ {
+ description: "update purchase order",
+ inputSchema: {
+ purchaseOrder: z.object({
+ id: z.string(),
+ status: z.any()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updatePurchaseOrder(ctx.client, {
+ ...params.purchaseOrder,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_updatePurchaseOrder")
+ );
+
+ server.registerTool(
+ "purchasing_updatePurchaseOrderExchangeRate",
+ {
+ description: "update purchase order exchange rate",
+ inputSchema: {
+ data: z.object({
+ id: z.string(),
+ exchangeRate: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updatePurchaseOrderExchangeRate(
+ ctx.client,
+ params.data
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_updatePurchaseOrderExchangeRate")
+ );
+
+ server.registerTool(
+ "purchasing_updatePurchaseOrderFavorite",
+ {
+ description: "update purchase order favorite",
+ inputSchema: {
+ args: z.object({
+ id: z.string(),
+ favorite: z.boolean()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updatePurchaseOrderFavorite(ctx.client, {
+ ...params.args,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_updatePurchaseOrderFavorite")
+ );
+
+ server.registerTool(
+ "purchasing_updatePurchaseOrderStatus",
+ {
+ description: "update purchase order status",
+ inputSchema: {
+ update: z.object({
+ id: z.string(),
+ status: z.any(),
+ assignee: z.any()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updatePurchaseOrderStatus(ctx.client, {
+ ...params.update,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_updatePurchaseOrderStatus")
+ );
+
+ server.registerTool(
+ "purchasing_updateSupplierAccounting",
+ {
+ description: "update supplier accounting",
+ inputSchema: {
+ supplierAccounting: supplierAccountingValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSupplierAccounting(ctx.client, {
+ ...params.supplierAccounting,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_updateSupplierAccounting")
+ );
+
+ server.registerTool(
+ "purchasing_updateSupplierContact",
+ {
+ description: "update supplier contact",
+ inputSchema: {
+ supplierContact: supplierContactValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSupplierContact(
+ ctx.client,
+ params.supplierContact
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_updateSupplierContact")
+ );
+
+ server.registerTool(
+ "purchasing_updateSupplierLocation",
+ {
+ description: "update supplier location",
+ inputSchema: {
+ supplierLocation: z.object({
+ addressId: z.string(),
+ name: z.string(),
+ address: z.any(),
+ addressLine1: z.string().optional(),
+ addressLine2: z.string().optional(),
+ city: z.string().optional(),
+ stateProvince: z.string().optional(),
+ countryCode: z.string().optional(),
+ postalCode: z.string().optional(),
+ customFields: z.any().optional()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSupplierLocation(
+ ctx.client,
+ params.supplierLocation
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_updateSupplierLocation")
+ );
+
+ server.registerTool(
+ "purchasing_updateSupplierPayment",
+ {
+ description: "update supplier payment",
+ inputSchema: {
+ supplierPayment: supplierPaymentValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSupplierPayment(ctx.client, {
+ ...params.supplierPayment,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_updateSupplierPayment")
+ );
+
+ server.registerTool(
+ "purchasing_updateSupplierQuoteExchangeRate",
+ {
+ description: "update supplier quote exchange rate",
+ inputSchema: {
+ data: z.object({
+ id: z.string(),
+ exchangeRate: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSupplierQuoteExchangeRate(
+ ctx.client,
+ params.data
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_updateSupplierQuoteExchangeRate")
+ );
+
+ server.registerTool(
+ "purchasing_updateSupplierQuoteFavorite",
+ {
+ description: "update supplier quote favorite",
+ inputSchema: {
+ args: z.object({
+ id: z.string(),
+ favorite: z.boolean()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSupplierQuoteFavorite(ctx.client, {
+ ...params.args,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_updateSupplierQuoteFavorite")
+ );
+
+ server.registerTool(
+ "purchasing_updateSupplierQuoteStatus",
+ {
+ description: "update supplier quote status",
+ inputSchema: {
+ update: z.object({
+ id: z.string(),
+ status: z.any(),
+ assignee: z.any()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSupplierQuoteStatus(ctx.client, {
+ ...params.update,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_updateSupplierQuoteStatus")
+ );
+
+ server.registerTool(
+ "purchasing_updateSupplierShipping",
+ {
+ description: "update supplier shipping",
+ inputSchema: {
+ supplierShipping: supplierShippingValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSupplierShipping(ctx.client, {
+ ...params.supplierShipping,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_updateSupplierShipping")
+ );
+
+ server.registerTool(
+ "purchasing_upsertPurchaseOrder",
+ {
+ description: "upsert purchase order",
+ inputSchema: {
+ purchaseOrder: purchaseOrderValidator,
+ receiptRequestedDate: z.string().optional()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertPurchaseOrder(
+ ctx.client,
+ {
+ ...params.purchaseOrder,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ },
+ params.receiptRequestedDate
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_upsertPurchaseOrder")
+ );
+
+ server.registerTool(
+ "purchasing_upsertPurchaseOrderDelivery",
+ {
+ description: "upsert purchase order delivery",
+ inputSchema: {
+ purchaseOrderDelivery: purchaseOrderDeliveryValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertPurchaseOrderDelivery(ctx.client, {
+ ...params.purchaseOrderDelivery,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_upsertPurchaseOrderDelivery")
+ );
+
+ server.registerTool(
+ "purchasing_upsertPurchaseOrderLine",
+ {
+ description: "upsert purchase order line",
+ inputSchema: {
+ purchaseOrderLine: purchaseOrderLineValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertPurchaseOrderLine(ctx.client, {
+ ...params.purchaseOrderLine,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_upsertPurchaseOrderLine")
+ );
+
+ server.registerTool(
+ "purchasing_upsertPurchaseOrderPayment",
+ {
+ description: "upsert purchase order payment",
+ inputSchema: {
+ purchaseOrderPayment: purchaseOrderPaymentValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertPurchaseOrderPayment(ctx.client, {
+ ...params.purchaseOrderPayment,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_upsertPurchaseOrderPayment")
+ );
+
+ server.registerTool(
+ "purchasing_upsertSupplier",
+ {
+ description: "upsert supplier",
+ inputSchema: {
+ supplier: supplierValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertSupplier(ctx.client, {
+ ...params.supplier,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_upsertSupplier")
+ );
+
+ server.registerTool(
+ "purchasing_upsertSupplierProcess",
+ {
+ description: "upsert supplier process",
+ inputSchema: {
+ supplierProcess: supplierProcessValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertSupplierProcess(ctx.client, {
+ ...params.supplierProcess,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_upsertSupplierProcess")
+ );
+
+ server.registerTool(
+ "purchasing_upsertSupplierQuote",
+ {
+ description: "upsert supplier quote",
+ inputSchema: {
+ supplierQuote: supplierQuoteValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertSupplierQuote(ctx.client, {
+ ...params.supplierQuote,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_upsertSupplierQuote")
+ );
+
+ server.registerTool(
+ "purchasing_upsertSupplierQuoteLine",
+ {
+ description: "upsert supplier quote line",
+ inputSchema: {
+ supplierQuoteLine: supplierQuoteLineValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertSupplierQuoteLine(ctx.client, {
+ ...params.supplierQuoteLine,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_upsertSupplierQuoteLine")
+ );
+
+ server.registerTool(
+ "purchasing_upsertSupplierType",
+ {
+ description: "upsert supplier type",
+ inputSchema: {
+ supplierType: supplierTypeValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertSupplierType(ctx.client, {
+ ...params.supplierType,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_upsertSupplierType")
+ );
+
+ server.registerTool(
+ "purchasing_deletePurchasingRFQ",
+ {
+ description: "delete purchasing r f q",
+ inputSchema: {
+ purchasingRfqId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deletePurchasingRFQ(
+ ctx.client,
+ params.purchasingRfqId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_deletePurchasingRFQ")
+ );
+
+ server.registerTool(
+ "purchasing_deletePurchasingRFQLine",
+ {
+ description: "delete purchasing r f q line",
+ inputSchema: {
+ purchasingRfqLineId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deletePurchasingRFQLine(
+ ctx.client,
+ params.purchasingRfqLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_deletePurchasingRFQLine")
+ );
+
+ server.registerTool(
+ "purchasing_getPurchasingRFQ",
+ {
+ description: "get purchasing r f q",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchasingRFQ(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: purchasing_getPurchasingRFQ")
+ );
+
+ server.registerTool(
+ "purchasing_getPurchasingRFQs",
+ {
+ description: "get purchasing r f qs",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchasingRFQs(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getPurchasingRFQs")
+ );
+
+ server.registerTool(
+ "purchasing_getPurchasingRFQLine",
+ {
+ description: "get purchasing r f q line",
+ inputSchema: {
+ lineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchasingRFQLine(ctx.client, params.lineId);
+ return toMcpResult(result);
+ }, "Failed: purchasing_getPurchasingRFQLine")
+ );
+
+ server.registerTool(
+ "purchasing_getPurchasingRFQLines",
+ {
+ description: "get purchasing r f q lines",
+ inputSchema: {
+ purchasingRfqId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchasingRFQLines(
+ ctx.client,
+ params.purchasingRfqId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getPurchasingRFQLines")
+ );
+
+ server.registerTool(
+ "purchasing_getPurchasingRFQSuppliers",
+ {
+ description: "get purchasing r f q suppliers",
+ inputSchema: {
+ purchasingRfqId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchasingRFQSuppliers(
+ ctx.client,
+ params.purchasingRfqId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getPurchasingRFQSuppliers")
+ );
+
+ server.registerTool(
+ "purchasing_upsertPurchasingRFQ",
+ {
+ description: "upsert purchasing r f q",
+ inputSchema: {
+ purchasingRfq: z.object({
+ id: z.string().optional(),
+ rfqId: z.string(),
+ rfqDate: z.string(),
+ expirationDate: z.string().optional(),
+ locationId: z.string().optional(),
+ employeeId: z.string().optional(),
+ status: z.any().optional(),
+ customFields: z.any().optional()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertPurchasingRFQ(ctx.client, {
+ ...params.purchasingRfq,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_upsertPurchasingRFQ")
+ );
+
+ server.registerTool(
+ "purchasing_upsertPurchasingRFQLine",
+ {
+ description: "upsert purchasing r f q line",
+ inputSchema: {
+ purchasingRfqLine: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertPurchasingRFQLine(ctx.client, {
+ ...params.purchasingRfqLine,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_upsertPurchasingRFQLine")
+ );
+
+ server.registerTool(
+ "purchasing_upsertPurchasingRFQSuppliers",
+ {
+ description: "upsert purchasing r f q suppliers",
+ inputSchema: {
+ purchasingRfqId: z.string(),
+ supplierIds: z.array(z.string())
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertPurchasingRFQSuppliers(
+ ctx.client,
+ params.purchasingRfqId,
+ params.supplierIds,
+ ctx.companyId,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_upsertPurchasingRFQSuppliers")
+ );
+
+ server.registerTool(
+ "purchasing_updatePurchasingRFQStatus",
+ {
+ description: "update purchasing r f q status",
+ inputSchema: {
+ args: z.object({
+ id: z.string(),
+ status: z.any(),
+ assignee: z.string().nullable().optional()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updatePurchasingRFQStatus(ctx.client, {
+ ...params.args,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: purchasing_updatePurchasingRFQStatus")
+ );
+
+ server.registerTool(
+ "purchasing_getLinkedSupplierQuotes",
+ {
+ description: "get linked supplier quotes",
+ inputSchema: {
+ purchasingRfqId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getLinkedSupplierQuotes(
+ ctx.client,
+ params.purchasingRfqId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getLinkedSupplierQuotes")
+ );
+
+ server.registerTool(
+ "purchasing_getLinkedPurchasingRfqs",
+ {
+ description: "get linked purchasing rfqs",
+ inputSchema: {
+ supplierQuoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getLinkedPurchasingRfqs(
+ ctx.client,
+ params.supplierQuoteId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getLinkedPurchasingRfqs")
+ );
+
+ server.registerTool(
+ "purchasing_getLinkedPurchasingRfqsForInteraction",
+ {
+ description: "get linked purchasing rfqs for interaction",
+ inputSchema: {
+ supplierInteractionId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getLinkedPurchasingRfqsForInteraction(
+ ctx.client,
+ params.supplierInteractionId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getLinkedPurchasingRfqsForInteraction")
+ );
+
+ server.registerTool(
+ "purchasing_getSiblingQuotesForQuote",
+ {
+ description: "get sibling quotes for quote",
+ inputSchema: {
+ supplierQuoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSiblingQuotesForQuote(
+ ctx.client,
+ params.supplierQuoteId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSiblingQuotesForQuote")
+ );
+
+ server.registerTool(
+ "purchasing_getLinkedPurchasingRfqsForOrder",
+ {
+ description: "get linked purchasing rfqs for order",
+ inputSchema: {
+ purchaseOrderId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getLinkedPurchasingRfqsForOrder(
+ ctx.client,
+ params.purchaseOrderId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getLinkedPurchasingRfqsForOrder")
+ );
+
+ server.registerTool(
+ "purchasing_getSupplierQuotesForComparison",
+ {
+ description: "get supplier quotes for comparison",
+ inputSchema: {
+ purchasingRfqId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSupplierQuotesForComparison(
+ ctx.client,
+ params.purchasingRfqId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getSupplierQuotesForComparison")
+ );
+
+ server.registerTool(
+ "purchasing_getPurchasingRFQSuppliersWithLinks",
+ {
+ description: "get purchasing r f q suppliers with links",
+ inputSchema: {
+ purchasingRfqId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPurchasingRFQSuppliersWithLinks(
+ ctx.client,
+ params.purchasingRfqId
+ );
+ return toMcpResult(result);
+ }, "Failed: purchasing_getPurchasingRFQSuppliersWithLinks")
+ );
+};
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tools/quality.ts b/apps/erp/app/routes/api+/mcp+/lib/tools/quality.ts
new file mode 100644
index 0000000000..aacb4e2fab
--- /dev/null
+++ b/apps/erp/app/routes/api+/mcp+/lib/tools/quality.ts
@@ -0,0 +1,1357 @@
+// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+import { z } from "zod";
+import {
+ gaugeCalibrationRecordValidator,
+ gaugeTypeValidator,
+ gaugeValidator,
+ issueTypeValidator,
+ issueValidator,
+ issueWorkflowValidator,
+ nonConformanceReviewerValidator,
+ qualityDocumentStepValidator,
+ qualityDocumentValidator,
+ riskRegisterValidator
+} from "~/modules/quality/quality.models";
+import {
+ activateGauge,
+ deactivateGauge,
+ deleteGauge,
+ deleteGaugeCalibrationRecord,
+ deleteGaugeType,
+ deleteIssue,
+ deleteIssueAssociation,
+ deleteIssueType,
+ deleteIssueWorkflow,
+ deleteQualityDocument,
+ deleteQualityDocumentStep,
+ deleteRequiredAction,
+ deleteRisk,
+ getGauge,
+ getGaugeCalibrationRecord,
+ getGaugeCalibrationRecords,
+ getGaugeCalibrationRecordsByGaugeId,
+ getGauges,
+ getGaugesList,
+ getGaugeType,
+ getGaugeTypes,
+ getGaugeTypesList,
+ getIssue,
+ getIssueAction,
+ getIssueActionTasks,
+ getIssueApprovalTasks,
+ getIssueAssociations,
+ getIssueFromExternalLink,
+ getIssueItems,
+ getIssueReviewers,
+ getIssueSuppliers,
+ getIssues,
+ getIssueTasks,
+ getIssueType,
+ getIssueTypes,
+ getIssueTypesList,
+ getIssueWorkflow,
+ getIssueWorkflows,
+ getIssueWorkflowsList,
+ getQualityActions,
+ getQualityDocument,
+ getQualityDocumentSteps,
+ getQualityDocuments,
+ getQualityDocumentsList,
+ getQualityDocumentVersions,
+ getQualityFiles,
+ getRequiredAction,
+ getRequiredActions,
+ getRequiredActionsList,
+ getRisk,
+ getRisks,
+ insertIssueReviewer,
+ updateIssueActionProcesses,
+ updateIssueStatus,
+ updateIssueTaskContent,
+ updateIssueTaskStatus,
+ updateQualityDocumentStepOrder,
+ updateRiskStatus,
+ upsertGauge,
+ upsertGaugeCalibrationRecord,
+ upsertGaugeType,
+ upsertIssue,
+ upsertIssueType,
+ upsertIssueWorkflow,
+ upsertQualityDocument,
+ upsertQualityDocumentStep,
+ upsertRequiredAction,
+ upsertRisk
+} from "~/modules/quality/quality.service";
+import type { RegisterTools } from "../types";
+import {
+ DESTRUCTIVE_ANNOTATIONS,
+ READ_ONLY_ANNOTATIONS,
+ toMcpResult,
+ WRITE_ANNOTATIONS,
+ withErrorHandling
+} from "../types";
+
+export const registerQualityTools: RegisterTools = (server, ctx) => {
+ server.registerTool(
+ "quality_activateGauge",
+ {
+ description: "activate gauge",
+ inputSchema: {
+ gaugeId: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await activateGauge(ctx.client, params.gaugeId);
+ return toMcpResult(result);
+ }, "Failed: quality_activateGauge")
+ );
+
+ server.registerTool(
+ "quality_deactivateGauge",
+ {
+ description: "deactivate gauge",
+ inputSchema: {
+ gaugeId: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deactivateGauge(ctx.client, params.gaugeId);
+ return toMcpResult(result);
+ }, "Failed: quality_deactivateGauge")
+ );
+
+ server.registerTool(
+ "quality_deleteGauge",
+ {
+ description: "delete gauge",
+ inputSchema: {
+ gaugeId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteGauge(ctx.client, params.gaugeId);
+ return toMcpResult(result);
+ }, "Failed: quality_deleteGauge")
+ );
+
+ server.registerTool(
+ "quality_deleteGaugeCalibrationRecord",
+ {
+ description: "delete gauge calibration record",
+ inputSchema: {
+ gaugeCalibrationRecordId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteGaugeCalibrationRecord(
+ ctx.client,
+ params.gaugeCalibrationRecordId
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_deleteGaugeCalibrationRecord")
+ );
+
+ server.registerTool(
+ "quality_deleteGaugeType",
+ {
+ description: "delete gauge type",
+ inputSchema: {
+ gaugeTypeId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteGaugeType(ctx.client, params.gaugeTypeId);
+ return toMcpResult(result);
+ }, "Failed: quality_deleteGaugeType")
+ );
+
+ server.registerTool(
+ "quality_deleteIssue",
+ {
+ description: "delete issue",
+ inputSchema: {
+ nonConformanceId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteIssue(ctx.client, params.nonConformanceId);
+ return toMcpResult(result);
+ }, "Failed: quality_deleteIssue")
+ );
+
+ server.registerTool(
+ "quality_deleteIssueAssociation",
+ {
+ description: "delete issue association",
+ inputSchema: {
+ type: z.string(),
+ associationId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteIssueAssociation(
+ ctx.client,
+ params.type,
+ params.associationId
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_deleteIssueAssociation")
+ );
+
+ server.registerTool(
+ "quality_deleteIssueType",
+ {
+ description: "delete issue type",
+ inputSchema: {
+ nonConformanceTypeId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteIssueType(
+ ctx.client,
+ params.nonConformanceTypeId
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_deleteIssueType")
+ );
+
+ server.registerTool(
+ "quality_deleteIssueWorkflow",
+ {
+ description: "delete issue workflow",
+ inputSchema: {
+ nonConformanceWorkflowId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteIssueWorkflow(
+ ctx.client,
+ params.nonConformanceWorkflowId
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_deleteIssueWorkflow")
+ );
+
+ server.registerTool(
+ "quality_deleteRequiredAction",
+ {
+ description: "delete required action",
+ inputSchema: {
+ requiredActionId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteRequiredAction(
+ ctx.client,
+ params.requiredActionId
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_deleteRequiredAction")
+ );
+
+ server.registerTool(
+ "quality_deleteQualityDocument",
+ {
+ description: "delete quality document",
+ inputSchema: {
+ qualityDocumentId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteQualityDocument(
+ ctx.client,
+ params.qualityDocumentId
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_deleteQualityDocument")
+ );
+
+ server.registerTool(
+ "quality_deleteQualityDocumentStep",
+ {
+ description: "delete quality document step",
+ inputSchema: {
+ qualityDocumentStepId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteQualityDocumentStep(
+ ctx.client,
+ params.qualityDocumentStepId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_deleteQualityDocumentStep")
+ );
+
+ server.registerTool(
+ "quality_deleteRisk",
+ {
+ description: "delete risk",
+ inputSchema: {
+ riskId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteRisk(ctx.client, params.riskId);
+ return toMcpResult(result);
+ }, "Failed: quality_deleteRisk")
+ );
+
+ server.registerTool(
+ "quality_getIssueFromExternalLink",
+ {
+ description: "get issue from external link",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getIssueFromExternalLink(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: quality_getIssueFromExternalLink")
+ );
+
+ server.registerTool(
+ "quality_getGauge",
+ {
+ description: "get gauge",
+ inputSchema: {
+ gaugeId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getGauge(ctx.client, params.gaugeId);
+ return toMcpResult(result);
+ }, "Failed: quality_getGauge")
+ );
+
+ server.registerTool(
+ "quality_getGauges",
+ {
+ description: "get gauges",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getGauges(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: quality_getGauges")
+ );
+
+ server.registerTool(
+ "quality_getGaugesList",
+ {
+ description: "get gauges list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getGaugesList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: quality_getGaugesList")
+ );
+
+ server.registerTool(
+ "quality_getGaugeCalibrationRecord",
+ {
+ description: "get gauge calibration record",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getGaugeCalibrationRecord(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: quality_getGaugeCalibrationRecord")
+ );
+
+ server.registerTool(
+ "quality_getGaugeCalibrationRecords",
+ {
+ description: "get gauge calibration records",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getGaugeCalibrationRecords(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_getGaugeCalibrationRecords")
+ );
+
+ server.registerTool(
+ "quality_getGaugeCalibrationRecordsByGaugeId",
+ {
+ description: "get gauge calibration records by gauge id",
+ inputSchema: {
+ gaugeId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getGaugeCalibrationRecordsByGaugeId(
+ ctx.client,
+ params.gaugeId
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_getGaugeCalibrationRecordsByGaugeId")
+ );
+
+ server.registerTool(
+ "quality_getGaugeTypesList",
+ {
+ description: "get gauge types list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getGaugeTypesList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: quality_getGaugeTypesList")
+ );
+
+ server.registerTool(
+ "quality_getGaugeType",
+ {
+ description: "get gauge type",
+ inputSchema: {
+ gaugeTypeId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getGaugeType(ctx.client, params.gaugeTypeId);
+ return toMcpResult(result);
+ }, "Failed: quality_getGaugeType")
+ );
+
+ server.registerTool(
+ "quality_getGaugeTypes",
+ {
+ description: "get gauge types",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getGaugeTypes(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_getGaugeTypes")
+ );
+
+ server.registerTool(
+ "quality_getIssue",
+ {
+ description: "get issue",
+ inputSchema: {
+ nonConformanceId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getIssue(ctx.client, params.nonConformanceId);
+ return toMcpResult(result);
+ }, "Failed: quality_getIssue")
+ );
+
+ server.registerTool(
+ "quality_getIssues",
+ {
+ description: "get issues",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getIssues(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: quality_getIssues")
+ );
+
+ server.registerTool(
+ "quality_getIssueWorkflow",
+ {
+ description: "get issue workflow",
+ inputSchema: {
+ nonConformanceWorkflowId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getIssueWorkflow(
+ ctx.client,
+ params.nonConformanceWorkflowId
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_getIssueWorkflow")
+ );
+
+ server.registerTool(
+ "quality_getIssueAction",
+ {
+ description: "get issue action",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getIssueAction(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: quality_getIssueAction")
+ );
+
+ server.registerTool(
+ "quality_getIssueActionTasks",
+ {
+ description: "get issue action tasks",
+ inputSchema: {
+ id: z.string(),
+ supplierId: z.string().optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getIssueActionTasks(
+ ctx.client,
+ params.id,
+ ctx.companyId,
+ params.supplierId
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_getIssueActionTasks")
+ );
+
+ server.registerTool(
+ "quality_getIssueApprovalTasks",
+ {
+ description: "get issue approval tasks",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getIssueApprovalTasks(
+ ctx.client,
+ params.id,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_getIssueApprovalTasks")
+ );
+
+ server.registerTool(
+ "quality_getIssueItems",
+ {
+ description: "get issue items",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getIssueItems(ctx.client, params.id, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: quality_getIssueItems")
+ );
+
+ server.registerTool(
+ "quality_getIssueAssociations",
+ {
+ description: "get issue associations",
+ inputSchema: {
+ nonConformanceId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getIssueAssociations(
+ ctx.client,
+ params.nonConformanceId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_getIssueAssociations")
+ );
+
+ server.registerTool(
+ "quality_getIssueReviewers",
+ {
+ description: "get issue reviewers",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getIssueReviewers(
+ ctx.client,
+ params.id,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_getIssueReviewers")
+ );
+
+ server.registerTool(
+ "quality_getIssueSuppliers",
+ {
+ description: "get issue suppliers",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getIssueSuppliers(
+ ctx.client,
+ params.id,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_getIssueSuppliers")
+ );
+
+ server.registerTool(
+ "quality_getIssueTasks",
+ {
+ description: "get issue tasks",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getIssueTasks(ctx.client, params.id, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: quality_getIssueTasks")
+ );
+
+ server.registerTool(
+ "quality_getIssueType",
+ {
+ description: "get issue type",
+ inputSchema: {
+ nonConformanceTypeId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getIssueType(
+ ctx.client,
+ params.nonConformanceTypeId
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_getIssueType")
+ );
+
+ server.registerTool(
+ "quality_getIssueTypes",
+ {
+ description: "get issue types",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getIssueTypes(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_getIssueTypes")
+ );
+
+ server.registerTool(
+ "quality_getIssueWorkflows",
+ {
+ description: "get issue workflows",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getIssueWorkflows(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_getIssueWorkflows")
+ );
+
+ server.registerTool(
+ "quality_getIssueWorkflowsList",
+ {
+ description: "get issue workflows list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getIssueWorkflowsList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: quality_getIssueWorkflowsList")
+ );
+
+ server.registerTool(
+ "quality_getIssueTypesList",
+ {
+ description: "get issue types list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getIssueTypesList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: quality_getIssueTypesList")
+ );
+
+ server.registerTool(
+ "quality_getQualityActions",
+ {
+ description: "get quality actions",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQualityActions(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_getQualityActions")
+ );
+
+ server.registerTool(
+ "quality_getQualityDocument",
+ {
+ description: "get quality document",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQualityDocument(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: quality_getQualityDocument")
+ );
+
+ server.registerTool(
+ "quality_getQualityDocumentSteps",
+ {
+ description: "get quality document steps",
+ inputSchema: {
+ qualityDocumentId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQualityDocumentSteps(
+ ctx.client,
+ params.qualityDocumentId
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_getQualityDocumentSteps")
+ );
+
+ server.registerTool(
+ "quality_getQualityDocumentVersions",
+ {
+ description: "get quality document versions",
+ inputSchema: {
+ qualityDocument: z.object({
+ name: z.string(),
+ version: z.number()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQualityDocumentVersions(
+ ctx.client,
+ params.qualityDocument,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_getQualityDocumentVersions")
+ );
+
+ server.registerTool(
+ "quality_getQualityDocuments",
+ {
+ description: "get quality documents",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0)
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQualityDocuments(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_getQualityDocuments")
+ );
+
+ server.registerTool(
+ "quality_getQualityDocumentsList",
+ {
+ description: "get quality documents list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQualityDocumentsList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: quality_getQualityDocumentsList")
+ );
+
+ server.registerTool(
+ "quality_getQualityFiles",
+ {
+ description: "get quality files",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQualityFiles(
+ ctx.client,
+ params.id,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_getQualityFiles")
+ );
+
+ server.registerTool(
+ "quality_getRequiredActionsList",
+ {
+ description: "get required actions list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getRequiredActionsList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: quality_getRequiredActionsList")
+ );
+
+ server.registerTool(
+ "quality_getRequiredActions",
+ {
+ description: "get required actions",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getRequiredActions(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_getRequiredActions")
+ );
+
+ server.registerTool(
+ "quality_getRequiredAction",
+ {
+ description: "get required action",
+ inputSchema: {
+ requiredActionId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getRequiredAction(
+ ctx.client,
+ params.requiredActionId
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_getRequiredAction")
+ );
+
+ server.registerTool(
+ "quality_getRisk",
+ {
+ description: "get risk",
+ inputSchema: {
+ riskId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getRisk(ctx.client, params.riskId);
+ return toMcpResult(result);
+ }, "Failed: quality_getRisk")
+ );
+
+ server.registerTool(
+ "quality_getRisks",
+ {
+ description: "get risks",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ status: z.any().optional(),
+ source: z.any().optional(),
+ assignee: z.array(z.string()).optional()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getRisks(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: quality_getRisks")
+ );
+
+ server.registerTool(
+ "quality_insertIssueReviewer",
+ {
+ description: "insert issue reviewer",
+ inputSchema: {
+ reviewer: nonConformanceReviewerValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertIssueReviewer(ctx.client, {
+ ...params.reviewer,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: quality_insertIssueReviewer")
+ );
+
+ server.registerTool(
+ "quality_updateIssueActionProcesses",
+ {
+ description: "update issue action processes",
+ inputSchema: {
+ args: z.object({
+ actionTaskId: z.string(),
+ processIds: z.array(z.string())
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateIssueActionProcesses(ctx.client, {
+ ...params.args,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: quality_updateIssueActionProcesses")
+ );
+
+ server.registerTool(
+ "quality_updateIssueStatus",
+ {
+ description: "update issue status",
+ inputSchema: {
+ update: z.object({
+ id: z.string(),
+ status: z.any(),
+ assignee: z.any(),
+ closeDate: z.any()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateIssueStatus(ctx.client, {
+ ...params.update,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: quality_updateIssueStatus")
+ );
+
+ server.registerTool(
+ "quality_updateIssueTaskStatus",
+ {
+ description: "update issue task status",
+ inputSchema: {
+ args: z.object({
+ id: z.string(),
+ status: z.enum(["Pending", "Completed", "Skipped", "In Progress"]),
+ type: z.enum(["investigation", "action", "approval", "review"]),
+ assignee: z.string().nullable().optional()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateIssueTaskStatus(ctx.client, {
+ ...params.args,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: quality_updateIssueTaskStatus")
+ );
+
+ server.registerTool(
+ "quality_updateIssueTaskContent",
+ {
+ description: "update issue task content",
+ inputSchema: {
+ args: z.object({
+ id: z.string(),
+ type: z.enum(["action", "approval", "review"]),
+ content: z.any()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateIssueTaskContent(ctx.client, params.args);
+ return toMcpResult(result);
+ }, "Failed: quality_updateIssueTaskContent")
+ );
+
+ server.registerTool(
+ "quality_updateQualityDocumentStepOrder",
+ {
+ description: "update quality document step order",
+ inputSchema: {
+ updates: z.object({
+ id: z.string(),
+ sortOrder: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateQualityDocumentStepOrder(ctx.client, {
+ ...params.updates,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: quality_updateQualityDocumentStepOrder")
+ );
+
+ server.registerTool(
+ "quality_updateRiskStatus",
+ {
+ description: "update risk status",
+ inputSchema: {
+ riskId: z.string(),
+ status: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateRiskStatus(
+ ctx.client,
+ params.riskId,
+ params.status
+ );
+ return toMcpResult(result);
+ }, "Failed: quality_updateRiskStatus")
+ );
+
+ server.registerTool(
+ "quality_upsertGauge",
+ {
+ description: "upsert gauge",
+ inputSchema: {
+ gauge: gaugeValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertGauge(ctx.client, {
+ ...params.gauge,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: quality_upsertGauge")
+ );
+
+ server.registerTool(
+ "quality_upsertGaugeCalibrationRecord",
+ {
+ description: "upsert gauge calibration record",
+ inputSchema: {
+ gaugeCalibrationRecord: gaugeCalibrationRecordValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertGaugeCalibrationRecord(ctx.client, {
+ ...params.gaugeCalibrationRecord,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: quality_upsertGaugeCalibrationRecord")
+ );
+
+ server.registerTool(
+ "quality_upsertGaugeType",
+ {
+ description: "upsert gauge type",
+ inputSchema: {
+ gaugeType: gaugeTypeValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertGaugeType(ctx.client, {
+ ...params.gaugeType,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: quality_upsertGaugeType")
+ );
+
+ server.registerTool(
+ "quality_upsertIssue",
+ {
+ description: "upsert issue",
+ inputSchema: {
+ nonConformance: issueValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertIssue(ctx.client, {
+ ...params.nonConformance,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: quality_upsertIssue")
+ );
+
+ server.registerTool(
+ "quality_upsertIssueWorkflow",
+ {
+ description: "upsert issue workflow",
+ inputSchema: {
+ nonConformanceWorkflow: issueWorkflowValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertIssueWorkflow(ctx.client, {
+ ...params.nonConformanceWorkflow,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: quality_upsertIssueWorkflow")
+ );
+
+ server.registerTool(
+ "quality_upsertIssueType",
+ {
+ description: "upsert issue type",
+ inputSchema: {
+ nonConformanceType: issueTypeValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertIssueType(ctx.client, {
+ ...params.nonConformanceType,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: quality_upsertIssueType")
+ );
+
+ server.registerTool(
+ "quality_upsertRequiredAction",
+ {
+ description: "upsert required action",
+ inputSchema: {
+ requiredAction: issueTypeValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertRequiredAction(ctx.client, {
+ ...params.requiredAction,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: quality_upsertRequiredAction")
+ );
+
+ server.registerTool(
+ "quality_upsertQualityDocument",
+ {
+ description: "upsert quality document",
+ inputSchema: {
+ qualityDocument: qualityDocumentValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertQualityDocument(ctx.client, {
+ ...params.qualityDocument,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: quality_upsertQualityDocument")
+ );
+
+ server.registerTool(
+ "quality_upsertQualityDocumentStep",
+ {
+ description: "upsert quality document step",
+ inputSchema: {
+ qualityDocumentStep: qualityDocumentStepValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertQualityDocumentStep(ctx.client, {
+ ...params.qualityDocumentStep,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: quality_upsertQualityDocumentStep")
+ );
+
+ server.registerTool(
+ "quality_upsertRisk",
+ {
+ description: "upsert risk",
+ inputSchema: {
+ risk: riskRegisterValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertRisk(ctx.client, {
+ ...params.risk,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: quality_upsertRisk")
+ );
+};
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tools/resources.ts b/apps/erp/app/routes/api+/mcp+/lib/tools/resources.ts
new file mode 100644
index 0000000000..5b5afd3983
--- /dev/null
+++ b/apps/erp/app/routes/api+/mcp+/lib/tools/resources.ts
@@ -0,0 +1,1866 @@
+// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+import { z } from "zod";
+import {
+ failureModeValidator,
+ locationValidator,
+ maintenanceDispatchCommentValidator,
+ maintenanceDispatchEventValidator,
+ maintenanceDispatchItemValidator,
+ maintenanceDispatchValidator,
+ maintenanceDispatchWorkCenterValidator,
+ maintenanceScheduleItemValidator,
+ maintenanceScheduleValidator,
+ partnerValidator,
+ processValidator,
+ trainingQuestionValidator,
+ trainingValidator,
+ workCenterValidator
+} from "~/modules/resources/resources.models";
+import {
+ activateProcess,
+ activateWorkCenter,
+ deleteAbility,
+ deleteContractor,
+ deleteEmployeeAbility,
+ deleteFailureMode,
+ deleteLocation,
+ deleteMaintenanceDispatch,
+ deleteMaintenanceDispatchComment,
+ deleteMaintenanceDispatchEvent,
+ deleteMaintenanceDispatchItem,
+ deleteMaintenanceDispatchWorkCenter,
+ deleteMaintenanceSchedule,
+ deleteMaintenanceScheduleItem,
+ deletePartner,
+ deleteProcess,
+ deleteShift,
+ deleteSuggestion,
+ deleteTraining,
+ deleteTrainingAssignment,
+ deleteTrainingQuestion,
+ deleteWorkCenter,
+ getAbilities,
+ getAbilitiesList,
+ getAbility,
+ getContractor,
+ getContractors,
+ getEmployeeAbilities,
+ getFailureMode,
+ getFailureModes,
+ getFailureModesList,
+ getLocation,
+ getLocations,
+ getLocationsList,
+ getMaintenanceDispatch,
+ getMaintenanceDispatchComments,
+ getMaintenanceDispatchEvents,
+ getMaintenanceDispatches,
+ getMaintenanceDispatchesByLocation,
+ getMaintenanceDispatchItems,
+ getMaintenanceDispatchItemTrackedEntities,
+ getMaintenanceDispatchWorkCenters,
+ getMaintenanceSchedule,
+ getMaintenanceScheduleItems,
+ getMaintenanceSchedules,
+ getMaintenanceSchedulesByLocation,
+ getOutstandingTrainingsForUser,
+ getPartner,
+ getPartnerBySupplierId,
+ getPartners,
+ getProcess,
+ getProcesses,
+ getProcessesList,
+ getSuggestion,
+ getSuggestions,
+ getTraining,
+ getTrainingAssignment,
+ getTrainingAssignmentForCompletion,
+ getTrainingAssignmentStatus,
+ getTrainingAssignmentSummary,
+ getTrainingAssignments,
+ getTrainingQuestions,
+ getTrainings,
+ getTrainingsList,
+ getWorkCenter,
+ getWorkCenters,
+ getWorkCentersByLocation,
+ getWorkCentersList,
+ getWorkCentersListWithBlockingStatus,
+ insertAbility,
+ insertEmployeeAbilities,
+ insertTrainingCompletion,
+ processDeactivate,
+ updateAbility,
+ updateSuggestionEmoji,
+ updateSuggestionTags,
+ updateTrainingQuestionOrder,
+ upsertContractor,
+ upsertEmployeeAbility,
+ upsertFailureMode,
+ upsertLocation,
+ upsertMaintenanceDispatch,
+ upsertMaintenanceDispatchComment,
+ upsertMaintenanceDispatchEvent,
+ upsertMaintenanceDispatchItem,
+ upsertMaintenanceDispatchWorkCenter,
+ upsertMaintenanceSchedule,
+ upsertMaintenanceScheduleItem,
+ upsertPartner,
+ upsertProcess,
+ upsertTraining,
+ upsertTrainingAssignment,
+ upsertTrainingQuestion,
+ upsertWorkCenter
+} from "~/modules/resources/resources.service";
+import type { RegisterTools } from "../types";
+import {
+ DESTRUCTIVE_ANNOTATIONS,
+ READ_ONLY_ANNOTATIONS,
+ toMcpResult,
+ WRITE_ANNOTATIONS,
+ withErrorHandling
+} from "../types";
+
+export const registerResourcesTools: RegisterTools = (server, ctx) => {
+ server.registerTool(
+ "resources_activateWorkCenter",
+ {
+ description: "activate work center",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await activateWorkCenter(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: resources_activateWorkCenter")
+ );
+
+ server.registerTool(
+ "resources_deleteAbility",
+ {
+ description: "delete ability",
+ inputSchema: {
+ abilityId: z.string(),
+ hardDelete: z.boolean().optional()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteAbility(
+ ctx.client,
+ params.abilityId,
+ params.hardDelete
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_deleteAbility")
+ );
+
+ server.registerTool(
+ "resources_deleteContractor",
+ {
+ description: "delete contractor",
+ inputSchema: {
+ contractorId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteContractor(ctx.client, params.contractorId);
+ return toMcpResult(result);
+ }, "Failed: resources_deleteContractor")
+ );
+
+ server.registerTool(
+ "resources_deleteEmployeeAbility",
+ {
+ description: "delete employee ability",
+ inputSchema: {
+ employeeAbilityId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteEmployeeAbility(
+ ctx.client,
+ params.employeeAbilityId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_deleteEmployeeAbility")
+ );
+
+ server.registerTool(
+ "resources_deleteFailureMode",
+ {
+ description: "delete failure mode",
+ inputSchema: {
+ failureModeId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteFailureMode(ctx.client, params.failureModeId);
+ return toMcpResult(result);
+ }, "Failed: resources_deleteFailureMode")
+ );
+
+ server.registerTool(
+ "resources_deleteLocation",
+ {
+ description: "delete location",
+ inputSchema: {
+ locationId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteLocation(ctx.client, params.locationId);
+ return toMcpResult(result);
+ }, "Failed: resources_deleteLocation")
+ );
+
+ server.registerTool(
+ "resources_deleteMaintenanceDispatch",
+ {
+ description: "delete maintenance dispatch",
+ inputSchema: {
+ dispatchId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaintenanceDispatch(
+ ctx.client,
+ params.dispatchId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_deleteMaintenanceDispatch")
+ );
+
+ server.registerTool(
+ "resources_deleteMaintenanceDispatchComment",
+ {
+ description: "delete maintenance dispatch comment",
+ inputSchema: {
+ commentId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaintenanceDispatchComment(
+ ctx.client,
+ params.commentId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_deleteMaintenanceDispatchComment")
+ );
+
+ server.registerTool(
+ "resources_deleteMaintenanceDispatchEvent",
+ {
+ description: "delete maintenance dispatch event",
+ inputSchema: {
+ eventId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaintenanceDispatchEvent(
+ ctx.client,
+ params.eventId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_deleteMaintenanceDispatchEvent")
+ );
+
+ server.registerTool(
+ "resources_deleteMaintenanceDispatchItem",
+ {
+ description: "delete maintenance dispatch item",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaintenanceDispatchItem(
+ ctx.client,
+ params.itemId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_deleteMaintenanceDispatchItem")
+ );
+
+ server.registerTool(
+ "resources_deleteMaintenanceDispatchWorkCenter",
+ {
+ description: "delete maintenance dispatch work center",
+ inputSchema: {
+ workCenterId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaintenanceDispatchWorkCenter(
+ ctx.client,
+ params.workCenterId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_deleteMaintenanceDispatchWorkCenter")
+ );
+
+ server.registerTool(
+ "resources_deleteMaintenanceSchedule",
+ {
+ description: "delete maintenance schedule",
+ inputSchema: {
+ scheduleId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaintenanceSchedule(
+ ctx.client,
+ params.scheduleId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_deleteMaintenanceSchedule")
+ );
+
+ server.registerTool(
+ "resources_deleteMaintenanceScheduleItem",
+ {
+ description: "delete maintenance schedule item",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteMaintenanceScheduleItem(
+ ctx.client,
+ params.itemId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_deleteMaintenanceScheduleItem")
+ );
+
+ server.registerTool(
+ "resources_deletePartner",
+ {
+ description: "delete partner",
+ inputSchema: {
+ partnerId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deletePartner(ctx.client, params.partnerId);
+ return toMcpResult(result);
+ }, "Failed: resources_deletePartner")
+ );
+
+ server.registerTool(
+ "resources_activateProcess",
+ {
+ description: "activate process",
+ inputSchema: {
+ processId: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await activateProcess(ctx.client, params.processId);
+ return toMcpResult(result);
+ }, "Failed: resources_activateProcess")
+ );
+
+ server.registerTool(
+ "resources_processDeactivate",
+ {
+ description: "process deactivate",
+ inputSchema: {
+ processId: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await processDeactivate(ctx.client, params.processId);
+ return toMcpResult(result);
+ }, "Failed: resources_processDeactivate")
+ );
+
+ server.registerTool(
+ "resources_deleteProcess",
+ {
+ description: "delete process",
+ inputSchema: {
+ processId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteProcess(ctx.client, params.processId);
+ return toMcpResult(result);
+ }, "Failed: resources_deleteProcess")
+ );
+
+ server.registerTool(
+ "resources_deleteShift",
+ {
+ description: "delete shift",
+ inputSchema: {
+ shiftId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteShift(ctx.client, params.shiftId);
+ return toMcpResult(result);
+ }, "Failed: resources_deleteShift")
+ );
+
+ server.registerTool(
+ "resources_deleteSuggestion",
+ {
+ description: "delete suggestion",
+ inputSchema: {
+ suggestionId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteSuggestion(ctx.client, params.suggestionId);
+ return toMcpResult(result);
+ }, "Failed: resources_deleteSuggestion")
+ );
+
+ server.registerTool(
+ "resources_deleteTraining",
+ {
+ description: "delete training",
+ inputSchema: {
+ trainingId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteTraining(ctx.client, params.trainingId);
+ return toMcpResult(result);
+ }, "Failed: resources_deleteTraining")
+ );
+
+ server.registerTool(
+ "resources_deleteTrainingAssignment",
+ {
+ description: "delete training assignment",
+ inputSchema: {
+ assignmentId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteTrainingAssignment(
+ ctx.client,
+ params.assignmentId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_deleteTrainingAssignment")
+ );
+
+ server.registerTool(
+ "resources_deleteTrainingQuestion",
+ {
+ description: "delete training question",
+ inputSchema: {
+ trainingQuestionId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteTrainingQuestion(
+ ctx.client,
+ params.trainingQuestionId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_deleteTrainingQuestion")
+ );
+
+ server.registerTool(
+ "resources_deleteWorkCenter",
+ {
+ description: "delete work center",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteWorkCenter(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: resources_deleteWorkCenter")
+ );
+
+ server.registerTool(
+ "resources_getAbilities",
+ {
+ description: "get abilities",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAbilities(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: resources_getAbilities")
+ );
+
+ server.registerTool(
+ "resources_getAbilitiesList",
+ {
+ description: "get abilities list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAbilitiesList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: resources_getAbilitiesList")
+ );
+
+ server.registerTool(
+ "resources_getAbility",
+ {
+ description: "get ability",
+ inputSchema: {
+ abilityId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAbility(ctx.client, params.abilityId);
+ return toMcpResult(result);
+ }, "Failed: resources_getAbility")
+ );
+
+ server.registerTool(
+ "resources_getContractor",
+ {
+ description: "get contractor",
+ inputSchema: {
+ contractorId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getContractor(ctx.client, params.contractorId);
+ return toMcpResult(result);
+ }, "Failed: resources_getContractor")
+ );
+
+ server.registerTool(
+ "resources_getContractors",
+ {
+ description: "get contractors",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getContractors(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getContractors")
+ );
+
+ server.registerTool(
+ "resources_getEmployeeAbilities",
+ {
+ description: "get employee abilities",
+ inputSchema: {
+ employeeId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getEmployeeAbilities(ctx.client, params.employeeId);
+ return toMcpResult(result);
+ }, "Failed: resources_getEmployeeAbilities")
+ );
+
+ server.registerTool(
+ "resources_getFailureMode",
+ {
+ description: "get failure mode",
+ inputSchema: {
+ failureModeId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getFailureMode(ctx.client, params.failureModeId);
+ return toMcpResult(result);
+ }, "Failed: resources_getFailureMode")
+ );
+
+ server.registerTool(
+ "resources_getFailureModes",
+ {
+ description: "get failure modes",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getFailureModes(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getFailureModes")
+ );
+
+ server.registerTool(
+ "resources_getFailureModesList",
+ {
+ description: "get failure modes list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getFailureModesList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: resources_getFailureModesList")
+ );
+
+ server.registerTool(
+ "resources_getLocation",
+ {
+ description: "get location",
+ inputSchema: {
+ locationId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getLocation(ctx.client, params.locationId);
+ return toMcpResult(result);
+ }, "Failed: resources_getLocation")
+ );
+
+ server.registerTool(
+ "resources_getLocations",
+ {
+ description: "get locations",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getLocations(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: resources_getLocations")
+ );
+
+ server.registerTool(
+ "resources_getLocationsList",
+ {
+ description: "get locations list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getLocationsList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: resources_getLocationsList")
+ );
+
+ server.registerTool(
+ "resources_getMaintenanceDispatch",
+ {
+ description: "get maintenance dispatch",
+ inputSchema: {
+ dispatchId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceDispatch(
+ ctx.client,
+ params.dispatchId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getMaintenanceDispatch")
+ );
+
+ server.registerTool(
+ "resources_getMaintenanceDispatchComments",
+ {
+ description: "get maintenance dispatch comments",
+ inputSchema: {
+ dispatchId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceDispatchComments(
+ ctx.client,
+ params.dispatchId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getMaintenanceDispatchComments")
+ );
+
+ server.registerTool(
+ "resources_getMaintenanceDispatchEvents",
+ {
+ description: "get maintenance dispatch events",
+ inputSchema: {
+ dispatchId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceDispatchEvents(
+ ctx.client,
+ params.dispatchId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getMaintenanceDispatchEvents")
+ );
+
+ server.registerTool(
+ "resources_getMaintenanceDispatchItems",
+ {
+ description: "get maintenance dispatch items",
+ inputSchema: {
+ dispatchId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceDispatchItems(
+ ctx.client,
+ params.dispatchId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getMaintenanceDispatchItems")
+ );
+
+ server.registerTool(
+ "resources_getMaintenanceDispatchItemTrackedEntities",
+ {
+ description: "get maintenance dispatch item tracked entities",
+ inputSchema: {
+ maintenanceDispatchItemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceDispatchItemTrackedEntities(
+ ctx.client,
+ params.maintenanceDispatchItemId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getMaintenanceDispatchItemTrackedEntities")
+ );
+
+ server.registerTool(
+ "resources_getMaintenanceDispatches",
+ {
+ description: "get maintenance dispatches",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ status: z.string().optional()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceDispatches(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getMaintenanceDispatches")
+ );
+
+ server.registerTool(
+ "resources_getMaintenanceDispatchesByLocation",
+ {
+ description: "get maintenance dispatches by location",
+ inputSchema: {
+ locationId: z.string(),
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ status: z.string().optional()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceDispatchesByLocation(
+ ctx.client,
+ ctx.companyId,
+ params.locationId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getMaintenanceDispatchesByLocation")
+ );
+
+ server.registerTool(
+ "resources_getMaintenanceDispatchWorkCenters",
+ {
+ description: "get maintenance dispatch work centers",
+ inputSchema: {
+ dispatchId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceDispatchWorkCenters(
+ ctx.client,
+ params.dispatchId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getMaintenanceDispatchWorkCenters")
+ );
+
+ server.registerTool(
+ "resources_getMaintenanceSchedule",
+ {
+ description: "get maintenance schedule",
+ inputSchema: {
+ scheduleId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceSchedule(
+ ctx.client,
+ params.scheduleId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getMaintenanceSchedule")
+ );
+
+ server.registerTool(
+ "resources_getMaintenanceScheduleItems",
+ {
+ description: "get maintenance schedule items",
+ inputSchema: {
+ scheduleId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceScheduleItems(
+ ctx.client,
+ params.scheduleId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getMaintenanceScheduleItems")
+ );
+
+ server.registerTool(
+ "resources_getMaintenanceSchedules",
+ {
+ description: "get maintenance schedules",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ active: z.boolean().optional()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceSchedules(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getMaintenanceSchedules")
+ );
+
+ server.registerTool(
+ "resources_getMaintenanceSchedulesByLocation",
+ {
+ description: "get maintenance schedules by location",
+ inputSchema: {
+ locationId: z.string(),
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ active: z.boolean().optional()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getMaintenanceSchedulesByLocation(
+ ctx.client,
+ ctx.companyId,
+ params.locationId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getMaintenanceSchedulesByLocation")
+ );
+
+ server.registerTool(
+ "resources_getOutstandingTrainingsForUser",
+ {
+ description: "get outstanding trainings for user",
+ inputSchema: {
+ employeeId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getOutstandingTrainingsForUser(
+ ctx.client,
+ ctx.companyId,
+ params.employeeId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getOutstandingTrainingsForUser")
+ );
+
+ server.registerTool(
+ "resources_getPartner",
+ {
+ description: "get partner",
+ inputSchema: {
+ partnerId: z.string(),
+ abilityId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPartner(
+ ctx.client,
+ params.partnerId,
+ params.abilityId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getPartner")
+ );
+
+ server.registerTool(
+ "resources_getPartnerBySupplierId",
+ {
+ description: "get partner by supplier id",
+ inputSchema: {
+ partnerId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPartnerBySupplierId(ctx.client, params.partnerId);
+ return toMcpResult(result);
+ }, "Failed: resources_getPartnerBySupplierId")
+ );
+
+ server.registerTool(
+ "resources_getPartners",
+ {
+ description: "get partners",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPartners(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: resources_getPartners")
+ );
+
+ server.registerTool(
+ "resources_getProcess",
+ {
+ description: "get process",
+ inputSchema: {
+ processId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getProcess(ctx.client, params.processId);
+ return toMcpResult(result);
+ }, "Failed: resources_getProcess")
+ );
+
+ server.registerTool(
+ "resources_getProcesses",
+ {
+ description: "get processes",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getProcesses(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: resources_getProcesses")
+ );
+
+ server.registerTool(
+ "resources_getProcessesList",
+ {
+ description: "get processes list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getProcessesList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: resources_getProcessesList")
+ );
+
+ server.registerTool(
+ "resources_getSuggestion",
+ {
+ description: "get suggestion",
+ inputSchema: {
+ suggestionId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSuggestion(ctx.client, params.suggestionId);
+ return toMcpResult(result);
+ }, "Failed: resources_getSuggestion")
+ );
+
+ server.registerTool(
+ "resources_getSuggestions",
+ {
+ description: "get suggestions",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSuggestions(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getSuggestions")
+ );
+
+ server.registerTool(
+ "resources_getTraining",
+ {
+ description: "get training",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTraining(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: resources_getTraining")
+ );
+
+ server.registerTool(
+ "resources_getTrainingAssignment",
+ {
+ description: "get training assignment",
+ inputSchema: {
+ assignmentId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTrainingAssignment(
+ ctx.client,
+ params.assignmentId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getTrainingAssignment")
+ );
+
+ server.registerTool(
+ "resources_getTrainingAssignmentForCompletion",
+ {
+ description: "get training assignment for completion",
+ inputSchema: {
+ assignmentId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTrainingAssignmentForCompletion(
+ ctx.client,
+ params.assignmentId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getTrainingAssignmentForCompletion")
+ );
+
+ server.registerTool(
+ "resources_getTrainingAssignments",
+ {
+ description: "get training assignments",
+ inputSchema: {
+ trainingId: z.string().optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTrainingAssignments(
+ ctx.client,
+ ctx.companyId,
+ params.trainingId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getTrainingAssignments")
+ );
+
+ server.registerTool(
+ "resources_getTrainingAssignmentStatus",
+ {
+ description: "get training assignment status",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0)
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTrainingAssignmentStatus(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getTrainingAssignmentStatus")
+ );
+
+ server.registerTool(
+ "resources_getTrainingAssignmentSummary",
+ {
+ description: "get training assignment summary",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTrainingAssignmentSummary(
+ ctx.client,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getTrainingAssignmentSummary")
+ );
+
+ server.registerTool(
+ "resources_getTrainingQuestions",
+ {
+ description: "get training questions",
+ inputSchema: {
+ trainingId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTrainingQuestions(ctx.client, params.trainingId);
+ return toMcpResult(result);
+ }, "Failed: resources_getTrainingQuestions")
+ );
+
+ server.registerTool(
+ "resources_getTrainings",
+ {
+ description: "get trainings",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0)
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTrainings(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: resources_getTrainings")
+ );
+
+ server.registerTool(
+ "resources_getTrainingsList",
+ {
+ description: "get trainings list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTrainingsList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: resources_getTrainingsList")
+ );
+
+ server.registerTool(
+ "resources_getWorkCenter",
+ {
+ description: "get work center",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getWorkCenter(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: resources_getWorkCenter")
+ );
+
+ server.registerTool(
+ "resources_getWorkCenters",
+ {
+ description: "get work centers",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0)
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getWorkCenters(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getWorkCenters")
+ );
+
+ server.registerTool(
+ "resources_getWorkCentersByLocation",
+ {
+ description: "get work centers by location",
+ inputSchema: {
+ locationId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getWorkCentersByLocation(
+ ctx.client,
+ params.locationId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getWorkCentersByLocation")
+ );
+
+ server.registerTool(
+ "resources_getWorkCentersList",
+ {
+ description: "get work centers list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getWorkCentersList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: resources_getWorkCentersList")
+ );
+
+ server.registerTool(
+ "resources_getWorkCentersListWithBlockingStatus",
+ {
+ description: "get work centers list with blocking status",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getWorkCentersListWithBlockingStatus(
+ ctx.client,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_getWorkCentersListWithBlockingStatus")
+ );
+
+ server.registerTool(
+ "resources_insertAbility",
+ {
+ description: "insert ability",
+ inputSchema: {
+ ability: z.object({
+ name: z.string(),
+ curve: z.any(),
+ data: z.any(),
+ week: z.number(),
+ value: z.number(),
+ shadowWeeks: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertAbility(ctx.client, {
+ ...params.ability,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_insertAbility")
+ );
+
+ server.registerTool(
+ "resources_insertEmployeeAbilities",
+ {
+ description: "insert employee abilities",
+ inputSchema: {
+ abilityId: z.string(),
+ employeeIds: z.array(z.string())
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertEmployeeAbilities(
+ ctx.client,
+ params.abilityId,
+ params.employeeIds,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_insertEmployeeAbilities")
+ );
+
+ server.registerTool(
+ "resources_insertTrainingCompletion",
+ {
+ description: "insert training completion",
+ inputSchema: {
+ completion: z.object({
+ trainingAssignmentId: z.string(),
+ employeeId: z.string(),
+ period: z.string().nullable(),
+ completedBy: z.string()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertTrainingCompletion(ctx.client, {
+ ...params.completion,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_insertTrainingCompletion")
+ );
+
+ server.registerTool(
+ "resources_updateAbility",
+ {
+ description: "update ability",
+ inputSchema: {
+ id: z.string(),
+ ability: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateAbility(ctx.client, params.id, params.ability);
+ return toMcpResult(result);
+ }, "Failed: resources_updateAbility")
+ );
+
+ server.registerTool(
+ "resources_updateSuggestionEmoji",
+ {
+ description: "update suggestion emoji",
+ inputSchema: {
+ suggestionId: z.string(),
+ emoji: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSuggestionEmoji(
+ ctx.client,
+ params.suggestionId,
+ params.emoji
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_updateSuggestionEmoji")
+ );
+
+ server.registerTool(
+ "resources_updateSuggestionTags",
+ {
+ description: "update suggestion tags",
+ inputSchema: {
+ suggestionId: z.string(),
+ tags: z.array(z.string())
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSuggestionTags(
+ ctx.client,
+ params.suggestionId,
+ params.tags
+ );
+ return toMcpResult(result);
+ }, "Failed: resources_updateSuggestionTags")
+ );
+
+ server.registerTool(
+ "resources_updateTrainingQuestionOrder",
+ {
+ description: "update training question order",
+ inputSchema: {
+ updates: z.object({
+ id: z.string(),
+ sortOrder: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateTrainingQuestionOrder(ctx.client, {
+ ...params.updates,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_updateTrainingQuestionOrder")
+ );
+
+ server.registerTool(
+ "resources_upsertContractor",
+ {
+ description: "upsert contractor",
+ inputSchema: {
+ contractorWithAbilities: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertContractor(ctx.client, {
+ ...params.contractorWithAbilities,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_upsertContractor")
+ );
+
+ server.registerTool(
+ "resources_upsertEmployeeAbility",
+ {
+ description: "upsert employee ability",
+ inputSchema: {
+ employeeAbility: z.object({
+ id: z.string().optional(),
+ abilityId: z.string(),
+ employeeId: z.string(),
+ trainingCompleted: z.boolean(),
+ trainingDays: z.number().optional()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertEmployeeAbility(ctx.client, {
+ ...params.employeeAbility,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_upsertEmployeeAbility")
+ );
+
+ server.registerTool(
+ "resources_upsertFailureMode",
+ {
+ description: "upsert failure mode",
+ inputSchema: {
+ failureMode: failureModeValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertFailureMode(ctx.client, {
+ ...params.failureMode,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_upsertFailureMode")
+ );
+
+ server.registerTool(
+ "resources_upsertLocation",
+ {
+ description: "upsert location",
+ inputSchema: {
+ location: locationValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertLocation(ctx.client, {
+ ...params.location,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_upsertLocation")
+ );
+
+ server.registerTool(
+ "resources_upsertMaintenanceDispatch",
+ {
+ description: "upsert maintenance dispatch",
+ inputSchema: {
+ dispatch: maintenanceDispatchValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaintenanceDispatch(ctx.client, {
+ ...params.dispatch,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_upsertMaintenanceDispatch")
+ );
+
+ server.registerTool(
+ "resources_upsertMaintenanceDispatchComment",
+ {
+ description: "upsert maintenance dispatch comment",
+ inputSchema: {
+ comment: maintenanceDispatchCommentValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaintenanceDispatchComment(ctx.client, {
+ ...params.comment,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_upsertMaintenanceDispatchComment")
+ );
+
+ server.registerTool(
+ "resources_upsertMaintenanceDispatchEvent",
+ {
+ description: "upsert maintenance dispatch event",
+ inputSchema: {
+ event: maintenanceDispatchEventValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaintenanceDispatchEvent(ctx.client, {
+ ...params.event,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_upsertMaintenanceDispatchEvent")
+ );
+
+ server.registerTool(
+ "resources_upsertMaintenanceDispatchItem",
+ {
+ description: "upsert maintenance dispatch item",
+ inputSchema: {
+ item: maintenanceDispatchItemValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaintenanceDispatchItem(ctx.client, {
+ ...params.item,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_upsertMaintenanceDispatchItem")
+ );
+
+ server.registerTool(
+ "resources_upsertMaintenanceDispatchWorkCenter",
+ {
+ description: "upsert maintenance dispatch work center",
+ inputSchema: {
+ workCenter: maintenanceDispatchWorkCenterValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaintenanceDispatchWorkCenter(ctx.client, {
+ ...params.workCenter,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_upsertMaintenanceDispatchWorkCenter")
+ );
+
+ server.registerTool(
+ "resources_upsertMaintenanceSchedule",
+ {
+ description: "upsert maintenance schedule",
+ inputSchema: {
+ schedule: maintenanceScheduleValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaintenanceSchedule(ctx.client, {
+ ...params.schedule,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_upsertMaintenanceSchedule")
+ );
+
+ server.registerTool(
+ "resources_upsertMaintenanceScheduleItem",
+ {
+ description: "upsert maintenance schedule item",
+ inputSchema: {
+ item: maintenanceScheduleItemValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMaintenanceScheduleItem(ctx.client, {
+ ...params.item,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_upsertMaintenanceScheduleItem")
+ );
+
+ server.registerTool(
+ "resources_upsertPartner",
+ {
+ description: "upsert partner",
+ inputSchema: {
+ partner: partnerValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertPartner(ctx.client, {
+ ...params.partner,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_upsertPartner")
+ );
+
+ server.registerTool(
+ "resources_upsertProcess",
+ {
+ description: "upsert process",
+ inputSchema: {
+ process: processValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertProcess(ctx.client, {
+ ...params.process,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_upsertProcess")
+ );
+
+ server.registerTool(
+ "resources_upsertTraining",
+ {
+ description: "upsert training",
+ inputSchema: {
+ training: trainingValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertTraining(ctx.client, {
+ ...params.training,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_upsertTraining")
+ );
+
+ server.registerTool(
+ "resources_upsertTrainingAssignment",
+ {
+ description: "upsert training assignment",
+ inputSchema: {
+ assignment: z.object({
+ id: z.string().optional(),
+ trainingId: z.string(),
+ groupIds: z.array(z.string())
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertTrainingAssignment(ctx.client, {
+ ...params.assignment,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_upsertTrainingAssignment")
+ );
+
+ server.registerTool(
+ "resources_upsertTrainingQuestion",
+ {
+ description: "upsert training question",
+ inputSchema: {
+ trainingQuestion: trainingQuestionValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertTrainingQuestion(ctx.client, {
+ ...params.trainingQuestion,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_upsertTrainingQuestion")
+ );
+
+ server.registerTool(
+ "resources_upsertWorkCenter",
+ {
+ description: "upsert work center",
+ inputSchema: {
+ workCenter: workCenterValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertWorkCenter(ctx.client, {
+ ...params.workCenter,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: resources_upsertWorkCenter")
+ );
+};
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tools/sales.ts b/apps/erp/app/routes/api+/mcp+/lib/tools/sales.ts
new file mode 100644
index 0000000000..f937bbc099
--- /dev/null
+++ b/apps/erp/app/routes/api+/mcp+/lib/tools/sales.ts
@@ -0,0 +1,2968 @@
+// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+import { z } from "zod";
+import {
+ customerAccountingValidator,
+ customerContactValidator,
+ customerPaymentValidator,
+ customerShippingValidator,
+ customerStatusValidator,
+ customerTypeValidator,
+ customerValidator,
+ getMethodValidator,
+ noQuoteReasonValidator,
+ quoteLineAdditionalChargesValidator,
+ quoteLineValidator,
+ quoteMaterialValidator,
+ quoteOperationValidator,
+ quotePaymentValidator,
+ quoteShipmentValidator,
+ quoteValidator,
+ salesOrderLineValidator,
+ salesOrderPaymentValidator,
+ salesOrderShipmentValidator,
+ salesOrderValidator,
+ salesRfqLineValidator,
+ salesRfqValidator,
+ selectedLinesValidator
+} from "~/modules/sales/sales.models";
+import {
+ calculatePricesForQuantities,
+ closeSalesOrder,
+ convertQuoteToOrder,
+ convertSalesRfqToQuote,
+ copyQuote,
+ copyQuoteLine,
+ deleteCustomer,
+ deleteCustomerContact,
+ deleteCustomerLocation,
+ deleteCustomerStatus,
+ deleteCustomerType,
+ deleteNoQuoteReason,
+ deleteQuote,
+ deleteQuoteLine,
+ deleteQuoteMakeMethod,
+ deleteQuoteMaterial,
+ deleteQuoteOperation,
+ deleteQuoteOperationParameter,
+ deleteQuoteOperationStep,
+ deleteQuoteOperationTool,
+ deleteSalesOrder,
+ deleteSalesOrderLine,
+ deleteSalesRFQ,
+ deleteSalesRFQLine,
+ finalizeQuote,
+ getConfigurationParametersByQuoteLineId,
+ getCustomer,
+ getCustomerContact,
+ getCustomerContacts,
+ getCustomerLocation,
+ getCustomerLocations,
+ getCustomerPayment,
+ getCustomerShipping,
+ getCustomerStatus,
+ getCustomerStatuses,
+ getCustomerStatusesList,
+ getCustomers,
+ getCustomersList,
+ getCustomerType,
+ getCustomerTypes,
+ getCustomerTypesList,
+ getExternalSalesOrderLines,
+ getModelByQuoteLineId,
+ getNoQuoteReason,
+ getNoQuoteReasons,
+ getNoQuoteReasonsList,
+ getOpportunity,
+ getOpportunityDocuments,
+ getOpportunityLineDocuments,
+ getQuote,
+ getQuoteAssemblies,
+ getQuoteAssembliesByLine,
+ getQuoteByExternalId,
+ getQuoteCustomerDetails,
+ getQuoteFavorites,
+ getQuoteLine,
+ getQuoteLinePrices,
+ getQuoteLinePricesByItemId,
+ getQuoteLinePricesByItemIds,
+ getQuoteLinePricesByQuoteId,
+ getQuoteLines,
+ getQuoteLinesList,
+ getQuoteMakeMethod,
+ getQuoteMaterial,
+ getQuoteMaterials,
+ getQuoteMaterialsByLine,
+ getQuoteMaterialsByMethodId,
+ getQuoteMaterialsByOperation,
+ getQuoteMethodTreeArray,
+ getQuoteMethodTrees,
+ getQuoteOperation,
+ getQuoteOperations,
+ getQuoteOperationsByLine,
+ getQuoteOperationsByMethodId,
+ getQuotePayment,
+ getQuoteShipment,
+ getQuotes,
+ getQuotesList,
+ getRelatedPricesForQuoteLine,
+ getRootQuoteMakeMethod,
+ getSalesDocumentsAssignedToMe,
+ getSalesOrder,
+ getSalesOrderCustomerDetails,
+ getSalesOrderCustomers,
+ getSalesOrderFavorites,
+ getSalesOrderInvoiceLines,
+ getSalesOrderInvoicesByIds,
+ getSalesOrderLine,
+ getSalesOrderLineShipments,
+ getSalesOrderLines,
+ getSalesOrderLinesByItemId,
+ getSalesOrderLinesByItemIds,
+ getSalesOrderPayment,
+ getSalesOrderRelatedItems,
+ getSalesOrderShipment,
+ getSalesOrders,
+ getSalesOrdersList,
+ getSalesRFQ,
+ getSalesRFQFavorites,
+ getSalesRFQLine,
+ getSalesRFQLines,
+ getSalesRFQs,
+ getSalesTerms,
+ insertCustomerContact,
+ insertCustomerLocation,
+ insertSalesOrderLines,
+ recalculateQuoteLinePrices,
+ releaseSalesOrder,
+ updateCustomerAccounting,
+ updateCustomerContact,
+ updateCustomerLocation,
+ updateCustomerPayment,
+ updateCustomerShipping,
+ updateQuoteExchangeRate,
+ updateQuoteFavorite,
+ updateQuoteLinePrecision,
+ updateQuoteMaterialOrder,
+ updateQuoteOperationOrder,
+ updateQuoteStatus,
+ updateSalesOrderExchangeRate,
+ updateSalesOrderFavorite,
+ updateSalesOrderStatus,
+ updateSalesRFQFavorite,
+ updateSalesRFQLineOrder,
+ updateSalesRFQStatus,
+ upsertCustomer,
+ upsertCustomerStatus,
+ upsertCustomerType,
+ upsertMakeMethodFromQuoteLine,
+ upsertMakeMethodFromQuoteMethod,
+ upsertNoQuoteReason,
+ upsertQuote,
+ upsertQuoteLine,
+ upsertQuoteLineAdditionalCharges,
+ upsertQuoteLineMethod,
+ upsertQuoteLinePrices,
+ upsertQuoteMaterial,
+ upsertQuoteMaterialMakeMethod,
+ upsertQuoteOperation,
+ upsertQuoteOperationParameter,
+ upsertQuoteOperationStep,
+ upsertQuoteOperationTool,
+ upsertQuotePayment,
+ upsertQuoteShipment,
+ upsertSalesOrder,
+ upsertSalesOrderLine,
+ upsertSalesOrderPayment,
+ upsertSalesOrderShipment,
+ upsertSalesRFQ,
+ upsertSalesRFQLine
+} from "~/modules/sales/sales.service";
+import {
+ operationParameterValidator,
+ operationStepValidator,
+ operationToolValidator
+} from "~/modules/shared";
+import type { RegisterTools } from "../types";
+import {
+ DESTRUCTIVE_ANNOTATIONS,
+ READ_ONLY_ANNOTATIONS,
+ toMcpResult,
+ WRITE_ANNOTATIONS,
+ withErrorHandling
+} from "../types";
+
+export const registerSalesTools: RegisterTools = (server, ctx) => {
+ server.registerTool(
+ "sales_closeSalesOrder",
+ {
+ description: "close sales order",
+ inputSchema: {
+ salesOrderId: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await closeSalesOrder(
+ ctx.client,
+ params.salesOrderId,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_closeSalesOrder")
+ );
+
+ server.registerTool(
+ "sales_convertSalesRfqToQuote",
+ {
+ description: "convert sales rfq to quote",
+ inputSchema: {
+ payload: z.object({
+ id: z.string()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await convertSalesRfqToQuote(ctx.client, {
+ ...params.payload,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_convertSalesRfqToQuote")
+ );
+
+ server.registerTool(
+ "sales_convertQuoteToOrder",
+ {
+ description: "convert quote to order",
+ inputSchema: {
+ payload: selectedLinesValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await convertQuoteToOrder(ctx.client, {
+ ...params.payload,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_convertQuoteToOrder")
+ );
+
+ server.registerTool(
+ "sales_copyQuoteLine",
+ {
+ description: "copy quote line",
+ inputSchema: {
+ payload: getMethodValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await copyQuoteLine(ctx.client, {
+ ...params.payload,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_copyQuoteLine")
+ );
+
+ server.registerTool(
+ "sales_copyQuote",
+ {
+ description: "copy quote",
+ inputSchema: {
+ payload: getMethodValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await copyQuote(ctx.client, {
+ ...params.payload,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_copyQuote")
+ );
+
+ server.registerTool(
+ "sales_deleteCustomer",
+ {
+ description: "delete customer",
+ inputSchema: {
+ customerId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteCustomer(ctx.client, params.customerId);
+ return toMcpResult(result);
+ }, "Failed: sales_deleteCustomer")
+ );
+
+ server.registerTool(
+ "sales_deleteCustomerContact",
+ {
+ description: "delete customer contact",
+ inputSchema: {
+ customerId: z.string(),
+ customerContactId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteCustomerContact(
+ ctx.client,
+ params.customerId,
+ params.customerContactId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_deleteCustomerContact")
+ );
+
+ server.registerTool(
+ "sales_deleteCustomerLocation",
+ {
+ description: "delete customer location",
+ inputSchema: {
+ customerId: z.string(),
+ customerLocationId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteCustomerLocation(
+ ctx.client,
+ params.customerId,
+ params.customerLocationId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_deleteCustomerLocation")
+ );
+
+ server.registerTool(
+ "sales_deleteCustomerStatus",
+ {
+ description: "delete customer status",
+ inputSchema: {
+ customerStatusId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteCustomerStatus(
+ ctx.client,
+ params.customerStatusId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_deleteCustomerStatus")
+ );
+
+ server.registerTool(
+ "sales_deleteCustomerType",
+ {
+ description: "delete customer type",
+ inputSchema: {
+ customerTypeId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteCustomerType(
+ ctx.client,
+ params.customerTypeId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_deleteCustomerType")
+ );
+
+ server.registerTool(
+ "sales_deleteNoQuoteReason",
+ {
+ description: "delete no quote reason",
+ inputSchema: {
+ noQuoteReasonId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteNoQuoteReason(
+ ctx.client,
+ params.noQuoteReasonId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_deleteNoQuoteReason")
+ );
+
+ server.registerTool(
+ "sales_deleteQuote",
+ {
+ description: "delete quote",
+ inputSchema: {
+ quoteId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteQuote(ctx.client, params.quoteId);
+ return toMcpResult(result);
+ }, "Failed: sales_deleteQuote")
+ );
+
+ server.registerTool(
+ "sales_deleteQuoteMakeMethod",
+ {
+ description: "delete quote make method",
+ inputSchema: {
+ quoteMakeMethodId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteQuoteMakeMethod(
+ ctx.client,
+ params.quoteMakeMethodId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_deleteQuoteMakeMethod")
+ );
+
+ server.registerTool(
+ "sales_deleteQuoteLine",
+ {
+ description: "delete quote line",
+ inputSchema: {
+ quoteLineId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteQuoteLine(ctx.client, params.quoteLineId);
+ return toMcpResult(result);
+ }, "Failed: sales_deleteQuoteLine")
+ );
+
+ server.registerTool(
+ "sales_deleteQuoteMaterial",
+ {
+ description: "delete quote material",
+ inputSchema: {
+ quoteMaterialId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteQuoteMaterial(
+ ctx.client,
+ params.quoteMaterialId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_deleteQuoteMaterial")
+ );
+
+ server.registerTool(
+ "sales_deleteQuoteOperation",
+ {
+ description: "delete quote operation",
+ inputSchema: {
+ quoteOperationId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteQuoteOperation(
+ ctx.client,
+ params.quoteOperationId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_deleteQuoteOperation")
+ );
+
+ server.registerTool(
+ "sales_deleteQuoteOperationStep",
+ {
+ description: "delete quote operation step",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteQuoteOperationStep(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: sales_deleteQuoteOperationStep")
+ );
+
+ server.registerTool(
+ "sales_deleteQuoteOperationParameter",
+ {
+ description: "delete quote operation parameter",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteQuoteOperationParameter(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: sales_deleteQuoteOperationParameter")
+ );
+
+ server.registerTool(
+ "sales_deleteQuoteOperationTool",
+ {
+ description: "delete quote operation tool",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteQuoteOperationTool(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: sales_deleteQuoteOperationTool")
+ );
+
+ server.registerTool(
+ "sales_deleteSalesOrder",
+ {
+ description: "delete sales order",
+ inputSchema: {
+ salesOrderId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteSalesOrder(ctx.client, params.salesOrderId);
+ return toMcpResult(result);
+ }, "Failed: sales_deleteSalesOrder")
+ );
+
+ server.registerTool(
+ "sales_deleteSalesOrderLine",
+ {
+ description: "delete sales order line",
+ inputSchema: {
+ salesOrderLineId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteSalesOrderLine(
+ ctx.client,
+ params.salesOrderLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_deleteSalesOrderLine")
+ );
+
+ server.registerTool(
+ "sales_deleteSalesRFQ",
+ {
+ description: "delete sales r f q",
+ inputSchema: {
+ salesRfqId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteSalesRFQ(ctx.client, params.salesRfqId);
+ return toMcpResult(result);
+ }, "Failed: sales_deleteSalesRFQ")
+ );
+
+ server.registerTool(
+ "sales_deleteSalesRFQLine",
+ {
+ description: "delete sales r f q line",
+ inputSchema: {
+ salesRFQLineId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteSalesRFQLine(
+ ctx.client,
+ params.salesRFQLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_deleteSalesRFQLine")
+ );
+
+ server.registerTool(
+ "sales_getConfigurationParametersByQuoteLineId",
+ {
+ description: "get configuration parameters by quote line id",
+ inputSchema: {
+ quoteLineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getConfigurationParametersByQuoteLineId(
+ ctx.client,
+ params.quoteLineId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getConfigurationParametersByQuoteLineId")
+ );
+
+ server.registerTool(
+ "sales_getCustomer",
+ {
+ description: "get customer",
+ inputSchema: {
+ customerId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomer(ctx.client, params.customerId);
+ return toMcpResult(result);
+ }, "Failed: sales_getCustomer")
+ );
+
+ server.registerTool(
+ "sales_getCustomerContact",
+ {
+ description: "get customer contact",
+ inputSchema: {
+ customerContactId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomerContact(
+ ctx.client,
+ params.customerContactId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getCustomerContact")
+ );
+
+ server.registerTool(
+ "sales_getCustomerContacts",
+ {
+ description: "get customer contacts",
+ inputSchema: {
+ customerId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomerContacts(ctx.client, params.customerId);
+ return toMcpResult(result);
+ }, "Failed: sales_getCustomerContacts")
+ );
+
+ server.registerTool(
+ "sales_getCustomerLocation",
+ {
+ description: "get customer location",
+ inputSchema: {
+ customerLocationId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomerLocation(
+ ctx.client,
+ params.customerLocationId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getCustomerLocation")
+ );
+
+ server.registerTool(
+ "sales_getCustomerLocations",
+ {
+ description: "get customer locations",
+ inputSchema: {
+ customerId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomerLocations(ctx.client, params.customerId);
+ return toMcpResult(result);
+ }, "Failed: sales_getCustomerLocations")
+ );
+
+ server.registerTool(
+ "sales_getCustomerPayment",
+ {
+ description: "get customer payment",
+ inputSchema: {
+ customerId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomerPayment(ctx.client, params.customerId);
+ return toMcpResult(result);
+ }, "Failed: sales_getCustomerPayment")
+ );
+
+ server.registerTool(
+ "sales_getCustomerShipping",
+ {
+ description: "get customer shipping",
+ inputSchema: {
+ customerId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomerShipping(ctx.client, params.customerId);
+ return toMcpResult(result);
+ }, "Failed: sales_getCustomerShipping")
+ );
+
+ server.registerTool(
+ "sales_getCustomers",
+ {
+ description: "get customers",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomers(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: sales_getCustomers")
+ );
+
+ server.registerTool(
+ "sales_getCustomersList",
+ {
+ description: "get customers list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomersList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: sales_getCustomersList")
+ );
+
+ server.registerTool(
+ "sales_getCustomerStatus",
+ {
+ description: "get customer status",
+ inputSchema: {
+ customerStatusId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomerStatus(
+ ctx.client,
+ params.customerStatusId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getCustomerStatus")
+ );
+
+ server.registerTool(
+ "sales_getCustomerStatuses",
+ {
+ description: "get customer statuses",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomerStatuses(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getCustomerStatuses")
+ );
+
+ server.registerTool(
+ "sales_getCustomerStatusesList",
+ {
+ description: "get customer statuses list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomerStatusesList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: sales_getCustomerStatusesList")
+ );
+
+ server.registerTool(
+ "sales_getCustomerType",
+ {
+ description: "get customer type",
+ inputSchema: {
+ customerTypeId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomerType(ctx.client, params.customerTypeId);
+ return toMcpResult(result);
+ }, "Failed: sales_getCustomerType")
+ );
+
+ server.registerTool(
+ "sales_getCustomerTypes",
+ {
+ description: "get customer types",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomerTypes(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getCustomerTypes")
+ );
+
+ server.registerTool(
+ "sales_getCustomerTypesList",
+ {
+ description: "get customer types list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomerTypesList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: sales_getCustomerTypesList")
+ );
+
+ server.registerTool(
+ "sales_getExternalSalesOrderLines",
+ {
+ description: "get external sales order lines",
+ inputSchema: {
+ customerId: z.string(),
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getExternalSalesOrderLines(
+ ctx.client,
+ params.customerId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getExternalSalesOrderLines")
+ );
+
+ server.registerTool(
+ "sales_getModelByQuoteLineId",
+ {
+ description: "get model by quote line id",
+ inputSchema: {
+ quoteLineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getModelByQuoteLineId(
+ ctx.client,
+ params.quoteLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getModelByQuoteLineId")
+ );
+
+ server.registerTool(
+ "sales_getNoQuoteReasonsList",
+ {
+ description: "get no quote reasons list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getNoQuoteReasonsList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: sales_getNoQuoteReasonsList")
+ );
+
+ server.registerTool(
+ "sales_getNoQuoteReason",
+ {
+ description: "get no quote reason",
+ inputSchema: {
+ noQuoteReasonId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getNoQuoteReason(ctx.client, params.noQuoteReasonId);
+ return toMcpResult(result);
+ }, "Failed: sales_getNoQuoteReason")
+ );
+
+ server.registerTool(
+ "sales_getNoQuoteReasons",
+ {
+ description: "get no quote reasons",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getNoQuoteReasons(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getNoQuoteReasons")
+ );
+
+ server.registerTool(
+ "sales_getOpportunity",
+ {
+ description: "get opportunity",
+ inputSchema: {
+ opportunityId: z.string().nullable()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getOpportunity(ctx.client, params.opportunityId);
+ return toMcpResult(result);
+ }, "Failed: sales_getOpportunity")
+ );
+
+ server.registerTool(
+ "sales_getOpportunityDocuments",
+ {
+ description: "get opportunity documents",
+ inputSchema: {
+ opportunityId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getOpportunityDocuments(
+ ctx.client,
+ ctx.companyId,
+ params.opportunityId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getOpportunityDocuments")
+ );
+
+ server.registerTool(
+ "sales_getOpportunityLineDocuments",
+ {
+ description: "get opportunity line documents",
+ inputSchema: {
+ lineId: z.string(),
+ itemId: z.string().nullable().optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getOpportunityLineDocuments(
+ ctx.client,
+ ctx.companyId,
+ params.lineId,
+ params.itemId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getOpportunityLineDocuments")
+ );
+
+ server.registerTool(
+ "sales_getQuote",
+ {
+ description: "get quote",
+ inputSchema: {
+ quoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuote(ctx.client, params.quoteId);
+ return toMcpResult(result);
+ }, "Failed: sales_getQuote")
+ );
+
+ server.registerTool(
+ "sales_getQuoteFavorites",
+ {
+ description: "get quote favorites",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteFavorites(
+ ctx.client,
+ ctx.companyId,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteFavorites")
+ );
+
+ server.registerTool(
+ "sales_getQuotes",
+ {
+ description: "get quotes",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuotes(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: sales_getQuotes")
+ );
+
+ server.registerTool(
+ "sales_getQuotesList",
+ {
+ description: "get quotes list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuotesList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: sales_getQuotesList")
+ );
+
+ server.registerTool(
+ "sales_getQuoteAssembliesByLine",
+ {
+ description: "get quote assemblies by line",
+ inputSchema: {
+ quoteLineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteAssembliesByLine(
+ ctx.client,
+ params.quoteLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteAssembliesByLine")
+ );
+
+ server.registerTool(
+ "sales_getQuoteAssemblies",
+ {
+ description: "get quote assemblies",
+ inputSchema: {
+ quoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteAssemblies(ctx.client, params.quoteId);
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteAssemblies")
+ );
+
+ server.registerTool(
+ "sales_getQuoteCustomerDetails",
+ {
+ description: "get quote customer details",
+ inputSchema: {
+ quoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteCustomerDetails(ctx.client, params.quoteId);
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteCustomerDetails")
+ );
+
+ server.registerTool(
+ "sales_getQuoteLine",
+ {
+ description: "get quote line",
+ inputSchema: {
+ quoteLineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteLine(ctx.client, params.quoteLineId);
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteLine")
+ );
+
+ server.registerTool(
+ "sales_getQuoteLinesList",
+ {
+ description: "get quote lines list",
+ inputSchema: {
+ quoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteLinesList(ctx.client, params.quoteId);
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteLinesList")
+ );
+
+ server.registerTool(
+ "sales_getQuoteMakeMethod",
+ {
+ description: "get quote make method",
+ inputSchema: {
+ quoteMakeMethodId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteMakeMethod(
+ ctx.client,
+ params.quoteMakeMethodId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteMakeMethod")
+ );
+
+ server.registerTool(
+ "sales_getRootQuoteMakeMethod",
+ {
+ description: "get root quote make method",
+ inputSchema: {
+ quoteLineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getRootQuoteMakeMethod(
+ ctx.client,
+ params.quoteLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getRootQuoteMakeMethod")
+ );
+
+ server.registerTool(
+ "sales_getQuoteMethodTrees",
+ {
+ description: "get quote method trees",
+ inputSchema: {
+ quoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteMethodTrees(ctx.client, params.quoteId);
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteMethodTrees")
+ );
+
+ server.registerTool(
+ "sales_getQuoteMethodTreeArray",
+ {
+ description: "get quote method tree array",
+ inputSchema: {
+ quoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteMethodTreeArray(ctx.client, params.quoteId);
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteMethodTreeArray")
+ );
+
+ server.registerTool(
+ "sales_getQuoteLines",
+ {
+ description: "get quote lines",
+ inputSchema: {
+ quoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteLines(ctx.client, params.quoteId);
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteLines")
+ );
+
+ server.registerTool(
+ "sales_getQuoteByExternalId",
+ {
+ description: "get quote by external id",
+ inputSchema: {
+ externalId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteByExternalId(ctx.client, params.externalId);
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteByExternalId")
+ );
+
+ server.registerTool(
+ "sales_getQuoteLinePrices",
+ {
+ description: "get quote line prices",
+ inputSchema: {
+ quoteLineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteLinePrices(ctx.client, params.quoteLineId);
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteLinePrices")
+ );
+
+ server.registerTool(
+ "sales_getQuoteLinePricesByQuoteId",
+ {
+ description: "get quote line prices by quote id",
+ inputSchema: {
+ quoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteLinePricesByQuoteId(
+ ctx.client,
+ params.quoteId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteLinePricesByQuoteId")
+ );
+
+ server.registerTool(
+ "sales_getQuoteLinePricesByItemId",
+ {
+ description: "get quote line prices by item id",
+ inputSchema: {
+ itemId: z.string(),
+ currentQuoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteLinePricesByItemId(
+ ctx.client,
+ params.itemId,
+ params.currentQuoteId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteLinePricesByItemId")
+ );
+
+ server.registerTool(
+ "sales_getQuoteLinePricesByItemIds",
+ {
+ description: "get quote line prices by item ids",
+ inputSchema: {
+ itemIds: z.array(z.string()),
+ currentQuoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteLinePricesByItemIds(
+ ctx.client,
+ params.itemIds,
+ params.currentQuoteId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteLinePricesByItemIds")
+ );
+
+ server.registerTool(
+ "sales_getQuoteMaterials",
+ {
+ description: "get quote materials",
+ inputSchema: {
+ quoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteMaterials(ctx.client, params.quoteId);
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteMaterials")
+ );
+
+ server.registerTool(
+ "sales_getQuoteMaterial",
+ {
+ description: "get quote material",
+ inputSchema: {
+ materialId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteMaterial(ctx.client, params.materialId);
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteMaterial")
+ );
+
+ server.registerTool(
+ "sales_getQuoteMaterialsByLine",
+ {
+ description: "get quote materials by line",
+ inputSchema: {
+ quoteLineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteMaterialsByLine(
+ ctx.client,
+ params.quoteLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteMaterialsByLine")
+ );
+
+ server.registerTool(
+ "sales_getQuoteMaterialsByMethodId",
+ {
+ description: "get quote materials by method id",
+ inputSchema: {
+ quoteMakeMethodId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteMaterialsByMethodId(
+ ctx.client,
+ params.quoteMakeMethodId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteMaterialsByMethodId")
+ );
+
+ server.registerTool(
+ "sales_getQuoteMaterialsByOperation",
+ {
+ description: "get quote materials by operation",
+ inputSchema: {
+ quoteOperationId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteMaterialsByOperation(
+ ctx.client,
+ params.quoteOperationId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteMaterialsByOperation")
+ );
+
+ server.registerTool(
+ "sales_getQuoteOperation",
+ {
+ description: "get quote operation",
+ inputSchema: {
+ quoteOperationId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteOperation(
+ ctx.client,
+ params.quoteOperationId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteOperation")
+ );
+
+ server.registerTool(
+ "sales_getQuoteOperationsByLine",
+ {
+ description: "get quote operations by line",
+ inputSchema: {
+ quoteLineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteOperationsByLine(
+ ctx.client,
+ params.quoteLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteOperationsByLine")
+ );
+
+ server.registerTool(
+ "sales_getQuoteOperationsByMethodId",
+ {
+ description: "get quote operations by method id",
+ inputSchema: {
+ quoteMakeMethodId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteOperationsByMethodId(
+ ctx.client,
+ params.quoteMakeMethodId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteOperationsByMethodId")
+ );
+
+ server.registerTool(
+ "sales_getQuoteOperations",
+ {
+ description: "get quote operations",
+ inputSchema: {
+ quoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteOperations(ctx.client, params.quoteId);
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteOperations")
+ );
+
+ server.registerTool(
+ "sales_getQuotePayment",
+ {
+ description: "get quote payment",
+ inputSchema: {
+ quoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuotePayment(ctx.client, params.quoteId);
+ return toMcpResult(result);
+ }, "Failed: sales_getQuotePayment")
+ );
+
+ server.registerTool(
+ "sales_getQuoteShipment",
+ {
+ description: "get quote shipment",
+ inputSchema: {
+ quoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getQuoteShipment(ctx.client, params.quoteId);
+ return toMcpResult(result);
+ }, "Failed: sales_getQuoteShipment")
+ );
+
+ server.registerTool(
+ "sales_getRelatedPricesForQuoteLine",
+ {
+ description: "get related prices for quote line",
+ inputSchema: {
+ itemId: z.string(),
+ quoteId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getRelatedPricesForQuoteLine(
+ ctx.client,
+ params.itemId,
+ params.quoteId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getRelatedPricesForQuoteLine")
+ );
+
+ server.registerTool(
+ "sales_getSalesDocumentsAssignedToMe",
+ {
+ description: "get sales documents assigned to me",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesDocumentsAssignedToMe(
+ ctx.client,
+ ctx.userId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesDocumentsAssignedToMe")
+ );
+
+ server.registerTool(
+ "sales_getSalesOrder",
+ {
+ description: "get sales order",
+ inputSchema: {
+ salesOrderId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesOrder(ctx.client, params.salesOrderId);
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesOrder")
+ );
+
+ server.registerTool(
+ "sales_getSalesOrderCustomerDetails",
+ {
+ description: "get sales order customer details",
+ inputSchema: {
+ salesOrderId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesOrderCustomerDetails(
+ ctx.client,
+ params.salesOrderId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesOrderCustomerDetails")
+ );
+
+ server.registerTool(
+ "sales_getSalesOrderFavorites",
+ {
+ description: "get sales order favorites",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesOrderFavorites(
+ ctx.client,
+ ctx.companyId,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesOrderFavorites")
+ );
+
+ server.registerTool(
+ "sales_getSalesOrderRelatedItems",
+ {
+ description: "get sales order related items",
+ inputSchema: {
+ salesOrderId: z.string(),
+ opportunityId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesOrderRelatedItems(
+ ctx.client,
+ params.salesOrderId,
+ params.opportunityId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesOrderRelatedItems")
+ );
+
+ server.registerTool(
+ "sales_getSalesOrders",
+ {
+ description: "get sales orders",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ status: z.string().nullable(),
+ customerId: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesOrders(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesOrders")
+ );
+
+ server.registerTool(
+ "sales_getSalesOrdersList",
+ {
+ description: "get sales orders list",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesOrdersList(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesOrdersList")
+ );
+
+ server.registerTool(
+ "sales_getSalesOrderPayment",
+ {
+ description: "get sales order payment",
+ inputSchema: {
+ salesOrderId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesOrderPayment(
+ ctx.client,
+ params.salesOrderId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesOrderPayment")
+ );
+
+ server.registerTool(
+ "sales_getSalesTerms",
+ {
+ description: "get sales terms",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesTerms(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesTerms")
+ );
+
+ server.registerTool(
+ "sales_getSalesOrderShipment",
+ {
+ description: "get sales order shipment",
+ inputSchema: {
+ salesOrderId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesOrderShipment(
+ ctx.client,
+ params.salesOrderId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesOrderShipment")
+ );
+
+ server.registerTool(
+ "sales_getSalesOrderCustomers",
+ {
+ description: "get sales order customers",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesOrderCustomers(ctx.client);
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesOrderCustomers")
+ );
+
+ server.registerTool(
+ "sales_getSalesOrderLines",
+ {
+ description: "get sales order lines",
+ inputSchema: {
+ salesOrderId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesOrderLines(ctx.client, params.salesOrderId);
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesOrderLines")
+ );
+
+ server.registerTool(
+ "sales_getSalesOrderInvoiceLines",
+ {
+ description: "get sales order invoice lines",
+ inputSchema: {
+ salesOrderId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesOrderInvoiceLines(
+ ctx.client,
+ params.salesOrderId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesOrderInvoiceLines")
+ );
+
+ server.registerTool(
+ "sales_getSalesOrderInvoicesByIds",
+ {
+ description: "get sales order invoices by ids",
+ inputSchema: {
+ invoiceIds: z.array(z.string())
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesOrderInvoicesByIds(
+ ctx.client,
+ params.invoiceIds
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesOrderInvoicesByIds")
+ );
+
+ server.registerTool(
+ "sales_getSalesOrderLinesByItemId",
+ {
+ description: "get sales order lines by item id",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesOrderLinesByItemId(
+ ctx.client,
+ params.itemId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesOrderLinesByItemId")
+ );
+
+ server.registerTool(
+ "sales_getSalesOrderLinesByItemIds",
+ {
+ description: "get sales order lines by item ids",
+ inputSchema: {
+ itemIds: z.array(z.string())
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesOrderLinesByItemIds(
+ ctx.client,
+ params.itemIds
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesOrderLinesByItemIds")
+ );
+
+ server.registerTool(
+ "sales_getSalesOrderLine",
+ {
+ description: "get sales order line",
+ inputSchema: {
+ salesOrderLineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesOrderLine(
+ ctx.client,
+ params.salesOrderLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesOrderLine")
+ );
+
+ server.registerTool(
+ "sales_getSalesOrderLineShipments",
+ {
+ description: "get sales order line shipments",
+ inputSchema: {
+ salesOrderLineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesOrderLineShipments(
+ ctx.client,
+ params.salesOrderLineId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesOrderLineShipments")
+ );
+
+ server.registerTool(
+ "sales_getSalesRFQ",
+ {
+ description: "get sales r f q",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesRFQ(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesRFQ")
+ );
+
+ server.registerTool(
+ "sales_getSalesRFQFavorites",
+ {
+ description: "get sales r f q favorites",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesRFQFavorites(
+ ctx.client,
+ ctx.companyId,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesRFQFavorites")
+ );
+
+ server.registerTool(
+ "sales_getSalesRFQs",
+ {
+ description: "get sales r f qs",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesRFQs(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesRFQs")
+ );
+
+ server.registerTool(
+ "sales_getSalesRFQLine",
+ {
+ description: "get sales r f q line",
+ inputSchema: {
+ lineId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesRFQLine(ctx.client, params.lineId);
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesRFQLine")
+ );
+
+ server.registerTool(
+ "sales_getSalesRFQLines",
+ {
+ description: "get sales r f q lines",
+ inputSchema: {
+ salesRfqId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSalesRFQLines(ctx.client, params.salesRfqId);
+ return toMcpResult(result);
+ }, "Failed: sales_getSalesRFQLines")
+ );
+
+ server.registerTool(
+ "sales_insertCustomerContact",
+ {
+ description: "insert customer contact",
+ inputSchema: {
+ customerContact: customerContactValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertCustomerContact(ctx.client, {
+ ...params.customerContact,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_insertCustomerContact")
+ );
+
+ server.registerTool(
+ "sales_insertCustomerLocation",
+ {
+ description: "insert customer location",
+ inputSchema: {
+ customerLocation: z.object({
+ customerId: z.string(),
+ name: z.string(),
+ address: z.any(),
+ addressLine1: z.string().optional(),
+ addressLine2: z.string().optional(),
+ city: z.string().optional(),
+ stateProvince: z.string().optional(),
+ countryCode: z.string().optional(),
+ postalCode: z.string().optional(),
+ customFields: z.any().optional()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertCustomerLocation(ctx.client, {
+ ...params.customerLocation,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_insertCustomerLocation")
+ );
+
+ server.registerTool(
+ "sales_insertSalesOrderLines",
+ {
+ description: "insert sales order lines",
+ inputSchema: {
+ salesOrderLines: salesOrderLineValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertSalesOrderLines(ctx.client, {
+ ...params.salesOrderLines,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_insertSalesOrderLines")
+ );
+
+ server.registerTool(
+ "sales_finalizeQuote",
+ {
+ description: "finalize quote",
+ inputSchema: {
+ quoteId: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await finalizeQuote(
+ ctx.client,
+ params.quoteId,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_finalizeQuote")
+ );
+
+ server.registerTool(
+ "sales_releaseSalesOrder",
+ {
+ description: "release sales order",
+ inputSchema: {
+ salesOrderId: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await releaseSalesOrder(
+ ctx.client,
+ params.salesOrderId,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_releaseSalesOrder")
+ );
+
+ server.registerTool(
+ "sales_upsertCustomer",
+ {
+ description: "upsert customer",
+ inputSchema: {
+ customer: customerValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertCustomer(ctx.client, {
+ ...params.customer,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertCustomer")
+ );
+
+ server.registerTool(
+ "sales_updateCustomerAccounting",
+ {
+ description: "update customer accounting",
+ inputSchema: {
+ customerAccounting: customerAccountingValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateCustomerAccounting(ctx.client, {
+ ...params.customerAccounting,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_updateCustomerAccounting")
+ );
+
+ server.registerTool(
+ "sales_updateCustomerContact",
+ {
+ description: "update customer contact",
+ inputSchema: {
+ customerContact: customerContactValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateCustomerContact(
+ ctx.client,
+ params.customerContact
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_updateCustomerContact")
+ );
+
+ server.registerTool(
+ "sales_updateCustomerLocation",
+ {
+ description: "update customer location",
+ inputSchema: {
+ customerLocation: z.object({
+ addressId: z.string(),
+ name: z.string(),
+ address: z.any(),
+ addressLine1: z.string().optional(),
+ addressLine2: z.string().optional(),
+ city: z.string().optional(),
+ stateProvince: z.string().optional(),
+ countryCode: z.string().optional(),
+ postalCode: z.string().optional(),
+ customFields: z.any().optional()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateCustomerLocation(
+ ctx.client,
+ params.customerLocation
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_updateCustomerLocation")
+ );
+
+ server.registerTool(
+ "sales_updateCustomerPayment",
+ {
+ description: "update customer payment",
+ inputSchema: {
+ customerPayment: customerPaymentValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateCustomerPayment(ctx.client, {
+ ...params.customerPayment,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_updateCustomerPayment")
+ );
+
+ server.registerTool(
+ "sales_updateCustomerShipping",
+ {
+ description: "update customer shipping",
+ inputSchema: {
+ customerShipping: customerShippingValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateCustomerShipping(ctx.client, {
+ ...params.customerShipping,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_updateCustomerShipping")
+ );
+
+ server.registerTool(
+ "sales_upsertCustomerStatus",
+ {
+ description: "upsert customer status",
+ inputSchema: {
+ customerStatus: customerStatusValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertCustomerStatus(ctx.client, {
+ ...params.customerStatus,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertCustomerStatus")
+ );
+
+ server.registerTool(
+ "sales_upsertCustomerType",
+ {
+ description: "upsert customer type",
+ inputSchema: {
+ customerType: customerTypeValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertCustomerType(ctx.client, {
+ ...params.customerType,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertCustomerType")
+ );
+
+ server.registerTool(
+ "sales_upsertNoQuoteReason",
+ {
+ description: "upsert no quote reason",
+ inputSchema: {
+ noQuoteReason: noQuoteReasonValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertNoQuoteReason(ctx.client, {
+ ...params.noQuoteReason,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertNoQuoteReason")
+ );
+
+ server.registerTool(
+ "sales_updateSalesRFQFavorite",
+ {
+ description: "update sales r f q favorite",
+ inputSchema: {
+ args: z.object({
+ id: z.string(),
+ favorite: z.boolean()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSalesRFQFavorite(ctx.client, {
+ ...params.args,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_updateSalesRFQFavorite")
+ );
+
+ server.registerTool(
+ "sales_updateSalesRFQLineOrder",
+ {
+ description: "update sales r f q line order",
+ inputSchema: {
+ updates: z.object({
+ id: z.string(),
+ order: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSalesRFQLineOrder(ctx.client, {
+ ...params.updates,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_updateSalesRFQLineOrder")
+ );
+
+ server.registerTool(
+ "sales_updateQuoteExchangeRate",
+ {
+ description: "update quote exchange rate",
+ inputSchema: {
+ data: z.object({
+ id: z.string(),
+ exchangeRate: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateQuoteExchangeRate(ctx.client, params.data);
+ return toMcpResult(result);
+ }, "Failed: sales_updateQuoteExchangeRate")
+ );
+
+ server.registerTool(
+ "sales_updateQuoteLinePrecision",
+ {
+ description: "update quote line precision",
+ inputSchema: {
+ quoteLineId: z.string(),
+ precision: z.number()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateQuoteLinePrecision(
+ ctx.client,
+ params.quoteLineId,
+ params.precision
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_updateQuoteLinePrecision")
+ );
+
+ server.registerTool(
+ "sales_updateSalesOrderExchangeRate",
+ {
+ description: "update sales order exchange rate",
+ inputSchema: {
+ data: z.object({
+ id: z.string(),
+ exchangeRate: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSalesOrderExchangeRate(
+ ctx.client,
+ params.data
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_updateSalesOrderExchangeRate")
+ );
+
+ server.registerTool(
+ "sales_updateQuoteFavorite",
+ {
+ description: "update quote favorite",
+ inputSchema: {
+ args: z.object({
+ id: z.string(),
+ favorite: z.boolean()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateQuoteFavorite(ctx.client, {
+ ...params.args,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_updateQuoteFavorite")
+ );
+
+ server.registerTool(
+ "sales_updateSalesRFQStatus",
+ {
+ description: "update sales r f q status",
+ inputSchema: {
+ update: z.object({
+ id: z.string(),
+ status: z.any(),
+ noQuoteReasonId: z.string().nullable(),
+ assignee: z.any()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSalesRFQStatus(ctx.client, {
+ ...params.update,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_updateSalesRFQStatus")
+ );
+
+ server.registerTool(
+ "sales_updateQuoteMaterialOrder",
+ {
+ description: "update quote material order",
+ inputSchema: {
+ updates: z.object({
+ id: z.string(),
+ order: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateQuoteMaterialOrder(ctx.client, {
+ ...params.updates,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_updateQuoteMaterialOrder")
+ );
+
+ server.registerTool(
+ "sales_updateQuoteOperationOrder",
+ {
+ description: "update quote operation order",
+ inputSchema: {
+ updates: z.object({
+ id: z.string(),
+ order: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateQuoteOperationOrder(ctx.client, {
+ ...params.updates,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_updateQuoteOperationOrder")
+ );
+
+ server.registerTool(
+ "sales_updateQuoteStatus",
+ {
+ description: "update quote status",
+ inputSchema: {
+ update: z.object({
+ id: z.string(),
+ status: z.any(),
+ assignee: z.any()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateQuoteStatus(ctx.client, {
+ ...params.update,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_updateQuoteStatus")
+ );
+
+ server.registerTool(
+ "sales_upsertMakeMethodFromQuoteLine",
+ {
+ description: "upsert make method from quote line",
+ inputSchema: {
+ lineMethod: z.object({
+ itemId: z.string(),
+ quoteId: z.string(),
+ quoteLineId: z.string(),
+ parts: z.any().optional(),
+ billOfMaterial: z.boolean(),
+ billOfProcess: z.boolean(),
+ parameters: z.boolean(),
+ tools: z.boolean(),
+ steps: z.boolean(),
+ workInstructions: z.boolean()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMakeMethodFromQuoteLine(ctx.client, {
+ ...params.lineMethod,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertMakeMethodFromQuoteLine")
+ );
+
+ server.registerTool(
+ "sales_upsertMakeMethodFromQuoteMethod",
+ {
+ description: "upsert make method from quote method",
+ inputSchema: {
+ quoteMethod: z.object({
+ sourceId: z.string(),
+ targetId: z.string(),
+ parts: z.any().optional(),
+ billOfMaterial: z.boolean(),
+ billOfProcess: z.boolean(),
+ parameters: z.boolean(),
+ tools: z.boolean(),
+ steps: z.boolean(),
+ workInstructions: z.boolean()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertMakeMethodFromQuoteMethod(ctx.client, {
+ ...params.quoteMethod,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertMakeMethodFromQuoteMethod")
+ );
+
+ server.registerTool(
+ "sales_upsertQuote",
+ {
+ description: "upsert quote",
+ inputSchema: {
+ quote: quoteValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertQuote(ctx.client, {
+ ...params.quote,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertQuote")
+ );
+
+ server.registerTool(
+ "sales_upsertQuoteLine",
+ {
+ description: "upsert quote line",
+ inputSchema: {
+ quotationLine: quoteLineValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertQuoteLine(ctx.client, {
+ ...params.quotationLine,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertQuoteLine")
+ );
+
+ server.registerTool(
+ "sales_upsertQuoteLineAdditionalCharges",
+ {
+ description: "upsert quote line additional charges",
+ inputSchema: {
+ lineId: z.string(),
+ update: quoteLineAdditionalChargesValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertQuoteLineAdditionalCharges(
+ ctx.client,
+ params.lineId,
+ { ...params.update, updatedBy: ctx.userId }
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_upsertQuoteLineAdditionalCharges")
+ );
+
+ server.registerTool(
+ "sales_upsertQuoteLinePrices",
+ {
+ description: "upsert quote line prices",
+ inputSchema: {
+ quoteId: z.string(),
+ lineId: z.string(),
+ quoteLinePrices: z.object({
+ quoteLineId: z.string(),
+ unitPrice: z.number(),
+ leadTime: z.number(),
+ discountPercent: z.number(),
+ quantity: z.number(),
+ categoryMarkups: z.any().optional()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertQuoteLinePrices(
+ ctx.client,
+ params.quoteId,
+ params.lineId,
+ { ...params.quoteLinePrices, createdBy: ctx.userId }
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_upsertQuoteLinePrices")
+ );
+
+ server.registerTool(
+ "sales_calculatePricesForQuantities",
+ {
+ description: "calculate prices for quantities",
+ inputSchema: {
+ quoteId: z.string(),
+ quoteLineId: z.string(),
+ quantities: z.array(z.number())
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await calculatePricesForQuantities(
+ ctx.client,
+ params.quoteId,
+ params.quoteLineId,
+ params.quantities,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_calculatePricesForQuantities")
+ );
+
+ server.registerTool(
+ "sales_recalculateQuoteLinePrices",
+ {
+ description: "recalculate quote line prices",
+ inputSchema: {
+ quoteId: z.string(),
+ quoteLineId: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await recalculateQuoteLinePrices(
+ ctx.client,
+ params.quoteId,
+ params.quoteLineId,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: sales_recalculateQuoteLinePrices")
+ );
+
+ server.registerTool(
+ "sales_upsertQuoteLineMethod",
+ {
+ description: "upsert quote line method",
+ inputSchema: {
+ lineMethod: z.object({
+ itemId: z.string(),
+ quoteId: z.string(),
+ quoteLineId: z.string(),
+ configuration: z.any().optional(),
+ parts: z.any().optional(),
+ billOfMaterial: z.boolean(),
+ billOfProcess: z.boolean(),
+ parameters: z.boolean(),
+ tools: z.boolean(),
+ steps: z.boolean(),
+ workInstructions: z.boolean()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertQuoteLineMethod(ctx.client, {
+ ...params.lineMethod,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertQuoteLineMethod")
+ );
+
+ server.registerTool(
+ "sales_upsertQuoteMaterial",
+ {
+ description: "upsert quote material",
+ inputSchema: {
+ quoteMaterial: quoteMaterialValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertQuoteMaterial(ctx.client, {
+ ...params.quoteMaterial,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertQuoteMaterial")
+ );
+
+ server.registerTool(
+ "sales_upsertQuoteMaterialMakeMethod",
+ {
+ description: "upsert quote material make method",
+ inputSchema: {
+ quoteMethod: z.object({
+ sourceId: z.string(),
+ targetId: z.string(),
+ configuration: z.any().optional(),
+ parts: z.any().optional(),
+ billOfMaterial: z.boolean(),
+ billOfProcess: z.boolean(),
+ parameters: z.boolean(),
+ tools: z.boolean(),
+ steps: z.boolean(),
+ workInstructions: z.boolean()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertQuoteMaterialMakeMethod(ctx.client, {
+ ...params.quoteMethod,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertQuoteMaterialMakeMethod")
+ );
+
+ server.registerTool(
+ "sales_upsertQuoteOperation",
+ {
+ description: "upsert quote operation",
+ inputSchema: {
+ operation: quoteOperationValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertQuoteOperation(ctx.client, {
+ ...params.operation,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertQuoteOperation")
+ );
+
+ server.registerTool(
+ "sales_upsertQuoteOperationStep",
+ {
+ description: "upsert quote operation step",
+ inputSchema: {
+ quoteOperationStep: operationStepValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertQuoteOperationStep(ctx.client, {
+ ...params.quoteOperationStep,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertQuoteOperationStep")
+ );
+
+ server.registerTool(
+ "sales_upsertQuoteOperationParameter",
+ {
+ description: "upsert quote operation parameter",
+ inputSchema: {
+ quoteOperationParameter: operationParameterValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertQuoteOperationParameter(ctx.client, {
+ ...params.quoteOperationParameter,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertQuoteOperationParameter")
+ );
+
+ server.registerTool(
+ "sales_upsertQuoteOperationTool",
+ {
+ description: "upsert quote operation tool",
+ inputSchema: {
+ quoteOperationTool: operationToolValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertQuoteOperationTool(ctx.client, {
+ ...params.quoteOperationTool,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertQuoteOperationTool")
+ );
+
+ server.registerTool(
+ "sales_upsertQuotePayment",
+ {
+ description: "upsert quote payment",
+ inputSchema: {
+ quotePayment: quotePaymentValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertQuotePayment(ctx.client, {
+ ...params.quotePayment,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertQuotePayment")
+ );
+
+ server.registerTool(
+ "sales_upsertQuoteShipment",
+ {
+ description: "upsert quote shipment",
+ inputSchema: {
+ quoteShipment: quoteShipmentValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertQuoteShipment(ctx.client, {
+ ...params.quoteShipment,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertQuoteShipment")
+ );
+
+ server.registerTool(
+ "sales_updateSalesOrderFavorite",
+ {
+ description: "update sales order favorite",
+ inputSchema: {
+ args: z.object({
+ id: z.string(),
+ favorite: z.boolean()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSalesOrderFavorite(ctx.client, {
+ ...params.args,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_updateSalesOrderFavorite")
+ );
+
+ server.registerTool(
+ "sales_updateSalesOrderStatus",
+ {
+ description: "update sales order status",
+ inputSchema: {
+ update: z.object({
+ id: z.string(),
+ status: z.any(),
+ assignee: z.any()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSalesOrderStatus(ctx.client, {
+ ...params.update,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_updateSalesOrderStatus")
+ );
+
+ server.registerTool(
+ "sales_upsertSalesOrder",
+ {
+ description: "upsert sales order",
+ inputSchema: {
+ salesOrder: salesOrderValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertSalesOrder(ctx.client, {
+ ...params.salesOrder,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertSalesOrder")
+ );
+
+ server.registerTool(
+ "sales_upsertSalesOrderShipment",
+ {
+ description: "upsert sales order shipment",
+ inputSchema: {
+ salesOrderShipment: salesOrderShipmentValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertSalesOrderShipment(ctx.client, {
+ ...params.salesOrderShipment,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertSalesOrderShipment")
+ );
+
+ server.registerTool(
+ "sales_upsertSalesOrderLine",
+ {
+ description: "upsert sales order line",
+ inputSchema: {
+ salesOrderLine: salesOrderLineValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertSalesOrderLine(ctx.client, {
+ ...params.salesOrderLine,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertSalesOrderLine")
+ );
+
+ server.registerTool(
+ "sales_upsertSalesOrderPayment",
+ {
+ description: "upsert sales order payment",
+ inputSchema: {
+ salesOrderPayment: salesOrderPaymentValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertSalesOrderPayment(ctx.client, {
+ ...params.salesOrderPayment,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertSalesOrderPayment")
+ );
+
+ server.registerTool(
+ "sales_upsertSalesRFQ",
+ {
+ description: "upsert sales r f q",
+ inputSchema: {
+ rfq: salesRfqValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertSalesRFQ(ctx.client, {
+ ...params.rfq,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertSalesRFQ")
+ );
+
+ server.registerTool(
+ "sales_upsertSalesRFQLine",
+ {
+ description: "upsert sales r f q line",
+ inputSchema: {
+ salesRfqLine: salesRfqLineValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertSalesRFQLine(ctx.client, {
+ ...params.salesRfqLine,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: sales_upsertSalesRFQLine")
+ );
+};
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tools/settings.ts b/apps/erp/app/routes/api+/mcp+/lib/tools/settings.ts
new file mode 100644
index 0000000000..d97edcdf5a
--- /dev/null
+++ b/apps/erp/app/routes/api+/mcp+/lib/tools/settings.ts
@@ -0,0 +1,1301 @@
+// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+import { z } from "zod";
+import {
+ accountsPayableBillingAddressValidator,
+ accountsReceivableBillingAddressValidator,
+ apiKeyValidator,
+ companyValidator,
+ sequenceValidator,
+ webhookValidator
+} from "~/modules/settings/settings.models";
+import {
+ deactivateWebhooks,
+ deleteApiKey,
+ deleteWebhook,
+ getAccountsPayableBillingAddress,
+ getAccountsReceivableBillingAddress,
+ getApiKeys,
+ getCompanies,
+ getCompany,
+ getCompanyIntegrations,
+ getCompanyPlan,
+ getCompanySettings,
+ getConfig,
+ getCurrentSequence,
+ getCustomField,
+ getCustomFields,
+ getCustomFieldsTables,
+ getIntegration,
+ getIntegrations,
+ getKanbanOutputSetting,
+ getNextSequence,
+ getPlanById,
+ getPlans,
+ getSequence,
+ getSequences,
+ getSequencesList,
+ getTerms,
+ getWebhook,
+ getWebhooks,
+ getWebhookTables,
+ insertCompany,
+ seedCompany,
+ updateAccountsPayableAddressSetting,
+ updateAccountsPayableBillingAddress,
+ updateAccountsPayableEmail,
+ updateAccountsReceivableAddressSetting,
+ updateAccountsReceivableBillingAddress,
+ updateAccountsReceivableEmail,
+ updateCompany,
+ updateCompanyPlan,
+ updateConsoleSetting,
+ updateDefaultCustomerCc,
+ updateDefaultSupplierCc,
+ updateDigitalQuoteSetting,
+ updateIntegrationMetadata,
+ updateJobTravelerWorkInstructions,
+ updateKanbanOutputSetting,
+ updateLeadTimesOnReceiptSetting,
+ updateLogoDark,
+ updateLogoDarkIcon,
+ updateLogoLight,
+ updateLogoLightIcon,
+ updateMaintenanceDispatchNotificationSettings,
+ updateMaterialGeneratedIdsSetting,
+ updateMaterialUnitsSetting,
+ updateMetricSettings,
+ updateProductLabelSize,
+ updatePurchasePriceUpdateTimingSetting,
+ updatePurchasingPdfThumbnails,
+ updateQuoteLineCategoryMarkups,
+ updateRfqReadySetting,
+ updateSalesPdfThumbnails,
+ updateSequence,
+ updateSuggestionNotificationSetting,
+ updateSupplierApprovalSetting,
+ updateSupplierQuoteNotificationSetting,
+ updateTimeCardSetting,
+ upsertApiKey,
+ upsertWebhook
+} from "~/modules/settings/settings.service";
+import type { RegisterTools } from "../types";
+import {
+ DESTRUCTIVE_ANNOTATIONS,
+ READ_ONLY_ANNOTATIONS,
+ toMcpResult,
+ WRITE_ANNOTATIONS,
+ withErrorHandling
+} from "../types";
+
+export const registerSettingsTools: RegisterTools = (server, ctx) => {
+ server.registerTool(
+ "settings_getAccountsPayableBillingAddress",
+ {
+ description: "get accounts payable billing address",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAccountsPayableBillingAddress(
+ ctx.client,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_getAccountsPayableBillingAddress")
+ );
+
+ server.registerTool(
+ "settings_getAccountsReceivableBillingAddress",
+ {
+ description: "get accounts receivable billing address",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getAccountsReceivableBillingAddress(
+ ctx.client,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_getAccountsReceivableBillingAddress")
+ );
+
+ server.registerTool(
+ "settings_updateAccountsPayableBillingAddress",
+ {
+ description: "update accounts payable billing address",
+ inputSchema: {
+ data: accountsPayableBillingAddressValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateAccountsPayableBillingAddress(
+ ctx.client,
+ ctx.companyId,
+ params.data,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateAccountsPayableBillingAddress")
+ );
+
+ server.registerTool(
+ "settings_updateAccountsReceivableBillingAddress",
+ {
+ description: "update accounts receivable billing address",
+ inputSchema: {
+ data: accountsReceivableBillingAddressValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateAccountsReceivableBillingAddress(
+ ctx.client,
+ ctx.companyId,
+ params.data,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateAccountsReceivableBillingAddress")
+ );
+
+ server.registerTool(
+ "settings_deleteApiKey",
+ {
+ description: "delete api key",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteApiKey(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: settings_deleteApiKey")
+ );
+
+ server.registerTool(
+ "settings_deleteWebhook",
+ {
+ description: "delete webhook",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteWebhook(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: settings_deleteWebhook")
+ );
+
+ server.registerTool(
+ "settings_deactivateWebhooks",
+ {
+ description: "deactivate webhooks",
+ inputSchema: {},
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deactivateWebhooks(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: settings_deactivateWebhooks")
+ );
+
+ server.registerTool(
+ "settings_getApiKeys",
+ {
+ description: "get api keys",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getApiKeys(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: settings_getApiKeys")
+ );
+
+ server.registerTool(
+ "settings_getCompanies",
+ {
+ description: "get companies",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCompanies(ctx.client, ctx.userId);
+ return toMcpResult(result);
+ }, "Failed: settings_getCompanies")
+ );
+
+ server.registerTool(
+ "settings_getCompany",
+ {
+ description: "get company",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCompany(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: settings_getCompany")
+ );
+
+ server.registerTool(
+ "settings_getCompanyPlan",
+ {
+ description: "get company plan",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCompanyPlan(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: settings_getCompanyPlan")
+ );
+
+ server.registerTool(
+ "settings_getCompanySettings",
+ {
+ description: "get company settings",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCompanySettings(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: settings_getCompanySettings")
+ );
+
+ server.registerTool(
+ "settings_getCompanyIntegrations",
+ {
+ description: "get company integrations",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCompanyIntegrations(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: settings_getCompanyIntegrations")
+ );
+
+ server.registerTool(
+ "settings_getConfig",
+ {
+ description: "get config",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getConfig(ctx.client);
+ return toMcpResult(result);
+ }, "Failed: settings_getConfig")
+ );
+
+ server.registerTool(
+ "settings_getCurrentSequence",
+ {
+ description: "get current sequence",
+ inputSchema: {
+ table: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCurrentSequence(
+ ctx.client,
+ params.table,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_getCurrentSequence")
+ );
+
+ server.registerTool(
+ "settings_getCustomField",
+ {
+ description: "get custom field",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomField(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: settings_getCustomField")
+ );
+
+ server.registerTool(
+ "settings_getCustomFields",
+ {
+ description: "get custom fields",
+ inputSchema: {
+ table: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomFields(
+ ctx.client,
+ params.table,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_getCustomFields")
+ );
+
+ server.registerTool(
+ "settings_getCustomFieldsTables",
+ {
+ description: "get custom fields tables",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomFieldsTables(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_getCustomFieldsTables")
+ );
+
+ server.registerTool(
+ "settings_getIntegration",
+ {
+ description: "get integration",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getIntegration(ctx.client, params.id, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: settings_getIntegration")
+ );
+
+ server.registerTool(
+ "settings_getIntegrations",
+ {
+ description: "get integrations",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getIntegrations(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: settings_getIntegrations")
+ );
+
+ server.registerTool(
+ "settings_getKanbanOutputSetting",
+ {
+ description: "get kanban output setting",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getKanbanOutputSetting(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: settings_getKanbanOutputSetting")
+ );
+
+ server.registerTool(
+ "settings_getPlanById",
+ {
+ description: "get plan by id",
+ inputSchema: {
+ planId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPlanById(ctx.client, params.planId);
+ return toMcpResult(result);
+ }, "Failed: settings_getPlanById")
+ );
+
+ server.registerTool(
+ "settings_getPlans",
+ {
+ description: "get plans",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPlans(ctx.client);
+ return toMcpResult(result);
+ }, "Failed: settings_getPlans")
+ );
+
+ server.registerTool(
+ "settings_getNextSequence",
+ {
+ description: "get next sequence",
+ inputSchema: {
+ table: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getNextSequence(
+ ctx.client,
+ params.table,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_getNextSequence")
+ );
+
+ server.registerTool(
+ "settings_getSequence",
+ {
+ description: "get sequence",
+ inputSchema: {
+ table: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSequence(ctx.client, params.table, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: settings_getSequence")
+ );
+
+ server.registerTool(
+ "settings_getSequences",
+ {
+ description: "get sequences",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSequences(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: settings_getSequences")
+ );
+
+ server.registerTool(
+ "settings_getSequencesList",
+ {
+ description: "get sequences list",
+ inputSchema: {
+ table: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSequencesList(
+ ctx.client,
+ params.table,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_getSequencesList")
+ );
+
+ server.registerTool(
+ "settings_getTerms",
+ {
+ description: "get terms",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTerms(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: settings_getTerms")
+ );
+
+ server.registerTool(
+ "settings_getWebhook",
+ {
+ description: "get webhook",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getWebhook(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: settings_getWebhook")
+ );
+
+ server.registerTool(
+ "settings_getWebhookTables",
+ {
+ description: "get webhook tables",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getWebhookTables(ctx.client);
+ return toMcpResult(result);
+ }, "Failed: settings_getWebhookTables")
+ );
+
+ server.registerTool(
+ "settings_getWebhooks",
+ {
+ description: "get webhooks",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getWebhooks(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: settings_getWebhooks")
+ );
+
+ server.registerTool(
+ "settings_insertCompany",
+ {
+ description: "insert company",
+ inputSchema: {
+ company: companyValidator,
+ ownerId: z.string().optional()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertCompany(
+ ctx.client,
+ params.company,
+ params.ownerId
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_insertCompany")
+ );
+
+ server.registerTool(
+ "settings_updateCompanyPlan",
+ {
+ description: "update company plan",
+ inputSchema: {
+ data: z.object({
+ stripeCustomerId: z.string(),
+ stripeSubscriptionId: z.string(),
+ stripeSubscriptionStatus: z.string(),
+ subscriptionStartDate: z.string()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateCompanyPlan(ctx.client, {
+ ...params.data,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: settings_updateCompanyPlan")
+ );
+
+ server.registerTool(
+ "settings_seedCompany",
+ {
+ description: "seed company",
+ inputSchema: {},
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await seedCompany(ctx.client, ctx.companyId, ctx.userId);
+ return toMcpResult(result);
+ }, "Failed: settings_seedCompany")
+ );
+
+ server.registerTool(
+ "settings_updateCompany",
+ {
+ description: "update company",
+ inputSchema: {
+ company: companyValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateCompany(ctx.client, ctx.companyId, {
+ ...params.company,
+ updatedBy: ctx.userId,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: settings_updateCompany")
+ );
+
+ server.registerTool(
+ "settings_updateKanbanOutputSetting",
+ {
+ description: "update kanban output setting",
+ inputSchema: {
+ kanbanOutput: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateKanbanOutputSetting(
+ ctx.client,
+ ctx.companyId,
+ params.kanbanOutput
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateKanbanOutputSetting")
+ );
+
+ server.registerTool(
+ "settings_updateMetricSettings",
+ {
+ description: "update metric settings",
+ inputSchema: {
+ useMetric: z.boolean()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateMetricSettings(
+ ctx.client,
+ ctx.companyId,
+ params.useMetric
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateMetricSettings")
+ );
+
+ server.registerTool(
+ "settings_upsertApiKey",
+ {
+ description: "upsert api key",
+ inputSchema: {
+ apiKey: apiKeyValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertApiKey(ctx.client, {
+ ...params.apiKey,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: settings_upsertApiKey")
+ );
+
+ server.registerTool(
+ "settings_updateDigitalQuoteSetting",
+ {
+ description: "update digital quote setting",
+ inputSchema: {
+ digitalQuoteEnabled: z.boolean(),
+ digitalQuoteNotificationGroup: z.array(z.string()),
+ digitalQuoteIncludesPurchaseOrders: z.boolean()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateDigitalQuoteSetting(
+ ctx.client,
+ ctx.companyId,
+ params.digitalQuoteEnabled,
+ params.digitalQuoteNotificationGroup,
+ params.digitalQuoteIncludesPurchaseOrders
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateDigitalQuoteSetting")
+ );
+
+ server.registerTool(
+ "settings_updateLogoDark",
+ {
+ description: "update logo dark",
+ inputSchema: {
+ logoDark: z.string().nullable()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateLogoDark(
+ ctx.client,
+ ctx.companyId,
+ params.logoDark
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateLogoDark")
+ );
+
+ server.registerTool(
+ "settings_updateLogoLight",
+ {
+ description: "update logo light",
+ inputSchema: {
+ logoLight: z.string().nullable()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateLogoLight(
+ ctx.client,
+ ctx.companyId,
+ params.logoLight
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateLogoLight")
+ );
+
+ server.registerTool(
+ "settings_updateLogoDarkIcon",
+ {
+ description: "update logo dark icon",
+ inputSchema: {
+ logoDarkIcon: z.string().nullable()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateLogoDarkIcon(
+ ctx.client,
+ ctx.companyId,
+ params.logoDarkIcon
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateLogoDarkIcon")
+ );
+
+ server.registerTool(
+ "settings_updateLogoLightIcon",
+ {
+ description: "update logo light icon",
+ inputSchema: {
+ logoLightIcon: z.string().nullable()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateLogoLightIcon(
+ ctx.client,
+ ctx.companyId,
+ params.logoLightIcon
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateLogoLightIcon")
+ );
+
+ server.registerTool(
+ "settings_updateMaterialGeneratedIdsSetting",
+ {
+ description: "update material generated ids setting",
+ inputSchema: {
+ materialGeneratedIds: z.boolean()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateMaterialGeneratedIdsSetting(
+ ctx.client,
+ ctx.companyId,
+ params.materialGeneratedIds
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateMaterialGeneratedIdsSetting")
+ );
+
+ server.registerTool(
+ "settings_updateMaterialUnitsSetting",
+ {
+ description: "update material units setting",
+ inputSchema: {
+ useMetric: z.boolean()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateMaterialUnitsSetting(
+ ctx.client,
+ ctx.companyId,
+ params.useMetric
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateMaterialUnitsSetting")
+ );
+
+ server.registerTool(
+ "settings_updateProductLabelSize",
+ {
+ description: "update product label size",
+ inputSchema: {
+ productLabelSize: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateProductLabelSize(
+ ctx.client,
+ ctx.companyId,
+ params.productLabelSize
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateProductLabelSize")
+ );
+
+ server.registerTool(
+ "settings_updatePurchasingPdfThumbnails",
+ {
+ description: "update purchasing pdf thumbnails",
+ inputSchema: {
+ includeThumbnailsOnPurchasingPdfs: z.boolean()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updatePurchasingPdfThumbnails(
+ ctx.client,
+ ctx.companyId,
+ params.includeThumbnailsOnPurchasingPdfs
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updatePurchasingPdfThumbnails")
+ );
+
+ server.registerTool(
+ "settings_updateSalesPdfThumbnails",
+ {
+ description: "update sales pdf thumbnails",
+ inputSchema: {
+ includeThumbnailsOnSalesPdfs: z.boolean()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSalesPdfThumbnails(
+ ctx.client,
+ ctx.companyId,
+ params.includeThumbnailsOnSalesPdfs
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateSalesPdfThumbnails")
+ );
+
+ server.registerTool(
+ "settings_updateJobTravelerWorkInstructions",
+ {
+ description: "update job traveler work instructions",
+ inputSchema: {
+ jobTravelerIncludeWorkInstructions: z.boolean()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateJobTravelerWorkInstructions(
+ ctx.client,
+ ctx.companyId,
+ params.jobTravelerIncludeWorkInstructions
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateJobTravelerWorkInstructions")
+ );
+
+ server.registerTool(
+ "settings_updateTimeCardSetting",
+ {
+ description: "update time card setting",
+ inputSchema: {
+ timeCardEnabled: z.boolean()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateTimeCardSetting(
+ ctx.client,
+ ctx.companyId,
+ params.timeCardEnabled
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateTimeCardSetting")
+ );
+
+ server.registerTool(
+ "settings_updateConsoleSetting",
+ {
+ description: "update console setting",
+ inputSchema: {
+ consoleEnabled: z.boolean()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateConsoleSetting(
+ ctx.client,
+ ctx.companyId,
+ params.consoleEnabled,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateConsoleSetting")
+ );
+
+ server.registerTool(
+ "settings_updateRfqReadySetting",
+ {
+ description: "update rfq ready setting",
+ inputSchema: {
+ rfqReadyNotificationGroup: z.array(z.string())
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateRfqReadySetting(
+ ctx.client,
+ ctx.companyId,
+ params.rfqReadyNotificationGroup
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateRfqReadySetting")
+ );
+
+ server.registerTool(
+ "settings_updateSuggestionNotificationSetting",
+ {
+ description: "update suggestion notification setting",
+ inputSchema: {
+ suggestionNotificationGroup: z.array(z.string())
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSuggestionNotificationSetting(
+ ctx.client,
+ ctx.companyId,
+ params.suggestionNotificationGroup
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateSuggestionNotificationSetting")
+ );
+
+ server.registerTool(
+ "settings_updateMaintenanceDispatchNotificationSettings",
+ {
+ description: "update maintenance dispatch notification settings",
+ inputSchema: {
+ settings: z.object({
+ maintenanceDispatchNotificationGroup: z.array(z.string()).optional(),
+ qualityDispatchNotificationGroup: z.array(z.string()).optional(),
+ operationsDispatchNotificationGroup: z.array(z.string()).optional(),
+ otherDispatchNotificationGroup: z.array(z.string()).optional()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateMaintenanceDispatchNotificationSettings(
+ ctx.client,
+ ctx.companyId,
+ params.settings
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateMaintenanceDispatchNotificationSettings")
+ );
+
+ server.registerTool(
+ "settings_updateSupplierQuoteNotificationSetting",
+ {
+ description: "update supplier quote notification setting",
+ inputSchema: {
+ supplierQuoteNotificationGroup: z.array(z.string())
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSupplierQuoteNotificationSetting(
+ ctx.client,
+ ctx.companyId,
+ params.supplierQuoteNotificationGroup
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateSupplierQuoteNotificationSetting")
+ );
+
+ server.registerTool(
+ "settings_updatePurchasePriceUpdateTimingSetting",
+ {
+ description: "update purchase price update timing setting",
+ inputSchema: {
+ purchasePriceUpdateTiming: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updatePurchasePriceUpdateTimingSetting(
+ ctx.client,
+ ctx.companyId,
+ params.purchasePriceUpdateTiming
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updatePurchasePriceUpdateTimingSetting")
+ );
+
+ server.registerTool(
+ "settings_updateLeadTimesOnReceiptSetting",
+ {
+ description: "update lead times on receipt setting",
+ inputSchema: {
+ updateLeadTimesOnReceipt: z.boolean()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateLeadTimesOnReceiptSetting(
+ ctx.client,
+ ctx.companyId,
+ params.updateLeadTimesOnReceipt
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateLeadTimesOnReceiptSetting")
+ );
+
+ server.registerTool(
+ "settings_updateSupplierApprovalSetting",
+ {
+ description: "update supplier approval setting",
+ inputSchema: {
+ supplierApproval: z.boolean()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSupplierApprovalSetting(
+ ctx.client,
+ ctx.companyId,
+ params.supplierApproval
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateSupplierApprovalSetting")
+ );
+
+ server.registerTool(
+ "settings_updateAccountsPayableAddressSetting",
+ {
+ description: "update accounts payable address setting",
+ inputSchema: {
+ accountsPayableAddress: z.boolean()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateAccountsPayableAddressSetting(
+ ctx.client,
+ ctx.companyId,
+ params.accountsPayableAddress
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateAccountsPayableAddressSetting")
+ );
+
+ server.registerTool(
+ "settings_updateAccountsReceivableAddressSetting",
+ {
+ description: "update accounts receivable address setting",
+ inputSchema: {
+ accountsReceivableAddress: z.boolean()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateAccountsReceivableAddressSetting(
+ ctx.client,
+ ctx.companyId,
+ params.accountsReceivableAddress
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateAccountsReceivableAddressSetting")
+ );
+
+ server.registerTool(
+ "settings_updateAccountsPayableEmail",
+ {
+ description: "update accounts payable email",
+ inputSchema: {
+ accountsPayableEmail: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateAccountsPayableEmail(
+ ctx.client,
+ ctx.companyId,
+ params.accountsPayableEmail
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateAccountsPayableEmail")
+ );
+
+ server.registerTool(
+ "settings_updateAccountsReceivableEmail",
+ {
+ description: "update accounts receivable email",
+ inputSchema: {
+ accountsReceivableEmail: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateAccountsReceivableEmail(
+ ctx.client,
+ ctx.companyId,
+ params.accountsReceivableEmail
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateAccountsReceivableEmail")
+ );
+
+ server.registerTool(
+ "settings_updateDefaultSupplierCc",
+ {
+ description: "update default supplier cc",
+ inputSchema: {
+ defaultSupplierCc: z.array(z.string())
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateDefaultSupplierCc(
+ ctx.client,
+ ctx.companyId,
+ params.defaultSupplierCc
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateDefaultSupplierCc")
+ );
+
+ server.registerTool(
+ "settings_updateDefaultCustomerCc",
+ {
+ description: "update default customer cc",
+ inputSchema: {
+ defaultCustomerCc: z.array(z.string())
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateDefaultCustomerCc(
+ ctx.client,
+ ctx.companyId,
+ params.defaultCustomerCc
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateDefaultCustomerCc")
+ );
+
+ server.registerTool(
+ "settings_updateQuoteLineCategoryMarkups",
+ {
+ description: "update quote line category markups",
+ inputSchema: {
+ quoteLineCategoryMarkups: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateQuoteLineCategoryMarkups(
+ ctx.client,
+ ctx.companyId,
+ params.quoteLineCategoryMarkups
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateQuoteLineCategoryMarkups")
+ );
+
+ server.registerTool(
+ "settings_updateSequence",
+ {
+ description: "update sequence",
+ inputSchema: {
+ table: z.string(),
+ sequence: sequenceValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSequence(
+ ctx.client,
+ params.table,
+ ctx.companyId,
+ { ...params.sequence, updatedBy: ctx.userId, companyId: ctx.companyId }
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateSequence")
+ );
+
+ server.registerTool(
+ "settings_updateIntegrationMetadata",
+ {
+ description: "update integration metadata",
+ inputSchema: {
+ integrationId: z.string(),
+ metadata: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateIntegrationMetadata(
+ ctx.client,
+ ctx.companyId,
+ params.integrationId,
+ params.metadata,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: settings_updateIntegrationMetadata")
+ );
+
+ server.registerTool(
+ "settings_upsertWebhook",
+ {
+ description: "upsert webhook",
+ inputSchema: {
+ webhook: webhookValidator
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertWebhook(ctx.client, {
+ ...params.webhook,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: settings_upsertWebhook")
+ );
+};
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tools/shared.ts b/apps/erp/app/routes/api+/mcp+/lib/tools/shared.ts
new file mode 100644
index 0000000000..a18e3008f8
--- /dev/null
+++ b/apps/erp/app/routes/api+/mcp+/lib/tools/shared.ts
@@ -0,0 +1,856 @@
+// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+import { z } from "zod";
+import {
+ approveRequest,
+ canApproveRequest,
+ canApproveRequestInWindow,
+ cancelApprovalRequest,
+ canViewApprovalRequest,
+ createApprovalRequest,
+ deleteApprovalRule,
+ deleteCustomerPortal,
+ deleteNote,
+ deleteSavedView,
+ generateEmbedding,
+ getApprovalById,
+ getApprovalRequestsByDocument,
+ getApprovalRuleByAmount,
+ getApprovalRuleById,
+ getApprovalRules,
+ getApprovalRulesForApprover,
+ getApprovalsForUser,
+ getApproverUserIdsForRule,
+ getBase64ImageFromSupabase,
+ getCountries,
+ getCustomerPortal,
+ getCustomerPortals,
+ getExternalLink,
+ getLatestApprovalRequestForDocument,
+ getModelByItemId,
+ getNotes,
+ getPendingApprovalsForApprover,
+ getPeriods,
+ getSavedViews,
+ getTagsList,
+ hasPendingApproval,
+ importCsv,
+ insertNote,
+ insertTag,
+ isApprovalRequired,
+ rejectRequest,
+ updateModelThumbnail,
+ updateNote,
+ updateSavedViewOrder,
+ upsertApprovalRule,
+ upsertExternalLink,
+ upsertModelUpload,
+ upsertSavedView
+} from "~/modules/shared/shared.service";
+import type { RegisterTools } from "../types";
+import {
+ DESTRUCTIVE_ANNOTATIONS,
+ READ_ONLY_ANNOTATIONS,
+ toMcpResult,
+ WRITE_ANNOTATIONS,
+ withErrorHandling
+} from "../types";
+
+export const registerSharedTools: RegisterTools = (server, ctx) => {
+ server.registerTool(
+ "shared_approveRequest",
+ {
+ description: "approve request",
+ inputSchema: {
+ db: z.any(),
+ id: z.string(),
+ notes: z.string().optional()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await approveRequest(
+ ctx.client,
+ params.db,
+ params.id,
+ ctx.userId,
+ params.notes
+ );
+ return toMcpResult(result);
+ }, "Failed: shared_approveRequest")
+ );
+
+ server.registerTool(
+ "shared_canApproveRequest",
+ {
+ description: "can approve request",
+ inputSchema: {
+ approvalRequest: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await canApproveRequest(
+ ctx.client,
+ params.approvalRequest,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: shared_canApproveRequest")
+ );
+
+ server.registerTool(
+ "shared_canApproveRequestInWindow",
+ {
+ description: "can approve request in window",
+ inputSchema: {
+ approvalRequest: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await canApproveRequestInWindow(
+ ctx.client,
+ params.approvalRequest,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: shared_canApproveRequestInWindow")
+ );
+
+ server.registerTool(
+ "shared_cancelApprovalRequest",
+ {
+ description: "cancel approval request",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await cancelApprovalRequest(
+ ctx.client,
+ params.id,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: shared_cancelApprovalRequest")
+ );
+
+ server.registerTool(
+ "shared_canViewApprovalRequest",
+ {
+ description: "can view approval request",
+ inputSchema: {
+ approvalRequest: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await canViewApprovalRequest(
+ ctx.client,
+ params.approvalRequest,
+ ctx.userId
+ );
+ return toMcpResult(result);
+ }, "Failed: shared_canViewApprovalRequest")
+ );
+
+ server.registerTool(
+ "shared_createApprovalRequest",
+ {
+ description: "create approval request",
+ inputSchema: {
+ request: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await createApprovalRequest(ctx.client, params.request);
+ return toMcpResult(result);
+ }, "Failed: shared_createApprovalRequest")
+ );
+
+ server.registerTool(
+ "shared_deleteApprovalRule",
+ {
+ description: "delete approval rule",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteApprovalRule(
+ ctx.client,
+ params.id,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: shared_deleteApprovalRule")
+ );
+
+ server.registerTool(
+ "shared_deleteNote",
+ {
+ description: "delete note",
+ inputSchema: {
+ noteId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteNote(ctx.client, params.noteId);
+ return toMcpResult(result);
+ }, "Failed: shared_deleteNote")
+ );
+
+ server.registerTool(
+ "shared_deleteSavedView",
+ {
+ description: "delete saved view",
+ inputSchema: {
+ viewId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteSavedView(ctx.client, params.viewId);
+ return toMcpResult(result);
+ }, "Failed: shared_deleteSavedView")
+ );
+
+ server.registerTool(
+ "shared_generateEmbedding",
+ {
+ description: "generate embedding",
+ inputSchema: {
+ text: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await generateEmbedding(ctx.client, params.text);
+ return toMcpResult(result);
+ }, "Failed: shared_generateEmbedding")
+ );
+
+ server.registerTool(
+ "shared_getApprovalById",
+ {
+ description: "get approval by id",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getApprovalById(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: shared_getApprovalById")
+ );
+
+ server.registerTool(
+ "shared_getApprovalRequestsByDocument",
+ {
+ description: "get approval requests by document",
+ inputSchema: {
+ documentType: z.any(),
+ documentId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getApprovalRequestsByDocument(
+ ctx.client,
+ params.documentType,
+ params.documentId
+ );
+ return toMcpResult(result);
+ }, "Failed: shared_getApprovalRequestsByDocument")
+ );
+
+ server.registerTool(
+ "shared_getApprovalRuleByAmount",
+ {
+ description: "get approval rule by amount",
+ inputSchema: {
+ documentType: z.any(),
+ amount: z.number().optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getApprovalRuleByAmount(
+ ctx.client,
+ params.documentType,
+ ctx.companyId,
+ params.amount
+ );
+ return toMcpResult(result);
+ }, "Failed: shared_getApprovalRuleByAmount")
+ );
+
+ server.registerTool(
+ "shared_getApproverUserIdsForRule",
+ {
+ description: "get approver user ids for rule",
+ inputSchema: {
+ rule: z.any()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getApproverUserIdsForRule(ctx.client, params.rule);
+ return toMcpResult(result);
+ }, "Failed: shared_getApproverUserIdsForRule")
+ );
+
+ server.registerTool(
+ "shared_getApprovalRuleById",
+ {
+ description: "get approval rule by id",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getApprovalRuleById(
+ ctx.client,
+ params.id,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: shared_getApprovalRuleById")
+ );
+
+ server.registerTool(
+ "shared_getApprovalRules",
+ {
+ description: "get approval rules",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getApprovalRules(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: shared_getApprovalRules")
+ );
+
+ server.registerTool(
+ "shared_getApprovalRulesForApprover",
+ {
+ description: "get approval rules for approver",
+ inputSchema: {
+ documentType: z.any()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getApprovalRulesForApprover(
+ ctx.client,
+ params.documentType,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: shared_getApprovalRulesForApprover")
+ );
+
+ server.registerTool(
+ "shared_getApprovalsForUser",
+ {
+ description: "get approvals for user",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0)
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getApprovalsForUser(
+ ctx.client,
+ ctx.userId,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: shared_getApprovalsForUser")
+ );
+
+ server.registerTool(
+ "shared_getBase64ImageFromSupabase",
+ {
+ description: "get base64 image from supabase",
+ inputSchema: {
+ path: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getBase64ImageFromSupabase(ctx.client, params.path);
+ return toMcpResult(result);
+ }, "Failed: shared_getBase64ImageFromSupabase")
+ );
+
+ server.registerTool(
+ "shared_getCountries",
+ {
+ description: "get countries",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCountries(ctx.client);
+ return toMcpResult(result);
+ }, "Failed: shared_getCountries")
+ );
+
+ server.registerTool(
+ "shared_getLatestApprovalRequestForDocument",
+ {
+ description: "get latest approval request for document",
+ inputSchema: {
+ documentType: z.any(),
+ documentId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getLatestApprovalRequestForDocument(
+ ctx.client,
+ params.documentType,
+ params.documentId
+ );
+ return toMcpResult(result);
+ }, "Failed: shared_getLatestApprovalRequestForDocument")
+ );
+
+ server.registerTool(
+ "shared_getModelByItemId",
+ {
+ description: "get model by item id",
+ inputSchema: {
+ itemId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getModelByItemId(ctx.client, params.itemId);
+ return toMcpResult(result);
+ }, "Failed: shared_getModelByItemId")
+ );
+
+ server.registerTool(
+ "shared_getNotes",
+ {
+ description: "get notes",
+ inputSchema: {
+ documentId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getNotes(ctx.client, params.documentId);
+ return toMcpResult(result);
+ }, "Failed: shared_getNotes")
+ );
+
+ server.registerTool(
+ "shared_getPendingApprovalsForApprover",
+ {
+ description: "get pending approvals for approver",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPendingApprovalsForApprover(
+ ctx.client,
+ ctx.userId,
+ ctx.companyId
+ );
+ return toMcpResult(result);
+ }, "Failed: shared_getPendingApprovalsForApprover")
+ );
+
+ server.registerTool(
+ "shared_getPeriods",
+ {
+ description: "get periods",
+ inputSchema: {
+ arg1: z.object({
+ startDate: z.string(),
+ endDate: z.string()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPeriods(ctx.client, params.arg1);
+ return toMcpResult(result);
+ }, "Failed: shared_getPeriods")
+ );
+
+ server.registerTool(
+ "shared_getSavedViews",
+ {
+ description: "get saved views",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSavedViews(ctx.client, ctx.userId, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: shared_getSavedViews")
+ );
+
+ server.registerTool(
+ "shared_getTagsList",
+ {
+ description: "get tags list",
+ inputSchema: {
+ table: z.string().nullable().optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getTagsList(ctx.client, ctx.companyId, params.table);
+ return toMcpResult(result);
+ }, "Failed: shared_getTagsList")
+ );
+
+ server.registerTool(
+ "shared_hasPendingApproval",
+ {
+ description: "has pending approval",
+ inputSchema: {
+ documentType: z.any(),
+ documentId: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await hasPendingApproval(
+ ctx.client,
+ params.documentType,
+ params.documentId
+ );
+ return toMcpResult(result);
+ }, "Failed: shared_hasPendingApproval")
+ );
+
+ server.registerTool(
+ "shared_importCsv",
+ {
+ description: "import csv",
+ inputSchema: {
+ args: z.object({
+ table: z.string(),
+ filePath: z.string(),
+ columnMappings: z.any(),
+ enumMappings: z.any().optional()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await importCsv(ctx.client, {
+ ...params.args,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: shared_importCsv")
+ );
+
+ server.registerTool(
+ "shared_insertNote",
+ {
+ description: "insert note",
+ inputSchema: {
+ note: z.object({
+ note: z.string(),
+ documentId: z.string()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertNote(ctx.client, {
+ ...params.note,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: shared_insertNote")
+ );
+
+ server.registerTool(
+ "shared_insertTag",
+ {
+ description: "insert tag",
+ inputSchema: {
+ tag: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertTag(ctx.client, params.tag);
+ return toMcpResult(result);
+ }, "Failed: shared_insertTag")
+ );
+
+ server.registerTool(
+ "shared_isApprovalRequired",
+ {
+ description: "is approval required",
+ inputSchema: {
+ documentType: z.any(),
+ amount: z.number().optional()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await isApprovalRequired(
+ ctx.client,
+ params.documentType,
+ ctx.companyId,
+ params.amount
+ );
+ return toMcpResult(result);
+ }, "Failed: shared_isApprovalRequired")
+ );
+
+ server.registerTool(
+ "shared_getExternalLink",
+ {
+ description: "get external link",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getExternalLink(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: shared_getExternalLink")
+ );
+
+ server.registerTool(
+ "shared_upsertExternalLink",
+ {
+ description: "upsert external link",
+ inputSchema: {
+ externalLink: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertExternalLink(ctx.client, params.externalLink);
+ return toMcpResult(result);
+ }, "Failed: shared_upsertExternalLink")
+ );
+
+ server.registerTool(
+ "shared_getCustomerPortals",
+ {
+ description: "get customer portals",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomerPortals(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: shared_getCustomerPortals")
+ );
+
+ server.registerTool(
+ "shared_getCustomerPortal",
+ {
+ description: "get customer portal",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomerPortal(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: shared_getCustomerPortal")
+ );
+
+ server.registerTool(
+ "shared_deleteCustomerPortal",
+ {
+ description: "delete customer portal",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteCustomerPortal(ctx.client, params.id);
+ return toMcpResult(result);
+ }, "Failed: shared_deleteCustomerPortal")
+ );
+
+ server.registerTool(
+ "shared_updateModelThumbnail",
+ {
+ description: "update model thumbnail",
+ inputSchema: {
+ modelId: z.string(),
+ thumbnailPath: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateModelThumbnail(
+ ctx.client,
+ params.modelId,
+ params.thumbnailPath
+ );
+ return toMcpResult(result);
+ }, "Failed: shared_updateModelThumbnail")
+ );
+
+ server.registerTool(
+ "shared_upsertModelUpload",
+ {
+ description: "upsert model upload",
+ inputSchema: {
+ upload: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertModelUpload(ctx.client, {
+ ...params.upload,
+ companyId: ctx.companyId,
+ createdBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: shared_upsertModelUpload")
+ );
+
+ server.registerTool(
+ "shared_updateNote",
+ {
+ description: "update note",
+ inputSchema: {
+ id: z.string(),
+ note: z.string()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateNote(ctx.client, params.id, params.note);
+ return toMcpResult(result);
+ }, "Failed: shared_updateNote")
+ );
+
+ server.registerTool(
+ "shared_rejectRequest",
+ {
+ description: "reject request",
+ inputSchema: {
+ db: z.any(),
+ id: z.string(),
+ notes: z.string().optional()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await rejectRequest(
+ ctx.client,
+ params.db,
+ params.id,
+ ctx.userId,
+ params.notes
+ );
+ return toMcpResult(result);
+ }, "Failed: shared_rejectRequest")
+ );
+
+ server.registerTool(
+ "shared_upsertApprovalRule",
+ {
+ description: "upsert approval rule",
+ inputSchema: {
+ rule: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertApprovalRule(ctx.client, params.rule);
+ return toMcpResult(result);
+ }, "Failed: shared_upsertApprovalRule")
+ );
+
+ server.registerTool(
+ "shared_upsertSavedView",
+ {
+ description: "upsert saved view",
+ inputSchema: {
+ view: z.object({
+ id: z.string().optional(),
+ name: z.string(),
+ description: z.string().optional(),
+ table: z.string(),
+ type: z.enum(["Public", "Private"]),
+ filters: z.array(z.string()).optional(),
+ sorts: z.array(z.string()).optional(),
+ columnPinning: z.any().optional(),
+ columnVisibility: z.any().optional(),
+ columnOrder: z.array(z.string()).optional()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertSavedView(ctx.client, {
+ ...params.view,
+ companyId: ctx.companyId,
+ userId: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: shared_upsertSavedView")
+ );
+
+ server.registerTool(
+ "shared_updateSavedViewOrder",
+ {
+ description: "update saved view order",
+ inputSchema: {
+ updates: z.object({
+ id: z.string(),
+ sortOrder: z.number()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await updateSavedViewOrder(ctx.client, {
+ ...params.updates,
+ updatedBy: ctx.userId
+ });
+ return toMcpResult(result);
+ }, "Failed: shared_updateSavedViewOrder")
+ );
+};
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tools/users.ts b/apps/erp/app/routes/api+/mcp+/lib/tools/users.ts
new file mode 100644
index 0000000000..aebf31245c
--- /dev/null
+++ b/apps/erp/app/routes/api+/mcp+/lib/tools/users.ts
@@ -0,0 +1,483 @@
+// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+import { z } from "zod";
+import {
+ deleteEmployeeType,
+ deleteGroup,
+ getCompaniesForUser,
+ getConsoleOperators,
+ getCustomers,
+ getEmployee,
+ getEmployees,
+ getEmployeeType,
+ getEmployeeTypes,
+ getGroup,
+ getGroupEmails,
+ getGroupMembers,
+ getGroups,
+ getInvitable,
+ getModules,
+ getPermissionsByEmployeeType,
+ getSuppliers,
+ getUserEmails,
+ getUsers,
+ insertEmployeeType,
+ insertGroup,
+ upsertEmployeeType,
+ upsertEmployeeTypePermissions,
+ upsertGroup,
+ upsertGroupMembers
+} from "~/modules/users/users.service";
+import type { RegisterTools } from "../types";
+import {
+ DESTRUCTIVE_ANNOTATIONS,
+ READ_ONLY_ANNOTATIONS,
+ toMcpResult,
+ WRITE_ANNOTATIONS,
+ withErrorHandling
+} from "../types";
+
+export const registerUsersTools: RegisterTools = (server, ctx) => {
+ server.registerTool(
+ "users_deleteEmployeeType",
+ {
+ description: "delete employee type",
+ inputSchema: {
+ employeeTypeId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteEmployeeType(
+ ctx.client,
+ params.employeeTypeId
+ );
+ return toMcpResult(result);
+ }, "Failed: users_deleteEmployeeType")
+ );
+
+ server.registerTool(
+ "users_deleteGroup",
+ {
+ description: "delete group",
+ inputSchema: {
+ groupId: z.string()
+ },
+ annotations: DESTRUCTIVE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await deleteGroup(ctx.client, params.groupId);
+ return toMcpResult(result);
+ }, "Failed: users_deleteGroup")
+ );
+
+ server.registerTool(
+ "users_getCompaniesForUser",
+ {
+ description: "get companies for user",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCompaniesForUser(ctx.client, ctx.userId);
+ return toMcpResult(result);
+ }, "Failed: users_getCompaniesForUser")
+ );
+
+ server.registerTool(
+ "users_getCustomers",
+ {
+ description: "get customers",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getCustomers(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: users_getCustomers")
+ );
+
+ server.registerTool(
+ "users_getEmployee",
+ {
+ description: "get employee",
+ inputSchema: {
+ id: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getEmployee(ctx.client, params.id, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: users_getEmployee")
+ );
+
+ server.registerTool(
+ "users_getEmployees",
+ {
+ description: "get employees",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getEmployees(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: users_getEmployees")
+ );
+
+ server.registerTool(
+ "users_getConsoleOperators",
+ {
+ description: "get console operators",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getConsoleOperators(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: users_getConsoleOperators")
+ );
+
+ server.registerTool(
+ "users_getEmployeeType",
+ {
+ description: "get employee type",
+ inputSchema: {
+ employeeTypeId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getEmployeeType(ctx.client, params.employeeTypeId);
+ return toMcpResult(result);
+ }, "Failed: users_getEmployeeType")
+ );
+
+ server.registerTool(
+ "users_getEmployeeTypes",
+ {
+ description: "get employee types",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getEmployeeTypes(
+ ctx.client,
+ ctx.companyId,
+ params.args
+ );
+ return toMcpResult(result);
+ }, "Failed: users_getEmployeeTypes")
+ );
+
+ server.registerTool(
+ "users_getInvitable",
+ {
+ description: "get invitable",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getInvitable(ctx.client, ctx.companyId);
+ return toMcpResult(result);
+ }, "Failed: users_getInvitable")
+ );
+
+ server.registerTool(
+ "users_getModules",
+ {
+ description: "get modules",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getModules(ctx.client);
+ return toMcpResult(result);
+ }, "Failed: users_getModules")
+ );
+
+ server.registerTool(
+ "users_getGroup",
+ {
+ description: "get group",
+ inputSchema: {
+ groupId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getGroup(ctx.client, params.groupId);
+ return toMcpResult(result);
+ }, "Failed: users_getGroup")
+ );
+
+ server.registerTool(
+ "users_getGroupMembers",
+ {
+ description: "get group members",
+ inputSchema: {
+ groupId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getGroupMembers(ctx.client, params.groupId);
+ return toMcpResult(result);
+ }, "Failed: users_getGroupMembers")
+ );
+
+ server.registerTool(
+ "users_getGroups",
+ {
+ description: "get groups",
+ inputSchema: {
+ args: z
+ .object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable(),
+ uid: z.string().nullable()
+ })
+ .optional()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getGroups(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: users_getGroups")
+ );
+
+ server.registerTool(
+ "users_getGroupEmails",
+ {
+ description: "get group emails",
+ inputSchema: {
+ groupIds: z.array(z.string())
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getGroupEmails(ctx.client, params.groupIds);
+ return toMcpResult(result);
+ }, "Failed: users_getGroupEmails")
+ );
+
+ server.registerTool(
+ "users_getPermissionsByEmployeeType",
+ {
+ description: "get permissions by employee type",
+ inputSchema: {
+ employeeTypeId: z.string()
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getPermissionsByEmployeeType(
+ ctx.client,
+ params.employeeTypeId
+ );
+ return toMcpResult(result);
+ }, "Failed: users_getPermissionsByEmployeeType")
+ );
+
+ server.registerTool(
+ "users_getSuppliers",
+ {
+ description: "get suppliers",
+ inputSchema: {
+ args: z.object({
+ limit: z.number().int().default(100),
+ offset: z.number().int().default(0),
+ search: z.string().nullable()
+ })
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getSuppliers(ctx.client, ctx.companyId, params.args);
+ return toMcpResult(result);
+ }, "Failed: users_getSuppliers")
+ );
+
+ server.registerTool(
+ "users_getUsers",
+ {
+ description: "get users",
+ inputSchema: {},
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getUsers(ctx.client);
+ return toMcpResult(result);
+ }, "Failed: users_getUsers")
+ );
+
+ server.registerTool(
+ "users_getUserEmails",
+ {
+ description: "get user emails",
+ inputSchema: {
+ userIds: z.array(z.string())
+ },
+ annotations: READ_ONLY_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await getUserEmails(ctx.client, params.userIds);
+ return toMcpResult(result);
+ }, "Failed: users_getUserEmails")
+ );
+
+ server.registerTool(
+ "users_insertEmployeeType",
+ {
+ description: "insert employee type",
+ inputSchema: {
+ employeeType: z.object({
+ name: z.string()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertEmployeeType(ctx.client, {
+ ...params.employeeType,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: users_insertEmployeeType")
+ );
+
+ server.registerTool(
+ "users_insertGroup",
+ {
+ description: "insert group",
+ inputSchema: {
+ group: z.object({
+ name: z.string()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await insertGroup(ctx.client, {
+ ...params.group,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: users_insertGroup")
+ );
+
+ server.registerTool(
+ "users_upsertEmployeeType",
+ {
+ description: "upsert employee type",
+ inputSchema: {
+ employeeType: z.any()
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertEmployeeType(ctx.client, {
+ ...params.employeeType,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: users_upsertEmployeeType")
+ );
+
+ server.registerTool(
+ "users_upsertEmployeeTypePermissions",
+ {
+ description: "upsert employee type permissions",
+ inputSchema: {
+ employeeTypeId: z.string(),
+ permissions: z.object({
+ name: z.string(),
+ permission: z.any()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertEmployeeTypePermissions(
+ ctx.client,
+ params.employeeTypeId,
+ ctx.companyId,
+ params.permissions
+ );
+ return toMcpResult(result);
+ }, "Failed: users_upsertEmployeeTypePermissions")
+ );
+
+ server.registerTool(
+ "users_upsertGroup",
+ {
+ description: "upsert group",
+ inputSchema: {
+ arg1: z.object({
+ id: z.string(),
+ name: z.string()
+ })
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertGroup(ctx.client, {
+ ...params.arg1,
+ companyId: ctx.companyId
+ });
+ return toMcpResult(result);
+ }, "Failed: users_upsertGroup")
+ );
+
+ server.registerTool(
+ "users_upsertGroupMembers",
+ {
+ description: "upsert group members",
+ inputSchema: {
+ groupId: z.string(),
+ selections: z.array(z.string())
+ },
+ annotations: WRITE_ANNOTATIONS
+ },
+ withErrorHandling(async (params) => {
+ const result = await upsertGroupMembers(
+ ctx.client,
+ params.groupId,
+ params.selections
+ );
+ return toMcpResult(result);
+ }, "Failed: users_upsertGroupMembers")
+ );
+};
diff --git a/apps/erp/app/routes/api+/mcp+/lib/types.ts b/apps/erp/app/routes/api+/mcp+/lib/types.ts
new file mode 100644
index 0000000000..2716b8185d
--- /dev/null
+++ b/apps/erp/app/routes/api+/mcp+/lib/types.ts
@@ -0,0 +1,74 @@
+import type { Database } from "@carbon/database";
+import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
+import type { SupabaseClient } from "@supabase/supabase-js";
+
+export interface McpContext {
+ client: SupabaseClient<Database>;
+ companyId: string;
+ userId: string;
+}
+
+export type RegisterTools = (server: McpServer, ctx: McpContext) => void;
+
+export const READ_ONLY_ANNOTATIONS = {
+ readOnlyHint: true,
+ destructiveHint: false,
+ idempotentHint: true,
+ openWorldHint: false
+} as const;
+
+export const WRITE_ANNOTATIONS = {
+ readOnlyHint: false,
+ destructiveHint: false,
+ idempotentHint: false,
+ openWorldHint: false
+} as const;
+
+export const DESTRUCTIVE_ANNOTATIONS = {
+ readOnlyHint: false,
+ destructiveHint: true,
+ idempotentHint: true,
+ openWorldHint: false
+} as const;
+
+export function toMcpResult(result: { data: unknown; error: unknown }) {
+ if (result.error) {
+ const message =
+ typeof result.error === "object" &&
+ result.error !== null &&
+ "message" in result.error
+ ? (result.error as { message: string }).message
+ : JSON.stringify(result.error);
+ return {
+ content: [{ type: "text" as const, text: message }],
+ isError: true
+ };
+ }
+ return {
+ content: [{ type: "text" as const, text: JSON.stringify(result.data) }]
+ };
+}
+
+export function withErrorHandling<T extends Record<string, unknown>>(
+ handler: (params: T) => Promise<{
+ content: { type: "text"; text: string }[];
+ isError?: boolean;
+ }>,
+ fallbackMessage: string
+) {
+ return async (params: T) => {
+ try {
+ return await handler(params);
+ } catch (error) {
+ return {
+ content: [
+ {
+ type: "text" as const,
+ text: error instanceof Error ? error.message : fallbackMessage
+ }
+ ],
+ isError: true
+ };
+ }
+ };
+}
diff --git a/apps/erp/package.json b/apps/erp/package.json
index 253ccdcbe4..2dd4ef1fb4 100644
--- a/apps/erp/package.json
+++ b/apps/erp/package.json
@@ -29,6 +29,7 @@
"@epic-web/remember": "^1.1.0",
"@internationalized/date": "^3.5.2",
"@marsidev/react-turnstile": "^1.1.0",
+ "@modelcontextprotocol/sdk": "^1.29.0",
"@monaco-editor/react": "^4.6.0",
"@nanostores/react": "^0.7.1",
"@novu/framework": "^2.9.0",
diff --git a/biome.jsonc b/biome.jsonc
index 90b3adfb32..9e61443841 100644
--- a/biome.jsonc
+++ b/biome.jsonc
@@ -9,6 +9,8 @@
"!sst.env.d.ts",
"!packages/database/src/types.ts",
"!packages/database/src/swagger-docs-schema.ts",
+ "!apps/erp/app/routes/api+/mcp+/lib/tools/**",
+ "!apps/erp/app/routes/api+/mcp+/lib/server.ts",
"**/*.json",
"examples/**/*"
]
diff --git a/llm/cache/mcp-tools-reference.md b/llm/cache/mcp-tools-reference.md
new file mode 100644
index 0000000000..7c54876198
--- /dev/null
+++ b/llm/cache/mcp-tools-reference.md
@@ -0,0 +1,7217 @@
+# Carbon ERP MCP Tools Reference
+
+> Auto-generated by scripts/generate-mcp.ts
+> Total: 1016 tools across 15 modules
+
+## account (10 tools)
+
+### account_deleteUserAttributeValue (DESTRUCTIVE)
+delete user attribute value
+**Parameters:**
+- `args`: {
+ userId: string;
+ userAttributeId: string;
+ userAttributeValueId: string;
+ }
+
+### account_getAccount (READ)
+get account
+**Parameters:**
+- `id`: string
+
+### account_getAttributes (READ)
+get attributes
+**Parameters:**
+- `isPublic`: boolean
+
+### account_getPrivateAttributes (READ)
+get private attributes
+**Parameters:** none (context auto-filled)
+
+### account_getPublicAttributes (READ)
+get public attributes
+**Parameters:** none (context auto-filled)
+
+### account_getAllAttributeCategories (READ)
+get all attribute categories
+**Parameters:** none (context auto-filled)
+
+### account_getAttributeCategoryWithValues (READ)
+get attribute category with values
+**Parameters:**
+- `categoryId`: string
+
+### account_updateAvatar (WRITE)
+update avatar
+**Parameters:**
+- `avatarUrl`: string | null
+
+### account_updatePublicAccount (WRITE)
+update public account
+**Parameters:**
+- `account`: {
+ id: string;
+ firstName: string;
+ lastName: string;
+ about?: string;
+ }
+
+### account_upsertUserAttributeValue (WRITE)
+upsert user attribute value
+**Parameters:**
+- `update`: {
+ userAttributeValueId?: string | undefined;
+ userAttributeId: string;
+ value: boolean | string | number;
+ type: string;
+ userId: string;
+ updatedBy: string;
+ }
+
+---
+
+## accounting (39 tools)
+
+### accounting_deleteAccount (DESTRUCTIVE)
+delete account
+**Parameters:**
+- `accountId`: string
+
+### accounting_deleteAccountCategory (DESTRUCTIVE)
+delete account category
+**Parameters:**
+- `accountCategoryId`: string
+
+### accounting_deleteAccountSubcategory (DESTRUCTIVE)
+delete account subcategory
+**Parameters:**
+- `accountSubcategoryId`: string
+
+### accounting_deletePaymentTerm (DESTRUCTIVE)
+delete payment term
+**Parameters:**
+- `paymentTermId`: string
+
+### accounting_getAccount (READ)
+get account
+**Parameters:**
+- `accountId`: string
+
+### accounting_getAccounts (READ)
+get accounts
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### accounting_getAccountsList (READ)
+get accounts list
+**Parameters:**
+- `args`: {
+ type?: Database["public"]["Enums"]["glAccountType"] | null;
+ incomeBalance?: Database["public"]["Enums"]["glIncomeBalance"] | null;
+ classes?: Database["public"]["Enums"]["glAccountClass"][];
+ } (optional)
+
+### accounting_getAccountCategories (READ)
+get account categories
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### accounting_getAccountCategoriesList (READ)
+get account categories list
+**Parameters:** none (context auto-filled)
+
+### accounting_getAccountCategory (READ)
+get account category
+**Parameters:**
+- `accountCategoryId`: string
+
+### accounting_getAccountSubcategories (READ)
+get account subcategories
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### accounting_getAccountSubcategoriesByCategory (READ)
+get account subcategories by category
+**Parameters:**
+- `accountCategoryId`: string
+
+### accounting_getAccountSubcategory (READ)
+get account subcategory
+**Parameters:**
+- `accountSubcategoryId`: string
+
+### accounting_getBaseCurrency (READ)
+get base currency
+**Parameters:** none (context auto-filled)
+
+### accounting_getChartOfAccounts (READ)
+get chart of accounts
+**Parameters:**
+- `args`: Omit<GenericQueryFilters, "limit" | "offset"> & {
+ name: string | null;
+ incomeBalance: "Income Statement" | "Balance Sheet" | null;
+ startDate: string | null;
+ endDate: string | null;
+ }
+
+### accounting_getCurrency (READ)
+get currency
+**Parameters:**
+- `currencyId`: string
+
+### accounting_getCurrencyByCode (READ)
+get currency by code
+**Parameters:**
+- `currencyCode`: string
+
+### accounting_getCurrencies (READ)
+get currencies
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### accounting_getCurrenciesList (READ)
+get currencies list
+**Parameters:** none (context auto-filled)
+
+### accounting_getCurrentAccountingPeriod (READ)
+get current accounting period
+**Parameters:**
+- `date`: string
+
+### accounting_getDefaultAccounts (READ)
+get default accounts
+**Parameters:** none (context auto-filled)
+
+### accounting_getFiscalYearSettings (READ)
+get fiscal year settings
+**Parameters:** none (context auto-filled)
+
+### accounting_getInventoryPostingGroup (READ)
+get inventory posting group
+**Parameters:**
+- `args`: {
+ itemPostingGroupId: string | null;
+ locationId: string | null;
+ }
+
+### accounting_getInventoryPostingGroups (READ)
+get inventory posting groups
+**Parameters:**
+- `args`: GenericQueryFilters
+
+### accounting_getPaymentTerm (READ)
+get payment term
+**Parameters:**
+- `paymentTermId`: string
+
+### accounting_getPaymentTerms (READ)
+get payment terms
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### accounting_getPaymentTermsList (READ)
+get payment terms list
+**Parameters:** none (context auto-filled)
+
+### accounting_getPurchasingPostingGroup (READ)
+get purchasing posting group
+**Parameters:**
+- `args`: {
+ itemPostingGroupId: string | null;
+ supplierTypeId: string | null;
+ }
+
+### accounting_getPurchasingPostingGroups (READ)
+get purchasing posting groups
+**Parameters:**
+- `args`: GenericQueryFilters
+
+### accounting_getPurchasingSalesGroup (READ)
+get purchasing sales group
+**Parameters:**
+- `args`: {
+ itemPostingGroupId: string | null;
+ customerTypeId: string | null;
+ }
+
+### accounting_getSalesPostingGroups (READ)
+get sales posting groups
+**Parameters:**
+- `args`: GenericQueryFilters
+
+### accounting_updateDefaultBalanceSheetAccounts (WRITE)
+update default balance sheet accounts
+**Parameters:**
+- `defaultAccounts`: z.infer<typeof defaultBalanceSheetAccountValidator> & {
+ companyId: string;
+ updatedBy: string;
+ }
+
+### accounting_updateDefaultIncomeAccounts (WRITE)
+update default income accounts
+**Parameters:**
+- `defaultAccounts`: z.infer<typeof defaultIncomeAcountValidator> & {
+ companyId: string;
+ updatedBy: string;
+ }
+
+### accounting_updateFiscalYearSettings (WRITE)
+update fiscal year settings
+**Parameters:**
+- `fiscalYearSettings`: z.infer<typeof fiscalYearSettingsValidator> & {
+ companyId: string;
+ updatedBy: string;
+ }
+
+### accounting_upsertAccount (WRITE)
+upsert account
+**Parameters:**
+- `account`: | (Omit<z.infer<typeof accountValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof accountValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### accounting_upsertAccountCategory (WRITE)
+upsert account category
+**Parameters:**
+- `accountCategory`: | (Omit<z.infer<typeof accountCategoryValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof accountCategoryValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### accounting_upsertAccountSubcategory (WRITE)
+upsert account subcategory
+**Parameters:**
+- `accountSubcategory`: | (Omit<z.infer<typeof accountSubcategoryValidator>, "id"> & {
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof accountSubcategoryValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### accounting_upsertCurrency (WRITE)
+upsert currency
+**Parameters:**
+- `currency`: | (Omit<z.infer<typeof currencyValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof currencyValidator>, "id"> & {
+ id: string;
+ companyId: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### accounting_upsertPaymentTerm (WRITE)
+upsert payment term
+**Parameters:**
+- `paymentTerm`: | (Omit<z.infer<typeof paymentTermValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof paymentTermValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+---
+
+## documents (14 tools)
+
+### documents_deleteDocument (DESTRUCTIVE)
+delete document
+**Parameters:**
+- `id`: string
+
+### documents_deleteDocumentFavorite (DESTRUCTIVE)
+delete document favorite
+**Parameters:**
+- `id`: string
+
+### documents_deleteDocumentLabel (DESTRUCTIVE)
+delete document label
+**Parameters:**
+- `id`: string
+- `label`: string
+
+### documents_getDocument (READ)
+get document
+**Parameters:**
+- `documentId`: string
+
+### documents_getDocuments (READ)
+get documents
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ favorite?: boolean;
+ recent?: boolean;
+ createdBy?: string;
+ active: boolean;
+ }
+
+### documents_getDocumentExtensions (READ)
+get document extensions
+**Parameters:** none (context auto-filled)
+
+### documents_getDocumentLabels (READ)
+get document labels
+**Parameters:** none (context auto-filled)
+
+### documents_insertDocumentFavorite (WRITE)
+insert document favorite
+**Parameters:**
+- `id`: string
+
+### documents_insertDocumentLabel (WRITE)
+insert document label
+**Parameters:**
+- `id`: string
+- `label`: string
+
+### documents_moveDocumentToTrash (WRITE)
+move document to trash
+**Parameters:**
+- `id`: string
+
+### documents_restoreDocument (WRITE)
+restore document
+**Parameters:**
+- `id`: string
+
+### documents_upsertDocument (WRITE)
+upsert document
+**Parameters:**
+- `document`: | (Omit<z.infer<typeof documentValidator>, "id"> & {
+ path: string;
+ size: number;
+ companyId: string;
+ createdBy: string;
+ } & SourceDocumentData)
+ | (Omit<z.infer<typeof documentValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### documents_updateDocumentFavorite (WRITE)
+update document favorite
+**Parameters:**
+- `args`: {
+ id: string;
+ favorite: boolean;
+ userId: string;
+ }
+
+### documents_updateDocumentLabels (WRITE)
+update document labels
+**Parameters:**
+- `document`: z.infer<typeof documentLabelsValidator> & {
+ userId: string;
+ }
+
+---
+
+## inventory (72 tools)
+
+### inventory_deleteBatchProperty (DESTRUCTIVE)
+delete batch property
+**Parameters:**
+- `id`: string
+
+### inventory_deleteKanban (DESTRUCTIVE)
+delete kanban
+**Parameters:**
+- `kanbanId`: string
+
+### inventory_deleteReceipt (DESTRUCTIVE)
+delete receipt
+**Parameters:**
+- `receiptId`: string
+
+### inventory_deleteReceiptLine (DESTRUCTIVE)
+delete receipt line
+**Parameters:**
+- `receiptLineId`: string
+
+### inventory_deleteShelf (DESTRUCTIVE)
+delete shelf
+**Parameters:**
+- `shelfId`: string
+
+### inventory_deleteShipment (DESTRUCTIVE)
+delete shipment
+**Parameters:**
+- `shipmentId`: string
+
+### inventory_deleteShipmentLine (DESTRUCTIVE)
+delete shipment line
+**Parameters:**
+- `shipmentLineId`: string
+
+### inventory_deleteShippingMethod (DESTRUCTIVE)
+delete shipping method
+**Parameters:**
+- `shippingMethodId`: string
+
+### inventory_deleteStockTransfer (DESTRUCTIVE)
+delete stock transfer
+**Parameters:**
+- `stockTransferId`: string
+
+### inventory_deleteStockTransferLine (DESTRUCTIVE)
+delete stock transfer line
+**Parameters:**
+- `stockTransferLineId`: string
+
+### inventory_deleteWarehouseTransfer (DESTRUCTIVE)
+delete warehouse transfer
+**Parameters:**
+- `transferId`: string
+
+### inventory_deleteWarehouseTransferLine (DESTRUCTIVE)
+delete warehouse transfer line
+**Parameters:**
+- `transferLineId`: string
+
+### inventory_getItemLedgerPage (READ)
+get item ledger page
+**Parameters:**
+- `itemId`: string
+- `locationId`: string
+- `sortDescending`: boolean (optional)
+- `page`: number (optional)
+
+### inventory_getBatchProperties (READ)
+get batch properties
+**Parameters:**
+- `itemIds`: string[]
+
+### inventory_getInventoryItems (READ)
+get inventory items
+**Parameters:**
+- `locationId`: string
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### inventory_getInventoryItemsCount (READ)
+get inventory items count
+**Parameters:**
+- `locationId`: string
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### inventory_getKanbans (READ)
+get kanbans
+**Parameters:**
+- `locationId`: string
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### inventory_getKanban (READ)
+get kanban
+**Parameters:**
+- `kanbanId`: string
+
+### inventory_getStockTransfer (READ)
+get stock transfer
+**Parameters:**
+- `stockTransferId`: string
+
+### inventory_getStockTransferLine (READ)
+get stock transfer line
+**Parameters:**
+- `stockTransferLineId`: string
+
+### inventory_getStockTransferLines (READ)
+get stock transfer lines
+**Parameters:**
+- `stockTransferId`: string
+
+### inventory_getStockTransferTracking (READ)
+get stock transfer tracking
+**Parameters:**
+- `stockTransferId`: string
+
+### inventory_getStockTransfers (READ)
+get stock transfers
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ locationId: string | null;
+ }
+
+### inventory_getDefaultShelfOrShelfWithHighestQuantity (READ)
+get default shelf or shelf with highest quantity
+**Parameters:**
+- `itemId`: string
+- `locationId`: string
+
+### inventory_getReceipts (READ)
+get receipts
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### inventory_getReceipt (READ)
+get receipt
+**Parameters:**
+- `receiptId`: string
+
+### inventory_getReceiptLines (READ)
+get receipt lines
+**Parameters:**
+- `receiptId`: string
+
+### inventory_getReceiptTracking (READ)
+get receipt tracking
+**Parameters:**
+- `receiptId`: string
+
+### inventory_getReceiptLineTracking (READ)
+get receipt line tracking
+**Parameters:**
+- `receiptLineId`: string
+
+### inventory_getReceiptFiles (READ)
+get receipt files
+**Parameters:**
+- `lineIds`: string[]
+
+### inventory_getSerialNumbersForItem (READ)
+get serial numbers for item
+**Parameters:**
+- `args`: {
+ itemId: string;
+ companyId: string;
+ }
+
+### inventory_getBatchNumbersForItem (READ)
+get batch numbers for item
+**Parameters:**
+- `args`: {
+ itemId: string;
+ companyId: string;
+ isReadOnly?: boolean;
+ }
+
+### inventory_getShelvesList (READ)
+get shelves list
+**Parameters:** none (context auto-filled)
+
+### inventory_getShelvesListForLocation (READ)
+get shelves list for location
+**Parameters:**
+- `locationId`: string
+
+### inventory_getShelves (READ)
+get shelves
+**Parameters:**
+- `locationId`: string
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### inventory_getShelf (READ)
+get shelf
+**Parameters:**
+- `shelfId`: string
+
+### inventory_getShipments (READ)
+get shipments
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### inventory_getShipment (READ)
+get shipment
+**Parameters:**
+- `shipmentId`: string
+
+### inventory_getShipmentLines (READ)
+get shipment lines
+**Parameters:**
+- `shipmentId`: string
+
+### inventory_getShipmentLinesWithDetails (READ)
+get shipment lines with details
+**Parameters:**
+- `shipmentId`: string
+
+### inventory_getShipmentFiles (READ)
+get shipment files
+**Parameters:**
+- `lineIds`: string[]
+
+### inventory_getShipmentRelatedItems (READ)
+get shipment related items
+**Parameters:**
+- `shipmentId`: string
+- `sourceDocumentId`: string
+
+### inventory_getShipmentTracking (READ)
+get shipment tracking
+**Parameters:**
+- `shipmentId`: string
+
+### inventory_getShipmentLineTracking (READ)
+get shipment line tracking
+**Parameters:**
+- `shipmentLineId`: string
+
+### inventory_getShippingMethod (READ)
+get shipping method
+**Parameters:**
+- `shippingMethodId`: string
+
+### inventory_getShippingMethods (READ)
+get shipping methods
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### inventory_getShippingMethodsList (READ)
+get shipping methods list
+**Parameters:** none (context auto-filled)
+
+### inventory_getShippingTermsList (READ)
+get shipping terms list
+**Parameters:** none (context auto-filled)
+
+### inventory_getTrackedEntities (READ)
+get tracked entities
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### inventory_getTrackedEntitiesByMakeMethodId (READ)
+get tracked entities by make method id
+**Parameters:**
+- `jobMakeMethodId`: string
+
+### inventory_getTrackedEntity (READ)
+get tracked entity
+**Parameters:**
+- `trackedEntityId`: string
+
+### inventory_getTrackedEntitiesByOperationId (READ)
+get tracked entities by operation id
+**Parameters:**
+- `operationId`: string
+
+### inventory_getWarehouseTransfers (READ)
+get warehouse transfers
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### inventory_getWarehouseTransfer (READ)
+get warehouse transfer
+**Parameters:**
+- `transferId`: string
+
+### inventory_getWarehouseTransferLine (READ)
+get warehouse transfer line
+**Parameters:**
+- `transferId`: string
+- `lineId`: string
+
+### inventory_getWarehouseTransferLines (READ)
+get warehouse transfer lines
+**Parameters:**
+- `transferId`: string
+
+### inventory_insertManualInventoryAdjustment (WRITE)
+insert manual inventory adjustment
+**Parameters:**
+- `inventoryAdjustment`: z.infer<typeof inventoryAdjustmentValidator> & {
+ companyId: string;
+ createdBy: string;
+ }
+
+### inventory_updateBatchPropertyOrder (WRITE)
+update batch property order
+**Parameters:**
+- `data`: Omit<
+ z.infer<typeof batchPropertyOrderValidator>,
+ "batchPropertyGroupId"
+ > & {
+ batchPropertyGroupId?: string | null;
+ updatedBy: string;
+ }
+
+### inventory_updateStockTransferStatus (WRITE)
+update stock transfer status
+**Parameters:**
+- `args`: {
+ id: string;
+ status: Database["public"]["Enums"]["stockTransferStatus"];
+ assignee?: string | null;
+ completedAt: string | null;
+ updatedBy: string;
+ }
+
+### inventory_upsertBatchProperty (WRITE)
+upsert batch property
+**Parameters:**
+- `batchProperty`: z.infer<typeof batchPropertyValidator> & {
+ companyId: string;
+ userId: string;
+ }
+
+### inventory_upsertKanban (WRITE)
+upsert kanban
+**Parameters:**
+- `kanban`: | (Omit<z.infer<typeof kanbanValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof kanbanValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### inventory_upsertReceipt (WRITE)
+upsert receipt
+**Parameters:**
+- `receipt`: | (Omit<z.infer<typeof receiptValidator>, "id" | "receiptId"> & {
+ receiptId: string;
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof receiptValidator>, "id" | "receiptId"> & {
+ id: string;
+ receiptId: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### inventory_upsertShelf (WRITE)
+upsert shelf
+**Parameters:**
+- `shelf`: | (Omit<z.infer<typeof shelfValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof shelfValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### inventory_upsertShippingMethod (WRITE)
+upsert shipping method
+**Parameters:**
+- `shippingMethod`: | (Omit<z.infer<typeof shippingMethodValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof shippingMethodValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### inventory_upsertShipment (WRITE)
+upsert shipment
+**Parameters:**
+- `shipment`: | (Omit<z.infer<typeof shipmentValidator>, "id" | "shipmentId"> & {
+ shipmentId: string;
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof shipmentValidator>, "id" | "shipmentId"> & {
+ id: string;
+ shipmentId: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### inventory_upsertStockTransfer (WRITE)
+upsert stock transfer
+**Parameters:**
+- `stockTransfer`: | {
+ locationId: string;
+ stockTransferId: string;
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ }
+ | {
+ id: string;
+ locationId: string;
+ stockTransferId: string;
+ companyId: string;
+ updatedBy: string;
+ customFields?: Json;
+ }
+
+### inventory_upsertStockTransferLine (WRITE)
+upsert stock transfer line
+**Parameters:**
+- `stockTransferLine`: | (Omit<z.infer<typeof stockTransferLineValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof stockTransferLineValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### inventory_upsertStockTransferLines (WRITE)
+upsert stock transfer lines
+**Parameters:**
+- `args`: {
+ lines: z.infer<typeof stockTransferValidator>["lines"];
+ stockTransferId: string;
+ companyId: string;
+ createdBy: string;
+ }
+
+### inventory_upsertWarehouseTransfer (WRITE)
+upsert warehouse transfer
+**Parameters:**
+- `transfer`: | (Omit<z.infer<typeof warehouseTransferValidator>, "id" | "transferId"> & {
+ transferId: string;
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof warehouseTransferValidator>, "id" | "transferId"> & {
+ id: string;
+ transferId: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### inventory_updateWarehouseTransferStatus (WRITE)
+update warehouse transfer status
+**Parameters:**
+- `transferId`: string
+- `status`: Database["public"]["Tables"]["warehouseTransfer"]["Row"]["status"]
+
+### inventory_upsertWarehouseTransferLine (WRITE)
+upsert warehouse transfer line
+**Parameters:**
+- `line`: | Database["public"]["Tables"]["warehouseTransferLine"]["Insert"]
+ | (Database["public"]["Tables"]["warehouseTransferLine"]["Update"] & {
+ id: string;
+ })
+
+### inventory_getDefaultShelfForJob (READ)
+get default shelf for job
+**Parameters:**
+- `itemId`: string
+- `locationId`: string
+
+---
+
+## invoicing (28 tools)
+
+### invoicing_createPurchaseInvoiceFromPurchaseOrder (WRITE)
+create purchase invoice from purchase order
+**Parameters:**
+- `purchaseOrderId`: string
+
+### invoicing_createSalesInvoiceFromSalesOrder (WRITE)
+create sales invoice from sales order
+**Parameters:**
+- `salesOrderId`: string
+
+### invoicing_createSalesInvoiceFromShipment (WRITE)
+create sales invoice from shipment
+**Parameters:**
+- `shipmentId`: string
+
+### invoicing_deletePurchaseInvoice (DESTRUCTIVE)
+delete purchase invoice
+**Parameters:**
+- `purchaseInvoiceId`: string
+
+### invoicing_deletePurchaseInvoiceLine (DESTRUCTIVE)
+delete purchase invoice line
+**Parameters:**
+- `purchaseInvoiceLineId`: string
+
+### invoicing_deleteSalesInvoice (DESTRUCTIVE)
+delete sales invoice
+**Parameters:**
+- `salesInvoiceId`: string
+
+### invoicing_deleteSalesInvoiceLine (DESTRUCTIVE)
+delete sales invoice line
+**Parameters:**
+- `salesInvoiceLineId`: string
+
+### invoicing_getPurchaseInvoice (READ)
+get purchase invoice
+**Parameters:**
+- `purchaseInvoiceId`: string
+
+### invoicing_getPurchaseInvoices (READ)
+get purchase invoices
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ supplierId: string | null;
+ }
+
+### invoicing_getPurchaseInvoiceDelivery (READ)
+get purchase invoice delivery
+**Parameters:**
+- `purchaseInvoiceId`: string
+
+### invoicing_getPurchaseInvoiceLines (READ)
+get purchase invoice lines
+**Parameters:**
+- `purchaseInvoiceId`: string
+
+### invoicing_getPurchaseInvoiceLine (READ)
+get purchase invoice line
+**Parameters:**
+- `purchaseInvoiceLineId`: string
+
+### invoicing_getSalesInvoice (READ)
+get sales invoice
+**Parameters:**
+- `salesInvoiceId`: string
+
+### invoicing_getSalesInvoiceCustomerDetails (READ)
+get sales invoice customer details
+**Parameters:**
+- `salesInvoiceId`: string
+
+### invoicing_getSalesInvoices (READ)
+get sales invoices
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ customerId: string | null;
+ }
+
+### invoicing_getSalesInvoiceShipment (READ)
+get sales invoice shipment
+**Parameters:**
+- `salesInvoiceId`: string
+
+### invoicing_getSalesInvoiceLines (READ)
+get sales invoice lines
+**Parameters:**
+- `salesInvoiceId`: string
+
+### invoicing_getSalesInvoiceLine (READ)
+get sales invoice line
+**Parameters:**
+- `salesInvoiceLineId`: string
+
+### invoicing_updatePurchaseInvoiceExchangeRate (WRITE)
+update purchase invoice exchange rate
+**Parameters:**
+- `data`: {
+ id: string;
+ exchangeRate: number;
+ }
+
+### invoicing_updatePurchaseInvoiceStatus (WRITE)
+update purchase invoice status
+**Parameters:**
+- `update`: {
+ id: string;
+ status: (typeof purchaseInvoiceStatusType)[number];
+ assignee: null | undefined;
+ updatedBy: string;
+ }
+
+### invoicing_updateSalesInvoiceExchangeRate (WRITE)
+update sales invoice exchange rate
+**Parameters:**
+- `data`: {
+ id: string;
+ exchangeRate: number;
+ }
+
+### invoicing_updateSalesInvoiceStatus (WRITE)
+update sales invoice status
+**Parameters:**
+- `update`: {
+ id: string;
+ status: (typeof salesInvoiceStatusType)[number];
+ assignee: null | undefined;
+ updatedBy: string;
+ }
+
+### invoicing_upsertPurchaseInvoice (WRITE)
+upsert purchase invoice
+**Parameters:**
+- `purchaseInvoice`: | (Omit<z.infer<typeof purchaseInvoiceValidator>, "id" | "invoiceId"> & {
+ invoiceId: string;
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof purchaseInvoiceValidator>, "id" | "invoiceId"> & {
+ id: string;
+ invoiceId: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### invoicing_upsertPurchaseInvoiceDelivery (WRITE)
+upsert purchase invoice delivery
+**Parameters:**
+- `purchaseInvoiceDelivery`: | (z.infer<typeof purchaseInvoiceDeliveryValidator> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (z.infer<typeof purchaseInvoiceDeliveryValidator> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### invoicing_upsertPurchaseInvoiceLine (WRITE)
+upsert purchase invoice line
+**Parameters:**
+- `purchaseInvoiceLine`: | (Omit<z.infer<typeof purchaseInvoiceLineValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof purchaseInvoiceLineValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### invoicing_upsertSalesInvoice (WRITE)
+upsert sales invoice
+**Parameters:**
+- `salesInvoice`: | (Omit<z.infer<typeof salesInvoiceValidator>, "id" | "invoiceId"> & {
+ invoiceId: string;
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof salesInvoiceValidator>, "id" | "invoiceId"> & {
+ id: string;
+ invoiceId: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### invoicing_upsertSalesInvoiceShipment (WRITE)
+upsert sales invoice shipment
+**Parameters:**
+- `salesInvoiceShipment`: | (z.infer<typeof salesInvoiceShipmentValidator> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (z.infer<typeof salesInvoiceShipmentValidator> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### invoicing_upsertSalesInvoiceLine (WRITE)
+upsert sales invoice line
+**Parameters:**
+- `salesInvoiceLine`: | (Omit<z.infer<typeof salesInvoiceLineValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof salesInvoiceLineValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+---
+
+## items (136 tools)
+
+### items_activateMethodVersion (WRITE)
+activate method version
+**Parameters:**
+- `payload`: {
+ id: string;
+ companyId: string;
+ userId: string;
+ }
+
+### items_copyItem (WRITE)
+copy item
+**Parameters:**
+- `args`: z.infer<typeof getMethodValidator> & {
+ companyId: string;
+ userId: string;
+ }
+
+### items_copyMakeMethod (WRITE)
+copy make method
+**Parameters:**
+- `args`: z.infer<typeof getMethodValidator> & {
+ companyId: string;
+ userId: string;
+ }
+
+### items_createRevision (WRITE)
+create revision
+**Parameters:**
+- `args`: {
+ item: NonNullable<Awaited<ReturnType<typeof getItem>>["data"]>;
+ revision: string;
+ createdBy: string;
+ }
+
+### items_deleteConfigurationParameter (DESTRUCTIVE)
+delete configuration parameter
+**Parameters:**
+- `id`: string
+
+### items_deleteConfigurationRule (DESTRUCTIVE)
+delete configuration rule
+**Parameters:**
+- `field`: string
+- `itemId`: string
+
+### items_deleteItemCustomerPart (DESTRUCTIVE)
+delete item customer part
+**Parameters:**
+- `id`: string
+
+### items_deleteConfigurationParameterGroup (DESTRUCTIVE)
+delete configuration parameter group
+**Parameters:**
+- `id`: string
+
+### items_deleteItem (DESTRUCTIVE)
+delete item
+**Parameters:**
+- `id`: string
+
+### items_deleteItemPostingGroup (DESTRUCTIVE)
+delete item posting group
+**Parameters:**
+- `id`: string
+
+### items_deleteMaterialDimension (DESTRUCTIVE)
+delete material dimension
+**Parameters:**
+- `id`: string
+
+### items_deleteMaterialFinish (DESTRUCTIVE)
+delete material finish
+**Parameters:**
+- `id`: string
+
+### items_deleteMaterialForm (DESTRUCTIVE)
+delete material form
+**Parameters:**
+- `id`: string
+
+### items_deleteMaterialGrade (DESTRUCTIVE)
+delete material grade
+**Parameters:**
+- `id`: string
+
+### items_deleteMaterialSubstance (DESTRUCTIVE)
+delete material substance
+**Parameters:**
+- `id`: string
+
+### items_deleteMethodMaterial (DESTRUCTIVE)
+delete method material
+**Parameters:**
+- `id`: string
+
+### items_assertMethodOperationIsDraft (WRITE)
+assert method operation is draft
+**Parameters:**
+- `operationId`: string
+
+### items_deleteMethodOperationStep (DESTRUCTIVE)
+delete method operation step
+**Parameters:**
+- `id`: string
+
+### items_deleteMethodOperationParameter (DESTRUCTIVE)
+delete method operation parameter
+**Parameters:**
+- `id`: string
+
+### items_deleteMethodOperationTool (DESTRUCTIVE)
+delete method operation tool
+**Parameters:**
+- `id`: string
+
+### items_deleteUnitOfMeasure (DESTRUCTIVE)
+delete unit of measure
+**Parameters:**
+- `id`: string
+
+### items_getConfigurationParameters (READ)
+get configuration parameters
+**Parameters:**
+- `itemId`: string
+
+### items_getConfigurationRules (READ)
+get configuration rules
+**Parameters:**
+- `itemId`: string
+
+### items_getConsumable (READ)
+get consumable
+**Parameters:**
+- `itemId`: string
+
+### items_getConsumables (READ)
+get consumables
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ supplierId: string | null;
+ }
+
+### items_getConsumablesList (READ)
+get consumables list
+**Parameters:** none (context auto-filled)
+
+### items_getItem (READ)
+get item
+**Parameters:**
+- `id`: string
+
+### items_getItemCost (READ)
+get item cost
+**Parameters:**
+- `itemId`: string
+
+### items_getItemCostHistory (READ)
+get item cost history
+**Parameters:**
+- `itemId`: string
+
+### items_getItemCustomerPart (READ)
+get item customer part
+**Parameters:**
+- `id`: string
+
+### items_getItemCustomerParts (READ)
+get item customer parts
+**Parameters:**
+- `itemId`: string
+
+### items_getItemDemand (READ)
+get item demand
+**Parameters:**
+- `arg1`: {
+ itemId: string;
+ locationId: string;
+ periods: string[];
+ companyId: string;
+ }
+
+### items_getItemFiles (READ)
+get item files
+**Parameters:**
+- `itemId`: string
+
+### items_getItemPostingGroup (READ)
+get item posting group
+**Parameters:**
+- `id`: string
+
+### items_getItemPostingGroups (READ)
+get item posting groups
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### items_getItemPostingGroupsList (READ)
+get item posting groups list
+**Parameters:** none (context auto-filled)
+
+### items_getItemManufacturing (READ)
+get item manufacturing
+**Parameters:**
+- `id`: string
+
+### items_getItemPlanning (READ)
+get item planning
+**Parameters:**
+- `itemId`: string
+- `locationId`: string
+
+### items_getItemQuantities (READ)
+get item quantities
+**Parameters:**
+- `itemId`: string
+- `locationId`: string
+
+### items_getItemReplenishment (READ)
+get item replenishment
+**Parameters:**
+- `itemId`: string
+
+### items_getItemShelfQuantities (READ)
+get item shelf quantities
+**Parameters:**
+- `itemId`: string
+- `locationId`: string
+
+### items_getItemSupply (READ)
+get item supply
+**Parameters:**
+- `arg1`: {
+ itemId: string;
+ locationId: string;
+ periods: string[];
+ companyId: string;
+ }
+
+### items_getItemUnitSalePrice (READ)
+get item unit sale price
+**Parameters:**
+- `id`: string
+
+### items_getMaterialUsedIn (READ)
+get material used in
+**Parameters:**
+- `itemId`: string
+
+### items_getMakeMethods (READ)
+get make methods
+**Parameters:**
+- `itemId`: string
+
+### items_getMakeMethodById (READ)
+get make method by id
+**Parameters:**
+- `makeMethodId`: string
+
+### items_getMaterial (READ)
+get material
+**Parameters:**
+- `itemId`: string
+
+### items_getMaterials (READ)
+get materials
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ supplierId: string | null;
+ }
+
+### items_getMaterialsList (READ)
+get materials list
+**Parameters:** none (context auto-filled)
+
+### items_getMaterialDimension (READ)
+get material dimension
+**Parameters:**
+- `id`: string
+
+### items_getMaterialDimensions (READ)
+get material dimensions
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null; isMetric: boolean } (optional)
+
+### items_getMaterialDimensionList (READ)
+get material dimension list
+**Parameters:**
+- `materialFormId`: string
+- `isMetric`: boolean
+
+### items_getMaterialFinish (READ)
+get material finish
+**Parameters:**
+- `id`: string
+
+### items_getMaterialFinishes (READ)
+get material finishes
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### items_getMaterialFinishList (READ)
+get material finish list
+**Parameters:**
+- `materialSubstanceId`: string
+
+### items_getMaterialForm (READ)
+get material form
+**Parameters:**
+- `id`: string
+
+### items_getMaterialForms (READ)
+get material forms
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### items_getMaterialFormsList (READ)
+get material forms list
+**Parameters:** none (context auto-filled)
+
+### items_getMaterialGrades (READ)
+get material grades
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### items_getMaterialGrade (READ)
+get material grade
+**Parameters:**
+- `id`: string
+
+### items_getMaterialGradeList (READ)
+get material grade list
+**Parameters:**
+- `materialSubstanceId`: string
+
+### items_getMaterialSubstance (READ)
+get material substance
+**Parameters:**
+- `id`: string
+
+### items_getMaterialSubstances (READ)
+get material substances
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### items_getMaterialSubstancesList (READ)
+get material substances list
+**Parameters:** none (context auto-filled)
+
+### items_getMethodMaterial (READ)
+get method material
+**Parameters:**
+- `materialId`: string
+
+### items_getMethodMaterials (READ)
+get method materials
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### items_getMethodMaterialsByMakeMethod (READ)
+get method materials by make method
+**Parameters:**
+- `makeMethodId`: string
+
+### items_getMethodOperations (READ)
+get method operations
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### items_getMethodOperationsByMakeMethodId (READ)
+get method operations by make method id
+**Parameters:**
+- `makeMethodId`: string
+
+### items_getMethodTree (READ)
+get method tree
+**Parameters:**
+- `makeMethodId`: string
+
+### items_getMethodTreeArray (READ)
+get method tree array
+**Parameters:**
+- `makeMethodId`: string
+
+### items_getOpenJobMaterials (READ)
+get open job materials
+**Parameters:**
+- `arg1`: { itemId: string; companyId: string; locationId: string }
+
+### items_getOpenProductionOrders (READ)
+get open production orders
+**Parameters:**
+- `arg1`: { itemId: string; companyId: string; locationId: string }
+
+### items_getOpenPurchaseOrderLines (READ)
+get open purchase order lines
+**Parameters:**
+- `arg1`: { itemId: string; companyId: string; locationId: string }
+
+### items_getOpenSalesOrderLines (READ)
+get open sales order lines
+**Parameters:**
+- `arg1`: { itemId: string; companyId: string; locationId: string }
+
+### items_getPart (READ)
+get part
+**Parameters:**
+- `itemId`: string
+
+### items_getParts (READ)
+get parts
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ supplierId: string | null;
+ }
+
+### items_getPartsList (READ)
+get parts list
+**Parameters:** none (context auto-filled)
+
+### items_getPartUsedIn (READ)
+get part used in
+**Parameters:**
+- `itemId`: string
+
+### items_getPickMethod (READ)
+get pick method
+**Parameters:**
+- `itemId`: string
+- `locationId`: string
+
+### items_getPickMethods (READ)
+get pick methods
+**Parameters:**
+- `itemId`: string
+
+### items_getServices (READ)
+get services
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ type: string | null;
+ group: string | null;
+ supplierId: string | null;
+ }
+
+### items_getService (READ)
+get service
+**Parameters:**
+- `itemId`: string
+
+### items_getServicesList (READ)
+get services list
+**Parameters:** none (context auto-filled)
+
+### items_getSupplierParts (READ)
+get supplier parts
+**Parameters:**
+- `id`: string
+
+### items_getTool (READ)
+get tool
+**Parameters:**
+- `itemId`: string
+
+### items_getTools (READ)
+get tools
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ supplierId: string | null;
+ }
+
+### items_getToolsList (READ)
+get tools list
+**Parameters:** none (context auto-filled)
+
+### items_getUnitOfMeasure (READ)
+get unit of measure
+**Parameters:**
+- `id`: string
+
+### items_getUnitOfMeasures (READ)
+get unit of measures
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null }
+
+### items_getUnitOfMeasuresList (READ)
+get unit of measures list
+**Parameters:** none (context auto-filled)
+
+### items_updateConfigurationParameterGroupOrder (WRITE)
+update configuration parameter group order
+**Parameters:**
+- `data`: z.infer<typeof configurationParameterGroupOrderValidator>
+
+### items_updateDefaultRevision (WRITE)
+update default revision
+**Parameters:**
+- `data`: {
+ id: string;
+ updatedBy: string;
+ }
+
+### items_updateConfigurationParameterOrder (WRITE)
+update configuration parameter order
+**Parameters:**
+- `data`: Omit<
+ z.infer<typeof configurationParameterOrderValidator>,
+ "configurationParameterGroupId"
+ > & {
+ configurationParameterGroupId?: string | null;
+ updatedBy: string;
+ }
+
+### items_updateItemCost (WRITE)
+update item cost
+**Parameters:**
+- `itemId`: string
+- `cost`: {
+ unitCost: number;
+ updatedBy: string;
+ }
+
+### items_updateMaterialOrder (WRITE)
+update material order
+**Parameters:**
+- `updates`: {
+ id: string;
+ order: number;
+ updatedBy: string;
+ }[]
+
+### items_updateOperationOrder (WRITE)
+update operation order
+**Parameters:**
+- `updates`: {
+ id: string;
+ order: number;
+ updatedBy: string;
+ }[]
+
+### items_updateRevision (WRITE)
+update revision
+**Parameters:**
+- `revision`: {
+ id: string;
+ revision: string;
+ updatedBy: string;
+ }
+
+### items_upsertConfigurationParameter (WRITE)
+upsert configuration parameter
+**Parameters:**
+- `configurationParameter`: z.infer<typeof configurationParameterValidator> & {
+ companyId: string;
+ userId: string;
+ }
+
+### items_upsertConfigurationParameterGroup (WRITE)
+upsert configuration parameter group
+**Parameters:**
+- `configurationParameterGroup`: z.infer<
+ typeof configurationParameterGroupValidator
+ > & {
+ companyId: string;
+ itemId: string;
+ }
+
+### items_upsertConfigurationRule (WRITE)
+upsert configuration rule
+**Parameters:**
+- `configurationRule`: z.infer<typeof configurationRuleValidator> & {
+ itemId: string;
+ companyId: string;
+ updatedBy: string;
+ }
+
+### items_upsertConsumable (WRITE)
+upsert consumable
+**Parameters:**
+- `consumable`: | (z.infer<typeof consumableValidator> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (z.infer<typeof consumableValidator> & {
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### items_upsertPart (WRITE)
+upsert part
+**Parameters:**
+- `part`: | (z.infer<typeof partValidator> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (z.infer<typeof partValidator> & {
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### items_updateItem (WRITE)
+update item
+**Parameters:**
+- `item`: z.infer<typeof itemValidator> & {
+ companyId: string;
+ type: Database["public"]["Enums"]["itemType"];
+ }
+
+### items_upsertItemCost (WRITE)
+upsert item cost
+**Parameters:**
+- `itemCost`: z.infer<typeof itemCostValidator> & {
+ updatedBy: string;
+ customFields?: Json;
+ }
+
+### items_upsertPickMethod (WRITE)
+upsert pick method
+**Parameters:**
+- `pickMethod`: | (z.infer<typeof pickMethodValidator> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (z.infer<typeof pickMethodValidator> & {
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### items_upsertItemManufacturing (WRITE)
+upsert item manufacturing
+**Parameters:**
+- `partManufacturing`: z.infer<typeof itemManufacturingValidator> & {
+ updatedBy: string;
+ customFields?: Json;
+ }
+
+### items_upsertItemPlanning (WRITE)
+upsert item planning
+**Parameters:**
+- `partPlanning`: | {
+ companyId: string;
+ itemId: string;
+ locationId: string;
+ createdBy: string;
+ }
+ | (z.infer<typeof itemPlanningValidator> & {
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### items_upsertItemPurchasing (WRITE)
+upsert item purchasing
+**Parameters:**
+- `itemPurchasing`: z.infer<typeof itemPurchasingValidator> & {
+ updatedBy: string;
+ }
+
+### items_upsertItemPostingGroup (WRITE)
+upsert item posting group
+**Parameters:**
+- `itemPostingGroup`: | (Omit<z.infer<typeof itemPostingGroupValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof itemPostingGroupValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### items_upsertSupplierPart (WRITE)
+upsert supplier part
+**Parameters:**
+- `supplierPart`: | (Omit<z.infer<typeof supplierPartValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof supplierPartValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### items_upsertItemCustomerPart (WRITE)
+upsert item customer part
+**Parameters:**
+- `customerPart`: | (Omit<z.infer<typeof customerPartValidator>, "id"> & {
+ companyId: string;
+ })
+ | (Omit<z.infer<typeof customerPartValidator>, "id"> & {
+ id: string;
+ })
+
+### items_upsertItemUnitSalePrice (WRITE)
+upsert item unit sale price
+**Parameters:**
+- `itemUnitSalePrice`: z.infer<typeof itemUnitSalePriceValidator> & {
+ updatedBy: string;
+ customFields?: Json;
+ }
+
+### items_upsertMakeMethodVersion (WRITE)
+upsert make method version
+**Parameters:**
+- `makeMethodVersion`: z.infer<typeof makeMethodVersionValidator> & {
+ companyId: string;
+ createdBy: string;
+ }
+
+### items_upsertMethodMaterial (WRITE)
+upsert method material
+**Parameters:**
+- `methodMaterial`: | (z.infer<typeof methodMaterialValidator> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (z.infer<typeof methodMaterialValidator> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### items_upsertMethodOperation (WRITE)
+upsert method operation
+**Parameters:**
+- `methodOperation`: | (Omit<z.infer<typeof methodOperationValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (z.infer<typeof methodOperationValidator> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof methodOperationValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### items_upsertMethodOperationStep (WRITE)
+upsert method operation step
+**Parameters:**
+- `methodOperationStep`: | (Omit<z.infer<typeof operationStepValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<
+ z.infer<typeof operationStepValidator>,
+ "id" | "minValue" | "maxValue"
+ > & {
+ id: string;
+ minValue: number | null;
+ maxValue: number | null;
+ updatedBy: string;
+ updatedAt: string;
+ })
+
+### items_upsertMethodOperationParameter (WRITE)
+upsert method operation parameter
+**Parameters:**
+- `methodOperationParameter`: | (Omit<z.infer<typeof operationParameterValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof operationParameterValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ updatedAt: string;
+ })
+
+### items_upsertMethodOperationTool (WRITE)
+upsert method operation tool
+**Parameters:**
+- `methodOperationTool`: | (Omit<z.infer<typeof operationToolValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof operationToolValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ updatedAt: string;
+ })
+
+### items_upsertMaterial (WRITE)
+upsert material
+**Parameters:**
+- `material`: | (z.infer<typeof materialValidator> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ sizes?: string[];
+ })
+ | (z.infer<typeof materialValidator> & {
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### items_upsertMaterialDimension (WRITE)
+upsert material dimension
+**Parameters:**
+- `materialDimension`: | (Omit<z.infer<typeof materialDimensionValidator>, "id"> & {
+ companyId: string;
+ isMetric: boolean;
+ })
+ | (Omit<z.infer<typeof materialDimensionValidator>, "id"> & {
+ id: string;
+ })
+
+### items_upsertMaterialFinish (WRITE)
+upsert material finish
+**Parameters:**
+- `materialFinish`: | (Omit<z.infer<typeof materialFinishValidator>, "id"> & {
+ companyId: string;
+ })
+ | (Omit<z.infer<typeof materialFinishValidator>, "id"> & {
+ id: string;
+ })
+
+### items_upsertMaterialForm (WRITE)
+upsert material form
+**Parameters:**
+- `materialForm`: | (Omit<z.infer<typeof materialFormValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof materialFormValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### items_upsertMaterialGrade (WRITE)
+upsert material grade
+**Parameters:**
+- `materialGrade`: | (Omit<z.infer<typeof materialGradeValidator>, "id"> & {
+ companyId: string;
+ })
+ | (Omit<z.infer<typeof materialGradeValidator>, "id"> & {
+ id: string;
+ })
+
+### items_deleteMaterialType (DESTRUCTIVE)
+delete material type
+**Parameters:**
+- `id`: string
+
+### items_getMaterialTypes (READ)
+get material types
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### items_getMaterialType (READ)
+get material type
+**Parameters:**
+- `id`: string
+
+### items_getMaterialTypeList (READ)
+get material type list
+**Parameters:**
+- `materialSubstanceId`: string
+- `materialFormId`: string
+
+### items_upsertMaterialType (WRITE)
+upsert material type
+**Parameters:**
+- `materialType`: | (Omit<z.infer<typeof materialTypeValidator>, "id"> & {
+ companyId: string;
+ })
+ | (Omit<z.infer<typeof materialTypeValidator>, "id"> & {
+ id: string;
+ })
+
+### items_upsertMaterialSubstance (WRITE)
+upsert material substance
+**Parameters:**
+- `materialSubstance`: | (Omit<z.infer<typeof materialSubstanceValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof materialSubstanceValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### items_upsertService (WRITE)
+upsert service
+**Parameters:**
+- `service`: | (z.infer<typeof serviceValidator> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof serviceValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### items_upsertUnitOfMeasure (WRITE)
+upsert unit of measure
+**Parameters:**
+- `unitOfMeasure`: | (Omit<z.infer<typeof unitOfMeasureValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof unitOfMeasureValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### items_upsertTool (WRITE)
+upsert tool
+**Parameters:**
+- `tool`: | (z.infer<typeof toolValidator> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (z.infer<typeof toolValidator> & {
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### items_getSupplierPriceBreaksForItems (READ)
+get supplier price breaks for items
+**Parameters:**
+- `itemIds`: string[]
+
+### items_lookupBuyPrice (WRITE)
+lookup buy price
+**Parameters:**
+- `itemId`: string
+- `qty`: number
+- `fallbackCost`: number
+
+### items_getSupplierPartPriceBreaks (READ)
+get supplier part price breaks
+**Parameters:**
+- `supplierPartId`: string
+
+---
+
+## people (44 tools)
+
+### people_deleteAttribute (DESTRUCTIVE)
+delete attribute
+**Parameters:**
+- `attributeId`: string
+
+### people_deleteAttributeCategory (DESTRUCTIVE)
+delete attribute category
+**Parameters:**
+- `attributeCategoryId`: string
+
+### people_deleteDepartment (DESTRUCTIVE)
+delete department
+**Parameters:**
+- `departmentId`: string
+
+### people_deleteHoliday (DESTRUCTIVE)
+delete holiday
+**Parameters:**
+- `holidayId`: string
+
+### people_deleteShift (DESTRUCTIVE)
+delete shift
+**Parameters:**
+- `shiftId`: string
+
+### people_getAttribute (READ)
+get attribute
+**Parameters:**
+- `attributeId`: string
+
+### people_getAttributeCategories (READ)
+get attribute categories
+**Parameters:**
+- `args`: { search: string | null } & GenericQueryFilters (optional)
+
+### people_getAttributeCategory (READ)
+get attribute category
+**Parameters:**
+- `id`: string
+
+### people_getAttributeDataTypes (READ)
+get attribute data types
+**Parameters:** none (context auto-filled)
+
+### people_getDepartment (READ)
+get department
+**Parameters:**
+- `departmentId`: string
+
+### people_getDepartments (READ)
+get departments
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### people_getDepartmentsList (READ)
+get departments list
+**Parameters:** none (context auto-filled)
+
+### people_getEmployeeJob (READ)
+get employee job
+**Parameters:**
+- `employeeId`: string
+
+### people_getEmployeeSummary (READ)
+get employee summary
+**Parameters:**
+- `employeeId`: string
+
+### people_getHoliday (READ)
+get holiday
+**Parameters:**
+- `holidayId`: string
+
+### people_getHolidays (READ)
+get holidays
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### people_getPeople (READ)
+get people
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### people_getContacts (READ)
+get contacts
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### people_getShift (READ)
+get shift
+**Parameters:**
+- `shiftId`: string
+
+### people_getShifts (READ)
+get shifts
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null }
+
+### people_getShiftsList (READ)
+get shifts list
+**Parameters:**
+- `locationId`: string | null
+
+### people_insertAttribute (WRITE)
+insert attribute
+**Parameters:**
+- `attribute`: {
+ name: string;
+ attributeDataTypeId: number;
+ userAttributeCategoryId: string;
+ listOptions?: string[];
+ canSelfManage: boolean;
+ createdBy: string;
+ }
+
+### people_insertAttributeCategory (WRITE)
+insert attribute category
+**Parameters:**
+- `attributeCategory`: {
+ name: string;
+ emoji?: string;
+ public: boolean;
+ companyId: string;
+ createdBy: string;
+ }
+
+### people_insertEmployeeJob (WRITE)
+insert employee job
+**Parameters:**
+- `job`: {
+ id: string;
+ companyId: string;
+ locationId?: string;
+ }
+
+### people_updateAttribute (WRITE)
+update attribute
+**Parameters:**
+- `attribute`: {
+ id?: string;
+ name: string;
+ listOptions?: string[];
+ canSelfManage: boolean;
+ updatedBy: string;
+ }
+
+### people_updateAttributeCategory (WRITE)
+update attribute category
+**Parameters:**
+- `attributeCategory`: {
+ id: string;
+ name: string;
+ emoji?: string;
+ public: boolean;
+ updatedBy: string;
+ }
+
+### people_updateAttributeSortOrder (WRITE)
+update attribute sort order
+**Parameters:**
+- `updates`: {
+ id: string;
+ sortOrder: number;
+ updatedBy: string;
+ }[]
+
+### people_updateEmployeeJob (WRITE)
+update employee job
+**Parameters:**
+- `employeeId`: string
+- `employeeJob`: z.infer<typeof employeeJobValidator> & {
+ companyId: string;
+ updatedBy: string;
+ customFields?: Json;
+ }
+
+### people_upsertDepartment (WRITE)
+upsert department
+**Parameters:**
+- `department`: | (Omit<z.infer<typeof departmentValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof departmentValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### people_upsertHoliday (WRITE)
+upsert holiday
+**Parameters:**
+- `holiday`: | (Omit<z.infer<typeof holidayValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof holidayValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### people_upsertShift (WRITE)
+upsert shift
+**Parameters:**
+- `shift`: | (Omit<z.infer<typeof shiftValidator>, "id"> & {
+ createdBy: string;
+ companyId: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof shiftValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### people_clockIn (WRITE)
+clock in
+**Parameters:**
+- `args`: {
+ employeeId: string;
+ companyId: string;
+ createdBy: string;
+ }
+
+### people_clockOut (WRITE)
+clock out
+**Parameters:**
+- `args`: {
+ employeeId: string;
+ companyId: string;
+ updatedBy: string;
+ clockOut?: string;
+ note?: string;
+ }
+
+### people_createTimeCardEntry (WRITE)
+create time card entry
+**Parameters:**
+- `entry`: {
+ employeeId: string;
+ companyId: string;
+ clockIn: string;
+ clockOut?: string | null;
+ note?: string | null;
+ createdBy: string;
+ }
+
+### people_deleteTimeCardEntry (DESTRUCTIVE)
+delete time card entry
+**Parameters:**
+- `entryId`: string
+
+### people_getClockedInEmployees (READ)
+get clocked in employees
+**Parameters:** none (context auto-filled)
+
+### people_getOpenClockEntry (READ)
+get open clock entry
+**Parameters:**
+- `employeeId`: string
+
+### people_getRecentTimecards (READ)
+get recent timecards
+**Parameters:** none (context auto-filled)
+
+### people_getScheduledEmployeesToday (READ)
+get scheduled employees today
+**Parameters:** none (context auto-filled)
+
+### people_getTimeCardEntry (READ)
+get time card entry
+**Parameters:**
+- `entryId`: string
+
+### people_getTimeCardEntries (READ)
+get time card entries
+**Parameters:**
+- `args`: {
+ employeeId: string;
+ companyId: string;
+ from?: string;
+ to?: string;
+ }
+
+### people_getTimecardEntries (READ)
+get timecard entries
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null }
+
+### people_getWeeklyHoursForEmployees (READ)
+get weekly hours for employees
+**Parameters:**
+- `employeeIds`: string[]
+
+### people_updateTimeCardEntry (WRITE)
+update time card entry
+**Parameters:**
+- `args`: {
+ entryId: string;
+ clockIn?: string;
+ clockOut?: string | null;
+ note?: string | null;
+ updatedBy: string;
+ }
+
+---
+
+## production (128 tools)
+
+### production_convertSalesOrderLinesToJobs (WRITE)
+convert sales order lines to jobs
+**Parameters:**
+- `arg1`: {
+ orderId: string;
+ companyId: string;
+ userId: string;
+ }
+
+### production_calculateJobPriority (WRITE)
+calculate job priority
+**Parameters:**
+- `params`: {
+ jobId?: string; // Optional - if updating an existing job
+ dueDate: string | null;
+ deadlineType: (typeof deadlineTypes)[number];
+ companyId: string;
+ locationId: string;
+ }
+
+### production_deleteDemandForecasts (DESTRUCTIVE)
+delete demand forecasts
+**Parameters:**
+- `params`: {
+ itemId: string;
+ locationId: string;
+ companyId: string;
+ futurePeriodIds: string[];
+ }
+
+### production_deleteDemandProjections (DESTRUCTIVE)
+delete demand projections
+**Parameters:**
+- `params`: {
+ itemId: string;
+ locationId: string;
+ companyId: string;
+ futurePeriodIds: string[];
+ }
+
+### production_deleteJob (DESTRUCTIVE)
+delete job
+**Parameters:**
+- `jobId`: string
+
+### production_deleteJobMaterial (DESTRUCTIVE)
+delete job material
+**Parameters:**
+- `jobMaterialId`: string
+
+### production_deleteJobOperation (DESTRUCTIVE)
+delete job operation
+**Parameters:**
+- `jobOperationId`: string
+
+### production_deleteJobOperationStep (DESTRUCTIVE)
+delete job operation step
+**Parameters:**
+- `id`: string
+
+### production_deleteJobOperationParameter (DESTRUCTIVE)
+delete job operation parameter
+**Parameters:**
+- `id`: string
+
+### production_deleteJobOperationTool (DESTRUCTIVE)
+delete job operation tool
+**Parameters:**
+- `id`: string
+
+### production_deleteProcedure (DESTRUCTIVE)
+delete procedure
+**Parameters:**
+- `procedureId`: string
+
+### production_deleteProcedureStep (DESTRUCTIVE)
+delete procedure step
+**Parameters:**
+- `procedureStepId`: string
+
+### production_deleteProcedureParameter (DESTRUCTIVE)
+delete procedure parameter
+**Parameters:**
+- `procedureParameterId`: string
+
+### production_deleteProductionEvent (DESTRUCTIVE)
+delete production event
+**Parameters:**
+- `productionEventId`: string
+
+### production_deleteProductionQuantity (DESTRUCTIVE)
+delete production quantity
+**Parameters:**
+- `productionQuantityId`: string
+
+### production_getActiveJobOperationByJobId (READ)
+get active job operation by job id
+**Parameters:**
+- `jobId`: string
+
+### production_getActiveJobOperationsByLocation (READ)
+get active job operations by location
+**Parameters:**
+- `locationId`: string
+- `workCenterIds`: string[] (optional)
+
+### production_getJobsByDateRange (READ)
+get jobs by date range
+**Parameters:**
+- `locationId`: string
+- `startDate`: string
+- `endDate`: string
+
+### production_getUnscheduledJobs (READ)
+get unscheduled jobs
+**Parameters:**
+- `locationId`: string
+
+### production_getActiveProductionEvents (READ)
+get active production events
+**Parameters:** none (context auto-filled)
+
+### production_deleteScrapReason (DESTRUCTIVE)
+delete scrap reason
+**Parameters:**
+- `scrapReasonId`: string
+
+### production_deleteFailureMode (DESTRUCTIVE)
+delete failure mode
+**Parameters:**
+- `failureModeId`: string
+
+### production_deleteMaintenanceDispatch (DESTRUCTIVE)
+delete maintenance dispatch
+**Parameters:**
+- `dispatchId`: string
+
+### production_deleteMaintenanceDispatchComment (DESTRUCTIVE)
+delete maintenance dispatch comment
+**Parameters:**
+- `commentId`: string
+
+### production_deleteMaintenanceDispatchEvent (DESTRUCTIVE)
+delete maintenance dispatch event
+**Parameters:**
+- `eventId`: string
+
+### production_deleteMaintenanceDispatchItem (DESTRUCTIVE)
+delete maintenance dispatch item
+**Parameters:**
+- `itemId`: string
+
+### production_deleteMaintenanceDispatchWorkCenter (DESTRUCTIVE)
+delete maintenance dispatch work center
+**Parameters:**
+- `workCenterId`: string
+
+### production_deleteMaintenanceSchedule (DESTRUCTIVE)
+delete maintenance schedule
+**Parameters:**
+- `scheduleId`: string
+
+### production_deleteMaintenanceScheduleItem (DESTRUCTIVE)
+delete maintenance schedule item
+**Parameters:**
+- `itemId`: string
+
+### production_getDemandForecasts (READ)
+get demand forecasts
+**Parameters:**
+- `params`: {
+ itemId: string;
+ locationId: string;
+ companyId: string;
+ periodIds: string[];
+ }
+
+### production_getDemandProjections (READ)
+get demand projections
+**Parameters:**
+- `params`: {
+ itemId: string;
+ locationId: string;
+ companyId: string;
+ periodIds: string[];
+ }
+
+### production_getJobDocuments (READ)
+get job documents
+**Parameters:**
+- `job`: {
+ id: string | null;
+ salesOrderLineId?: string | null;
+ quoteLineId?: string | null;
+ itemId?: string | null;
+ }
+
+### production_getJobDocumentsWithItemId (READ)
+get job documents with item id
+**Parameters:**
+- `job`: Job
+- `itemId`: string
+
+### production_getJob (READ)
+get job
+**Parameters:**
+- `id`: string
+
+### production_getJobByOperationId (READ)
+get job by operation id
+**Parameters:**
+- `operationId`: string
+
+### production_getJobPurchaseOrderLines (READ)
+get job purchase order lines
+**Parameters:**
+- `jobId`: string
+
+### production_getJobs (READ)
+get jobs
+**Parameters:**
+- `args`: { search: string | null } & GenericQueryFilters (optional)
+
+### production_getJobsBySalesOrderLine (READ)
+get jobs by sales order line
+**Parameters:**
+- `salesOrderLineId`: string
+
+### production_getJobsList (READ)
+get jobs list
+**Parameters:** none (context auto-filled)
+
+### production_getJobMakeMethodById (READ)
+get job make method by id
+**Parameters:**
+- `jobMakeMethodId`: string
+
+### production_getRootMakeMethod (READ)
+get root make method
+**Parameters:**
+- `jobId`: string
+
+### production_getJobMaterialsWithQuantityOnHand (READ)
+get job materials with quantity on hand
+**Parameters:**
+- `jobId`: string
+- `locationId`: string
+- `args`: { search: string | null } & GenericQueryFilters (optional)
+
+### production_getJobMethodTree (READ)
+get job method tree
+**Parameters:**
+- `jobId`: string
+
+### production_getJobMethodTreeArray (READ)
+get job method tree array
+**Parameters:**
+- `jobId`: string
+
+### production_getJobMaterial (READ)
+get job material
+**Parameters:**
+- `materialId`: string
+
+### production_getJobMaterialsByMethodId (READ)
+get job materials by method id
+**Parameters:**
+- `jobMakeMethodId`: string
+
+### production_getJobOperation (READ)
+get job operation
+**Parameters:**
+- `jobOperationId`: string
+
+### production_getJobOperations (READ)
+get job operations
+**Parameters:**
+- `jobId`: string
+- `args`: { search: string | null } & GenericQueryFilters (optional)
+
+### production_getJobOperationsAssignedToEmployee (READ)
+get job operations assigned to employee
+**Parameters:**
+- `employeeId`: string
+
+### production_getJobOperationAttachments (READ)
+get job operation attachments
+**Parameters:**
+- `jobOperationIds`: string[]
+
+### production_getJobOperationsList (READ)
+get job operations list
+**Parameters:**
+- `jobId`: string
+
+### production_getJobOperationsByMethodId (READ)
+get job operations by method id
+**Parameters:**
+- `jobMakeMethodId`: string
+
+### production_getJobOperationStepRecords (READ)
+get job operation step records
+**Parameters:**
+- `jobId`: string
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### production_getOutsideOperationsByJobId (READ)
+get outside operations by job id
+**Parameters:**
+- `jobId`: string
+
+### production_getProcedure (READ)
+get procedure
+**Parameters:**
+- `id`: string
+
+### production_getProcedureSteps (READ)
+get procedure steps
+**Parameters:**
+- `procedureId`: string
+
+### production_getProcedureParameters (READ)
+get procedure parameters
+**Parameters:**
+- `procedureId`: string
+
+### production_getProcedureVersions (READ)
+get procedure versions
+**Parameters:**
+- `procedure`: { name: string; version: number }
+
+### production_getProcedures (READ)
+get procedures
+**Parameters:**
+- `args`: { search: string | null } & GenericQueryFilters (optional)
+
+### production_getProceduresList (READ)
+get procedures list
+**Parameters:** none (context auto-filled)
+
+### production_getProductionEvent (READ)
+get production event
+**Parameters:**
+- `id`: string
+
+### production_getProductionEvents (READ)
+get production events
+**Parameters:**
+- `jobOperationIds`: string[]
+- `args`: { search: string | null } & GenericQueryFilters (optional)
+
+### production_getProductionEventsPage (READ)
+get production events page
+**Parameters:**
+- `jobOperationId`: string
+- `sortDescending`: boolean (optional)
+- `page`: number (optional)
+
+### production_getProductionEventsByOperations (READ)
+get production events by operations
+**Parameters:**
+- `jobOperationIds`: string[]
+
+### production_getProductionPlanning (READ)
+get production planning
+**Parameters:**
+- `locationId`: string
+- `periods`: string[]
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### production_getProductionProjections (READ)
+get production projections
+**Parameters:**
+- `locationId`: string
+- `periods`: string[]
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### production_getProductionQuantity (READ)
+get production quantity
+**Parameters:**
+- `id`: string
+
+### production_getProductionQuantities (READ)
+get production quantities
+**Parameters:**
+- `jobOperationIds`: string[]
+- `args`: { search: string | null } & GenericQueryFilters (optional)
+
+### production_getProductionDataByOperations (READ)
+get production data by operations
+**Parameters:**
+- `jobOperationIds`: string[]
+
+### production_getScrapReasonsList (READ)
+get scrap reasons list
+**Parameters:** none (context auto-filled)
+
+### production_getScrapReason (READ)
+get scrap reason
+**Parameters:**
+- `scrapReasonId`: string
+
+### production_getScrapReasons (READ)
+get scrap reasons
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### production_getFailureMode (READ)
+get failure mode
+**Parameters:**
+- `failureModeId`: string
+
+### production_getFailureModes (READ)
+get failure modes
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### production_getFailureModesList (READ)
+get failure modes list
+**Parameters:** none (context auto-filled)
+
+### production_getMaintenanceDispatch (READ)
+get maintenance dispatch
+**Parameters:**
+- `dispatchId`: string
+
+### production_getMaintenanceDispatches (READ)
+get maintenance dispatches
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null; status?: string } (optional)
+
+### production_getMaintenanceDispatchComments (READ)
+get maintenance dispatch comments
+**Parameters:**
+- `dispatchId`: string
+
+### production_getMaintenanceDispatchEvents (READ)
+get maintenance dispatch events
+**Parameters:**
+- `dispatchId`: string
+
+### production_getMaintenanceDispatchItems (READ)
+get maintenance dispatch items
+**Parameters:**
+- `dispatchId`: string
+
+### production_getMaintenanceDispatchWorkCenters (READ)
+get maintenance dispatch work centers
+**Parameters:**
+- `dispatchId`: string
+
+### production_getMaintenanceSchedule (READ)
+get maintenance schedule
+**Parameters:**
+- `scheduleId`: string
+
+### production_getMaintenanceSchedules (READ)
+get maintenance schedules
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null; active?: boolean } (optional)
+
+### production_getMaintenanceScheduleItems (READ)
+get maintenance schedule items
+**Parameters:**
+- `scheduleId`: string
+
+### production_getTrackedEntityByJobId (READ)
+get tracked entity by job id
+**Parameters:**
+- `jobId`: string
+
+### production_getTrackedEntitiesByJobId (READ)
+get tracked entities by job id
+**Parameters:**
+- `jobId`: string
+
+### production_recalculateJobOperationDependencies (WRITE)
+recalculate job operation dependencies
+**Parameters:**
+- `params`: {
+ jobId: string;
+ companyId: string;
+ userId: string;
+ }
+
+### production_recalculateJobRequirements (WRITE)
+recalculate job requirements
+**Parameters:**
+- `params`: {
+ id: string; // job id
+ companyId: string;
+ userId: string;
+ }
+
+### production_recalculateJobMakeMethodRequirements (WRITE)
+recalculate job make method requirements
+**Parameters:**
+- `params`: {
+ id: string; // job make method id
+ companyId: string;
+ userId: string;
+ }
+
+### production_runMRP (WRITE)
+run m r p
+**Parameters:**
+- `params`: {
+ type:
+ | "company"
+ | "location"
+ | "job"
+ | "salesOrder"
+ | "item"
+ | "purchaseOrder";
+ id: string;
+ companyId: string;
+ userId: string;
+ }
+
+### production_updateJobBatchNumber (WRITE)
+update job batch number
+**Parameters:**
+- `trackedEntityId`: string
+- `value`: string
+
+### production_updateJobStatus (WRITE)
+update job status
+**Parameters:**
+- `params`: {
+ id: string;
+ status: (typeof jobStatus)[number];
+ assignee?: string | null;
+ updatedBy: string;
+ }
+
+### production_updateJobMaterialOrder (WRITE)
+update job material order
+**Parameters:**
+- `updates`: {
+ id: string;
+ order: number;
+ updatedBy: string;
+ }[]
+
+### production_updateJobOperationOrder (WRITE)
+update job operation order
+**Parameters:**
+- `updates`: {
+ id: string;
+ order: number;
+ updatedBy: string;
+ }[]
+
+### production_updateJobOperationStepOrder (WRITE)
+update job operation step order
+**Parameters:**
+- `updates`: {
+ id: string;
+ sortOrder: number;
+ updatedBy: string;
+ }[]
+
+### production_updateKanbanJob (WRITE)
+update kanban job
+**Parameters:**
+- `params`: {
+ id: string;
+ jobId: string | null;
+ companyId: string;
+ userId: string;
+ }
+
+### production_updateQuoteOperationStepOrder (WRITE)
+update quote operation step order
+**Parameters:**
+- `updates`: {
+ id: string;
+ sortOrder: number;
+ updatedBy: string;
+ }[]
+
+### production_updateMethodOperationStepOrder (WRITE)
+update method operation step order
+**Parameters:**
+- `updates`: {
+ id: string;
+ sortOrder: number;
+ updatedBy: string;
+ }[]
+
+### production_updateJobOperationStatus (WRITE)
+update job operation status
+**Parameters:**
+- `id`: string
+- `status`: (typeof jobOperationStatus)[number]
+
+### production_updateJobOperationDueDate (WRITE)
+update job operation due date
+**Parameters:**
+- `id`: string
+- `dueDate`: string | null
+
+### production_updateProcedureStepOrder (WRITE)
+update procedure step order
+**Parameters:**
+- `updates`: {
+ id: string;
+ sortOrder: number;
+ updatedBy: string;
+ }[]
+
+### production_upsertProductionEvent (WRITE)
+upsert production event
+**Parameters:**
+- `productionEvent`: | (Omit<z.infer<typeof productionEventValidator>, "id"> & {
+ createdBy: string;
+ companyId: string;
+ })
+ | (Omit<z.infer<typeof productionEventValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ companyId: string;
+ })
+
+### production_updateProductionQuantity (WRITE)
+update production quantity
+**Parameters:**
+- `productionQuantity`: z.infer<typeof productionQuantityValidator> & {
+ id: string;
+ updatedBy: string;
+ companyId: string;
+ }
+
+### production_upsertProductionQuantity (WRITE)
+upsert production quantity
+**Parameters:**
+- `productionQuantity`: | (Omit<z.infer<typeof productionQuantityValidator>, "id"> & {
+ companyId: string;
+ })
+ | (Omit<z.infer<typeof productionQuantityValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ companyId: string;
+ })
+
+### production_upsertJob (WRITE)
+upsert job
+**Parameters:**
+- `job`: | (Omit<z.infer<typeof jobValidator>, "id" | "jobId"> & {
+ jobId: string;
+ shelfId?: string;
+ startDate?: string;
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof jobValidator>, "id" | "jobId"> & {
+ id: string;
+ jobId: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+- `status`: (typeof jobStatus)[number] (optional)
+
+### production_upsertJobMaterial (WRITE)
+upsert job material
+**Parameters:**
+- `jobMaterial`: | (z.infer<typeof jobMaterialValidator> & {
+ jobId: string;
+ jobOperationId?: string;
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (z.infer<typeof jobMaterialValidator> & {
+ jobId: string;
+ jobOperationId?: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### production_upsertJobOperation (WRITE)
+upsert job operation
+**Parameters:**
+- `jobOperation`: | (z.infer<typeof jobOperationValidator> & {
+ jobId: string;
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (z.infer<typeof jobOperationValidator> & {
+ jobId: string;
+ companyId: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### production_upsertJobOperationStep (WRITE)
+upsert job operation step
+**Parameters:**
+- `jobOperationStep`: | (Omit<z.infer<typeof operationStepValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<
+ z.infer<typeof operationStepValidator>,
+ "id" | "minValue" | "maxValue"
+ > & {
+ id: string;
+ minValue: number | null;
+ maxValue: number | null;
+ updatedBy: string;
+ updatedAt: string;
+ })
+
+### production_upsertJobOperationParameter (WRITE)
+upsert job operation parameter
+**Parameters:**
+- `jobOperationParameter`: | (Omit<z.infer<typeof operationParameterValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof operationParameterValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ updatedAt: string;
+ })
+
+### production_upsertJobOperationTool (WRITE)
+upsert job operation tool
+**Parameters:**
+- `jobOperationTool`: | (Omit<z.infer<typeof operationToolValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof operationToolValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ updatedAt: string;
+ })
+
+### production_upsertJobMethod (WRITE)
+upsert job method
+**Parameters:**
+- `type`: "itemToJob" | "quoteLineToJob"
+- `jobMethod`: {
+ sourceId: string;
+ targetId: string;
+ companyId: string;
+ userId: string;
+ configuration?: Record<string, unknown>;
+ parts?: {
+ billOfMaterial: boolean;
+ billOfProcess: boolean;
+ parameters: boolean;
+ tools: boolean;
+ steps: boolean;
+ workInstructions: boolean;
+ };
+ }
+
+### production_upsertJobMaterialMakeMethod (WRITE)
+upsert job material make method
+**Parameters:**
+- `jobMaterial`: {
+ sourceId: string;
+ targetId: string;
+ companyId: string;
+ userId: string;
+ configuration?: Record<string, unknown>;
+ parts?: {
+ billOfMaterial: boolean;
+ billOfProcess: boolean;
+ parameters: boolean;
+ tools: boolean;
+ steps: boolean;
+ workInstructions: boolean;
+ };
+ }
+
+### production_upsertMakeMethodFromJob (WRITE)
+upsert make method from job
+**Parameters:**
+- `jobMethod`: {
+ sourceId: string;
+ targetId: string;
+ companyId: string;
+ userId: string;
+ parts?: {
+ billOfMaterial: boolean;
+ billOfProcess: boolean;
+ parameters: boolean;
+ tools: boolean;
+ steps: boolean;
+ workInstructions: boolean;
+ };
+ }
+
+### production_upsertMakeMethodFromJobMethod (WRITE)
+upsert make method from job method
+**Parameters:**
+- `jobMethod`: {
+ sourceId: string;
+ targetId: string;
+ companyId: string;
+ userId: string;
+ parts?: {
+ billOfMaterial: boolean;
+ billOfProcess: boolean;
+ parameters: boolean;
+ tools: boolean;
+ steps: boolean;
+ workInstructions: boolean;
+ };
+ }
+
+### production_upsertProcedure (WRITE)
+upsert procedure
+**Parameters:**
+- `procedure`: | (Omit<z.infer<typeof procedureValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof procedureValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### production_upsertProcedureStep (WRITE)
+upsert procedure step
+**Parameters:**
+- `procedureStep`: | (Omit<z.infer<typeof procedureStepValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof procedureStepValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### production_upsertProcedureParameter (WRITE)
+upsert procedure parameter
+**Parameters:**
+- `procedureParameter`: | (Omit<z.infer<typeof procedureParameterValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof procedureParameterValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### production_upsertScrapReason (WRITE)
+upsert scrap reason
+**Parameters:**
+- `scrapReason`: | (Omit<z.infer<typeof scrapReasonValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof scrapReasonValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### production_upsertFailureMode (WRITE)
+upsert failure mode
+**Parameters:**
+- `failureMode`: | (Omit<z.infer<typeof failureModeValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof failureModeValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### production_upsertMaintenanceDispatch (WRITE)
+upsert maintenance dispatch
+**Parameters:**
+- `dispatch`: | (Omit<z.infer<typeof maintenanceDispatchValidator>, "id"> & {
+ maintenanceDispatchId: string;
+ companyId: string;
+ createdBy: string;
+ content?: Json;
+ })
+ | (Omit<z.infer<typeof maintenanceDispatchValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ content?: Json;
+ })
+
+### production_upsertMaintenanceDispatchComment (WRITE)
+upsert maintenance dispatch comment
+**Parameters:**
+- `comment`: | (Omit<z.infer<typeof maintenanceDispatchCommentValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof maintenanceDispatchCommentValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### production_upsertMaintenanceDispatchEvent (WRITE)
+upsert maintenance dispatch event
+**Parameters:**
+- `event`: | (Omit<z.infer<typeof maintenanceDispatchEventValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof maintenanceDispatchEventValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### production_upsertMaintenanceDispatchItem (WRITE)
+upsert maintenance dispatch item
+**Parameters:**
+- `item`: | (Omit<z.infer<typeof maintenanceDispatchItemValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof maintenanceDispatchItemValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### production_upsertMaintenanceDispatchWorkCenter (WRITE)
+upsert maintenance dispatch work center
+**Parameters:**
+- `workCenter`: | (Omit<z.infer<typeof maintenanceDispatchWorkCenterValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof maintenanceDispatchWorkCenterValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### production_upsertMaintenanceSchedule (WRITE)
+upsert maintenance schedule
+**Parameters:**
+- `schedule`: | (Omit<z.infer<typeof maintenanceScheduleValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof maintenanceScheduleValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### production_upsertMaintenanceScheduleItem (WRITE)
+upsert maintenance schedule item
+**Parameters:**
+- `item`: | (Omit<z.infer<typeof maintenanceScheduleItemValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof maintenanceScheduleItemValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### production_upsertDemandForecasts (WRITE)
+upsert demand forecasts
+**Parameters:**
+- `forecasts`: Array<{
+ itemId: string;
+ locationId: string;
+ periodId: string;
+ forecastQuantity: number;
+ companyId: string;
+ createdBy: string;
+ updatedBy?: string;
+ }>
+
+### production_upsertDemandProjections (WRITE)
+upsert demand projections
+**Parameters:**
+- `forecasts`: Array<{
+ itemId: string;
+ locationId: string;
+ periodId: string;
+ forecastQuantity: number;
+ companyId: string;
+ createdBy: string;
+ updatedBy?: string;
+ }>
+
+---
+
+## purchasing (96 tools)
+
+### purchasing_closePurchaseOrder (WRITE)
+close purchase order
+**Parameters:**
+- `purchaseOrderId`: string
+
+### purchasing_convertSupplierQuoteToOrder (WRITE)
+convert supplier quote to order
+**Parameters:**
+- `payload`: {
+ id: string;
+ selectedLines: z.infer<typeof selectedLinesValidator>;
+ companyId: string;
+ userId: string;
+ }
+
+### purchasing_deletePurchaseOrder (DESTRUCTIVE)
+delete purchase order
+**Parameters:**
+- `purchaseOrderId`: string
+
+### purchasing_deletePurchaseOrderLine (DESTRUCTIVE)
+delete purchase order line
+**Parameters:**
+- `purchaseOrderLineId`: string
+
+### purchasing_deleteSupplier (DESTRUCTIVE)
+delete supplier
+**Parameters:**
+- `supplierId`: string
+
+### purchasing_deleteSupplierContact (DESTRUCTIVE)
+delete supplier contact
+**Parameters:**
+- `supplierId`: string
+- `supplierContactId`: string
+
+### purchasing_deleteSupplierLocation (DESTRUCTIVE)
+delete supplier location
+**Parameters:**
+- `supplierId`: string
+- `supplierLocationId`: string
+
+### purchasing_deleteSupplierProcess (DESTRUCTIVE)
+delete supplier process
+**Parameters:**
+- `supplierProcessId`: string
+
+### purchasing_deleteSupplierQuote (DESTRUCTIVE)
+delete supplier quote
+**Parameters:**
+- `supplierQuoteId`: string
+
+### purchasing_deleteSupplierQuoteLine (DESTRUCTIVE)
+delete supplier quote line
+**Parameters:**
+- `id`: string
+
+### purchasing_deleteSupplierType (DESTRUCTIVE)
+delete supplier type
+**Parameters:**
+- `supplierTypeId`: string
+
+### purchasing_getPurchaseOrder (READ)
+get purchase order
+**Parameters:**
+- `purchaseOrderId`: string
+
+### purchasing_finalizeSupplierQuote (WRITE)
+finalize supplier quote
+**Parameters:**
+- `supplierQuoteId`: string
+
+### purchasing_getPurchaseOrders (READ)
+get purchase orders
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ status: string | null;
+ supplierId: string | null;
+ }
+
+### purchasing_getPurchaseOrderDelivery (READ)
+get purchase order delivery
+**Parameters:**
+- `purchaseOrderId`: string
+
+### purchasing_getPurchaseOrderLocations (READ)
+get purchase order locations
+**Parameters:**
+- `purchaseOrderId`: string
+
+### purchasing_getPurchaseOrderPayment (READ)
+get purchase order payment
+**Parameters:**
+- `purchaseOrderId`: string
+
+### purchasing_getPurchaseOrderLines (READ)
+get purchase order lines
+**Parameters:**
+- `purchaseOrderId`: string
+
+### purchasing_getPurchaseOrderLine (READ)
+get purchase order line
+**Parameters:**
+- `purchaseOrderLineId`: string
+
+### purchasing_getPurchaseOrderSuppliers (READ)
+get purchase order suppliers
+**Parameters:** none (context auto-filled)
+
+### purchasing_getPurchasingDocumentsAssignedToMe (READ)
+get purchasing documents assigned to me
+**Parameters:** none (context auto-filled)
+
+### purchasing_getPurchasingPlanning (READ)
+get purchasing planning
+**Parameters:**
+- `locationId`: string
+- `periods`: string[]
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### purchasing_getPurchasingTerms (READ)
+get purchasing terms
+**Parameters:** none (context auto-filled)
+
+### purchasing_getSupplier (READ)
+get supplier
+**Parameters:**
+- `supplierId`: string
+
+### purchasing_getSupplierApprovalContext (READ)
+get supplier approval context
+**Parameters:**
+- `supplierId`: string
+- `status`: string | null
+
+### purchasing_getSupplierContact (READ)
+get supplier contact
+**Parameters:**
+- `supplierContactId`: string
+
+### purchasing_getSupplierContacts (READ)
+get supplier contacts
+**Parameters:**
+- `supplierId`: string
+
+### purchasing_getSupplierInteraction (READ)
+get supplier interaction
+**Parameters:**
+- `opportunityId`: string | null
+
+### purchasing_getSupplierInteractionDocuments (READ)
+get supplier interaction documents
+**Parameters:**
+- `interactionId`: string
+
+### purchasing_getSupplierInteractionLineDocuments (READ)
+get supplier interaction line documents
+**Parameters:**
+- `lineId`: string
+
+### purchasing_getSupplierLocations (READ)
+get supplier locations
+**Parameters:**
+- `supplierId`: string
+
+### purchasing_getSupplierLocation (READ)
+get supplier location
+**Parameters:**
+- `supplierContactId`: string
+
+### purchasing_getSupplierPayment (READ)
+get supplier payment
+**Parameters:**
+- `supplierId`: string
+
+### purchasing_getSupplierProcessById (READ)
+get supplier process by id
+**Parameters:**
+- `supplierProcessId`: string
+
+### purchasing_getSupplierProcessesByProcess (READ)
+get supplier processes by process
+**Parameters:**
+- `processId`: string
+
+### purchasing_getSupplierProcessesBySupplier (READ)
+get supplier processes by supplier
+**Parameters:**
+- `supplierId`: string
+
+### purchasing_getSupplierQuote (READ)
+get supplier quote
+**Parameters:**
+- `supplierQuoteId`: string
+
+### purchasing_getSupplierQuoteByInteractionId (READ)
+get supplier quote by interaction id
+**Parameters:**
+- `interactionId`: string
+
+### purchasing_getSupplierQuoteByExternalLinkId (READ)
+get supplier quote by external link id
+**Parameters:**
+- `externalLinkId`: string
+
+### purchasing_getSupplierQuotes (READ)
+get supplier quotes
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### purchasing_getSupplierQuoteLine (READ)
+get supplier quote line
+**Parameters:**
+- `supplierQuoteLineId`: string
+
+### purchasing_getSupplierQuoteLines (READ)
+get supplier quote lines
+**Parameters:**
+- `supplierQuoteId`: string
+
+### purchasing_getSupplierQuoteLinePrices (READ)
+get supplier quote line prices
+**Parameters:**
+- `supplierQuoteLineId`: string
+
+### purchasing_getSupplierQuoteLinePricesByQuoteId (READ)
+get supplier quote line prices by quote id
+**Parameters:**
+- `supplierQuoteId`: string
+
+### purchasing_getSupplierQuotesList (READ)
+get supplier quotes list
+**Parameters:** none (context auto-filled)
+
+### purchasing_getSupplierShipping (READ)
+get supplier shipping
+**Parameters:**
+- `supplierId`: string
+
+### purchasing_getSuppliers (READ)
+get suppliers
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ type: string | null;
+ status: string | null;
+ }
+
+### purchasing_getSuppliersList (READ)
+get suppliers list
+**Parameters:** none (context auto-filled)
+
+### purchasing_getSupplierType (READ)
+get supplier type
+**Parameters:**
+- `supplierTypeId`: string
+
+### purchasing_getSupplierTypes (READ)
+get supplier types
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### purchasing_getSupplierTypesList (READ)
+get supplier types list
+**Parameters:** none (context auto-filled)
+
+### purchasing_insertSupplier (WRITE)
+insert supplier
+**Parameters:**
+- `supplier`: Omit<z.infer<typeof supplierValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ }
+
+### purchasing_insertSupplierContact (WRITE)
+insert supplier contact
+**Parameters:**
+- `supplierContact`: {
+ supplierId: string;
+ companyId: string;
+ contact: z.infer<typeof supplierContactValidator>;
+ supplierLocationId?: string;
+ customFields?: Json;
+ }
+
+### purchasing_insertSupplierInteraction (WRITE)
+insert supplier interaction
+**Parameters:**
+- `supplierId`: string
+
+### purchasing_insertSupplierLocation (WRITE)
+insert supplier location
+**Parameters:**
+- `supplierLocation`: {
+ supplierId: string;
+ companyId: string;
+ name: string;
+ address: {
+ addressLine1?: string;
+ addressLine2?: string;
+ city?: string;
+ stateProvince?: string;
+ postalCode?: string;
+ countryCode?: string;
+ };
+ customFields?: Json;
+ }
+
+### purchasing_finalizePurchaseOrder (WRITE)
+finalize purchase order
+**Parameters:**
+- `purchaseOrderId`: string
+
+### purchasing_sendSupplierQuote (WRITE)
+send supplier quote
+**Parameters:**
+- `supplierQuoteId`: string
+
+### purchasing_updatePurchaseOrder (WRITE)
+update purchase order
+**Parameters:**
+- `purchaseOrder`: {
+ id: string;
+ status: (typeof purchaseOrderStatusType)[number];
+ updatedBy: string;
+ }
+
+### purchasing_updatePurchaseOrderExchangeRate (WRITE)
+update purchase order exchange rate
+**Parameters:**
+- `data`: {
+ id: string;
+ exchangeRate: number;
+ }
+
+### purchasing_updatePurchaseOrderFavorite (WRITE)
+update purchase order favorite
+**Parameters:**
+- `args`: {
+ id: string;
+ favorite: boolean;
+ userId: string;
+ }
+
+### purchasing_updatePurchaseOrderStatus (WRITE)
+update purchase order status
+**Parameters:**
+- `update`: {
+ id: string;
+ status: (typeof purchaseOrderStatusType)[number];
+ assignee: null | undefined;
+ updatedBy: string;
+ }
+
+### purchasing_updateSupplierAccounting (WRITE)
+update supplier accounting
+**Parameters:**
+- `supplierAccounting`: z.infer<typeof supplierAccountingValidator> & {
+ updatedBy: string;
+ }
+
+### purchasing_updateSupplierContact (WRITE)
+update supplier contact
+**Parameters:**
+- `supplierContact`: {
+ contactId: string;
+ contact: z.infer<typeof supplierContactValidator>;
+ supplierLocationId?: string;
+ customFields?: Json;
+ }
+
+### purchasing_updateSupplierLocation (WRITE)
+update supplier location
+**Parameters:**
+- `supplierLocation`: {
+ addressId: string;
+ name: string;
+ address: {
+ addressLine1?: string;
+ addressLine2?: string;
+ city?: string;
+ stateProvince?: string;
+ countryCode?: string;
+ postalCode?: string;
+ };
+ customFields?: Json;
+ }
+
+### purchasing_updateSupplierPayment (WRITE)
+update supplier payment
+**Parameters:**
+- `supplierPayment`: z.infer<typeof supplierPaymentValidator> & {
+ updatedBy: string;
+ customFields?: Json;
+ }
+
+### purchasing_updateSupplierQuoteExchangeRate (WRITE)
+update supplier quote exchange rate
+**Parameters:**
+- `data`: {
+ id: string;
+ exchangeRate: number;
+ }
+
+### purchasing_updateSupplierQuoteFavorite (WRITE)
+update supplier quote favorite
+**Parameters:**
+- `args`: {
+ id: string;
+ favorite: boolean;
+ userId: string;
+ }
+
+### purchasing_updateSupplierQuoteStatus (WRITE)
+update supplier quote status
+**Parameters:**
+- `update`: {
+ id: string;
+ status: (typeof supplierQuoteStatusType)[number];
+ assignee: null | undefined;
+ updatedBy: string;
+ }
+
+### purchasing_updateSupplierShipping (WRITE)
+update supplier shipping
+**Parameters:**
+- `supplierShipping`: z.infer<typeof supplierShippingValidator> & {
+ updatedBy: string;
+ customFields?: Json;
+ }
+
+### purchasing_upsertPurchaseOrder (WRITE)
+upsert purchase order
+**Parameters:**
+- `purchaseOrder`: | (Omit<
+ z.infer<typeof purchaseOrderValidator>,
+ "id" | "purchaseOrderId"
+ > & {
+ purchaseOrderId: string;
+ status?: (typeof purchaseOrderStatusType)[number];
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<
+ z.infer<typeof purchaseOrderValidator>,
+ "id" | "purchaseOrderId"
+ > & {
+ id: string;
+ purchaseOrderId: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+- `receiptRequestedDate`: string (optional)
+
+### purchasing_upsertPurchaseOrderDelivery (WRITE)
+upsert purchase order delivery
+**Parameters:**
+- `purchaseOrderDelivery`: | (z.infer<typeof purchaseOrderDeliveryValidator> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (z.infer<typeof purchaseOrderDeliveryValidator> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### purchasing_upsertPurchaseOrderLine (WRITE)
+upsert purchase order line
+**Parameters:**
+- `purchaseOrderLine`: | (Omit<z.infer<typeof purchaseOrderLineValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof purchaseOrderLineValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### purchasing_upsertPurchaseOrderPayment (WRITE)
+upsert purchase order payment
+**Parameters:**
+- `purchaseOrderPayment`: | (z.infer<typeof purchaseOrderPaymentValidator> & {
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (z.infer<typeof purchaseOrderPaymentValidator> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### purchasing_upsertSupplier (WRITE)
+upsert supplier
+**Parameters:**
+- `supplier`: | (Omit<z.infer<typeof supplierValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof supplierValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### purchasing_upsertSupplierProcess (WRITE)
+upsert supplier process
+**Parameters:**
+- `supplierProcess`: | (Omit<z.infer<typeof supplierProcessValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof supplierProcessValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### purchasing_upsertSupplierQuote (WRITE)
+upsert supplier quote
+**Parameters:**
+- `supplierQuote`: | (Omit<
+ z.infer<typeof supplierQuoteValidator>,
+ "id" | "supplierQuoteId"
+ > & {
+ supplierQuoteId: string;
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<
+ z.infer<typeof supplierQuoteValidator>,
+ "id" | "supplierQuoteId"
+ > & {
+ id: string;
+ supplierQuoteId: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### purchasing_upsertSupplierQuoteLine (WRITE)
+upsert supplier quote line
+**Parameters:**
+- `supplierQuoteLine`: | (Omit<z.infer<typeof supplierQuoteLineValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof supplierQuoteLineValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### purchasing_upsertSupplierType (WRITE)
+upsert supplier type
+**Parameters:**
+- `supplierType`: | (Omit<z.infer<typeof supplierTypeValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof supplierTypeValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### purchasing_deletePurchasingRFQ (DESTRUCTIVE)
+delete purchasing r f q
+**Parameters:**
+- `purchasingRfqId`: string
+
+### purchasing_deletePurchasingRFQLine (DESTRUCTIVE)
+delete purchasing r f q line
+**Parameters:**
+- `purchasingRfqLineId`: string
+
+### purchasing_getPurchasingRFQ (READ)
+get purchasing r f q
+**Parameters:**
+- `id`: string
+
+### purchasing_getPurchasingRFQs (READ)
+get purchasing r f qs
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### purchasing_getPurchasingRFQLine (READ)
+get purchasing r f q line
+**Parameters:**
+- `lineId`: string
+
+### purchasing_getPurchasingRFQLines (READ)
+get purchasing r f q lines
+**Parameters:**
+- `purchasingRfqId`: string
+
+### purchasing_getPurchasingRFQSuppliers (READ)
+get purchasing r f q suppliers
+**Parameters:**
+- `purchasingRfqId`: string
+
+### purchasing_upsertPurchasingRFQ (WRITE)
+upsert purchasing r f q
+**Parameters:**
+- `purchasingRfq`: {
+ id?: string;
+ rfqId: string;
+ rfqDate: string;
+ expirationDate?: string;
+ locationId?: string;
+ employeeId?: string;
+ status?: (typeof purchasingRfqStatusType)[number];
+ companyId: string;
+ createdBy?: string;
+ updatedBy?: string;
+ customFields?: Json;
+ }
+
+### purchasing_upsertPurchasingRFQLine (WRITE)
+upsert purchasing r f q line
+**Parameters:**
+- `purchasingRfqLine`: | {
+ purchasingRfqId: string;
+ itemId: string;
+ description?: string;
+ quantity: number[];
+ purchaseUnitOfMeasureCode: string;
+ inventoryUnitOfMeasureCode: string;
+ conversionFactor?: number;
+ order: number;
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ }
+ | {
+ id: string;
+ purchasingRfqId: string;
+ itemId: string;
+ description?: string;
+ quantity: number[];
+ purchaseUnitOfMeasureCode: string;
+ inventoryUnitOfMeasureCode: string;
+ conversionFactor?: number;
+ order: number;
+ companyId: string;
+ updatedBy: string;
+ customFields?: Json;
+ }
+
+### purchasing_upsertPurchasingRFQSuppliers (WRITE)
+upsert purchasing r f q suppliers
+**Parameters:**
+- `purchasingRfqId`: string
+- `supplierIds`: string[]
+
+### purchasing_updatePurchasingRFQStatus (WRITE)
+update purchasing r f q status
+**Parameters:**
+- `args`: {
+ id: string;
+ status: (typeof purchasingRfqStatusType)[number];
+ assignee?: string | null;
+ updatedBy: string;
+ }
+
+### purchasing_getLinkedSupplierQuotes (READ)
+get linked supplier quotes
+**Parameters:**
+- `purchasingRfqId`: string
+
+### purchasing_getLinkedPurchasingRfqs (READ)
+get linked purchasing rfqs
+**Parameters:**
+- `supplierQuoteId`: string
+
+### purchasing_getLinkedPurchasingRfqsForInteraction (READ)
+get linked purchasing rfqs for interaction
+**Parameters:**
+- `supplierInteractionId`: string
+
+### purchasing_getSiblingQuotesForQuote (READ)
+get sibling quotes for quote
+**Parameters:**
+- `supplierQuoteId`: string
+
+### purchasing_getLinkedPurchasingRfqsForOrder (READ)
+get linked purchasing rfqs for order
+**Parameters:**
+- `purchaseOrderId`: string
+
+### purchasing_getSupplierQuotesForComparison (READ)
+get supplier quotes for comparison
+**Parameters:**
+- `purchasingRfqId`: string
+
+### purchasing_getPurchasingRFQSuppliersWithLinks (READ)
+get purchasing r f q suppliers with links
+**Parameters:**
+- `purchasingRfqId`: string
+
+---
+
+## quality (68 tools)
+
+### quality_activateGauge (WRITE)
+activate gauge
+**Parameters:**
+- `gaugeId`: string
+
+### quality_deactivateGauge (WRITE)
+deactivate gauge
+**Parameters:**
+- `gaugeId`: string
+
+### quality_deleteGauge (DESTRUCTIVE)
+delete gauge
+**Parameters:**
+- `gaugeId`: string
+
+### quality_deleteGaugeCalibrationRecord (DESTRUCTIVE)
+delete gauge calibration record
+**Parameters:**
+- `gaugeCalibrationRecordId`: string
+
+### quality_deleteGaugeType (DESTRUCTIVE)
+delete gauge type
+**Parameters:**
+- `gaugeTypeId`: string
+
+### quality_deleteIssue (DESTRUCTIVE)
+delete issue
+**Parameters:**
+- `nonConformanceId`: string
+
+### quality_deleteIssueAssociation (DESTRUCTIVE)
+delete issue association
+**Parameters:**
+- `type`: string
+- `associationId`: string
+
+### quality_deleteIssueType (DESTRUCTIVE)
+delete issue type
+**Parameters:**
+- `nonConformanceTypeId`: string
+
+### quality_deleteIssueWorkflow (DESTRUCTIVE)
+delete issue workflow
+**Parameters:**
+- `nonConformanceWorkflowId`: string
+
+### quality_deleteRequiredAction (DESTRUCTIVE)
+delete required action
+**Parameters:**
+- `requiredActionId`: string
+
+### quality_deleteQualityDocument (DESTRUCTIVE)
+delete quality document
+**Parameters:**
+- `qualityDocumentId`: string
+
+### quality_deleteQualityDocumentStep (DESTRUCTIVE)
+delete quality document step
+**Parameters:**
+- `qualityDocumentStepId`: string
+
+### quality_deleteRisk (DESTRUCTIVE)
+delete risk
+**Parameters:**
+- `riskId`: string
+
+### quality_getIssueFromExternalLink (READ)
+get issue from external link
+**Parameters:**
+- `id`: string
+
+### quality_getGauge (READ)
+get gauge
+**Parameters:**
+- `gaugeId`: string
+
+### quality_getGauges (READ)
+get gauges
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### quality_getGaugesList (READ)
+get gauges list
+**Parameters:** none (context auto-filled)
+
+### quality_getGaugeCalibrationRecord (READ)
+get gauge calibration record
+**Parameters:**
+- `id`: string
+
+### quality_getGaugeCalibrationRecords (READ)
+get gauge calibration records
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### quality_getGaugeCalibrationRecordsByGaugeId (READ)
+get gauge calibration records by gauge id
+**Parameters:**
+- `gaugeId`: string
+
+### quality_getGaugeTypesList (READ)
+get gauge types list
+**Parameters:** none (context auto-filled)
+
+### quality_getGaugeType (READ)
+get gauge type
+**Parameters:**
+- `gaugeTypeId`: string
+
+### quality_getGaugeTypes (READ)
+get gauge types
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### quality_getIssue (READ)
+get issue
+**Parameters:**
+- `nonConformanceId`: string
+
+### quality_getIssues (READ)
+get issues
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### quality_getIssueWorkflow (READ)
+get issue workflow
+**Parameters:**
+- `nonConformanceWorkflowId`: string
+
+### quality_getIssueAction (READ)
+get issue action
+**Parameters:**
+- `id`: string
+
+### quality_getIssueActionTasks (READ)
+get issue action tasks
+**Parameters:**
+- `id`: string
+- `supplierId`: string (optional)
+
+### quality_getIssueApprovalTasks (READ)
+get issue approval tasks
+**Parameters:**
+- `id`: string
+
+### quality_getIssueItems (READ)
+get issue items
+**Parameters:**
+- `id`: string
+
+### quality_getIssueAssociations (READ)
+get issue associations
+**Parameters:**
+- `nonConformanceId`: string
+
+### quality_getIssueReviewers (READ)
+get issue reviewers
+**Parameters:**
+- `id`: string
+
+### quality_getIssueSuppliers (READ)
+get issue suppliers
+**Parameters:**
+- `id`: string
+
+### quality_getIssueTasks (READ)
+get issue tasks
+**Parameters:**
+- `id`: string
+
+### quality_getIssueType (READ)
+get issue type
+**Parameters:**
+- `nonConformanceTypeId`: string
+
+### quality_getIssueTypes (READ)
+get issue types
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### quality_getIssueWorkflows (READ)
+get issue workflows
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### quality_getIssueWorkflowsList (READ)
+get issue workflows list
+**Parameters:** none (context auto-filled)
+
+### quality_getIssueTypesList (READ)
+get issue types list
+**Parameters:** none (context auto-filled)
+
+### quality_getQualityActions (READ)
+get quality actions
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### quality_getQualityDocument (READ)
+get quality document
+**Parameters:**
+- `id`: string
+
+### quality_getQualityDocumentSteps (READ)
+get quality document steps
+**Parameters:**
+- `qualityDocumentId`: string
+
+### quality_getQualityDocumentVersions (READ)
+get quality document versions
+**Parameters:**
+- `qualityDocument`: { name: string; version: number }
+
+### quality_getQualityDocuments (READ)
+get quality documents
+**Parameters:**
+- `args`: { search: string | null } & GenericQueryFilters (optional)
+
+### quality_getQualityDocumentsList (READ)
+get quality documents list
+**Parameters:** none (context auto-filled)
+
+### quality_getQualityFiles (READ)
+get quality files
+**Parameters:**
+- `id`: string
+
+### quality_getRequiredActionsList (READ)
+get required actions list
+**Parameters:** none (context auto-filled)
+
+### quality_getRequiredActions (READ)
+get required actions
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### quality_getRequiredAction (READ)
+get required action
+**Parameters:**
+- `requiredActionId`: string
+
+### quality_getRisk (READ)
+get risk
+**Parameters:**
+- `riskId`: string
+
+### quality_getRisks (READ)
+get risks
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ status?: typeof riskStatus;
+ source?: typeof riskSource;
+ // might be needed later for filtering by assignee
+ assignee?: string[];
+ } (optional)
+
+### quality_insertIssueReviewer (WRITE)
+insert issue reviewer
+**Parameters:**
+- `reviewer`: z.infer<typeof nonConformanceReviewerValidator> & {
+ nonConformanceId: string;
+ companyId: string;
+ createdBy: string;
+ }
+
+### quality_updateIssueActionProcesses (WRITE)
+update issue action processes
+**Parameters:**
+- `args`: {
+ actionTaskId: string;
+ processIds: string[];
+ companyId: string;
+ createdBy: string;
+ }
+
+### quality_updateIssueStatus (WRITE)
+update issue status
+**Parameters:**
+- `update`: {
+ id: string;
+ status: (typeof nonConformanceStatus)[number];
+ assignee: string | null | undefined;
+ closeDate: string | null | undefined;
+ updatedBy: string;
+ }
+
+### quality_updateIssueTaskStatus (WRITE)
+update issue task status
+**Parameters:**
+- `args`: {
+ id: string;
+ status: "Pending" | "Completed" | "Skipped" | "In Progress";
+ type: "investigation" | "action" | "approval" | "review";
+ userId?: string;
+ assignee?: string | null;
+ }
+
+### quality_updateIssueTaskContent (WRITE)
+update issue task content
+**Parameters:**
+- `args`: {
+ id: string;
+ type: "action" | "approval" | "review";
+ content: JSONContent;
+ }
+
+### quality_updateQualityDocumentStepOrder (WRITE)
+update quality document step order
+**Parameters:**
+- `updates`: {
+ id: string;
+ sortOrder: number;
+ updatedBy: string;
+ }[]
+
+### quality_updateRiskStatus (WRITE)
+update risk status
+**Parameters:**
+- `riskId`: string
+- `status`: (typeof riskStatus)[number]
+
+### quality_upsertGauge (WRITE)
+upsert gauge
+**Parameters:**
+- `gauge`: | (Omit<z.infer<typeof gaugeValidator>, "id" | "gaugeId"> & {
+ gaugeId: string;
+ companyId: string;
+ gaugeCalibrationStatus: (typeof gaugeCalibrationStatus)[number];
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof gaugeValidator>, "id" | "gaugeId"> & {
+ id: string;
+ gaugeId: string;
+ gaugeCalibrationStatus: (typeof gaugeCalibrationStatus)[number];
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### quality_upsertGaugeCalibrationRecord (WRITE)
+upsert gauge calibration record
+**Parameters:**
+- `gaugeCalibrationRecord`: | (Omit<z.infer<typeof gaugeCalibrationRecordValidator>, "id"> & {
+ companyId: string;
+ inspectionStatus: (typeof inspectionStatus)[number];
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof gaugeCalibrationRecordValidator>, "id"> & {
+ id: string;
+ inspectionStatus: (typeof inspectionStatus)[number];
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### quality_upsertGaugeType (WRITE)
+upsert gauge type
+**Parameters:**
+- `gaugeType`: | (Omit<z.infer<typeof gaugeTypeValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof issueTypeValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### quality_upsertIssue (WRITE)
+upsert issue
+**Parameters:**
+- `nonConformance`: | (Omit<z.infer<typeof issueValidator>, "id" | "nonConformanceId"> & {
+ nonConformanceId: string;
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof issueValidator>, "id" | "nonConformanceId"> & {
+ id: string;
+ nonConformanceId: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### quality_upsertIssueWorkflow (WRITE)
+upsert issue workflow
+**Parameters:**
+- `nonConformanceWorkflow`: | (Omit<z.infer<typeof issueWorkflowValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof issueWorkflowValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### quality_upsertIssueType (WRITE)
+upsert issue type
+**Parameters:**
+- `nonConformanceType`: | (Omit<z.infer<typeof issueTypeValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof issueTypeValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### quality_upsertRequiredAction (WRITE)
+upsert required action
+**Parameters:**
+- `requiredAction`: | (Omit<z.infer<typeof issueTypeValidator>, "id"> & {
+ companyId: string;
+ active?: boolean;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof issueTypeValidator>, "id"> & {
+ id: string;
+ active?: boolean;
+ updatedBy: string;
+ })
+
+### quality_upsertQualityDocument (WRITE)
+upsert quality document
+**Parameters:**
+- `qualityDocument`: | (Omit<z.infer<typeof qualityDocumentValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof qualityDocumentValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### quality_upsertQualityDocumentStep (WRITE)
+upsert quality document step
+**Parameters:**
+- `qualityDocumentStep`: | (Omit<z.infer<typeof qualityDocumentStepValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof qualityDocumentStepValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### quality_upsertRisk (WRITE)
+upsert risk
+**Parameters:**
+- `risk`: | (Omit<
+ z.infer<typeof riskRegisterValidator>,
+ "id" | "severity" | "likelihood"
+ > & {
+ severity: number;
+ likelihood: number;
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<
+ z.infer<typeof riskRegisterValidator>,
+ "id" | "severity" | "likelihood"
+ > & {
+ severity: number;
+ likelihood: number;
+ id: string;
+ updatedBy: string; // This might be used for history/tracking if added
+ })
+
+---
+
+## resources (94 tools)
+
+### resources_activateWorkCenter (WRITE)
+activate work center
+**Parameters:**
+- `id`: string
+
+### resources_deleteAbility (DESTRUCTIVE)
+delete ability
+**Parameters:**
+- `abilityId`: string
+- `hardDelete`: boolean (optional)
+
+### resources_deleteContractor (DESTRUCTIVE)
+delete contractor
+**Parameters:**
+- `contractorId`: string
+
+### resources_deleteEmployeeAbility (DESTRUCTIVE)
+delete employee ability
+**Parameters:**
+- `employeeAbilityId`: string
+
+### resources_deleteFailureMode (DESTRUCTIVE)
+delete failure mode
+**Parameters:**
+- `failureModeId`: string
+
+### resources_deleteLocation (DESTRUCTIVE)
+delete location
+**Parameters:**
+- `locationId`: string
+
+### resources_deleteMaintenanceDispatch (DESTRUCTIVE)
+delete maintenance dispatch
+**Parameters:**
+- `dispatchId`: string
+
+### resources_deleteMaintenanceDispatchComment (DESTRUCTIVE)
+delete maintenance dispatch comment
+**Parameters:**
+- `commentId`: string
+
+### resources_deleteMaintenanceDispatchEvent (DESTRUCTIVE)
+delete maintenance dispatch event
+**Parameters:**
+- `eventId`: string
+
+### resources_deleteMaintenanceDispatchItem (DESTRUCTIVE)
+delete maintenance dispatch item
+**Parameters:**
+- `itemId`: string
+
+### resources_deleteMaintenanceDispatchWorkCenter (DESTRUCTIVE)
+delete maintenance dispatch work center
+**Parameters:**
+- `workCenterId`: string
+
+### resources_deleteMaintenanceSchedule (DESTRUCTIVE)
+delete maintenance schedule
+**Parameters:**
+- `scheduleId`: string
+
+### resources_deleteMaintenanceScheduleItem (DESTRUCTIVE)
+delete maintenance schedule item
+**Parameters:**
+- `itemId`: string
+
+### resources_deletePartner (DESTRUCTIVE)
+delete partner
+**Parameters:**
+- `partnerId`: string
+
+### resources_activateProcess (WRITE)
+activate process
+**Parameters:**
+- `processId`: string
+
+### resources_processDeactivate (WRITE)
+process deactivate
+**Parameters:**
+- `processId`: string
+
+### resources_deleteProcess (DESTRUCTIVE)
+delete process
+**Parameters:**
+- `processId`: string
+
+### resources_deleteShift (DESTRUCTIVE)
+delete shift
+**Parameters:**
+- `shiftId`: string
+
+### resources_deleteSuggestion (DESTRUCTIVE)
+delete suggestion
+**Parameters:**
+- `suggestionId`: string
+
+### resources_deleteTraining (DESTRUCTIVE)
+delete training
+**Parameters:**
+- `trainingId`: string
+
+### resources_deleteTrainingAssignment (DESTRUCTIVE)
+delete training assignment
+**Parameters:**
+- `assignmentId`: string
+
+### resources_deleteTrainingQuestion (DESTRUCTIVE)
+delete training question
+**Parameters:**
+- `trainingQuestionId`: string
+
+### resources_deleteWorkCenter (DESTRUCTIVE)
+delete work center
+**Parameters:**
+- `id`: string
+
+### resources_getAbilities (READ)
+get abilities
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null }
+
+### resources_getAbilitiesList (READ)
+get abilities list
+**Parameters:** none (context auto-filled)
+
+### resources_getAbility (READ)
+get ability
+**Parameters:**
+- `abilityId`: string
+
+### resources_getContractor (READ)
+get contractor
+**Parameters:**
+- `contractorId`: string
+
+### resources_getContractors (READ)
+get contractors
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### resources_getEmployeeAbilities (READ)
+get employee abilities
+**Parameters:**
+- `employeeId`: string
+
+### resources_getFailureMode (READ)
+get failure mode
+**Parameters:**
+- `failureModeId`: string
+
+### resources_getFailureModes (READ)
+get failure modes
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### resources_getFailureModesList (READ)
+get failure modes list
+**Parameters:** none (context auto-filled)
+
+### resources_getLocation (READ)
+get location
+**Parameters:**
+- `locationId`: string
+
+### resources_getLocations (READ)
+get locations
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### resources_getLocationsList (READ)
+get locations list
+**Parameters:** none (context auto-filled)
+
+### resources_getMaintenanceDispatch (READ)
+get maintenance dispatch
+**Parameters:**
+- `dispatchId`: string
+
+### resources_getMaintenanceDispatchComments (READ)
+get maintenance dispatch comments
+**Parameters:**
+- `dispatchId`: string
+
+### resources_getMaintenanceDispatchEvents (READ)
+get maintenance dispatch events
+**Parameters:**
+- `dispatchId`: string
+
+### resources_getMaintenanceDispatchItems (READ)
+get maintenance dispatch items
+**Parameters:**
+- `dispatchId`: string
+
+### resources_getMaintenanceDispatchItemTrackedEntities (READ)
+get maintenance dispatch item tracked entities
+**Parameters:**
+- `maintenanceDispatchItemId`: string
+
+### resources_getMaintenanceDispatches (READ)
+get maintenance dispatches
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null; status?: string } (optional)
+
+### resources_getMaintenanceDispatchesByLocation (READ)
+get maintenance dispatches by location
+**Parameters:**
+- `locationId`: string
+- `args`: GenericQueryFilters & { search: string | null; status?: string } (optional)
+
+### resources_getMaintenanceDispatchWorkCenters (READ)
+get maintenance dispatch work centers
+**Parameters:**
+- `dispatchId`: string
+
+### resources_getMaintenanceSchedule (READ)
+get maintenance schedule
+**Parameters:**
+- `scheduleId`: string
+
+### resources_getMaintenanceScheduleItems (READ)
+get maintenance schedule items
+**Parameters:**
+- `scheduleId`: string
+
+### resources_getMaintenanceSchedules (READ)
+get maintenance schedules
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null; active?: boolean } (optional)
+
+### resources_getMaintenanceSchedulesByLocation (READ)
+get maintenance schedules by location
+**Parameters:**
+- `locationId`: string
+- `args`: GenericQueryFilters & { search: string | null; active?: boolean } (optional)
+
+### resources_getOutstandingTrainingsForUser (READ)
+get outstanding trainings for user
+**Parameters:**
+- `employeeId`: string
+
+### resources_getPartner (READ)
+get partner
+**Parameters:**
+- `partnerId`: string
+- `abilityId`: string
+
+### resources_getPartnerBySupplierId (READ)
+get partner by supplier id
+**Parameters:**
+- `partnerId`: string
+
+### resources_getPartners (READ)
+get partners
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### resources_getProcess (READ)
+get process
+**Parameters:**
+- `processId`: string
+
+### resources_getProcesses (READ)
+get processes
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### resources_getProcessesList (READ)
+get processes list
+**Parameters:** none (context auto-filled)
+
+### resources_getSuggestion (READ)
+get suggestion
+**Parameters:**
+- `suggestionId`: string
+
+### resources_getSuggestions (READ)
+get suggestions
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### resources_getTraining (READ)
+get training
+**Parameters:**
+- `id`: string
+
+### resources_getTrainingAssignment (READ)
+get training assignment
+**Parameters:**
+- `assignmentId`: string
+
+### resources_getTrainingAssignmentForCompletion (READ)
+get training assignment for completion
+**Parameters:**
+- `assignmentId`: string
+
+### resources_getTrainingAssignments (READ)
+get training assignments
+**Parameters:**
+- `trainingId`: string (optional)
+
+### resources_getTrainingAssignmentStatus (READ)
+get training assignment status
+**Parameters:**
+- `args`: {
+ trainingId?: string;
+ status?: "Completed" | "Pending" | "Overdue" | "Not Required";
+ search?: string;
+ } & GenericQueryFilters (optional)
+
+### resources_getTrainingAssignmentSummary (READ)
+get training assignment summary
+**Parameters:** none (context auto-filled)
+
+### resources_getTrainingQuestions (READ)
+get training questions
+**Parameters:**
+- `trainingId`: string
+
+### resources_getTrainings (READ)
+get trainings
+**Parameters:**
+- `args`: { search: string | null } & GenericQueryFilters (optional)
+
+### resources_getTrainingsList (READ)
+get trainings list
+**Parameters:** none (context auto-filled)
+
+### resources_getWorkCenter (READ)
+get work center
+**Parameters:**
+- `id`: string
+
+### resources_getWorkCenters (READ)
+get work centers
+**Parameters:**
+- `args`: { search: string | null } & GenericQueryFilters (optional)
+
+### resources_getWorkCentersByLocation (READ)
+get work centers by location
+**Parameters:**
+- `locationId`: string
+
+### resources_getWorkCentersList (READ)
+get work centers list
+**Parameters:** none (context auto-filled)
+
+### resources_getWorkCentersListWithBlockingStatus (READ)
+get work centers list with blocking status
+**Parameters:** none (context auto-filled)
+
+### resources_insertAbility (WRITE)
+insert ability
+**Parameters:**
+- `ability`: {
+ name: string;
+ curve: {
+ data: {
+ week: number;
+ value: number;
+ }[];
+ };
+ shadowWeeks: number;
+ companyId: string;
+ createdBy: string;
+ }
+
+### resources_insertEmployeeAbilities (WRITE)
+insert employee abilities
+**Parameters:**
+- `abilityId`: string
+- `employeeIds`: string[]
+
+### resources_insertTrainingCompletion (WRITE)
+insert training completion
+**Parameters:**
+- `completion`: {
+ trainingAssignmentId: string;
+ employeeId: string;
+ period: string | null;
+ companyId: string;
+ completedBy: string;
+ createdBy: string;
+ }
+
+### resources_updateAbility (WRITE)
+update ability
+**Parameters:**
+- `id`: string
+- `ability`: Partial<{
+ name: string;
+ curve: {
+ data: {
+ week: number;
+ value: number;
+ }[];
+ };
+ shadowWeeks: number;
+ }>
+
+### resources_updateSuggestionEmoji (WRITE)
+update suggestion emoji
+**Parameters:**
+- `suggestionId`: string
+- `emoji`: string
+
+### resources_updateSuggestionTags (WRITE)
+update suggestion tags
+**Parameters:**
+- `suggestionId`: string
+- `tags`: string[]
+
+### resources_updateTrainingQuestionOrder (WRITE)
+update training question order
+**Parameters:**
+- `updates`: {
+ id: string;
+ sortOrder: number;
+ updatedBy: string;
+ }[]
+
+### resources_upsertContractor (WRITE)
+upsert contractor
+**Parameters:**
+- `contractorWithAbilities`: | {
+ id: string;
+ hoursPerWeek?: number;
+ abilities: string[];
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ }
+ | {
+ id: string;
+ hoursPerWeek?: number;
+ abilities: string[];
+ updatedBy: string;
+ customFields?: Json;
+ }
+
+### resources_upsertEmployeeAbility (WRITE)
+upsert employee ability
+**Parameters:**
+- `employeeAbility`: {
+ id?: string;
+ abilityId: string;
+ employeeId: string;
+ trainingCompleted: boolean;
+ trainingDays?: number;
+ companyId: string;
+ }
+
+### resources_upsertFailureMode (WRITE)
+upsert failure mode
+**Parameters:**
+- `failureMode`: | (Omit<z.infer<typeof failureModeValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof failureModeValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### resources_upsertLocation (WRITE)
+upsert location
+**Parameters:**
+- `location`: | (Omit<z.infer<typeof locationValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof locationValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### resources_upsertMaintenanceDispatch (WRITE)
+upsert maintenance dispatch
+**Parameters:**
+- `dispatch`: | (Omit<z.infer<typeof maintenanceDispatchValidator>, "id"> & {
+ maintenanceDispatchId: string;
+ companyId: string;
+ createdBy: string;
+ content?: Json;
+ })
+ | (Omit<z.infer<typeof maintenanceDispatchValidator>, "id" | "assignee"> & {
+ id: string;
+ assignee: string | null;
+ updatedBy: string;
+ content?: Json;
+ })
+
+### resources_upsertMaintenanceDispatchComment (WRITE)
+upsert maintenance dispatch comment
+**Parameters:**
+- `comment`: | (Omit<z.infer<typeof maintenanceDispatchCommentValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof maintenanceDispatchCommentValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### resources_upsertMaintenanceDispatchEvent (WRITE)
+upsert maintenance dispatch event
+**Parameters:**
+- `event`: | (Omit<z.infer<typeof maintenanceDispatchEventValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof maintenanceDispatchEventValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### resources_upsertMaintenanceDispatchItem (WRITE)
+upsert maintenance dispatch item
+**Parameters:**
+- `item`: | (Omit<z.infer<typeof maintenanceDispatchItemValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof maintenanceDispatchItemValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### resources_upsertMaintenanceDispatchWorkCenter (WRITE)
+upsert maintenance dispatch work center
+**Parameters:**
+- `workCenter`: | (Omit<z.infer<typeof maintenanceDispatchWorkCenterValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof maintenanceDispatchWorkCenterValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### resources_upsertMaintenanceSchedule (WRITE)
+upsert maintenance schedule
+**Parameters:**
+- `schedule`: | (Omit<z.infer<typeof maintenanceScheduleValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof maintenanceScheduleValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### resources_upsertMaintenanceScheduleItem (WRITE)
+upsert maintenance schedule item
+**Parameters:**
+- `item`: | (Omit<z.infer<typeof maintenanceScheduleItemValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof maintenanceScheduleItemValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### resources_upsertPartner (WRITE)
+upsert partner
+**Parameters:**
+- `partner`: | (Omit<z.infer<typeof partnerValidator>, "supplierId"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof partnerValidator>, "supplierId"> & {
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### resources_upsertProcess (WRITE)
+upsert process
+**Parameters:**
+- `process`: | (Omit<z.infer<typeof processValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof processValidator>, "id"> & {
+ id: string;
+ companyId: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### resources_upsertTraining (WRITE)
+upsert training
+**Parameters:**
+- `training`: | (Omit<z.infer<typeof trainingValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof trainingValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### resources_upsertTrainingAssignment (WRITE)
+upsert training assignment
+**Parameters:**
+- `assignment`: {
+ id?: string;
+ trainingId: string;
+ groupIds: string[];
+ companyId: string;
+ createdBy?: string;
+ updatedBy?: string;
+ }
+
+### resources_upsertTrainingQuestion (WRITE)
+upsert training question
+**Parameters:**
+- `trainingQuestion`: | (Omit<z.infer<typeof trainingQuestionValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof trainingQuestionValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### resources_upsertWorkCenter (WRITE)
+upsert work center
+**Parameters:**
+- `workCenter`: | (Omit<z.infer<typeof workCenterValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof workCenterValidator>, "id"> & {
+ id: string;
+ companyId: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+---
+
+## sales (150 tools)
+
+### sales_closeSalesOrder (WRITE)
+close sales order
+**Parameters:**
+- `salesOrderId`: string
+
+### sales_convertSalesRfqToQuote (WRITE)
+convert sales rfq to quote
+**Parameters:**
+- `payload`: {
+ id: string;
+ companyId: string;
+ userId: string;
+ }
+
+### sales_convertQuoteToOrder (WRITE)
+convert quote to order
+**Parameters:**
+- `payload`: {
+ id: string;
+ selectedLines: z.infer<typeof selectedLinesValidator>;
+ companyId: string;
+ purchaseOrderNumber?: string;
+ userId: string;
+ digitalQuoteAcceptedBy?: string;
+ digitalQuoteAcceptedByEmail?: string;
+ }
+
+### sales_copyQuoteLine (WRITE)
+copy quote line
+**Parameters:**
+- `payload`: z.infer<typeof getMethodValidator> & {
+ companyId: string;
+ userId: string;
+ }
+
+### sales_copyQuote (WRITE)
+copy quote
+**Parameters:**
+- `payload`: Omit<z.infer<typeof getMethodValidator>, "type"> & {
+ companyId: string;
+ userId: string;
+ }
+
+### sales_deleteCustomer (DESTRUCTIVE)
+delete customer
+**Parameters:**
+- `customerId`: string
+
+### sales_deleteCustomerContact (DESTRUCTIVE)
+delete customer contact
+**Parameters:**
+- `customerId`: string
+- `customerContactId`: string
+
+### sales_deleteCustomerLocation (DESTRUCTIVE)
+delete customer location
+**Parameters:**
+- `customerId`: string
+- `customerLocationId`: string
+
+### sales_deleteCustomerStatus (DESTRUCTIVE)
+delete customer status
+**Parameters:**
+- `customerStatusId`: string
+
+### sales_deleteCustomerType (DESTRUCTIVE)
+delete customer type
+**Parameters:**
+- `customerTypeId`: string
+
+### sales_deleteNoQuoteReason (DESTRUCTIVE)
+delete no quote reason
+**Parameters:**
+- `noQuoteReasonId`: string
+
+### sales_deleteQuote (DESTRUCTIVE)
+delete quote
+**Parameters:**
+- `quoteId`: string
+
+### sales_deleteQuoteMakeMethod (DESTRUCTIVE)
+delete quote make method
+**Parameters:**
+- `quoteMakeMethodId`: string
+
+### sales_deleteQuoteLine (DESTRUCTIVE)
+delete quote line
+**Parameters:**
+- `quoteLineId`: string
+
+### sales_deleteQuoteMaterial (DESTRUCTIVE)
+delete quote material
+**Parameters:**
+- `quoteMaterialId`: string
+
+### sales_deleteQuoteOperation (DESTRUCTIVE)
+delete quote operation
+**Parameters:**
+- `quoteOperationId`: string
+
+### sales_deleteQuoteOperationStep (DESTRUCTIVE)
+delete quote operation step
+**Parameters:**
+- `id`: string
+
+### sales_deleteQuoteOperationParameter (DESTRUCTIVE)
+delete quote operation parameter
+**Parameters:**
+- `id`: string
+
+### sales_deleteQuoteOperationTool (DESTRUCTIVE)
+delete quote operation tool
+**Parameters:**
+- `id`: string
+
+### sales_deleteSalesOrder (DESTRUCTIVE)
+delete sales order
+**Parameters:**
+- `salesOrderId`: string
+
+### sales_deleteSalesOrderLine (DESTRUCTIVE)
+delete sales order line
+**Parameters:**
+- `salesOrderLineId`: string
+
+### sales_deleteSalesRFQ (DESTRUCTIVE)
+delete sales r f q
+**Parameters:**
+- `salesRfqId`: string
+
+### sales_deleteSalesRFQLine (DESTRUCTIVE)
+delete sales r f q line
+**Parameters:**
+- `salesRFQLineId`: string
+
+### sales_getConfigurationParametersByQuoteLineId (READ)
+get configuration parameters by quote line id
+**Parameters:**
+- `quoteLineId`: string
+
+### sales_getCustomer (READ)
+get customer
+**Parameters:**
+- `customerId`: string
+
+### sales_getCustomerContact (READ)
+get customer contact
+**Parameters:**
+- `customerContactId`: string
+
+### sales_getCustomerContacts (READ)
+get customer contacts
+**Parameters:**
+- `customerId`: string
+
+### sales_getCustomerLocation (READ)
+get customer location
+**Parameters:**
+- `customerLocationId`: string
+
+### sales_getCustomerLocations (READ)
+get customer locations
+**Parameters:**
+- `customerId`: string
+
+### sales_getCustomerPayment (READ)
+get customer payment
+**Parameters:**
+- `customerId`: string
+
+### sales_getCustomerShipping (READ)
+get customer shipping
+**Parameters:**
+- `customerId`: string
+
+### sales_getCustomers (READ)
+get customers
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### sales_getCustomersList (READ)
+get customers list
+**Parameters:** none (context auto-filled)
+
+### sales_getCustomerStatus (READ)
+get customer status
+**Parameters:**
+- `customerStatusId`: string
+
+### sales_getCustomerStatuses (READ)
+get customer statuses
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### sales_getCustomerStatusesList (READ)
+get customer statuses list
+**Parameters:** none (context auto-filled)
+
+### sales_getCustomerType (READ)
+get customer type
+**Parameters:**
+- `customerTypeId`: string
+
+### sales_getCustomerTypes (READ)
+get customer types
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### sales_getCustomerTypesList (READ)
+get customer types list
+**Parameters:** none (context auto-filled)
+
+### sales_getExternalSalesOrderLines (READ)
+get external sales order lines
+**Parameters:**
+- `customerId`: string
+- `args`: GenericQueryFilters & { search: string | null }
+
+### sales_getModelByQuoteLineId (READ)
+get model by quote line id
+**Parameters:**
+- `quoteLineId`: string
+
+### sales_getNoQuoteReasonsList (READ)
+get no quote reasons list
+**Parameters:** none (context auto-filled)
+
+### sales_getNoQuoteReason (READ)
+get no quote reason
+**Parameters:**
+- `noQuoteReasonId`: string
+
+### sales_getNoQuoteReasons (READ)
+get no quote reasons
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### sales_getOpportunity (READ)
+get opportunity
+**Parameters:**
+- `opportunityId`: string | null
+
+### sales_getOpportunityDocuments (READ)
+get opportunity documents
+**Parameters:**
+- `opportunityId`: string
+
+### sales_getOpportunityLineDocuments (READ)
+get opportunity line documents
+**Parameters:**
+- `lineId`: string
+- `itemId`: string | null (optional)
+
+### sales_getQuote (READ)
+get quote
+**Parameters:**
+- `quoteId`: string
+
+### sales_getQuoteFavorites (READ)
+get quote favorites
+**Parameters:** none (context auto-filled)
+
+### sales_getQuotes (READ)
+get quotes
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### sales_getQuotesList (READ)
+get quotes list
+**Parameters:** none (context auto-filled)
+
+### sales_getQuoteAssembliesByLine (READ)
+get quote assemblies by line
+**Parameters:**
+- `quoteLineId`: string
+
+### sales_getQuoteAssemblies (READ)
+get quote assemblies
+**Parameters:**
+- `quoteId`: string
+
+### sales_getQuoteCustomerDetails (READ)
+get quote customer details
+**Parameters:**
+- `quoteId`: string
+
+### sales_getQuoteLine (READ)
+get quote line
+**Parameters:**
+- `quoteLineId`: string
+
+### sales_getQuoteLinesList (READ)
+get quote lines list
+**Parameters:**
+- `quoteId`: string
+
+### sales_getQuoteMakeMethod (READ)
+get quote make method
+**Parameters:**
+- `quoteMakeMethodId`: string
+
+### sales_getRootQuoteMakeMethod (READ)
+get root quote make method
+**Parameters:**
+- `quoteLineId`: string
+
+### sales_getQuoteMethodTrees (READ)
+get quote method trees
+**Parameters:**
+- `quoteId`: string
+
+### sales_getQuoteMethodTreeArray (READ)
+get quote method tree array
+**Parameters:**
+- `quoteId`: string
+
+### sales_getQuoteLines (READ)
+get quote lines
+**Parameters:**
+- `quoteId`: string
+
+### sales_getQuoteByExternalId (READ)
+get quote by external id
+**Parameters:**
+- `externalId`: string
+
+### sales_getQuoteLinePrices (READ)
+get quote line prices
+**Parameters:**
+- `quoteLineId`: string
+
+### sales_getQuoteLinePricesByQuoteId (READ)
+get quote line prices by quote id
+**Parameters:**
+- `quoteId`: string
+
+### sales_getQuoteLinePricesByItemId (READ)
+get quote line prices by item id
+**Parameters:**
+- `itemId`: string
+- `currentQuoteId`: string
+
+### sales_getQuoteLinePricesByItemIds (READ)
+get quote line prices by item ids
+**Parameters:**
+- `itemIds`: string[]
+- `currentQuoteId`: string
+
+### sales_getQuoteMaterials (READ)
+get quote materials
+**Parameters:**
+- `quoteId`: string
+
+### sales_getQuoteMaterial (READ)
+get quote material
+**Parameters:**
+- `materialId`: string
+
+### sales_getQuoteMaterialsByLine (READ)
+get quote materials by line
+**Parameters:**
+- `quoteLineId`: string
+
+### sales_getQuoteMaterialsByMethodId (READ)
+get quote materials by method id
+**Parameters:**
+- `quoteMakeMethodId`: string
+
+### sales_getQuoteMaterialsByOperation (READ)
+get quote materials by operation
+**Parameters:**
+- `quoteOperationId`: string
+
+### sales_getQuoteOperation (READ)
+get quote operation
+**Parameters:**
+- `quoteOperationId`: string
+
+### sales_getQuoteOperationsByLine (READ)
+get quote operations by line
+**Parameters:**
+- `quoteLineId`: string
+
+### sales_getQuoteOperationsByMethodId (READ)
+get quote operations by method id
+**Parameters:**
+- `quoteMakeMethodId`: string
+
+### sales_getQuoteOperations (READ)
+get quote operations
+**Parameters:**
+- `quoteId`: string
+
+### sales_getQuotePayment (READ)
+get quote payment
+**Parameters:**
+- `quoteId`: string
+
+### sales_getQuoteShipment (READ)
+get quote shipment
+**Parameters:**
+- `quoteId`: string
+
+### sales_getRelatedPricesForQuoteLine (READ)
+get related prices for quote line
+**Parameters:**
+- `itemId`: string
+- `quoteId`: string
+
+### sales_getSalesDocumentsAssignedToMe (READ)
+get sales documents assigned to me
+**Parameters:** none (context auto-filled)
+
+### sales_getSalesOrder (READ)
+get sales order
+**Parameters:**
+- `salesOrderId`: string
+
+### sales_getSalesOrderCustomerDetails (READ)
+get sales order customer details
+**Parameters:**
+- `salesOrderId`: string
+
+### sales_getSalesOrderFavorites (READ)
+get sales order favorites
+**Parameters:** none (context auto-filled)
+
+### sales_getSalesOrderRelatedItems (READ)
+get sales order related items
+**Parameters:**
+- `salesOrderId`: string
+- `opportunityId`: string
+
+### sales_getSalesOrders (READ)
+get sales orders
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ status: string | null;
+ customerId: string | null;
+ }
+
+### sales_getSalesOrdersList (READ)
+get sales orders list
+**Parameters:** none (context auto-filled)
+
+### sales_getSalesOrderPayment (READ)
+get sales order payment
+**Parameters:**
+- `salesOrderId`: string
+
+### sales_getSalesTerms (READ)
+get sales terms
+**Parameters:** none (context auto-filled)
+
+### sales_getSalesOrderShipment (READ)
+get sales order shipment
+**Parameters:**
+- `salesOrderId`: string
+
+### sales_getSalesOrderCustomers (READ)
+get sales order customers
+**Parameters:** none (context auto-filled)
+
+### sales_getSalesOrderLines (READ)
+get sales order lines
+**Parameters:**
+- `salesOrderId`: string
+
+### sales_getSalesOrderInvoiceLines (READ)
+get sales order invoice lines
+**Parameters:**
+- `salesOrderId`: string
+
+### sales_getSalesOrderInvoicesByIds (READ)
+get sales order invoices by ids
+**Parameters:**
+- `invoiceIds`: string[]
+
+### sales_getSalesOrderLinesByItemId (READ)
+get sales order lines by item id
+**Parameters:**
+- `itemId`: string
+
+### sales_getSalesOrderLinesByItemIds (READ)
+get sales order lines by item ids
+**Parameters:**
+- `itemIds`: string[]
+
+### sales_getSalesOrderLine (READ)
+get sales order line
+**Parameters:**
+- `salesOrderLineId`: string
+
+### sales_getSalesOrderLineShipments (READ)
+get sales order line shipments
+**Parameters:**
+- `salesOrderLineId`: string
+
+### sales_getSalesRFQ (READ)
+get sales r f q
+**Parameters:**
+- `id`: string
+
+### sales_getSalesRFQFavorites (READ)
+get sales r f q favorites
+**Parameters:** none (context auto-filled)
+
+### sales_getSalesRFQs (READ)
+get sales r f qs
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### sales_getSalesRFQLine (READ)
+get sales r f q line
+**Parameters:**
+- `lineId`: string
+
+### sales_getSalesRFQLines (READ)
+get sales r f q lines
+**Parameters:**
+- `salesRfqId`: string
+
+### sales_insertCustomerContact (WRITE)
+insert customer contact
+**Parameters:**
+- `customerContact`: {
+ customerId: string;
+ companyId: string;
+ contact: PickPartial<z.infer<typeof customerContactValidator>, "email">;
+ customerLocationId?: string;
+ customFields?: Json;
+ }
+
+### sales_insertCustomerLocation (WRITE)
+insert customer location
+**Parameters:**
+- `customerLocation`: {
+ customerId: string;
+ companyId: string;
+ name: string;
+ address: {
+ addressLine1?: string;
+ addressLine2?: string;
+ city?: string;
+ stateProvince?: string;
+ countryCode?: string;
+ postalCode?: string;
+ };
+ customFields?: Json;
+ }
+
+### sales_insertSalesOrderLines (WRITE)
+insert sales order lines
+**Parameters:**
+- `salesOrderLines`: (Omit<z.infer<typeof salesOrderLineValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })[]
+
+### sales_finalizeQuote (WRITE)
+finalize quote
+**Parameters:**
+- `quoteId`: string
+
+### sales_releaseSalesOrder (WRITE)
+release sales order
+**Parameters:**
+- `salesOrderId`: string
+
+### sales_upsertCustomer (WRITE)
+upsert customer
+**Parameters:**
+- `customer`: | (Omit<z.infer<typeof customerValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof customerValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### sales_updateCustomerAccounting (WRITE)
+update customer accounting
+**Parameters:**
+- `customerAccounting`: z.infer<typeof customerAccountingValidator> & {
+ updatedBy: string;
+ }
+
+### sales_updateCustomerContact (WRITE)
+update customer contact
+**Parameters:**
+- `customerContact`: {
+ contactId: string;
+ contact: z.infer<typeof customerContactValidator>;
+ customerLocationId?: string;
+ customFields?: Json;
+ }
+
+### sales_updateCustomerLocation (WRITE)
+update customer location
+**Parameters:**
+- `customerLocation`: {
+ addressId: string;
+ name: string;
+ address: {
+ addressLine1?: string;
+ addressLine2?: string;
+ city?: string;
+ stateProvince?: string;
+ countryCode?: string;
+ postalCode?: string;
+ };
+ customFields?: Json;
+ }
+
+### sales_updateCustomerPayment (WRITE)
+update customer payment
+**Parameters:**
+- `customerPayment`: z.infer<typeof customerPaymentValidator> & {
+ updatedBy: string;
+ }
+
+### sales_updateCustomerShipping (WRITE)
+update customer shipping
+**Parameters:**
+- `customerShipping`: z.infer<typeof customerShippingValidator> & {
+ updatedBy: string;
+ }
+
+### sales_upsertCustomerStatus (WRITE)
+upsert customer status
+**Parameters:**
+- `customerStatus`: | (Omit<z.infer<typeof customerStatusValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof customerStatusValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### sales_upsertCustomerType (WRITE)
+upsert customer type
+**Parameters:**
+- `customerType`: | (Omit<z.infer<typeof customerTypeValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof customerTypeValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### sales_upsertNoQuoteReason (WRITE)
+upsert no quote reason
+**Parameters:**
+- `noQuoteReason`: | (Omit<z.infer<typeof noQuoteReasonValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof noQuoteReasonValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### sales_updateSalesRFQFavorite (WRITE)
+update sales r f q favorite
+**Parameters:**
+- `args`: {
+ id: string;
+ favorite: boolean;
+ userId: string;
+ }
+
+### sales_updateSalesRFQLineOrder (WRITE)
+update sales r f q line order
+**Parameters:**
+- `updates`: {
+ id: string;
+ order: number;
+ updatedBy: string;
+ }[]
+
+### sales_updateQuoteExchangeRate (WRITE)
+update quote exchange rate
+**Parameters:**
+- `data`: {
+ id: string;
+ exchangeRate: number;
+ }
+
+### sales_updateQuoteLinePrecision (WRITE)
+update quote line precision
+**Parameters:**
+- `quoteLineId`: string
+- `precision`: number
+
+### sales_updateSalesOrderExchangeRate (WRITE)
+update sales order exchange rate
+**Parameters:**
+- `data`: {
+ id: string;
+ exchangeRate: number;
+ }
+
+### sales_updateQuoteFavorite (WRITE)
+update quote favorite
+**Parameters:**
+- `args`: {
+ id: string;
+ favorite: boolean;
+ userId: string;
+ }
+
+### sales_updateSalesRFQStatus (WRITE)
+update sales r f q status
+**Parameters:**
+- `update`: {
+ id: string;
+ status: (typeof salesRFQStatusType)[number];
+ noQuoteReasonId: string | null;
+ assignee: null | undefined;
+ updatedBy: string;
+ }
+
+### sales_updateQuoteMaterialOrder (WRITE)
+update quote material order
+**Parameters:**
+- `updates`: {
+ id: string;
+ order: number;
+ updatedBy: string;
+ }[]
+
+### sales_updateQuoteOperationOrder (WRITE)
+update quote operation order
+**Parameters:**
+- `updates`: {
+ id: string;
+ order: number;
+ updatedBy: string;
+ }[]
+
+### sales_updateQuoteStatus (WRITE)
+update quote status
+**Parameters:**
+- `update`: {
+ id: string;
+ status: (typeof quoteStatusType)[number];
+ assignee: null | undefined;
+ updatedBy: string;
+ }
+
+### sales_upsertMakeMethodFromQuoteLine (WRITE)
+upsert make method from quote line
+**Parameters:**
+- `lineMethod`: {
+ itemId: string;
+ quoteId: string;
+ quoteLineId: string;
+ companyId: string;
+ userId: string;
+ parts?: {
+ billOfMaterial: boolean;
+ billOfProcess: boolean;
+ parameters: boolean;
+ tools: boolean;
+ steps: boolean;
+ workInstructions: boolean;
+ };
+ }
+
+### sales_upsertMakeMethodFromQuoteMethod (WRITE)
+upsert make method from quote method
+**Parameters:**
+- `quoteMethod`: {
+ sourceId: string;
+ targetId: string;
+ companyId: string;
+ userId: string;
+ parts?: {
+ billOfMaterial: boolean;
+ billOfProcess: boolean;
+ parameters: boolean;
+ tools: boolean;
+ steps: boolean;
+ workInstructions: boolean;
+ };
+ }
+
+### sales_upsertQuote (WRITE)
+upsert quote
+**Parameters:**
+- `quote`: | (Omit<z.infer<typeof quoteValidator>, "id" | "quoteId"> & {
+ quoteId: string;
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof quoteValidator>, "id" | "quoteId"> & {
+ id: string;
+ quoteId: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### sales_upsertQuoteLine (WRITE)
+upsert quote line
+**Parameters:**
+- `quotationLine`: | (Omit<z.infer<typeof quoteLineValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof quoteLineValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### sales_upsertQuoteLineAdditionalCharges (WRITE)
+upsert quote line additional charges
+**Parameters:**
+- `lineId`: string
+- `update`: {
+ additionalCharges: z.infer<typeof quoteLineAdditionalChargesValidator>;
+ updatedBy: string;
+ }
+
+### sales_upsertQuoteLinePrices (WRITE)
+upsert quote line prices
+**Parameters:**
+- `quoteId`: string
+- `lineId`: string
+- `quoteLinePrices`: {
+ quoteLineId: string;
+ unitPrice: number;
+ leadTime: number;
+ discountPercent: number;
+ quantity: number;
+ createdBy: string;
+ categoryMarkups?: Record<string, number>;
+ }[]
+
+### sales_calculatePricesForQuantities (WRITE)
+calculate prices for quantities
+**Parameters:**
+- `quoteId`: string
+- `quoteLineId`: string
+- `quantities`: number[]
+
+### sales_recalculateQuoteLinePrices (WRITE)
+recalculate quote line prices
+**Parameters:**
+- `quoteId`: string
+- `quoteLineId`: string
+
+### sales_upsertQuoteLineMethod (WRITE)
+upsert quote line method
+**Parameters:**
+- `lineMethod`: {
+ itemId: string;
+ quoteId: string;
+ quoteLineId: string;
+ companyId: string;
+ userId: string;
+ configuration?: Record<string, unknown>;
+ parts?: {
+ billOfMaterial: boolean;
+ billOfProcess: boolean;
+ parameters: boolean;
+ tools: boolean;
+ steps: boolean;
+ workInstructions: boolean;
+ };
+ }
+
+### sales_upsertQuoteMaterial (WRITE)
+upsert quote material
+**Parameters:**
+- `quoteMaterial`: | (z.infer<typeof quoteMaterialValidator> & {
+ quoteId: string;
+ quoteLineId: string;
+ quoteOperationId?: string;
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (z.infer<typeof quoteMaterialValidator> & {
+ quoteId: string;
+ quoteLineId: string;
+ quoteOperationId?: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### sales_upsertQuoteMaterialMakeMethod (WRITE)
+upsert quote material make method
+**Parameters:**
+- `quoteMethod`: {
+ sourceId: string;
+ targetId: string;
+ companyId: string;
+ userId: string;
+ configuration?: Record<string, unknown>;
+ parts?: {
+ billOfMaterial: boolean;
+ billOfProcess: boolean;
+ parameters: boolean;
+ tools: boolean;
+ steps: boolean;
+ workInstructions: boolean;
+ };
+ }
+
+### sales_upsertQuoteOperation (WRITE)
+upsert quote operation
+**Parameters:**
+- `operation`: | (Omit<z.infer<typeof quoteOperationValidator>, "id"> & {
+ quoteId: string;
+ quoteLineId: string;
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (z.infer<typeof quoteOperationValidator> & {
+ quoteId: string;
+ quoteLineId: string;
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof quoteOperationValidator>, "id"> & {
+ id: string;
+ quoteId: string;
+ quoteLineId: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### sales_upsertQuoteOperationStep (WRITE)
+upsert quote operation step
+**Parameters:**
+- `quoteOperationStep`: | (Omit<z.infer<typeof operationStepValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<
+ z.infer<typeof operationStepValidator>,
+ "id" | "minValue" | "maxValue"
+ > & {
+ id: string;
+ minValue: number | null;
+ maxValue: number | null;
+ updatedBy: string;
+ updatedAt: string;
+ })
+
+### sales_upsertQuoteOperationParameter (WRITE)
+upsert quote operation parameter
+**Parameters:**
+- `quoteOperationParameter`: | (Omit<z.infer<typeof operationParameterValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof operationParameterValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ updatedAt: string;
+ })
+
+### sales_upsertQuoteOperationTool (WRITE)
+upsert quote operation tool
+**Parameters:**
+- `quoteOperationTool`: | (Omit<z.infer<typeof operationToolValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ })
+ | (Omit<z.infer<typeof operationToolValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ updatedAt: string;
+ })
+
+### sales_upsertQuotePayment (WRITE)
+upsert quote payment
+**Parameters:**
+- `quotePayment`: | (z.infer<typeof quotePaymentValidator> & {
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (z.infer<typeof quotePaymentValidator> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### sales_upsertQuoteShipment (WRITE)
+upsert quote shipment
+**Parameters:**
+- `quoteShipment`: | (z.infer<typeof quoteShipmentValidator> & {
+ createdBy: string;
+ })
+ | (z.infer<typeof quoteShipmentValidator> & {
+ id: string;
+ updatedBy: string;
+ })
+
+### sales_updateSalesOrderFavorite (WRITE)
+update sales order favorite
+**Parameters:**
+- `args`: {
+ id: string;
+ favorite: boolean;
+ userId: string;
+ }
+
+### sales_updateSalesOrderStatus (WRITE)
+update sales order status
+**Parameters:**
+- `update`: {
+ id: string;
+ status: (typeof salesOrderStatusType)[number];
+ assignee: null | undefined;
+ updatedBy: string;
+ }
+
+### sales_upsertSalesOrder (WRITE)
+upsert sales order
+**Parameters:**
+- `salesOrder`: | (Omit<z.infer<typeof salesOrderValidator>, "id" | "salesOrderId"> & {
+ salesOrderId: string;
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof salesOrderValidator>, "id" | "salesOrderId"> & {
+ id: string;
+ salesOrderId: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### sales_upsertSalesOrderShipment (WRITE)
+upsert sales order shipment
+**Parameters:**
+- `salesOrderShipment`: | (z.infer<typeof salesOrderShipmentValidator> & {
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (z.infer<typeof salesOrderShipmentValidator> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### sales_upsertSalesOrderLine (WRITE)
+upsert sales order line
+**Parameters:**
+- `salesOrderLine`: | (Omit<z.infer<typeof salesOrderLineValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof salesOrderLineValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### sales_upsertSalesOrderPayment (WRITE)
+upsert sales order payment
+**Parameters:**
+- `salesOrderPayment`: | (z.infer<typeof salesOrderPaymentValidator> & {
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (z.infer<typeof salesOrderPaymentValidator> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### sales_upsertSalesRFQ (WRITE)
+upsert sales r f q
+**Parameters:**
+- `rfq`: | (Omit<z.infer<typeof salesRfqValidator>, "id" | "rfqId"> & {
+ rfqId: string;
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof salesRfqValidator>, "id" | "rfqId"> & {
+ id: string;
+ rfqId: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+### sales_upsertSalesRFQLine (WRITE)
+upsert sales r f q line
+**Parameters:**
+- `salesRfqLine`: | (Omit<z.infer<typeof salesRfqLineValidator>, "id"> & {
+ companyId: string;
+ createdBy: string;
+ customFields?: Json;
+ })
+ | (Omit<z.infer<typeof salesRfqLineValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ customFields?: Json;
+ })
+
+---
+
+## settings (68 tools)
+
+### settings_getAccountsPayableBillingAddress (READ)
+get accounts payable billing address
+**Parameters:** none (context auto-filled)
+
+### settings_getAccountsReceivableBillingAddress (READ)
+get accounts receivable billing address
+**Parameters:** none (context auto-filled)
+
+### settings_updateAccountsPayableBillingAddress (WRITE)
+update accounts payable billing address
+**Parameters:**
+- `data`: z.infer<typeof accountsPayableBillingAddressValidator>
+
+### settings_updateAccountsReceivableBillingAddress (WRITE)
+update accounts receivable billing address
+**Parameters:**
+- `data`: z.infer<typeof accountsReceivableBillingAddressValidator>
+
+### settings_deleteApiKey (DESTRUCTIVE)
+delete api key
+**Parameters:**
+- `id`: string
+
+### settings_deleteWebhook (DESTRUCTIVE)
+delete webhook
+**Parameters:**
+- `id`: string
+
+### settings_deactivateWebhooks (WRITE)
+deactivate webhooks
+**Parameters:** none (context auto-filled)
+
+### settings_getApiKeys (READ)
+get api keys
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### settings_getCompanies (READ)
+get companies
+**Parameters:** none (context auto-filled)
+
+### settings_getCompany (READ)
+get company
+**Parameters:** none (context auto-filled)
+
+### settings_getCompanyPlan (READ)
+get company plan
+**Parameters:** none (context auto-filled)
+
+### settings_getCompanySettings (READ)
+get company settings
+**Parameters:** none (context auto-filled)
+
+### settings_getCompanyIntegrations (READ)
+get company integrations
+**Parameters:** none (context auto-filled)
+
+### settings_getConfig (READ)
+get config
+**Parameters:** none (context auto-filled)
+
+### settings_getCurrentSequence (READ)
+get current sequence
+**Parameters:**
+- `table`: string
+
+### settings_getCustomField (READ)
+get custom field
+**Parameters:**
+- `id`: string
+
+### settings_getCustomFields (READ)
+get custom fields
+**Parameters:**
+- `table`: string
+
+### settings_getCustomFieldsTables (READ)
+get custom fields tables
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### settings_getIntegration (READ)
+get integration
+**Parameters:**
+- `id`: string
+
+### settings_getIntegrations (READ)
+get integrations
+**Parameters:** none (context auto-filled)
+
+### settings_getKanbanOutputSetting (READ)
+get kanban output setting
+**Parameters:** none (context auto-filled)
+
+### settings_getPlanById (READ)
+get plan by id
+**Parameters:**
+- `planId`: string
+
+### settings_getPlans (READ)
+get plans
+**Parameters:** none (context auto-filled)
+
+### settings_getNextSequence (READ)
+get next sequence
+**Parameters:**
+- `table`: string
+
+### settings_getSequence (READ)
+get sequence
+**Parameters:**
+- `table`: string
+
+### settings_getSequences (READ)
+get sequences
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### settings_getSequencesList (READ)
+get sequences list
+**Parameters:**
+- `table`: string
+
+### settings_getTerms (READ)
+get terms
+**Parameters:** none (context auto-filled)
+
+### settings_getWebhook (READ)
+get webhook
+**Parameters:**
+- `id`: string
+
+### settings_getWebhookTables (READ)
+get webhook tables
+**Parameters:** none (context auto-filled)
+
+### settings_getWebhooks (READ)
+get webhooks
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### settings_insertCompany (WRITE)
+insert company
+**Parameters:**
+- `company`: z.infer<typeof companyValidator>
+- `ownerId`: string (optional)
+
+### settings_updateCompanyPlan (WRITE)
+update company plan
+**Parameters:**
+- `data`: {
+ companyId: string;
+ stripeCustomerId: string;
+ stripeSubscriptionId: string;
+ stripeSubscriptionStatus: string;
+ subscriptionStartDate: string;
+ }
+
+### settings_seedCompany (WRITE)
+seed company
+**Parameters:** none (context auto-filled)
+
+### settings_updateCompany (WRITE)
+update company
+**Parameters:**
+- `company`: Partial<z.infer<typeof companyValidator>> & {
+ updatedBy: string;
+ }
+
+### settings_updateKanbanOutputSetting (WRITE)
+update kanban output setting
+**Parameters:**
+- `kanbanOutput`: (typeof kanbanOutputTypes)[number]
+
+### settings_updateMetricSettings (WRITE)
+update metric settings
+**Parameters:**
+- `useMetric`: boolean
+
+### settings_upsertApiKey (WRITE)
+upsert api key
+**Parameters:**
+- `apiKey`: | (Omit<z.infer<typeof apiKeyValidator>, "id" | "scopes" | "expiresAt"> & {
+ createdBy: string;
+ companyId: string;
+ scopes: Record<string, string[]>;
+ expiresAt?: string;
+ rawKey: string;
+ keyHash: string;
+ keyPreview: string;
+ })
+ | (Omit<z.infer<typeof apiKeyValidator>, "id" | "scopes" | "expiresAt"> & {
+ id: string;
+ scopes: Record<string, string[]>;
+ expiresAt?: string;
+ })
+
+### settings_updateDigitalQuoteSetting (WRITE)
+update digital quote setting
+**Parameters:**
+- `digitalQuoteEnabled`: boolean
+- `digitalQuoteNotificationGroup`: string[]
+- `digitalQuoteIncludesPurchaseOrders`: boolean
+
+### settings_updateLogoDark (WRITE)
+update logo dark
+**Parameters:**
+- `logoDark`: string | null
+
+### settings_updateLogoLight (WRITE)
+update logo light
+**Parameters:**
+- `logoLight`: string | null
+
+### settings_updateLogoDarkIcon (WRITE)
+update logo dark icon
+**Parameters:**
+- `logoDarkIcon`: string | null
+
+### settings_updateLogoLightIcon (WRITE)
+update logo light icon
+**Parameters:**
+- `logoLightIcon`: string | null
+
+### settings_updateMaterialGeneratedIdsSetting (WRITE)
+update material generated ids setting
+**Parameters:**
+- `materialGeneratedIds`: boolean
+
+### settings_updateMaterialUnitsSetting (WRITE)
+update material units setting
+**Parameters:**
+- `useMetric`: boolean
+
+### settings_updateProductLabelSize (WRITE)
+update product label size
+**Parameters:**
+- `productLabelSize`: string
+
+### settings_updatePurchasingPdfThumbnails (WRITE)
+update purchasing pdf thumbnails
+**Parameters:**
+- `includeThumbnailsOnPurchasingPdfs`: boolean
+
+### settings_updateSalesPdfThumbnails (WRITE)
+update sales pdf thumbnails
+**Parameters:**
+- `includeThumbnailsOnSalesPdfs`: boolean
+
+### settings_updateJobTravelerWorkInstructions (WRITE)
+update job traveler work instructions
+**Parameters:**
+- `jobTravelerIncludeWorkInstructions`: boolean
+
+### settings_updateTimeCardSetting (WRITE)
+update time card setting
+**Parameters:**
+- `timeCardEnabled`: boolean
+
+### settings_updateConsoleSetting (WRITE)
+update console setting
+**Parameters:**
+- `consoleEnabled`: boolean
+
+### settings_updateRfqReadySetting (WRITE)
+update rfq ready setting
+**Parameters:**
+- `rfqReadyNotificationGroup`: string[]
+
+### settings_updateSuggestionNotificationSetting (WRITE)
+update suggestion notification setting
+**Parameters:**
+- `suggestionNotificationGroup`: string[]
+
+### settings_updateMaintenanceDispatchNotificationSettings (WRITE)
+update maintenance dispatch notification settings
+**Parameters:**
+- `settings`: {
+ maintenanceDispatchNotificationGroup?: string[];
+ qualityDispatchNotificationGroup?: string[];
+ operationsDispatchNotificationGroup?: string[];
+ otherDispatchNotificationGroup?: string[];
+ }
+
+### settings_updateSupplierQuoteNotificationSetting (WRITE)
+update supplier quote notification setting
+**Parameters:**
+- `supplierQuoteNotificationGroup`: string[]
+
+### settings_updatePurchasePriceUpdateTimingSetting (WRITE)
+update purchase price update timing setting
+**Parameters:**
+- `purchasePriceUpdateTiming`: (typeof purchasePriceUpdateTimingTypes)[number]
+
+### settings_updateLeadTimesOnReceiptSetting (WRITE)
+update lead times on receipt setting
+**Parameters:**
+- `updateLeadTimesOnReceipt`: boolean
+
+### settings_updateSupplierApprovalSetting (WRITE)
+update supplier approval setting
+**Parameters:**
+- `supplierApproval`: boolean
+
+### settings_updateAccountsPayableAddressSetting (WRITE)
+update accounts payable address setting
+**Parameters:**
+- `accountsPayableAddress`: boolean
+
+### settings_updateAccountsReceivableAddressSetting (WRITE)
+update accounts receivable address setting
+**Parameters:**
+- `accountsReceivableAddress`: boolean
+
+### settings_updateAccountsPayableEmail (WRITE)
+update accounts payable email
+**Parameters:**
+- `accountsPayableEmail`: string | undefined
+
+### settings_updateAccountsReceivableEmail (WRITE)
+update accounts receivable email
+**Parameters:**
+- `accountsReceivableEmail`: string | undefined
+
+### settings_updateDefaultSupplierCc (WRITE)
+update default supplier cc
+**Parameters:**
+- `defaultSupplierCc`: string[]
+
+### settings_updateDefaultCustomerCc (WRITE)
+update default customer cc
+**Parameters:**
+- `defaultCustomerCc`: string[]
+
+### settings_updateQuoteLineCategoryMarkups (WRITE)
+update quote line category markups
+**Parameters:**
+- `quoteLineCategoryMarkups`: Record<string, number>
+
+### settings_updateSequence (WRITE)
+update sequence
+**Parameters:**
+- `table`: string
+- `sequence`: Partial<z.infer<typeof sequenceValidator>> & {
+ updatedBy: string;
+ }
+
+### settings_updateIntegrationMetadata (WRITE)
+update integration metadata
+**Parameters:**
+- `integrationId`: string
+- `metadata`: any
+
+### settings_upsertWebhook (WRITE)
+upsert webhook
+**Parameters:**
+- `webhook`: | (Omit<z.infer<typeof webhookValidator>, "id"> & {
+ createdBy: string;
+ companyId: string;
+ })
+ | (Omit<z.infer<typeof apiKeyValidator>, "id"> & {
+ id: string;
+ })
+
+---
+
+## shared (44 tools)
+
+### shared_approveRequest (WRITE)
+approve request
+**Parameters:**
+- `db`: Kysely<KyselyDatabase>
+- `id`: string
+- `notes`: string (optional)
+
+### shared_canApproveRequest (WRITE)
+can approve request
+**Parameters:**
+- `approvalRequest`: ApprovalRequestForApproveCheck
+
+### shared_canApproveRequestInWindow (WRITE)
+can approve request in window
+**Parameters:**
+- `approvalRequest`: ApprovalRequestForApproveCheck
+
+### shared_cancelApprovalRequest (WRITE)
+cancel approval request
+**Parameters:**
+- `id`: string
+
+### shared_canViewApprovalRequest (WRITE)
+can view approval request
+**Parameters:**
+- `approvalRequest`: ApprovalRequestForViewCheck
+
+### shared_createApprovalRequest (WRITE)
+create approval request
+**Parameters:**
+- `request`: CreateApprovalRequestInput & { amount?: number }
+
+### shared_deleteApprovalRule (DESTRUCTIVE)
+delete approval rule
+**Parameters:**
+- `id`: string
+
+### shared_deleteNote (DESTRUCTIVE)
+delete note
+**Parameters:**
+- `noteId`: string
+
+### shared_deleteSavedView (DESTRUCTIVE)
+delete saved view
+**Parameters:**
+- `viewId`: string
+
+### shared_generateEmbedding (WRITE)
+generate embedding
+**Parameters:**
+- `text`: string
+
+### shared_getApprovalById (READ)
+get approval by id
+**Parameters:**
+- `id`: string
+
+### shared_getApprovalRequestsByDocument (READ)
+get approval requests by document
+**Parameters:**
+- `documentType`: (typeof approvalDocumentType)[number]
+- `documentId`: string
+
+### shared_getApprovalRuleByAmount (READ)
+get approval rule by amount
+**Parameters:**
+- `documentType`: (typeof approvalDocumentType)[number]
+- `amount`: number (optional)
+
+### shared_getApproverUserIdsForRule (READ)
+get approver user ids for rule
+**Parameters:**
+- `rule`: Pick<ApprovalRule, "approverGroupIds" | "defaultApproverId">
+
+### shared_getApprovalRuleById (READ)
+get approval rule by id
+**Parameters:**
+- `id`: string
+
+### shared_getApprovalRules (READ)
+get approval rules
+**Parameters:** none (context auto-filled)
+
+### shared_getApprovalRulesForApprover (READ)
+get approval rules for approver
+**Parameters:**
+- `documentType`: (typeof approvalDocumentType)[number]
+
+### shared_getApprovalsForUser (READ)
+get approvals for user
+**Parameters:**
+- `args`: GenericQueryFilters & ApprovalFilters (optional)
+
+### shared_getBase64ImageFromSupabase (READ)
+get base64 image from supabase
+**Parameters:**
+- `path`: string
+
+### shared_getCountries (READ)
+get countries
+**Parameters:** none (context auto-filled)
+
+### shared_getLatestApprovalRequestForDocument (READ)
+get latest approval request for document
+**Parameters:**
+- `documentType`: (typeof approvalDocumentType)[number]
+- `documentId`: string
+
+### shared_getModelByItemId (READ)
+get model by item id
+**Parameters:**
+- `itemId`: string
+
+### shared_getNotes (READ)
+get notes
+**Parameters:**
+- `documentId`: string
+
+### shared_getPendingApprovalsForApprover (READ)
+get pending approvals for approver
+**Parameters:** none (context auto-filled)
+
+### shared_getPeriods (READ)
+get periods
+**Parameters:**
+- `arg1`: { startDate: string; endDate: string }
+
+### shared_getSavedViews (READ)
+get saved views
+**Parameters:** none (context auto-filled)
+
+### shared_getTagsList (READ)
+get tags list
+**Parameters:**
+- `table`: string | null (optional)
+
+### shared_hasPendingApproval (WRITE)
+has pending approval
+**Parameters:**
+- `documentType`: (typeof approvalDocumentType)[number]
+- `documentId`: string
+
+### shared_importCsv (WRITE)
+import csv
+**Parameters:**
+- `args`: {
+ table: string;
+ filePath: string;
+ columnMappings: Record<string, string>;
+ enumMappings?: Record<string, string[]>;
+ companyId: string;
+ userId: string;
+ }
+
+### shared_insertNote (WRITE)
+insert note
+**Parameters:**
+- `note`: {
+ note: string;
+ documentId: string;
+ companyId: string;
+ createdBy: string;
+ }
+
+### shared_insertTag (WRITE)
+insert tag
+**Parameters:**
+- `tag`: Database["public"]["Tables"]["tag"]["Insert"]
+
+### shared_isApprovalRequired (WRITE)
+is approval required
+**Parameters:**
+- `documentType`: (typeof approvalDocumentType)[number]
+- `amount`: number (optional)
+
+### shared_getExternalLink (READ)
+get external link
+**Parameters:**
+- `id`: string
+
+### shared_upsertExternalLink (WRITE)
+upsert external link
+**Parameters:**
+- `externalLink`: | Database["public"]["Tables"]["externalLink"]["Insert"]
+ | Database["public"]["Tables"]["externalLink"]["Update"]
+
+### shared_getCustomerPortals (READ)
+get customer portals
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### shared_getCustomerPortal (READ)
+get customer portal
+**Parameters:**
+- `id`: string
+
+### shared_deleteCustomerPortal (DESTRUCTIVE)
+delete customer portal
+**Parameters:**
+- `id`: string
+
+### shared_updateModelThumbnail (WRITE)
+update model thumbnail
+**Parameters:**
+- `modelId`: string
+- `thumbnailPath`: string
+
+### shared_upsertModelUpload (WRITE)
+upsert model upload
+**Parameters:**
+- `upload`: | {
+ id: string;
+ modelPath: string;
+ companyId: string;
+ createdBy: string;
+ }
+ | {
+ id: string;
+ name: string;
+ size: number;
+ thumbnailPath: string;
+ }
+
+### shared_updateNote (WRITE)
+update note
+**Parameters:**
+- `id`: string
+- `note`: string
+
+### shared_rejectRequest (WRITE)
+reject request
+**Parameters:**
+- `db`: Kysely<KyselyDatabase>
+- `id`: string
+- `notes`: string (optional)
+
+### shared_upsertApprovalRule (WRITE)
+upsert approval rule
+**Parameters:**
+- `rule`: UpsertApprovalRuleInput
+
+### shared_upsertSavedView (WRITE)
+upsert saved view
+**Parameters:**
+- `view`: {
+ id?: string;
+ name: string;
+ description?: string;
+ table: string;
+ type: "Public" | "Private";
+ filters?: string[];
+ sorts?: string[];
+ columnPinning?: Record<string, boolean>;
+ columnVisibility?: Record<string, boolean>;
+ columnOrder?: string[];
+ userId: string;
+ companyId: string;
+ }
+
+### shared_updateSavedViewOrder (WRITE)
+update saved view order
+**Parameters:**
+- `updates`: {
+ id: string;
+ sortOrder: number;
+ updatedBy: string;
+ }[]
+
+---
+
+## users (25 tools)
+
+### users_deleteEmployeeType (DESTRUCTIVE)
+delete employee type
+**Parameters:**
+- `employeeTypeId`: string
+
+### users_deleteGroup (DESTRUCTIVE)
+delete group
+**Parameters:**
+- `groupId`: string
+
+### users_getCompaniesForUser (READ)
+get companies for user
+**Parameters:** none (context auto-filled)
+
+### users_getCustomers (READ)
+get customers
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### users_getEmployee (READ)
+get employee
+**Parameters:**
+- `id`: string
+
+### users_getEmployees (READ)
+get employees
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### users_getConsoleOperators (READ)
+get console operators
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### users_getEmployeeType (READ)
+get employee type
+**Parameters:**
+- `employeeTypeId`: string
+
+### users_getEmployeeTypes (READ)
+get employee types
+**Parameters:**
+- `args`: GenericQueryFilters & { search: string | null } (optional)
+
+### users_getInvitable (READ)
+get invitable
+**Parameters:** none (context auto-filled)
+
+### users_getModules (READ)
+get modules
+**Parameters:** none (context auto-filled)
+
+### users_getGroup (READ)
+get group
+**Parameters:**
+- `groupId`: string
+
+### users_getGroupMembers (READ)
+get group members
+**Parameters:**
+- `groupId`: string
+
+### users_getGroups (READ)
+get groups
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ uid: string | null;
+ } (optional)
+
+### users_getGroupEmails (READ)
+get group emails
+**Parameters:**
+- `groupIds`: string[]
+
+### users_getPermissionsByEmployeeType (READ)
+get permissions by employee type
+**Parameters:**
+- `employeeTypeId`: string
+
+### users_getSuppliers (READ)
+get suppliers
+**Parameters:**
+- `args`: GenericQueryFilters & {
+ search: string | null;
+ }
+
+### users_getUsers (READ)
+get users
+**Parameters:** none (context auto-filled)
+
+### users_getUserEmails (READ)
+get user emails
+**Parameters:**
+- `userIds`: string[]
+
+### users_insertEmployeeType (WRITE)
+insert employee type
+**Parameters:**
+- `employeeType`: { name: string; companyId: string }
+
+### users_insertGroup (WRITE)
+insert group
+**Parameters:**
+- `group`: { name: string; companyId: string }
+
+### users_upsertEmployeeType (WRITE)
+upsert employee type
+**Parameters:**
+- `employeeType`: | { name: string; companyId: string }
+ | { id: string; name: string }
+
+### users_upsertEmployeeTypePermissions (WRITE)
+upsert employee type permissions
+**Parameters:**
+- `employeeTypeId`: string
+- `permissions`: { name: string; permission: CompanyPermission }[]
+
+### users_upsertGroup (WRITE)
+upsert group
+**Parameters:**
+- `arg1`: {
+ id: string;
+ name: string;
+ companyId: string;
+ }
+
+### users_upsertGroupMembers (WRITE)
+upsert group members
+**Parameters:**
+- `groupId`: string
+- `selections`: string[]
diff --git a/package-lock.json b/package-lock.json
index 61c64717d3..ef21eab625 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -240,6 +240,7 @@
"@epic-web/remember": "^1.1.0",
"@internationalized/date": "^3.5.2",
"@marsidev/react-turnstile": "^1.1.0",
+ "@modelcontextprotocol/sdk": "^1.29.0",
"@monaco-editor/react": "^4.6.0",
"@nanostores/react": "^0.7.1",
"@novu/framework": "^2.9.0",
@@ -447,13 +448,6 @@
"node": ">=14.0.0"
}
},
- "apps/erp/node_modules/zod-to-json-schema": {
- "version": "3.25.1",
- "license": "ISC",
- "peerDependencies": {
- "zod": "^3.25 || ^4"
- }
- },
"apps/mes": {
"dependencies": {
"@carbon/auth": "*",
@@ -3054,6 +3048,18 @@
"@hapi/hoek": "^9.0.0"
}
},
+ "node_modules/@hono/node-server": {
+ "version": "1.19.13",
+ "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-1.19.13.tgz",
+ "integrity": "sha512-TsQLe4i2gvoTtrHje625ngThGBySOgSK3Xo2XRYOdqGN1teR8+I7vchQC46uLJi8OF62YTYA3AhSpumtkhsaKQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=18.14.1"
+ },
+ "peerDependencies": {
+ "hono": "^4"
+ }
+ },
"node_modules/@hookform/resolvers": {
"version": "3.10.0",
"license": "MIT",
@@ -3202,6 +3208,72 @@
"integrity": "sha512-EMlH1e30yzmTpGLQjlFmaDAjyOeZhng1/XCd7DExR8PNAnG/G1tyruZxEoUe11ClnwGhGrtsdnyyUx1frSzjng==",
"license": "MIT"
},
+ "node_modules/@modelcontextprotocol/sdk": {
+ "version": "1.29.0",
+ "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.29.0.tgz",
+ "integrity": "sha512-zo37mZA9hJWpULgkRpowewez1y6ML5GsXJPY8FI0tBBCd77HEvza4jDqRKOXgHNn867PVGCyTdzqpz0izu5ZjQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@hono/node-server": "^1.19.9",
+ "ajv": "^8.17.1",
+ "ajv-formats": "^3.0.1",
+ "content-type": "^1.0.5",
+ "cors": "^2.8.5",
+ "cross-spawn": "^7.0.5",
+ "eventsource": "^3.0.2",
+ "eventsource-parser": "^3.0.0",
+ "express": "^5.2.1",
+ "express-rate-limit": "^8.2.1",
+ "hono": "^4.11.4",
+ "jose": "^6.1.3",
+ "json-schema-typed": "^8.0.2",
+ "pkce-challenge": "^5.0.0",
+ "raw-body": "^3.0.0",
+ "zod": "^3.25 || ^4.0",
+ "zod-to-json-schema": "^3.25.1"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "peerDependencies": {
+ "@cfworker/json-schema": "^4.1.1",
+ "zod": "^3.25 || ^4.0"
+ },
+ "peerDependenciesMeta": {
+ "@cfworker/json-schema": {
+ "optional": true
+ },
+ "zod": {
+ "optional": false
+ }
+ }
+ },
+ "node_modules/@modelcontextprotocol/sdk/node_modules/ajv-formats": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz",
+ "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==",
+ "license": "MIT",
+ "dependencies": {
+ "ajv": "^8.0.0"
+ },
+ "peerDependencies": {
+ "ajv": "^8.0.0"
+ },
+ "peerDependenciesMeta": {
+ "ajv": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@modelcontextprotocol/sdk/node_modules/jose": {
+ "version": "6.2.2",
+ "resolved": "https://registry.npmjs.org/jose/-/jose-6.2.2.tgz",
+ "integrity": "sha512-d7kPDd34KO/YnzaDOlikGpOurfF0ByC2sEV4cANCtdqLlTfBlw2p14O/5d/zv40gJPbIQxfES3nSx1/oYNyuZQ==",
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/panva"
+ }
+ },
"node_modules/@monaco-editor/loader": {
"version": "1.7.0",
"license": "MIT",
@@ -14091,6 +14163,24 @@
"url": "https://opencollective.com/express"
}
},
+ "node_modules/express-rate-limit": {
+ "version": "8.3.2",
+ "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.3.2.tgz",
+ "integrity": "sha512-77VmFeJkO0/rvimEDuUC5H30oqUC4EyOhyGccfqoLebB0oiEYfM7nwPrsDsBL1gsTpwfzX8SFy2MT3TDyRq+bg==",
+ "license": "MIT",
+ "dependencies": {
+ "ip-address": "10.1.0"
+ },
+ "engines": {
+ "node": ">= 16"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/express-rate-limit"
+ },
+ "peerDependencies": {
+ "express": ">= 4.11"
+ }
+ },
"node_modules/express/node_modules/cookie": {
"version": "0.7.2",
"license": "MIT",
@@ -15075,6 +15165,15 @@
"version": "16.13.1",
"license": "MIT"
},
+ "node_modules/hono": {
+ "version": "4.12.12",
+ "resolved": "https://registry.npmjs.org/hono/-/hono-4.12.12.tgz",
+ "integrity": "sha512-p1JfQMKaceuCbpJKAPKVqyqviZdS0eUxH9v82oWo1kb9xjQ5wA6iP3FNVAPDFlz5/p7d45lO+BpSk1tuSZMF4Q==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=16.9.0"
+ }
+ },
"node_modules/hosted-git-info": {
"version": "2.8.9",
"dev": true,
@@ -15384,6 +15483,15 @@
"ioredis": "^5"
}
},
+ "node_modules/ip-address": {
+ "version": "10.1.0",
+ "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.1.0.tgz",
+ "integrity": "sha512-XXADHxXmvT9+CRxhXg56LJovE+bmWnEWB78LB83VZTprKTmaC5QfruXocxzTZ2Kl0DNwKuBdlIhjL8LeY8Sf8Q==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 12"
+ }
+ },
"node_modules/ipaddr.js": {
"version": "1.9.1",
"license": "MIT",
@@ -16181,6 +16289,12 @@
"version": "1.0.0",
"license": "MIT"
},
+ "node_modules/json-schema-typed": {
+ "version": "8.0.2",
+ "resolved": "https://registry.npmjs.org/json-schema-typed/-/json-schema-typed-8.0.2.tgz",
+ "integrity": "sha512-fQhoXdcvc3V28x7C7BMs4P5+kNlgUURe2jmUT1T//oBRMDrqy1QPelJimwZGo7Hg9VPV3EQV5Bnq4hbFy2vetA==",
+ "license": "BSD-2-Clause"
+ },
"node_modules/json-stable-stringify": {
"version": "1.3.0",
"dev": true,
@@ -18853,6 +18967,15 @@
"node": ">= 6"
}
},
+ "node_modules/pkce-challenge": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.1.tgz",
+ "integrity": "sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=16.20.0"
+ }
+ },
"node_modules/pkg-types": {
"version": "2.3.0",
"license": "MIT",
@@ -24243,12 +24366,12 @@
}
},
"node_modules/zod-to-json-schema": {
- "version": "3.24.3",
+ "version": "3.25.2",
+ "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.2.tgz",
+ "integrity": "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA==",
"license": "ISC",
- "optional": true,
- "peer": true,
"peerDependencies": {
- "zod": "^3.24.1"
+ "zod": "^3.25.28 || ^4"
}
},
"node_modules/zod-validation-error": {
diff --git a/scripts/generate-mcp.ts b/scripts/generate-mcp.ts
new file mode 100644
index 0000000000..86098f9ef3
--- /dev/null
+++ b/scripts/generate-mcp.ts
@@ -0,0 +1,909 @@
+/**
+ * MCP Tool Code Generator
+ *
+ * Parses all *.service.ts files and generates:
+ * 1. Tool registration files in apps/erp/app/modules/mcp/tools/
+ * 2. Documentation in llm/cache/mcp-tools-reference.md
+ *
+ * Usage: npx tsx scripts/generate-mcp.ts
+ */
+
+import { Project, SyntaxKind, type Type, type Symbol as TsSymbol, type Node } from "ts-morph";
+import * as path from "path";
+import * as fs from "fs";
+
+const ROOT = path.resolve(__dirname, "..");
+const MODULES_DIR = path.join(ROOT, "apps/erp/app/modules");
+const MCP_LIB_DIR = path.join(ROOT, "apps/erp/app/routes/api+/mcp+/lib");
+const TOOLS_DIR = path.join(MCP_LIB_DIR, "tools");
+const DOCS_PATH = path.join(ROOT, "llm/cache/mcp-tools-reference.md");
+
+// Parameters that should be auto-filled from McpContext
+const CONTEXT_PARAM_NAMES = ["companyId", "userId", "createdBy", "updatedBy"];
+const CONTEXT_PARAMS = new Set(CONTEXT_PARAM_NAMES);
+
+// Classify function by prefix
+function classifyFunction(name: string): "READ" | "WRITE" | "DESTRUCTIVE" {
+ if (name.startsWith("delete")) return "DESTRUCTIVE";
+ if (name.startsWith("get") || name.startsWith("list") || name.startsWith("fetch"))
+ return "READ";
+ return "WRITE";
+}
+
+function annotationConst(classification: "READ" | "WRITE" | "DESTRUCTIVE"): string {
+ switch (classification) {
+ case "READ":
+ return "READ_ONLY_ANNOTATIONS";
+ case "WRITE":
+ return "WRITE_ANNOTATIONS";
+ case "DESTRUCTIVE":
+ return "DESTRUCTIVE_ANNOTATIONS";
+ }
+}
+
+interface ParamInfo {
+ name: string;
+ zodSchema: string;
+ tsType: string;
+ isContextParam: boolean;
+ isOptional: boolean;
+}
+
+interface FunctionInfo {
+ name: string;
+ params: ParamInfo[];
+ classification: "READ" | "WRITE" | "DESTRUCTIVE";
+ /** Parameters that need validator imports from .models */
+ validatorImports: Set<string>;
+}
+
+interface ModuleInfo {
+ moduleName: string;
+ servicePath: string;
+ modelsPath: string | null;
+ functions: FunctionInfo[];
+ /** Maps validator name → import source path (resolved from the service file's imports) */
+ validatorSources: Map<string, string>;
+}
+
+/**
+ * Convert a source-level type annotation to a Zod schema string.
+ * This works from the raw annotation text to avoid deep type resolution
+ * that would expand z.infer<typeof X> into Zod's internal class hierarchy.
+ */
+function annotationToZod(
+ annotationText: string,
+ resolvedType: Type,
+ validatorImports: Set<string>
+): string {
+ const text = annotationText.trim();
+
+ // No annotation — fall back to resolved type for simple cases
+ if (!text) {
+ if (resolvedType.isString()) return "z.string()";
+ if (resolvedType.isNumber()) return "z.number()";
+ if (resolvedType.isBoolean()) return "z.boolean()";
+ return "z.any()";
+ }
+
+ // Simple primitives
+ if (text === "string") return "z.string()";
+ if (text === "number") return "z.number()";
+ if (text === "boolean") return "z.boolean()";
+ if (text === "Json") return "z.any()";
+
+ // z.infer<typeof xxxValidator> — reference the validator directly
+ const inferMatch = text.match(/z\.infer<typeof\s+(\w+)>/);
+ if (inferMatch) {
+ validatorImports.add(inferMatch[1]);
+ return `${inferMatch[1]}`;
+ }
+
+ // GenericQueryFilters (with or without intersection)
+ if (text.includes("GenericQueryFilters")) {
+ // Extract any additional properties from intersection: GenericQueryFilters & { search: string | null }
+ const extraMatch = text.match(/GenericQueryFilters\s*&\s*\{([^}]*)\}/s);
+ const baseParts = [
+ " limit: z.number().int().default(100)",
+ " offset: z.number().int().default(0)",
+ ];
+ if (extraMatch) {
+ const extraProps = parseInlineObjectProps(extraMatch[1]);
+ return `z.object({\n${[...baseParts, ...extraProps].join(",\n")}\n })`;
+ }
+ // Handle Omit<GenericQueryFilters, "..."> & { ... }
+ if (text.includes("Omit<GenericQueryFilters")) {
+ const omitMatch = text.match(/Omit<GenericQueryFilters,\s*["']([^"']+)["']>/);
+ const omitKeys = omitMatch ? omitMatch[1].split("|").map(s => s.trim().replace(/['"]/g, "")) : [];
+ const filteredParts = baseParts.filter(p => !omitKeys.some(k => p.includes(k)));
+ const extraAfterOmit = text.match(/>\s*&\s*\{([^}]*)\}/s);
+ const extraProps = extraAfterOmit ? parseInlineObjectProps(extraAfterOmit[1]) : [];
+ return `z.object({\n${[...filteredParts, ...extraProps].join(",\n")}\n })`;
+ }
+ return `z.object({\n${baseParts.join(",\n")}\n })`;
+ }
+
+ // Nullable shorthand: string | null
+ if (text.match(/^(\w+)\s*\|\s*null$/)) {
+ const inner = text.replace(/\s*\|\s*null$/, "").trim();
+ const innerZod = primitiveToZod(inner);
+ return `${innerZod}.nullable()`;
+ }
+
+ // Union types involving validators or complex objects — use z.any()
+ if (text.includes("|") && text.includes("z.infer")) {
+ // Extract all validator names
+ const validatorMatches = text.matchAll(/z\.infer<typeof\s+(\w+)>/g);
+ for (const m of validatorMatches) {
+ validatorImports.add(m[1]);
+ }
+ return "z.any()";
+ }
+
+ // Inline object type: { id: string; name: string; ... }
+ if (text.startsWith("{")) {
+ const inner = text.slice(1, -1);
+ const props = parseInlineObjectProps(inner);
+ return `z.object({\n${props.join(",\n")}\n })`;
+ }
+
+ // Array types
+ if (text.endsWith("[]")) {
+ const elementType = text.slice(0, -2);
+ return `z.array(${primitiveToZod(elementType)})`;
+ }
+
+ // Complex union/intersection with Omit, z.infer, etc. — too complex for auto-gen
+ if (text.includes("Omit<") || text.includes("z.infer<") || text.includes("&")) {
+ // Extract all validator names for imports even if we use z.any()
+ const validatorMatches = text.matchAll(/z\.infer<typeof\s+(\w+)>/g);
+ for (const m of validatorMatches) {
+ validatorImports.add(m[1]);
+ }
+ return "z.any()";
+ }
+
+ // String literal type
+ if (text.startsWith('"') || text.startsWith("'")) return "z.string()";
+
+ // Named types we don't know about — z.any()
+ return "z.any()";
+}
+
+/**
+ * Parse inline object properties from source text like "id: string; name: string | null"
+ */
+function parseInlineObjectProps(propsText: string): string[] {
+ const results: string[] = [];
+ // Split on semicolons or newlines
+ const parts = propsText.split(/[;\n]/).map(s => s.trim()).filter(Boolean);
+ for (const part of parts) {
+ const colonIndex = part.indexOf(":");
+ if (colonIndex === -1) continue;
+ let propName = part.slice(0, colonIndex).trim();
+ const typeStr = part.slice(colonIndex + 1).trim();
+
+ const isOptional = propName.endsWith("?");
+ if (isOptional) propName = propName.slice(0, -1).trim();
+
+ // Skip context params
+ if (CONTEXT_PARAMS.has(propName)) continue;
+
+ let zodType = primitiveToZod(typeStr);
+ if (isOptional && !zodType.includes(".optional()")) {
+ zodType += ".optional()";
+ }
+ results.push(` ${propName}: ${zodType}`);
+ }
+ return results;
+}
+
+/**
+ * Convert a primitive-ish type string to Zod
+ */
+function primitiveToZod(typeStr: string): string {
+ const t = typeStr.trim();
+ if (t === "string") return "z.string()";
+ if (t === "number") return "z.number()";
+ if (t === "boolean") return "z.boolean()";
+ if (t === "Json") return "z.any()";
+ if (t === "string | null") return "z.string().nullable()";
+ if (t === "number | null") return "z.number().nullable()";
+ if (t === "boolean | null") return "z.boolean().nullable()";
+ if (t.endsWith("[]")) return `z.array(${primitiveToZod(t.slice(0, -2))})`;
+ // String literal unions like "Draft" | "Active"
+ if (t.includes('" | "') || t.includes("' | '")) {
+ const values = t.split("|").map(s => s.trim().replace(/['"]/g, ""));
+ return `z.enum([${values.map(v => `"${v}"`).join(", ")}])`;
+ }
+ return "z.any()";
+}
+
+/**
+ * Safely get the type of a property symbol.
+ * Falls back to z.any() representation for properties from mapped types,
+ * Omit/Pick, or other type operations that lack value declarations.
+ */
+function getPropertyType(prop: TsSymbol): Type | null {
+ const decl = prop.getValueDeclaration();
+ if (decl) return decl.getType();
+
+ // Try declarations (plural) as fallback
+ const decls = prop.getDeclarations();
+ if (decls.length > 0) return decls[0].getType();
+
+ return null;
+}
+
+/**
+ * Convert a TypeScript type to a Zod schema string
+ */
+function typeToZod(
+ type: Type,
+ validatorImports: Set<string>,
+ depth: number = 0
+): string {
+ if (depth > 5) return "z.any()";
+
+ const typeText = type.getText();
+
+ // Check for z.infer<typeof xxxValidator> pattern
+ const inferMatch = typeText.match(
+ /z\.infer<typeof\s+(\w+)>/
+ );
+ if (inferMatch) {
+ validatorImports.add(inferMatch[1]);
+ return `${inferMatch[1]}`;
+ }
+
+ // Primitives
+ if (type.isString() || type.isStringLiteral()) return "z.string()";
+ if (type.isNumber() || type.isNumberLiteral()) return "z.number()";
+ if (type.isBoolean() || type.isBooleanLiteral()) return "z.boolean()";
+
+ // null / undefined
+ if (typeText === "null") return "z.null()";
+ if (typeText === "undefined") return "z.undefined()";
+
+ // Json type
+ if (typeText === "Json") return "z.any()";
+
+ // string literal unions
+ if (type.isUnion()) {
+ const unionTypes = type.getUnionTypes();
+
+ // Check if it's a nullable type (T | null)
+ const nonNullTypes = unionTypes.filter((t) => t.getText() !== "null");
+ const hasNull = nonNullTypes.length < unionTypes.length;
+ const nonUndefinedTypes = nonNullTypes.filter(
+ (t) => t.getText() !== "undefined"
+ );
+ const hasUndefined = nonNullTypes.length > nonUndefinedTypes.length;
+
+ if (nonUndefinedTypes.length === 1 && (hasNull || hasUndefined)) {
+ const inner = typeToZod(nonUndefinedTypes[0], validatorImports, depth + 1);
+ if (hasNull && hasUndefined) return `${inner}.nullable().optional()`;
+ if (hasNull) return `${inner}.nullable()`;
+ return `${inner}.optional()`;
+ }
+
+ // String literal union → z.enum
+ if (unionTypes.every((t) => t.isStringLiteral())) {
+ const values = unionTypes.map((t) =>
+ t.getText().replace(/^"/, "").replace(/"$/, "")
+ );
+ return `z.enum([${values.map((v) => `"${v}"`).join(", ")}])`;
+ }
+
+ // Generic union → z.union
+ if (nonUndefinedTypes.length > 1) {
+ const schemas = nonUndefinedTypes.map((t) =>
+ typeToZod(t, validatorImports, depth + 1)
+ );
+ return `z.union([${schemas.join(", ")}])`;
+ }
+ }
+
+ // Arrays
+ if (type.isArray()) {
+ const elementType = type.getArrayElementTypeOrThrow();
+ return `z.array(${typeToZod(elementType, validatorImports, depth + 1)})`;
+ }
+
+ // Object types (interfaces, type literals)
+ if (type.isObject() && !type.isArray()) {
+ const properties = type.getProperties();
+ if (properties.length === 0) return "z.object({})";
+
+ // Check for index signatures (Record types)
+ const stringIndex = type.getStringIndexType();
+ if (stringIndex) {
+ return `z.record(z.string(), ${typeToZod(stringIndex, validatorImports, depth + 1)})`;
+ }
+
+ const props = properties
+ .map((prop) => {
+ const propName = prop.getName();
+ const propType = getPropertyType(prop);
+ if (!propType) return ` ${propName}: z.any()`;
+ const isOptional = prop.isOptional();
+ let zodType = typeToZod(propType, validatorImports, depth + 1);
+ if (isOptional && !zodType.includes(".optional()")) {
+ zodType += ".optional()";
+ }
+ return ` ${propName}: ${zodType}`;
+ })
+ .join(",\n");
+
+ return `z.object({\n${props}\n })`;
+ }
+
+ // Intersection types - merge properties
+ if (type.isIntersection()) {
+ const intersectionTypes = type.getIntersectionTypes();
+ const allProps: string[] = [];
+
+ for (const t of intersectionTypes) {
+ const zodStr = typeToZod(t, validatorImports, depth + 1);
+ // If it resolves to a z.object, extract its properties
+ if (zodStr.startsWith("z.object(")) {
+ // We'll just use .merge pattern
+ allProps.push(zodStr);
+ } else {
+ // It's a named validator or other type
+ allProps.push(zodStr);
+ }
+ }
+
+ if (allProps.length === 1) return allProps[0];
+ // For intersections, use the first and merge the rest
+ return allProps.reduce((acc, curr) => {
+ if (acc.startsWith("z.object(") && curr.startsWith("z.object(")) {
+ return `${acc}.merge(${curr})`;
+ }
+ return `${acc}.and(${curr})`;
+ });
+ }
+
+ // Fallback
+ return "z.any()";
+}
+
+/**
+ * Extract function info and validator import sources from a service file
+ */
+function extractFunctions(
+ project: Project,
+ filePath: string,
+ moduleName: string
+): { functions: FunctionInfo[]; validatorSources: Map<string, string> } {
+ const sourceFile = project.addSourceFileAtPath(filePath);
+
+ // Build a map of imported names → their source module path
+ // This lets us know where validators are actually imported from
+ const validatorSources = new Map<string, string>();
+ for (const imp of sourceFile.getImportDeclarations()) {
+ const moduleSpecifier = imp.getModuleSpecifierValue();
+ for (const named of imp.getNamedImports()) {
+ const name = named.getName();
+ if (name.endsWith("Validator") || name.endsWith("Type") || name.endsWith("type")) {
+ validatorSources.set(name, moduleSpecifier);
+ }
+ }
+ }
+ const functions: FunctionInfo[] = [];
+
+ for (const fn of sourceFile.getFunctions()) {
+ if (!fn.isExported()) continue;
+ if (!fn.isAsync()) continue;
+
+ const name = fn.getName();
+ if (!name) continue;
+
+ const classification = classifyFunction(name);
+ const validatorImports = new Set<string>();
+ const params: ParamInfo[] = [];
+
+ const fnParams = fn.getParameters();
+
+ for (let i = 0; i < fnParams.length; i++) {
+ const param = fnParams[i];
+ let paramName = param.getName();
+ const paramType = param.getType();
+
+ // Get the source-level type annotation text (before TS resolves it)
+ const typeNode = param.getTypeNode();
+ const annotationText = typeNode?.getText() ?? "";
+ const resolvedText = paramType.getText();
+
+ // Skip the first parameter if it's a SupabaseClient
+ if (i === 0 && (annotationText.includes("SupabaseClient") || resolvedText.includes("SupabaseClient"))) continue;
+
+ // Handle destructured parameters — give them a synthetic name
+ const isDestructured = paramName.startsWith("{") || paramName.startsWith("[");
+ if (isDestructured) {
+ paramName = `arg${i}`;
+ }
+
+ const isContextParam = CONTEXT_PARAMS.has(paramName);
+ const isOptional = param.isOptional() || param.hasInitializer();
+
+ let zodSchema: string;
+
+ // Use annotation text to detect patterns BEFORE deep type resolution
+ zodSchema = annotationToZod(annotationText, paramType, validatorImports);
+
+ params.push({
+ name: paramName,
+ zodSchema,
+ tsType: annotationText || resolvedText,
+ isContextParam,
+ isOptional,
+ });
+ }
+
+ functions.push({ name, params, classification, validatorImports });
+ }
+
+ return { functions, validatorSources };
+}
+
+/**
+ * Generate tool file content for a module
+ */
+function generateToolFile(module: ModuleInfo): string {
+ const { moduleName, functions } = module;
+ const registerName = `register${capitalize(moduleName)}Tools`;
+
+ // Collect all validator imports needed
+ const allValidatorImports = new Set<string>();
+ for (const fn of functions) {
+ for (const v of fn.validatorImports) {
+ allValidatorImports.add(v);
+ }
+ }
+
+ // Collect all function imports
+ const fnNames = functions.map((f) => f.name);
+
+ let imports = `import { z } from "zod";
+import type { RegisterTools } from "../types";
+import {
+ READ_ONLY_ANNOTATIONS,
+ WRITE_ANNOTATIONS,
+ DESTRUCTIVE_ANNOTATIONS,
+ toMcpResult,
+ withErrorHandling,
+} from "../types";
+import {
+${fnNames.map((n) => ` ${n},`).join("\n")}
+} from "~/modules/${moduleName}/${moduleName}.service";`;
+
+ // Group validator imports by their actual source module
+ if (allValidatorImports.size > 0) {
+ const importsBySource = new Map<string, string[]>();
+ for (const v of allValidatorImports) {
+ const source = module.validatorSources.get(v);
+ // Resolve the import path: use the original source if available,
+ // otherwise fall back to the module's own models file
+ let importPath: string;
+ if (source) {
+ // Convert relative paths from the service file to be relative to mcp/tools/
+ // Service files are at ~/modules/{mod}/{mod}.service.ts
+ // Tool files are at ~/modules/mcp/tools/{mod}.ts
+ // So "../shared" from items.service.ts → "~/modules/shared"
+ if (source.startsWith("../")) {
+ importPath = `~/modules/${source.slice(3)}`;
+ } else if (source.startsWith("./")) {
+ importPath = `~/modules/${moduleName}/${source.slice(2)}`;
+ } else if (source.startsWith("~/")) {
+ importPath = source;
+ } else {
+ // External package — use as-is
+ importPath = source;
+ }
+ } else if (module.modelsPath) {
+ importPath = `~/modules/${moduleName}/${moduleName}.models`;
+ } else {
+ continue; // Skip if no source found and no models file
+ }
+ if (!importsBySource.has(importPath)) {
+ importsBySource.set(importPath, []);
+ }
+ importsBySource.get(importPath)!.push(v);
+ }
+
+ for (const [importPath, names] of importsBySource) {
+ imports += `\nimport {
+${names.map((n) => ` ${n},`).join("\n")}
+} from "${importPath}";`;
+ }
+ }
+
+ const toolRegistrations = functions
+ .map((fn) => generateToolRegistration(moduleName, fn))
+ .join("\n\n");
+
+ return `// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+${imports}
+
+export const ${registerName}: RegisterTools = (server, ctx) => {
+${toolRegistrations}
+};
+`;
+}
+
+/**
+ * Generate a single tool registration
+ */
+function generateToolRegistration(moduleName: string, fn: FunctionInfo): string {
+ const toolName = `${moduleName}_${fn.name}`;
+ const annotation = annotationConst(fn.classification);
+
+ // Build the input schema
+ const inputSchemaEntries: string[] = [];
+ const callArgs: string[] = ["ctx.client"];
+
+ for (const param of fn.params) {
+ if (param.isContextParam) {
+ // Auto-fill from context
+ if (param.name === "companyId") callArgs.push("ctx.companyId");
+ else if (param.name === "userId") callArgs.push("ctx.userId");
+ else if (param.name === "createdBy") callArgs.push("ctx.userId");
+ else if (param.name === "updatedBy") callArgs.push("ctx.userId");
+ continue;
+ }
+
+ // For object params that have context fields filtered out, we need special handling
+ if (param.zodSchema.startsWith("z.object(")) {
+ inputSchemaEntries.push(
+ ` ${param.name}: ${param.zodSchema}${param.isOptional ? ".optional()" : ""}`
+ );
+ callArgs.push(`params.${param.name}`);
+ } else {
+ inputSchemaEntries.push(
+ ` ${param.name}: ${param.zodSchema}${param.isOptional ? ".optional()" : ""}`
+ );
+ callArgs.push(`params.${param.name}`);
+ }
+ }
+
+ // If there are no visible params, check if we only had context params
+ // In that case, we still need to pass them through
+ const hasVisibleParams = fn.params.some((p) => !p.isContextParam);
+
+ // Build the handler
+ const inputSchema =
+ inputSchemaEntries.length > 0
+ ? `{\n${inputSchemaEntries.join(",\n")},\n }`
+ : "{}";
+
+ // Check if context params are embedded INSIDE an object parameter's type
+ // (e.g., `payload: { id, companyId, userId }`) vs being separate positional params
+ // (e.g., `(client, companyId, args)`). Only merge when context is inside the object.
+ const objectParamsWithEmbeddedContext = fn.params.filter(
+ (p) =>
+ !p.isContextParam &&
+ CONTEXT_PARAM_NAMES.some((cp) => p.tsType.includes(cp))
+ );
+
+ let handlerBody: string;
+
+ if (objectParamsWithEmbeddedContext.length > 0) {
+ // Context params live inside the object param — merge them in
+ const objectParam = objectParamsWithEmbeddedContext[0];
+
+ // Detect which context fields appear in the type annotation
+ const embeddedContextFields: string[] = [];
+ for (const cp of CONTEXT_PARAM_NAMES) {
+ // Check for the field name in the type annotation (as a property, not substring)
+ if (new RegExp(`\\b${cp}\\b`).test(objectParam.tsType)) {
+ if (cp === "createdBy" || cp === "updatedBy") {
+ embeddedContextFields.push(`${cp}: ctx.userId`);
+ } else {
+ embeddedContextFields.push(`${cp}: ctx.${cp}`);
+ }
+ }
+ }
+
+ // Also include any separate context params from callArgs
+ const separateContextAssignments = fn.params
+ .filter((p) => p.isContextParam)
+ .map((p) => {
+ if (p.name === "createdBy" || p.name === "updatedBy")
+ return `${p.name}: ctx.userId`;
+ return `${p.name}: ctx.${p.name}`;
+ });
+
+ const allContextAssignments = [
+ ...new Set([...embeddedContextFields, ...separateContextAssignments]),
+ ].join(", ");
+
+ // Build call args, replacing the object param with the merged version
+ const mergedCallArgs = callArgs.map((arg) =>
+ arg === `params.${objectParam.name}`
+ ? `{ ...params.${objectParam.name}, ${allContextAssignments} }`
+ : arg
+ );
+
+ handlerBody = ` const result = await ${fn.name}(${mergedCallArgs.join(", ")});
+ return toMcpResult(result);`;
+ } else {
+ handlerBody = ` const result = await ${fn.name}(${callArgs.join(", ")});
+ return toMcpResult(result);`;
+ }
+
+ // Build description from function name
+ const description = humanizeFunction(fn.name, moduleName);
+
+ return ` server.registerTool(
+ "${toolName}",
+ {
+ description: "${description}",
+ inputSchema: ${inputSchema},
+ annotations: ${annotation},
+ },
+ withErrorHandling(async (params) => {
+${handlerBody}
+ }, "Failed: ${toolName}"),
+ );`;
+}
+
+function humanizeFunction(name: string, moduleName: string): string {
+ // Split camelCase
+ const words = name
+ .replace(/([A-Z])/g, " $1")
+ .toLowerCase()
+ .trim()
+ .split(" ");
+ return words.join(" ");
+}
+
+function capitalize(s: string): string {
+ return s.charAt(0).toUpperCase() + s.slice(1);
+}
+
+/**
+ * Generate the barrel export (index.ts)
+ */
+function generateBarrelExport(modules: ModuleInfo[]): string {
+ const imports = modules
+ .map(
+ (m) =>
+ `export { register${capitalize(m.moduleName)}Tools } from "./${m.moduleName}";`
+ )
+ .join("\n");
+
+ return `// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+${imports}
+`;
+}
+
+/**
+ * Generate the server.ts file
+ */
+function generateServerFile(modules: ModuleInfo[]): string {
+ const imports = modules
+ .map(
+ (m) =>
+ ` register${capitalize(m.moduleName)}Tools,`
+ )
+ .join("\n");
+
+ const registrations = modules
+ .map(
+ (m) =>
+ ` register${capitalize(m.moduleName)}Tools(server, ctx);`
+ )
+ .join("\n");
+
+ const moduleDescriptions = modules
+ .map((m) => {
+ const readCount = m.functions.filter(
+ (f) => f.classification === "READ"
+ ).length;
+ const writeCount = m.functions.filter(
+ (f) => f.classification === "WRITE"
+ ).length;
+ const deleteCount = m.functions.filter(
+ (f) => f.classification === "DESTRUCTIVE"
+ ).length;
+ return `- ${m.moduleName}_* — ${readCount} read, ${writeCount} write, ${deleteCount} delete tools`;
+ })
+ .join("\n");
+
+ return `// @ts-nocheck
+// AUTO-GENERATED by scripts/generate-mcp.ts — do not edit manually
+import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
+import type { McpContext } from "./types";
+import {
+${imports}
+} from "./tools";
+
+function getServerInstructions(): string {
+ const today = new Date().toISOString().split("T")[0];
+
+ return \`Carbon ERP is a manufacturing system. This MCP server provides access to ERP data including sales, purchasing, inventory, production, quality, and more.
+
+## Current Date
+Today is \${today}.
+
+## Tool Organization
+Tools are namespaced by module — use the prefix to discover related tools:
+${moduleDescriptions}
+
+## Key Patterns
+- All monetary amounts use the company's base currency unless specified.
+- Date parameters use ISO 8601 format (YYYY-MM-DD).
+- List tools support pagination via limit/offset (GenericQueryFilters).
+- companyId and userId are auto-filled from the authenticated context — do not provide them.
+- Most get/list tools return { data, error, count? } — check error before using data.
+- Tool errors return isError: true with a text explanation.
+\`;
+}
+
+export function createMcpServer(ctx: McpContext): McpServer {
+ const server = new McpServer(
+ {
+ name: "carbon-erp",
+ version: process.env.VERCEL_GIT_COMMIT_SHA?.slice(0, 7) ?? "1.0.0",
+ },
+ {
+ instructions: getServerInstructions(),
+ },
+ );
+
+${registrations}
+
+ return server;
+}
+`;
+}
+
+/**
+ * Generate documentation
+ */
+function generateDocs(modules: ModuleInfo[]): string {
+ let totalTools = 0;
+ const sections: string[] = [];
+
+ for (const module of modules) {
+ totalTools += module.functions.length;
+ const lines: string[] = [
+ `## ${module.moduleName} (${module.functions.length} tools)`,
+ "",
+ ];
+
+ for (const fn of module.functions) {
+ lines.push(
+ `### ${module.moduleName}_${fn.name} (${fn.classification})`
+ );
+ lines.push(humanizeFunction(fn.name, module.moduleName));
+
+ const visibleParams = fn.params.filter((p) => !p.isContextParam);
+ if (visibleParams.length > 0) {
+ lines.push("**Parameters:**");
+ for (const param of visibleParams) {
+ const opt = param.isOptional ? " (optional)" : "";
+ lines.push(`- \`${param.name}\`: ${param.tsType}${opt}`);
+ }
+ } else {
+ lines.push("**Parameters:** none (context auto-filled)");
+ }
+ lines.push("");
+ }
+
+ sections.push(lines.join("\n"));
+ }
+
+ return `# Carbon ERP MCP Tools Reference
+
+> Auto-generated by scripts/generate-mcp.ts
+> Total: ${totalTools} tools across ${modules.length} modules
+
+${sections.join("\n---\n\n")}`;
+}
+
+// ─── Main ──────────────────────────────────────────────────────────────
+
+async function main() {
+ console.log("Initializing TypeScript project...");
+
+ const project = new Project({
+ tsConfigFilePath: path.join(ROOT, "apps/erp/tsconfig.json"),
+ skipAddingFilesFromTsConfig: true,
+ });
+
+ // Find all service files
+ const serviceFiles = fs
+ .readdirSync(MODULES_DIR, { withFileTypes: true })
+ .filter((d) => d.isDirectory())
+ .map((d) => ({
+ moduleName: d.name,
+ servicePath: path.join(MODULES_DIR, d.name, `${d.name}.service.ts`),
+ modelsPath: fs.existsSync(
+ path.join(MODULES_DIR, d.name, `${d.name}.models.ts`)
+ )
+ ? path.join(MODULES_DIR, d.name, `${d.name}.models.ts`)
+ : null,
+ }))
+ .filter((m) => {
+ if (!fs.existsSync(m.servicePath)) {
+ console.log(` Skipping ${m.moduleName}: no service file`);
+ return false;
+ }
+ // Skip the mcp module itself
+ if (m.moduleName === "mcp") return false;
+ return true;
+ });
+
+ console.log(`Found ${serviceFiles.length} service modules`);
+
+ const modules: ModuleInfo[] = [];
+
+ for (const sf of serviceFiles) {
+ console.log(` Parsing ${sf.moduleName}...`);
+ try {
+ const { functions, validatorSources } = extractFunctions(project, sf.servicePath, sf.moduleName);
+ console.log(` → ${functions.length} exported functions`);
+
+ modules.push({
+ moduleName: sf.moduleName,
+ servicePath: sf.servicePath,
+ modelsPath: sf.modelsPath,
+ functions,
+ validatorSources,
+ });
+ } catch (err) {
+ console.error(` ✗ Error parsing ${sf.moduleName}:`, err);
+ }
+ }
+
+ // Ensure output directory exists
+ fs.mkdirSync(TOOLS_DIR, { recursive: true });
+
+ // Generate tool files
+ console.log("\nGenerating tool files...");
+ for (const module of modules) {
+ if (module.functions.length === 0) {
+ console.log(` Skipping ${module.moduleName}: no functions`);
+ continue;
+ }
+
+ const content = generateToolFile(module);
+ const outPath = path.join(TOOLS_DIR, `${module.moduleName}.ts`);
+ fs.writeFileSync(outPath, content);
+ console.log(` ✓ ${module.moduleName}.ts (${module.functions.length} tools)`);
+ }
+
+ // Generate barrel export
+ const barrelContent = generateBarrelExport(
+ modules.filter((m) => m.functions.length > 0)
+ );
+ fs.writeFileSync(path.join(TOOLS_DIR, "index.ts"), barrelContent);
+ console.log(" ✓ index.ts (barrel export)");
+
+ // Generate server.ts
+ const serverContent = generateServerFile(
+ modules.filter((m) => m.functions.length > 0)
+ );
+ fs.writeFileSync(path.join(MCP_LIB_DIR, "server.ts"), serverContent);
+ console.log(" ✓ server.ts");
+
+ // Generate docs
+ console.log("\nGenerating documentation...");
+ fs.mkdirSync(path.dirname(DOCS_PATH), { recursive: true });
+ const docs = generateDocs(modules.filter((m) => m.functions.length > 0));
+ fs.writeFileSync(DOCS_PATH, docs);
+ console.log(` ✓ ${path.relative(ROOT, DOCS_PATH)}`);
+
+ const totalTools = modules.reduce((sum, m) => sum + m.functions.length, 0);
+ console.log(`\nDone! Generated ${totalTools} tools across ${modules.length} modules.`);
+}
+
+main().catch((err) => {
+ console.error("Fatal error:", err);
+ process.exit(1);
+});