- TypeScript 95.9%
- CSS 3.5%
- Dockerfile 0.3%
- Shell 0.2%
- HTML 0.1%
| .github/workflows | ||
| scripts | ||
| src | ||
| tests | ||
| .dockerignore | ||
| .gitignore | ||
| CHANGELOG.md | ||
| deno.json | ||
| deno.lock | ||
| docker-entrypoint.sh | ||
| Dockerfile | ||
| LICENSE | ||
| mod.ts | ||
| README.md | ||
| SECURITY.md | ||
| server.ts | ||
@vidimus/mcp-inventree
Stateless, strictly read-only Level-2 @mcpview/compose MCP server for
InvenTree — the open-source electronics & hardware PLM,
inventory, and BOM manager.
Built for the Vidimus Four-Layer Code Mode architecture:
- 12 read-only MCP tools + 12 matching Level-2 snippets (
list_snippets/run_snippet) covering parts, parametric specs, BOM validation, stock & warehouse locations, supplier parts & price breaks, build/purchase orders, and thebuy_captureDigital Thread &mcp-sourcingbridge. - 2 self-contained interactive Compose Board widgets (
@mcpview/components/layoutwide/panel/mobileresponsive treatments, light/dark theming,en/fri18n viahostContext.locale, andui/notifications/size-changed):ui://mcp-inventree/part-bom— assembly header, BOM validated badge, max buildable from stock, interactive BOM table/cards (OK/SHORTAGE/UNLINKEDbadges, supplier SKU & best unit price), bidirectionalpart.selected/part.focusandsemantic.selection.*portSync.ui://mcp-inventree/stock-status— warehouse location cards, stock items (batch/serial, location path, quantity, status), active Build Orders & Purchase Orders withpart.selected/part.focus,artifact.selected/artifact.focus, andsemantic.selection.*portSync.
- Dual credential modes with strict multi-tenant isolation:
- Per-request BYO-Key headers (
X-Vidimus-Inventree-Url+X-Vidimus-Inventree-Token, strictly opt-in viaVIDIMUS_ALLOW_REQUEST_CREDENTIALS=true), guarded by HTTPS-only anti-SSRF validation (assertSafeRequestBaseUrl) and isolated per concurrent HTTP request viaAsyncLocalStorage(zero cross-tenant cache sharing). - Environment variables (
INVENTREE_URL+INVENTREE_TOKEN) for local Docker, self-hosted InvenTree, or dedicated single-tenant deployments.
- Per-request BYO-Key headers (
- Literal provenance labels: live API responses carry
provenance: "inventree-live",instanceHost(hostname only, never credentials), andretrievedAt(ISO-8601). Missing credentials or unreachable instances always return explicitstatus: "unavailable"with recovery instructions — never fabricated data.
Quickstart
1. Local / Self-Hosted InvenTree (Docker or Deno)
Generate an API token in InvenTree (Settings → Account Settings → API Tokens, or
GET /api/user/token/).
Run with Deno (HTTP stateless on port 3026):
export INVENTREE_URL="http://localhost:8000"
export INVENTREE_TOKEN="inv-your-read-only-token"
deno task serve
# MCP endpoint: http://127.0.0.1:3026/mcp
# Health check: http://127.0.0.1:3026/health
Run with Deno (stdio for Claude Desktop / Cursor / local hosts):
INVENTREE_URL="https://inventree.example.com" \
INVENTREE_TOKEN="inv-your-read-only-token" \
deno task serve:stdio
Run with Docker (ghcr.io/vidimus-dev/mcp-inventree):
docker run --rm -p 127.0.0.1:3026:3026 \
-e INVENTREE_URL="https://inventree.example.com" \
-e INVENTREE_TOKEN="inv-your-read-only-token" \
ghcr.io/vidimus-dev/mcp-inventree:latest http
2. InvenTree Cloud or Self-Hosted behind Cloudflare Tunnel + Vidimus Cloud (BYO-Key)
Expose a self-hosted InvenTree instance safely over HTTPS using a Cloudflare Tunnel
(e.g. https://inv.acme-hardware.com), then register your InvenTree URL + Token at
https://app.vidimus.run/connectors.
When running @vidimus/mcp-inventree in multi-tenant Cloud Run mode:
docker run --rm -p 127.0.0.1:3026:3026 \
-e VIDIMUS_ALLOW_REQUEST_CREDENTIALS=true \
-e MCP_ALLOWED_HOSTS="mcp-inventree.example.com" \
-e MCP_ALLOWED_ORIGINS="https://app.vidimus.run" \
ghcr.io/vidimus-dev/mcp-inventree:latest http
HTTP requests pass through @mcpview/server@^0.31.0's Host and Origin guard before
every route:
- Set
MCP_ALLOWED_ORIGINS(comma-separated, e.g.https://app.vidimus.run,http://localhost:*; legacyMCP_CORS_ORIGINSandMCP_HTTP_ALLOWED_ORIGINSare also accepted; wildcard"*"is rejected) to authorize browser origins. - Set
MCP_ALLOWED_HOSTS(comma-separated, e.g.mcp-inventree.example.com; wildcard"*"is rejected) when serving an unauthenticated HTTP server on a non-loopback address (--hostname=0.0.0.0, such as Cloud Run). Omitting both preserves safe loopback defaults locally.
Each request supplies its own tenant headers:
POST /mcp HTTP/1.1
Content-Type: application/json
X-Vidimus-Inventree-Url: https://inv.acme-hardware.com
X-Vidimus-Inventree-Token: inv-tenant-token
SSRF security policy (assertSafeRequestBaseUrl): per-request URLs MUST use
https://, MUST NOT embed credentials (user:pass@), and block loopback
(127.0.0.0/8, localhost, ::1), RFC 1918 private networks (10.0.0.0/8,
172.16.0.0/12, 192.168.0.0/16), link-local/metadata (169.254.0.0/16,
metadata.google.internal), CGNAT (100.64.0.0/10), .local, .internal, and
IPv4-mapped IPv6 addresses.
Read-Only Tools & Level-2 Snippets (v0.1)
All 12 tools carry readOnlyHint: true, destructiveHint: false,
idempotentHint: true, openWorldHint: true and expose matching short-name snippets
via list_snippets / run_snippet:
| MCP Tool | Level-2 Snippet | InvenTree REST v1 Endpoint | Compose Viewer |
|---|---|---|---|
inventree_part_list |
part_list |
GET /api/part/ |
part-bom |
inventree_part_get |
part_get |
GET /api/part/{pk}/ |
part-bom |
inventree_part_parameters |
part_parameters |
GET /api/part/parameter/?part={pk} |
part-bom |
inventree_bom_list |
bom_list |
GET /api/bom/?part={pk}&sub_part_detail=true |
part-bom |
inventree_bom_validate |
bom_validate |
GET /api/part/{pk}/ + GET /api/bom/ |
part-bom |
inventree_stock_list |
stock_list |
GET /api/stock/ |
stock-status |
inventree_stock_location_list |
stock_location_list |
GET /api/stock/location/ |
stock-status |
inventree_supplier_part_list |
supplier_part_list |
GET /api/company/part/ |
part-bom |
inventree_supplier_price_breaks |
supplier_price_breaks |
GET /api/company/price-break/?part={pk} |
part-bom |
inventree_build_order_list |
build_order_list |
GET /api/build/ |
stock-status |
inventree_purchase_order_list |
purchase_order_list |
GET /api/order/po/ |
stock-status |
inventree_buy_capture |
buy_capture |
Assembly + BOM + Supplier Parts + Price Breaks | part-bom |
Digital Thread Composition (mcp-inventree -> mcp-sourcing)
In Vidimus Code Mode (execute), buy_capture pulls an assembly BOM directly from
InvenTree and hands its normalized sourcingBom straight to mcp-sourcing while
synchronizing the Compose Board via part.selected -> part.focus:
// 1. Capture live assembly BOM, stock coverage, and supplier tiers from InvenTree
const captured = await api.inventree.buy_capture({
partPk: 42,
buildQuantities: [1, 10, 100, 1000],
includePriceBreaks: true,
});
// 2. Roll up unit cost & supply-chain risk directly in mcp-sourcing
const pricing = await api.sourcing.bom_rollup({
bom: captured.sourcingBom,
});
const risk = await api.sourcing.supply_risk({
bom: captured.sourcingBom,
});
// 3. Render synchronized Compose Board panels
const bomPanel = api.panel("inventree", "part-bom", captured);
const stockPanel = api.panel(
"inventree",
"stock-status",
await api.inventree.stock_list({ in_stock: true }),
);
api.sync(bomPanel, "part.selected", stockPanel, "part.focus");
return {
summary: captured.inventreeSummary,
traceGaps: captured.traceGaps,
pricing,
risk,
};
Development & Quality Gates
deno task build:ui # Bundle self-contained HTML widgets into src/ui/dist/
deno task fmt # Check formatting
deno task check # Typecheck all modules, widgets, scripts, and tests
deno task lint # Lint source and tests
deno task test # Run full Deno.test suite (SSRF, BYO-Key, 12 tools, snippets, layout, i18n, UI)
deno task check:ui:bundle # Verify byte-for-byte freshness of committed HTML bundles
deno task ci:check # Run fmt + check + lint + test + check:ui:bundle
deno task smoke:stdio # End-to-end stdio JSON-RPC smoke test
deno task release:check # Run ci:check + smoke:stdio
deno task build:npm # Build Node/npm distribution in ./dist-node/ via @deno/dnt
License
MIT — see LICENSE.