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.

docs: add mcp documentation (#645)

Brad Barbind5a33538dc7c
diff --git a/.husky/pre-commit b/.husky/pre-commit
index c37466e2b3..a46169c27f 100755
--- a/.husky/pre-commit
+++ b/.husky/pre-commit
@@ -1,4 +1,10 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
-npx lint-staged
\ No newline at end of file
+npx lint-staged
+
+# Regenerate MCP tools if any .service.ts file was modified
+if git diff --cached --name-only | grep -q '\.service\.ts$'; then
+ npx tsx scripts/generate-mcp.ts
+ git add apps/erp/app/routes/api+/mcp+/lib/tools/ llm/cache/mcp-tools-reference.md
+fi
\ No newline at end of file
diff --git a/apps/erp/app/modules/settings/ui/ApiKeys/ApiKeysForm.tsx b/apps/erp/app/modules/settings/ui/ApiKeys/ApiKeysForm.tsx
index a4c0cadfb3..5eead3d58b 100644
--- a/apps/erp/app/modules/settings/ui/ApiKeys/ApiKeysForm.tsx
+++ b/apps/erp/app/modules/settings/ui/ApiKeys/ApiKeysForm.tsx
@@ -1,3 +1,4 @@
+import { getBrowserEnv } from "@carbon/auth";
import { DateTimePicker, ValidatedForm } from "@carbon/form";
import {
Alert,
@@ -8,6 +9,7 @@ import {
Input as InputBase,
InputGroup,
InputRightElement,
+ Label,
Modal,
ModalBody,
ModalContent,
@@ -140,13 +142,18 @@ type ApiKeyViewProps = {
};
function ApiKeyView({ apiKey, onClose }: ApiKeyViewProps) {
- const [copied, setCopied] = useState(false);
+ const [copied, setCopied] = useState<"key" | "mcp" | null>(null);
useEffect(() => {
if (!copied) return;
- const timer = setTimeout(() => setCopied(false), 2000);
+ const timer = setTimeout(() => setCopied(null), 2000);
return () => clearTimeout(timer);
}, [copied]);
+ const { ERP_URL } = getBrowserEnv();
+ const mcpCommand = `claude mcp add --transport http \\
+ carbon ${ERP_URL}/api/mcp \\
+ --header "Authorization: Bearer ${apiKey}"`;
+
return (
<Modal
open
@@ -166,21 +173,42 @@ function ApiKeyView({ apiKey, onClose }: ApiKeyViewProps) {
You can only see this key once. Store it safely.
</AlertTitle>
</Alert>
- <InputGroup>
- <InputBase value={apiKey} />
- <InputRightElement className="w-[2.75rem]">
- <IconButton
- aria-label="Copy"
- icon={copied ? <LuCheck /> : <LuClipboard />}
- variant="ghost"
- onClick={() => {
- copyToClipboard(apiKey, () => {
- setCopied(true);
- });
- }}
- />
- </InputRightElement>
- </InputGroup>
+ <div>
+ <Label htmlFor="api-key">API Key</Label>
+ <InputGroup>
+ <InputBase id="api-key" value={apiKey} />
+ <InputRightElement className="w-[2.75rem]">
+ <IconButton
+ aria-label="Copy API Key"
+ icon={copied === "key" ? <LuCheck /> : <LuClipboard />}
+ variant="ghost"
+ onClick={() => {
+ copyToClipboard(apiKey, () => {
+ setCopied("key");
+ });
+ }}
+ />
+ </InputRightElement>
+ </InputGroup>
+ </div>
+ <div>
+ <Label htmlFor="mcp-command">MCP Command</Label>
+ <InputGroup>
+ <InputBase id="mcp-command" value={mcpCommand} />
+ <InputRightElement className="w-[2.75rem]">
+ <IconButton
+ aria-label="Copy MCP Command"
+ icon={copied === "mcp" ? <LuCheck /> : <LuClipboard />}
+ variant="ghost"
+ onClick={() => {
+ copyToClipboard(mcpCommand, () => {
+ setCopied("mcp");
+ });
+ }}
+ />
+ </InputRightElement>
+ </InputGroup>
+ </div>
</VStack>
</ModalBody>
<ModalFooter>
diff --git a/apps/erp/app/routes/docs+/api+/$lang.intro.tsx b/apps/erp/app/routes/docs+/api+/$lang.intro.tsx
index 7e7640f65f..0575b871bb 100644
--- a/apps/erp/app/routes/docs+/api+/$lang.intro.tsx
+++ b/apps/erp/app/routes/docs+/api+/$lang.intro.tsx
@@ -10,7 +10,7 @@ import {
} from "~/modules/api";
import { path } from "~/utils/path";
-const { CARBON_API_URL } = getBrowserEnv();
+const { CARBON_API_URL, ERP_URL } = getBrowserEnv();
export default function Route() {
const selectedLang = useSelectedLang();
@@ -28,17 +28,45 @@ export default function Route() {
<p>
First you'll need an <Link to={path.to.apiKeys}>API Key</Link>.
</p>
- <p>Next save the API Key as an Environment Variable.</p>
+ <Alert variant="destructive">
+ <LuTriangleAlert className="h-4 w-4 my-1" />
+ <AlertTitle className="!my-0 font-bold text-base">
+ You should never expose the API key in the client
+ </AlertTitle>
+ <AlertDescription>
+ Your API key gives full access to your database. Never expose it
+ in a public-facing client.
+ </AlertDescription>
+ </Alert>
+ </article>
+ </div>
+ <h2 className="doc-heading">MCP</h2>
+ <div className="doc-section">
+ <article className="code-column text-foreground">
+ <p>
+ Carbon provides an MCP server that you can connect to from any MCP
+ client, such as Claude Code or Claude Desktop.
+ </p>
+ <p>To connect, run the following command with your API token:</p>
<article>
<CodeSnippet
selectedLang={selectedLang}
- snippet={Snippets.env({ apiUrl, apiKey })}
+ snippet={{
+ bash: {
+ language: "bash",
+ code: `claude mcp add --transport http \\
+ carbon ${ERP_URL}/api/mcp \\
+ --header "Authorization: Bearer ${apiKey}"`
+ },
+ js: {
+ language: "bash",
+ code: `claude mcp add --transport http \\
+ carbon ${ERP_URL}/api/mcp \\
+ --header "Authorization: Bearer ${apiKey}"`
+ }
+ }}
/>
</article>
- <p>
- The API Key is provided via the <code>Authorization</code> header
- when making requests to the API.
- </p>
</article>
</div>
{selectedLang == "js" ? (
@@ -50,21 +78,17 @@ export default function Route() {
The easiest way to interact with the public API is via the
JavaScript Client Library SDK.
</p>
+ <p>Save the API Key as an Environment Variable.</p>
+ <article>
+ <CodeSnippet
+ selectedLang={selectedLang}
+ snippet={Snippets.env({ apiUrl, apiKey })}
+ />
+ </article>
<p>
- To initialize the Client Library SDK, you will need the
- environment variables you set up earlier.
+ The API Key is provided via the <code>Authorization</code>{" "}
+ header when making requests to the API.
</p>
- <Alert variant="destructive">
- <LuTriangleAlert className="h-4 w-4 my-1" />
- <AlertTitle className="!my-0 font-bold text-base">
- You should never expose the API key in the client
- </AlertTitle>
- <AlertDescription>
- Your API key gives full access to your database. Never expose
- it in a public-facing client.
- </AlertDescription>
- </Alert>
-
<p>
As with your API Key, we recommend setting your Client Key as an
Environment Variable.