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.

review and cleanup

Gaurav Bhatt462d2323d1c1
diff --git a/apps/erp/app/routes/mcp+/_index.tsx b/apps/erp/app/routes/mcp+/_index.tsx
index eaac7620f6..0142f658d9 100644
--- a/apps/erp/app/routes/mcp+/_index.tsx
+++ b/apps/erp/app/routes/mcp+/_index.tsx
@@ -1,9 +1,9 @@
import type { LoaderFunctionArgs, MetaFunction } from "react-router";
import { useLoaderData } from "react-router";
-import McpStyle from "~/styles/mcp.css?url";
+import McpStyle from "~/styles/mcp-docs.css?url";
import { MCP_BLOCKED_TOOL_NAMES } from "../api+/mcp+/lib/mcp-blocked-tools";
import toolMetadata from "../api+/mcp+/lib/tool-metadata.json";
-import { buildMcpCatalog, type RawToolMeta } from "./catalog.server";
+import { buildMcpCatalog, type RawToolMeta } from "./catalog";
import { McpPage } from "./components/McpPage";
export const meta: MetaFunction = () => [
diff --git a/apps/erp/app/routes/mcp+/catalog.server.ts b/apps/erp/app/routes/mcp+/catalog.ts
similarity index 100%
rename from apps/erp/app/routes/mcp+/catalog.server.ts
rename to apps/erp/app/routes/mcp+/catalog.ts
diff --git a/apps/erp/app/routes/mcp+/components/CopyButton.tsx b/apps/erp/app/routes/mcp+/components/CopyButton.tsx
index 644f3b3300..0999b90e2b 100644
--- a/apps/erp/app/routes/mcp+/components/CopyButton.tsx
+++ b/apps/erp/app/routes/mcp+/components/CopyButton.tsx
@@ -1,6 +1,7 @@
import { cn } from "@carbon/react";
import { useState } from "react";
import { LuCheck, LuCopy } from "react-icons/lu";
+import { copyToClipboard } from "~/utils/string";
export function CopyButton({
text,
@@ -18,9 +19,10 @@ export function CopyButton({
aria-label={label}
className={cn(className, done && "done")}
onClick={() => {
- navigator.clipboard?.writeText(text);
- setDone(true);
- setTimeout(() => setDone(false), 1400);
+ copyToClipboard(text, () => {
+ setDone(true);
+ setTimeout(() => setDone(false), 1400);
+ });
}}
>
{done ? <LuCheck size={14} /> : <LuCopy size={14} />}
diff --git a/apps/erp/app/routes/mcp+/components/FlowDiagram.tsx b/apps/erp/app/routes/mcp+/components/FlowDiagram.tsx
index ccf41bacb5..202db91365 100644
--- a/apps/erp/app/routes/mcp+/components/FlowDiagram.tsx
+++ b/apps/erp/app/routes/mcp+/components/FlowDiagram.tsx
@@ -1,5 +1,5 @@
import { Fragment } from "react";
-import type { Classification } from "../catalog.server";
+import type { Classification } from "../catalog";
import { Tag } from "./Tag";
export interface FlowStep {
diff --git a/apps/erp/app/routes/mcp+/components/ImagePlaceholder.tsx b/apps/erp/app/routes/mcp+/components/ImagePlaceholder.tsx
deleted file mode 100644
index 73da675024..0000000000
--- a/apps/erp/app/routes/mcp+/components/ImagePlaceholder.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import { useState } from "react";
-
-export function ImagePlaceholder({
- src,
- alt,
- ratio = "16 / 9"
-}: {
- src?: string;
- alt: string;
- ratio?: string;
-}) {
- const [failed, setFailed] = useState(false);
-
- // Show the real screenshot once it exists; fall back to the labelled
- // placeholder while a src is missing or 404s (so it's never a broken image).
- if (src && !failed) {
- return (
- <img
- className="w-full rounded-[9px] block outline outline-1 outline-black/10 -outline-offset-1"
- src={src}
- alt={alt}
- onError={() => setFailed(true)}
- />
- );
- }
- return (
- <div
- className="w-full rounded-[9px] flex items-center justify-center bg-muted border border-dashed border-border text-muted-foreground"
- style={{ aspectRatio: ratio }}
- role="img"
- aria-label={alt}
- >
- <span className="font-[var(--mono)] text-[0.72rem] tracking-[0.04em] px-[14px] py-[10px] text-center">
- {alt}
- </span>
- </div>
- );
-}
diff --git a/apps/erp/app/routes/mcp+/components/McpPage.tsx b/apps/erp/app/routes/mcp+/components/McpPage.tsx
index 14ac44a3f4..69f5bc9a19 100644
--- a/apps/erp/app/routes/mcp+/components/McpPage.tsx
+++ b/apps/erp/app/routes/mcp+/components/McpPage.tsx
@@ -1,4 +1,4 @@
-import type { McpCatalog } from "../catalog.server";
+import type { McpCatalog } from "../catalog";
import { Authentication } from "./Authentication";
import { Cta } from "./Cta";
import { Faq } from "./Faq";
diff --git a/apps/erp/app/routes/mcp+/components/ModuleCards.tsx b/apps/erp/app/routes/mcp+/components/ModuleCards.tsx
index a63e2d7c52..25e82806fa 100644
--- a/apps/erp/app/routes/mcp+/components/ModuleCards.tsx
+++ b/apps/erp/app/routes/mcp+/components/ModuleCards.tsx
@@ -1,8 +1,44 @@
import { cn } from "@carbon/react";
import type { IconType } from "react-icons";
-import { LuLayoutGrid } from "react-icons/lu";
-import type { CatalogModule } from "../catalog.server";
-import { FALLBACK_MODULE_ICON, MODULE_ICONS } from "./module-icons";
+import {
+ LuBox,
+ LuCircleUser,
+ LuCrown,
+ LuFactory,
+ LuFiles,
+ LuFolderCheck,
+ LuLandmark,
+ LuLayers,
+ LuLayoutGrid,
+ LuReceipt,
+ LuSettings,
+ LuShield,
+ LuShoppingCart,
+ LuSquareStack,
+ LuUsers,
+ LuWrench
+} from "react-icons/lu";
+import type { CatalogModule } from "../catalog";
+
+// Mirrors the ERP module icons (app/hooks/useModules.tsx). invoicing/account/
+// shared have no top-level nav icon, so the closest lucide stands in.
+const MODULE_ICONS: Record<string, IconType> = {
+ sales: LuCrown,
+ items: LuSquareStack,
+ production: LuFactory,
+ purchasing: LuShoppingCart,
+ resources: LuWrench,
+ settings: LuSettings,
+ quality: LuFolderCheck,
+ accounting: LuLandmark,
+ inventory: LuBox,
+ people: LuUsers,
+ users: LuShield,
+ documents: LuFiles,
+ invoicing: LuReceipt,
+ account: LuCircleUser,
+ shared: LuLayers
+};
function Card({
icon: Icon,
@@ -71,7 +107,7 @@ export function ModuleCards({
{modules.map((m) => (
<Card
key={m.key}
- icon={MODULE_ICONS[m.key] ?? FALLBACK_MODULE_ICON}
+ icon={MODULE_ICONS[m.key] ?? LuBox}
label={m.label}
count={m.count}
active={value === m.key}
diff --git a/apps/erp/app/routes/mcp+/components/Nav.tsx b/apps/erp/app/routes/mcp+/components/Nav.tsx
index 3fc367a95b..2622f02ee6 100644
--- a/apps/erp/app/routes/mcp+/components/Nav.tsx
+++ b/apps/erp/app/routes/mcp+/components/Nav.tsx
@@ -3,7 +3,7 @@ import { ThemeToggle } from "./ThemeToggle";
export function Nav() {
return (
- <header className="sticky top-0 z-[999] h-[60px] flex items-center bg-[var(--canvas-blur)] backdrop-blur-[12px] saturate-[160%] border-b border-border">
+ <header className="sticky top-0 z-[999] h-[68px] flex items-center bg-[var(--canvas-blur)] backdrop-blur-[12px] saturate-[160%] border-b border-border">
<div className="container flex items-center gap-[26px] w-full">
<a
className="flex items-center gap-[9px] font-semibold text-base tracking-[-0.02em]"
diff --git a/apps/erp/app/routes/mcp+/components/SetupPipeline.tsx b/apps/erp/app/routes/mcp+/components/SetupPipeline.tsx
index 969a3b5a09..5e8fa5adc3 100644
--- a/apps/erp/app/routes/mcp+/components/SetupPipeline.tsx
+++ b/apps/erp/app/routes/mcp+/components/SetupPipeline.tsx
@@ -2,7 +2,6 @@ import { cn } from "@carbon/react";
import { useEffect, useState } from "react";
import { LuArrowDown, LuPlug, LuTerminal } from "react-icons/lu";
import { CopyButton } from "./CopyButton";
-import { ImagePlaceholder } from "./ImagePlaceholder";
import { CLIENTS, type Client, ENDPOINT } from "./mcp-content";
import { SELECT_CLIENT_EVENT } from "./quickstart-nav";
@@ -161,7 +160,11 @@ export function SetupPipeline() {
</pre>
</div>
)}
- <ImagePlaceholder src={s.img} alt={s.alt} />
+ <img
+ src={s.img}
+ alt={s.alt}
+ className="w-full rounded-[9px] block outline outline-1 outline-black/10 -outline-offset-1"
+ />
</div>
{i < steps.length - 1 && (
<div
diff --git a/apps/erp/app/routes/mcp+/components/ThemeToggle.tsx b/apps/erp/app/routes/mcp+/components/ThemeToggle.tsx
index ba946c5c01..2a1a1b4c72 100644
--- a/apps/erp/app/routes/mcp+/components/ThemeToggle.tsx
+++ b/apps/erp/app/routes/mcp+/components/ThemeToggle.tsx
@@ -1,29 +1,27 @@
-import { useEffect, useState } from "react";
+import { useMode } from "@carbon/react";
import { LuMoon, LuSun } from "react-icons/lu";
+import { useFetcher } from "react-router";
-// Toggles the app's light/dark mode. The token values are rendered server-side
-// from the `mode` cookie (see app/services/mode.server.ts), so we set the cookie
-// and reload to pick up the correct theme — the bulletproof, mechanism-matching way.
+// Uses the app's canonical mode mechanism: POST the new mode to the root action
+// (public — works signed-out), which sets the cookie and flips the theme
+// optimistically via useMode(). No reload.
export function ThemeToggle() {
- const [dark, setDark] = useState(false);
- useEffect(() => {
- setDark(document.documentElement.classList.contains("dark"));
- }, []);
-
- const toggle = () => {
- const next = !document.documentElement.classList.contains("dark");
- document.cookie = `mode=${next ? "dark" : "light"}; path=/; max-age=31536000; samesite=lax`;
- window.location.reload();
- };
+ const fetcher = useFetcher();
+ const mode = useMode();
+ const next = mode === "dark" ? "light" : "dark";
return (
- <button
- type="button"
- aria-label={dark ? "Switch to light mode" : "Switch to dark mode"}
- onClick={toggle}
- className="inline-flex items-center justify-center w-9 h-9 rounded-lg border border-border bg-card text-foreground hover:border-muted-foreground transition-[transform,border-color] duration-150 active:scale-[0.96]"
- >
- {dark ? <LuSun size={16} /> : <LuMoon size={16} />}
- </button>
+ <fetcher.Form method="post" action="/">
+ <input type="hidden" name="mode" value={next} />
+ <button
+ type="submit"
+ aria-label={
+ mode === "dark" ? "Switch to light mode" : "Switch to dark mode"
+ }
+ className="inline-flex items-center justify-center w-9 h-9 rounded-lg border border-border bg-card text-foreground hover:border-muted-foreground transition-[transform,border-color] duration-150 active:scale-[0.96]"
+ >
+ {mode === "dark" ? <LuSun size={16} /> : <LuMoon size={16} />}
+ </button>
+ </fetcher.Form>
);
}
diff --git a/apps/erp/app/routes/mcp+/components/ToolBrowser.tsx b/apps/erp/app/routes/mcp+/components/ToolBrowser.tsx
index 960128162f..0e68b1ee2b 100644
--- a/apps/erp/app/routes/mcp+/components/ToolBrowser.tsx
+++ b/apps/erp/app/routes/mcp+/components/ToolBrowser.tsx
@@ -1,6 +1,6 @@
import { useMemo, useState } from "react";
import { LuChevronDown } from "react-icons/lu";
-import type { CatalogModule, CatalogTool } from "../catalog.server";
+import type { CatalogModule, CatalogTool } from "../catalog";
import { filterTools } from "../tools-filter";
import { FilterSelect } from "./FilterSelect";
import { ModuleCards } from "./ModuleCards";
diff --git a/apps/erp/app/routes/mcp+/components/Tools.tsx b/apps/erp/app/routes/mcp+/components/Tools.tsx
index ab81e1b064..9c37604549 100644
--- a/apps/erp/app/routes/mcp+/components/Tools.tsx
+++ b/apps/erp/app/routes/mcp+/components/Tools.tsx
@@ -1,4 +1,4 @@
-import type { McpCatalog } from "../catalog.server";
+import type { McpCatalog } from "../catalog";
import { ToolBrowser } from "./ToolBrowser";
export function Tools({ catalog }: { catalog: McpCatalog }) {
diff --git a/apps/erp/app/routes/mcp+/components/module-icons.ts b/apps/erp/app/routes/mcp+/components/module-icons.ts
deleted file mode 100644
index d1d78f8ea3..0000000000
--- a/apps/erp/app/routes/mcp+/components/module-icons.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import type { IconType } from "react-icons";
-import {
- LuBox,
- LuCircleUser,
- LuCrown,
- LuFactory,
- LuFiles,
- LuFolderCheck,
- LuLandmark,
- LuLayers,
- LuReceipt,
- LuSettings,
- LuShield,
- LuShoppingCart,
- LuSquareStack,
- LuUsers,
- LuWrench
-} from "react-icons/lu";
-
-// Mirrors the ERP's module icons (app/hooks/useModules.tsx). invoicing/account/
-// shared have no top-level nav icon, so the closest lucide stands in.
-export const MODULE_ICONS: Record<string, IconType> = {
- sales: LuCrown,
- items: LuSquareStack,
- production: LuFactory,
- purchasing: LuShoppingCart,
- resources: LuWrench,
- settings: LuSettings,
- quality: LuFolderCheck,
- accounting: LuLandmark,
- inventory: LuBox,
- people: LuUsers,
- users: LuShield,
- documents: LuFiles,
- invoicing: LuReceipt,
- account: LuCircleUser,
- shared: LuLayers
-};
-
-export const FALLBACK_MODULE_ICON: IconType = LuBox;
diff --git a/apps/erp/app/routes/mcp+/tools-filter.ts b/apps/erp/app/routes/mcp+/tools-filter.ts
index 679d1cc981..31b8c2e702 100644
--- a/apps/erp/app/routes/mcp+/tools-filter.ts
+++ b/apps/erp/app/routes/mcp+/tools-filter.ts
@@ -1,4 +1,4 @@
-import type { CatalogTool } from "./catalog.server";
+import type { CatalogTool } from "./catalog";
export interface ToolFilter {
q: string;
diff --git a/apps/erp/app/styles/mcp.css b/apps/erp/app/styles/mcp-docs.css
similarity index 100%
rename from apps/erp/app/styles/mcp.css
rename to apps/erp/app/styles/mcp-docs.css