IntegrationsYour own code
Node.js and TypeScript
Build, edit, check and save decks and workbooks from your own Node.js or TypeScript code.
The artiwright npm package is the library the MCP server and the Python package are built on. Use it directly from
a Node.js backend, for features like “export to deck”, scheduled reports, or your own agent’s tools. It ships with
TypeScript types.
Prerequisites
Section titled “Prerequisites”Node.js 22.13 or newer (prerequisites). The examples use ES modules ("type": "module" in
package.json, or .mjs files).
Install
Section titled “Install”npm install artiwrightpnpm add artiwrightyarn add artiwrightA deck
Section titled “A deck”Ready-made layouts (TitleSlide, ChartTakeaway, KpiCards and more) lay out each slide; compose places one on a
slide. Lint finds problems; finalize checks the file and saves it.
import { ChartTakeaway, Presentation, TitleSlide, compose } from "artiwright";
const deck = Presentation.create({ theme: "spruce" });
compose(deck.slides.add(), TitleSlide({ title: "Q3 review", subtitle: "Results and the plan for Q4", date: "October 2026" }));compose( deck.slides.add(), ChartTakeaway({ eyebrow: "Growth", title: "Revenue grew every month", chart: { type: "column", categories: ["Jul", "Aug", "Sep"], format: '$0.0"M"', series: [{ name: "Revenue", values: [1.3, 1.4, 1.5] }], }, takeaways: ["Up 18% on Q2", "September was the best month", "Enterprise led the growth"], }),);
const { findings } = deck.lint();console.log(findings.length ? findings : "No issues");
const result = await deck.finalize({ output: "out/q3-review.pptx", requirements: { slideCount: 2 } });console.log(result.ok ? `Saved ${result.path}` : result.blocking);node report.mjsfinalize validates the file, checks the requirements you give, runs lint, reads the written file back, and never
overwrites an existing file. For a quick save without checks, use await deck.save("q3-review.pptx").
A workbook
Section titled “A workbook”Formulas are real Excel formulas; Artiwright also calculates them, so you can read results in code.
import { Workbook } from "artiwright";
const book = Workbook.create({ theme: "ledger" });const sheet = book.sheets.add("Budget");
sheet.range("A1:D1").values = [["Month", "Budget", "Actual", "Variance"]];sheet.range("A2:C4").values = [ ["Jul", 100, 96], ["Aug", 110, 118], ["Sep", 120, 121],];for (const row of [2, 3, 4]) sheet.range(`D${row}`).formula = `=C${row}-B${row}`;sheet.range("A5").value = "Total";sheet.range("B5").formula = "=SUM(B2:B4)";sheet.range("C5").formula = "=SUM(C2:C4)";sheet.range("D5").formula = "=C5-B5";sheet.charts.add("column", { data: "A1:C4", at: "F2", size: { w: 480, h: 280 }, title: "Budget and actual" });
console.log("D5 =", sheet.range("D5").value); // 5await book.save("budget.xlsx");Edit an existing file
Section titled “Edit an existing file”Open a deck (or Workbook.open a workbook), change what you need, and save a copy. Everything you don’t change stays
as it was, and new slides follow the file’s own theme.
import { writeFile } from "node:fs/promises";import { Presentation, TitleBullets, compose } from "artiwright";
const deck = await Presentation.open("out/q3-review.pptx");compose(deck.slides.add(), TitleBullets({ title: "Plan for Q4", bullets: ["Usage billing", "SSO for teams", "EU region"] }));
const [png] = await deck.render({ slides: [3] }); // slides are numbered from 1, as in PowerPointawait writeFile("slide-3.png", png);
await deck.save("q3-review-v2.pptx");To start from a company template instead, use await Presentation.fromTemplate("brand.potx").
Look things up
Section titled “Look things up”help prints the API from the same catalog the agents use:
npx artiwright help KpiCardsnpx artiwright help --search chartRun it for an agent
Section titled “Run it for an agent”To give an agent Artiwright’s tools, run the MCP server. From a terminal that’s npx artiwright mcp (see
HTTP server). To run it inside your own Node.js app instead, import it from
artiwright/mcp. That way your code decides the settings, for example a theme for each customer:
import { serveHttp } from "artiwright/mcp";
// Sessions are named by your app, for example "acme-chat-42".const brands = { acme: "ledger", globex: "/srv/brands/globex.potx" };
await serveHttp({ root: "/srv/artiwright", port: 8765, token: process.env.ARTIWRIGHT_MCP_TOKEN, theme: (session) => brands[session.split("-")[0]],});console.log("Artiwright MCP on http://127.0.0.1:8765/mcp");A theme is a preset name, a template path, or a defineTheme object. A file the user attaches keeps its own look.
serveStdio serves the same tools over stdin and stdout, and createServer returns the server for a transport of
your own. They take the same options as the server options.
Troubleshooting
Section titled “Troubleshooting”“Cannot use import statement outside a module”
Use .mjs files, or add "type": "module" to your package.json.
“No slide 0. Slides are numbered from 1”
Slide numbers start at 1 everywhere: in render, in the tools and on the command line.