@presentation-md/mcp-server 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Timur Isachenko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # @presentation-md/mcp-server
2
+
3
+ MCP server that exposes presentation-md tools to any MCP-compatible AI agent (Claude Code, Cursor, etc.).
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npx @presentation-md/mcp-server
9
+ ```
10
+
11
+ ## Add to Claude Code
12
+
13
+ Add to your project's `.claude/mcp.json` (or `~/.claude/mcp.json` for global):
14
+
15
+ ```json
16
+ {
17
+ "mcpServers": {
18
+ "presentation-md": {
19
+ "command": "npx",
20
+ "args": ["-y", "@presentation-md/mcp-server"]
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ ## Tools
27
+
28
+ | Tool | Description |
29
+ |------|-------------|
30
+ | `render_deck` | Render a deck JSON spec to a self-contained HTML slide deck; optionally write to a file. |
31
+ | `list_themes` | List all installed themes with name, version, vibe, and description. |
32
+ | `apply_theme` | Swap the theme in `meta.theme` while keeping all slide content unchanged. |
33
+ | `audit_deck` | Validate deck JSON against the schema and return structured issues with severity. |
34
+ | `generate_deck_prompt` | Build a system prompt with the active theme's palette and deck schema reference for an agent. |
35
+ | `import_brand_theme` | Generate a theme from a brand's URL or CSS file, with a contrast-safety pass. |
36
+ | `import_pptx` | Import a `.pptx` file into deck JSON (text, tables, images, notes → layouts). |
37
+
38
+ Note: when using `import_brand_theme` with a local CSS file, the `cssPath` parameter must be a `.css` file that resolves within the MCP server's working directory. Likewise, `import_pptx`'s `pptx_path` must be a `.pptx` within the working directory.
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ export interface ToolDefinition {
3
+ name: string;
4
+ description: string;
5
+ inputSchema: Record<string, unknown>;
6
+ handler: (input: Record<string, unknown>) => Promise<unknown>;
7
+ }
8
+ export declare function listToolDefinitions(): ToolDefinition[];
9
+ export declare function main(): Promise<void>;
package/dist/server.js ADDED
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env node
2
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
5
+ import { renderDeckTool } from "./tools/render-deck.js";
6
+ import { exportDeckTool } from "./tools/export-deck.js";
7
+ import { listThemesTool } from "./tools/list-themes.js";
8
+ import { applyThemeTool } from "./tools/apply-theme.js";
9
+ import { auditDeckTool } from "./tools/audit-deck.js";
10
+ import { generateDeckPromptTool } from "./tools/generate-deck-prompt.js";
11
+ import { importBrandThemeTool } from "./tools/import-brand-theme.js";
12
+ import { importPptxTool } from "./tools/import-pptx.js";
13
+ const TOOLS = [
14
+ renderDeckTool,
15
+ exportDeckTool,
16
+ listThemesTool,
17
+ applyThemeTool,
18
+ auditDeckTool,
19
+ generateDeckPromptTool,
20
+ importBrandThemeTool,
21
+ importPptxTool,
22
+ ];
23
+ export function listToolDefinitions() {
24
+ return TOOLS;
25
+ }
26
+ export async function main() {
27
+ const server = new Server({ name: "presentation-md", version: "0.1.0" }, { capabilities: { tools: {} } });
28
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
29
+ tools: TOOLS.map((t) => ({
30
+ name: t.name,
31
+ description: t.description,
32
+ inputSchema: t.inputSchema
33
+ }))
34
+ }));
35
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
36
+ const tool = TOOLS.find((t) => t.name === request.params.name);
37
+ if (!tool) {
38
+ return {
39
+ content: [{ type: "text", text: `Unknown tool: ${request.params.name}` }],
40
+ isError: true
41
+ };
42
+ }
43
+ try {
44
+ const result = await tool.handler((request.params.arguments ?? {}));
45
+ return {
46
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
47
+ };
48
+ }
49
+ catch (err) {
50
+ const message = err instanceof Error ? err.message : String(err);
51
+ return {
52
+ content: [{ type: "text", text: message }],
53
+ isError: true
54
+ };
55
+ }
56
+ });
57
+ const transport = new StdioServerTransport();
58
+ await server.connect(transport);
59
+ }
60
+ main().catch((err) => {
61
+ console.error(err);
62
+ process.exit(1);
63
+ });
64
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,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are const applyThemeTool: ToolDefinition;
@@ -0,0 +1,28 @@
1
+ export const applyThemeTool = {
2
+ name: "apply_theme",
3
+ description: "Re-theme an existing deck JSON — swap the theme in meta while keeping all slide content unchanged.",
4
+ inputSchema: {
5
+ type: "object",
6
+ properties: {
7
+ json: { type: "string", description: "Deck JSON string" },
8
+ target_theme: { type: "string", description: "Theme name to apply" }
9
+ },
10
+ required: ["json", "target_theme"]
11
+ },
12
+ handler: async (input) => {
13
+ const rawJson = input["json"];
14
+ const targetTheme = input["target_theme"];
15
+ let deck;
16
+ try {
17
+ deck = JSON.parse(rawJson);
18
+ }
19
+ catch (err) {
20
+ throw new Error(`Invalid JSON: ${err.message}`);
21
+ }
22
+ const meta = (deck["meta"] ?? {});
23
+ meta["theme"] = targetTheme;
24
+ deck["meta"] = meta;
25
+ return { json: JSON.stringify(deck, null, 2) };
26
+ }
27
+ };
28
+ //# sourceMappingURL=apply-theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-theme.js","sourceRoot":"","sources":["../../src/tools/apply-theme.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,oGAAoG;IACtG,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kBAAkB,EAAE;YACzD,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,qBAAqB,EAAE;SACrE;QACD,QAAQ,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC;KACnC;IACD,OAAO,EAAE,KAAK,EAAE,KAA8B,EAAE,EAAE;QAChD,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAW,CAAC;QACxC,MAAM,WAAW,GAAG,KAAK,CAAC,cAAc,CAAW,CAAC;QAEpD,IAAI,IAA6B,CAAC;QAClC,IAAI,CAAC;YACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAA4B,CAAC;QACxD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,iBAAkB,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7D,CAAC;QAED,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAA4B,CAAC;QAC7D,IAAI,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC;QAC5B,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;QAEpB,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;IACjD,CAAC;CACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ToolDefinition } from "../server.js";
2
+ export declare const auditDeckTool: ToolDefinition;
@@ -0,0 +1,106 @@
1
+ import { validateDeckJson } from "@presentation-md/core";
2
+ const HEADING_LAYOUTS = new Set(["title", "section", "closing"]);
3
+ const VALID_LAYOUTS = new Set([
4
+ "title", "two-column", "feature-grid", "quote",
5
+ "data-table", "stat-row", "timeline", "section", "closing"
6
+ ]);
7
+ function manualValidate(deck) {
8
+ const issues = [];
9
+ if (deck["type"] !== "deck") {
10
+ issues.push({ severity: "error", message: `/ must have "type": "deck"` });
11
+ }
12
+ const slides = deck["slides"];
13
+ if (!Array.isArray(slides)) {
14
+ issues.push({ severity: "error", message: `/ must have a "slides" array` });
15
+ return { valid: issues.length === 0, issues };
16
+ }
17
+ if (slides.length === 0) {
18
+ issues.push({ severity: "error", message: `"slides" array must not be empty` });
19
+ }
20
+ return { valid: issues.filter((i) => i.severity === "error").length === 0, issues };
21
+ }
22
+ function lightStructuralChecks(deck) {
23
+ const issues = [];
24
+ const slides = deck["slides"];
25
+ if (!Array.isArray(slides))
26
+ return issues;
27
+ if (slides.length < 2) {
28
+ issues.push({ severity: "warning", message: "Deck has fewer than 2 slides — consider adding more content" });
29
+ }
30
+ for (let i = 0; i < slides.length; i++) {
31
+ const slide = slides[i];
32
+ const layout = slide["layout"];
33
+ if (layout && !VALID_LAYOUTS.has(layout)) {
34
+ issues.push({
35
+ severity: "error",
36
+ message: `Slide ${i + 1}: unknown layout "${layout}"`
37
+ });
38
+ }
39
+ if (layout && HEADING_LAYOUTS.has(layout) && !slide["heading"]) {
40
+ issues.push({
41
+ severity: "warning",
42
+ message: `Slide ${i + 1} (layout "${layout}") is missing a "heading" field`
43
+ });
44
+ }
45
+ if (layout === "feature-grid") {
46
+ const columns = slide["columns"];
47
+ const cards = slide["cards"];
48
+ if (typeof columns === "number" && Array.isArray(cards)) {
49
+ if (cards.length % columns !== 0) {
50
+ issues.push({
51
+ severity: "warning",
52
+ message: `Slide ${i + 1} (feature-grid): "cards" count (${cards.length}) is not a multiple of "columns" (${columns})`
53
+ });
54
+ }
55
+ }
56
+ }
57
+ }
58
+ return issues;
59
+ }
60
+ export const auditDeckTool = {
61
+ name: "audit_deck",
62
+ description: "Validate a deck JSON against the schema and return structured issues.",
63
+ inputSchema: {
64
+ type: "object",
65
+ properties: {
66
+ json: { type: "string", description: "Deck JSON string to validate" }
67
+ },
68
+ required: ["json"]
69
+ },
70
+ handler: async (input) => {
71
+ const json = input["json"];
72
+ let parsed;
73
+ try {
74
+ parsed = JSON.parse(json);
75
+ }
76
+ catch (err) {
77
+ return {
78
+ valid: false,
79
+ issues: [{ severity: "error", message: `Invalid JSON: ${err.message}` }],
80
+ slide_count: 0
81
+ };
82
+ }
83
+ // Attempt full schema validation via core. If AJV can't load the meta-schema
84
+ // (e.g. draft/2020-12 not registered), fall back to manual structural validation.
85
+ let valid = false;
86
+ let issues = [];
87
+ try {
88
+ const result = validateDeckJson(json);
89
+ valid = result.valid;
90
+ issues = result.errors.map((msg) => ({ severity: "error", message: msg }));
91
+ }
92
+ catch {
93
+ // Core validator unavailable (e.g. AJV meta-schema not registered) — fall back
94
+ const fallback = manualValidate(parsed);
95
+ valid = fallback.valid;
96
+ issues = fallback.issues;
97
+ }
98
+ // Always run light structural checks regardless of schema validity
99
+ const structural = lightStructuralChecks(parsed);
100
+ issues.push(...structural);
101
+ const slides = parsed["slides"];
102
+ const slideCount = Array.isArray(slides) ? slides.length : 0;
103
+ return { valid, issues, slide_count: slideCount };
104
+ }
105
+ };
106
+ //# sourceMappingURL=audit-deck.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-deck.js","sourceRoot":"","sources":["../../src/tools/audit-deck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAQzD,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;AACjE,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,OAAO;IAC9C,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS;CAC3D,CAAC,CAAC;AAEH,SAAS,cAAc,CAAC,IAA6B;IACnD,MAAM,MAAM,GAAY,EAAE,CAAC;IAE3B,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,MAAM,EAAE,CAAC;QAC5B,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,8BAA8B,EAAE,CAAC,CAAC;QAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAChD,CAAC;IAED,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ToolDefinition } from "../server.js";
2
+ export declare const exportDeckTool: ToolDefinition;
@@ -0,0 +1,89 @@
1
+ import { writeFile } from "node:fs/promises";
2
+ import { renderDeck, renderDeckPptx, getBundledThemesDir } from "@presentation-md/render";
3
+ function applyThemeOverride(rawJson, theme) {
4
+ if (!theme)
5
+ return rawJson;
6
+ let parsed;
7
+ try {
8
+ parsed = JSON.parse(rawJson);
9
+ }
10
+ catch (err) {
11
+ throw new Error(`Invalid JSON: ${err.message}`);
12
+ }
13
+ const meta = (parsed["meta"] ?? {});
14
+ meta["theme"] = theme;
15
+ parsed["meta"] = meta;
16
+ return JSON.stringify(parsed);
17
+ }
18
+ function slideCountOf(json) {
19
+ try {
20
+ const deck = JSON.parse(json);
21
+ return Array.isArray(deck.slides) ? deck.slides.length : 0;
22
+ }
23
+ catch {
24
+ return 0;
25
+ }
26
+ }
27
+ export const exportDeckTool = {
28
+ name: "export_deck",
29
+ description: "Export a presentation-md deck JSON spec to a native, editable PowerPoint (.pptx) file — opens directly in PowerPoint and Keynote, and imports into Google Slides. Also supports html. Writes to output_path when given, otherwise returns base64 bytes.",
30
+ inputSchema: {
31
+ type: "object",
32
+ properties: {
33
+ json: { type: "string", description: "Deck JSON string conforming to the deck schema" },
34
+ format: {
35
+ type: "string",
36
+ enum: ["pptx", "html"],
37
+ description: "Output format (default: pptx)",
38
+ },
39
+ theme: { type: "string", description: "Theme name to apply (overrides meta.theme in the deck)" },
40
+ output_path: { type: "string", description: "Path to write the exported file" },
41
+ },
42
+ required: ["json"],
43
+ },
44
+ handler: async (input) => {
45
+ const rawJson = input["json"];
46
+ const format = (input["format"] ?? "pptx").toLowerCase();
47
+ const theme = input["theme"];
48
+ const outputPath = input["output_path"];
49
+ if (format !== "pptx" && format !== "html") {
50
+ throw new Error(`Unknown format "${format}" (expected pptx | html)`);
51
+ }
52
+ const deckJson = applyThemeOverride(rawJson, theme);
53
+ const warnings = [];
54
+ const slide_count = slideCountOf(deckJson);
55
+ if (format === "html") {
56
+ const html = await renderDeck(deckJson, { themesDir: getBundledThemesDir() });
57
+ const result = {
58
+ format,
59
+ slide_count,
60
+ };
61
+ if (outputPath) {
62
+ await writeFile(outputPath, html, "utf-8");
63
+ result.path = outputPath;
64
+ }
65
+ else {
66
+ result.html = html;
67
+ }
68
+ return result;
69
+ }
70
+ const buffer = await renderDeckPptx(deckJson, {
71
+ onWarn: (msg) => warnings.push(msg),
72
+ });
73
+ const result = {
74
+ format,
75
+ slide_count,
76
+ byte_length: buffer.byteLength,
77
+ warnings,
78
+ };
79
+ if (outputPath) {
80
+ await writeFile(outputPath, buffer);
81
+ result.path = outputPath;
82
+ }
83
+ else {
84
+ result.bytes_base64 = buffer.toString("base64");
85
+ }
86
+ return result;
87
+ },
88
+ };
89
+ //# sourceMappingURL=export-deck.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-deck.js","sourceRoot":"","sources":["../../src/tools/export-deck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAG1F,SAAS,kBAAkB,CAAC,OAAe,EAAE,KAAc;IACzD,IAAI,CAAC,KAAK;QAAE,OAAO,OAAO,CAAC;IAC3B,IAAI,MAA+B,CAAC;IACpC,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAA4B,CAAC;IAC1D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,iBAAkB,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7D,CAAC;IACD,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAA4B,CAAC;IAC/D,IAAI,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;IACtB,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACtB,OAAO,I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CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ToolDefinition } from "../server.js";
2
+ export declare const generateDeckPromptTool: ToolDefinition;
@@ -0,0 +1,42 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { join, dirname } from "node:path";
3
+ import { createRequire } from "node:module";
4
+ import { loadTheme } from "@presentation-md/core";
5
+ import { getBundledThemesDir } from "@presentation-md/render";
6
+ function getCoreRoot() {
7
+ const require = createRequire(import.meta.url);
8
+ const coreMain = require.resolve("@presentation-md/core");
9
+ // coreMain points to dist/index.js; core root is two levels up from dist/
10
+ return dirname(dirname(coreMain));
11
+ }
12
+ export const generateDeckPromptTool = {
13
+ name: "generate_deck_prompt",
14
+ description: "Build a system prompt with the active theme's palette and the deck schema reference, for an agent to produce a deck JSON spec.",
15
+ inputSchema: {
16
+ type: "object",
17
+ properties: {
18
+ theme: { type: "string", description: "Theme name to use (default: default-tech)" },
19
+ intent: { type: "string", description: "What the deck should argue or show" }
20
+ }
21
+ },
22
+ handler: async (input) => {
23
+ const themeName = input["theme"] ?? "default-tech";
24
+ const intent = input["intent"] ?? "";
25
+ const coreRoot = getCoreRoot();
26
+ const themesDir = getBundledThemesDir();
27
+ const [theme, skill, deckSchemaReference] = await Promise.all([
28
+ loadTheme(themeName, { themesDir }),
29
+ readFile(join(coreRoot, "SKILL.md"), "utf-8"),
30
+ readFile(join(coreRoot, "references", "deck-schema.md"), "utf-8")
31
+ ]);
32
+ return {
33
+ theme: themeName,
34
+ intent,
35
+ skill,
36
+ deck_schema_reference: deckSchemaReference,
37
+ palette: theme.palette,
38
+ typography: theme.typography
39
+ };
40
+ }
41
+ };
42
+ //# sourceMappingURL=generate-deck-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-deck-prompt.js","sourceRoot":"","sources":["../../src/tools/generate-deck-prompt.ts"],"names":[],"mapp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AS,EAAE,EAAE,SAAS,EAAE,CAAC;YACnC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,OAAO,CAAC;YAC7C,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,EAAE,gBAAgB,CAAC,EAAE,OAAO,CAAC;SAClE,CAAC,CAAC;QAEH,OAAO;YACL,KAAK,EAAE,SAAS;YAChB,MAAM;YACN,KAAK;YACL,qBAAqB,EAAE,mBAAmB;YAC1C,OAAO,EAAE,KAAK,CAAC,OAA4C;YAC3D,UAAU,EAAE,KAAK,CAAC,UAAU;SAC7B,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ToolDefinition } from "../server.js";
2
+ export declare const importBrandThemeTool: ToolDefinition;
@@ -0,0 +1,72 @@
1
+ import { extname, join, resolve, sep } from "node:path";
2
+ import { realpath } from "node:fs/promises";
3
+ import { extractBrand, buildThemeViewFromBrand, buildThemeManifestJson, scaffoldTheme, validateThemeName, deriveNameFromUrl, } from "@presentation-md/create-theme";
4
+ export const importBrandThemeTool = {
5
+ name: "import_brand_theme",
6
+ description: "Generate a presentation-md theme from a brand's website URL or a local CSS file. Extracts colors and fonts, maps them to the theme's 8 semantic roles, and applies a WCAG contrast-safety pass so the result stays legible. Use whenever the user wants a deck theme that matches an existing brand or product.",
7
+ inputSchema: {
8
+ type: "object",
9
+ properties: {
10
+ url: { type: "string", description: "Brand website URL to extract colors and fonts from" },
11
+ cssPath: { type: "string", description: "Local path to a CSS file to extract from, as an alternative to url" },
12
+ name: {
13
+ type: "string",
14
+ description: "Theme name in kebab-case; derived from the URL's hostname if omitted (required when using cssPath)",
15
+ },
16
+ write: {
17
+ type: "boolean",
18
+ description: "Also scaffold the full installable theme package to disk under packages/themes/<name>. Defaults to false.",
19
+ },
20
+ },
21
+ },
22
+ handler: async (input) => {
23
+ const url = input.url;
24
+ const cssPath = input.cssPath;
25
+ if (!url && !cssPath)
26
+ throw new Error("Provide either 'url' or 'cssPath'.");
27
+ if (url && cssPath)
28
+ throw new Error("Provide only one of 'url' or 'cssPath', not both.");
29
+ if (cssPath) {
30
+ if (extname(cssPath).toLowerCase() !== ".css") {
31
+ throw new Error("'cssPath' must point to a .css file.");
32
+ }
33
+ const root = await realpath(process.cwd());
34
+ let resolvedPath;
35
+ try {
36
+ resolvedPath = await realpath(resolve(process.cwd(), cssPath));
37
+ }
38
+ catch {
39
+ throw new Error(`'cssPath' not found: ${cssPath}`);
40
+ }
41
+ if (resolvedPath !== root && !resolvedPath.startsWith(root + sep)) {
42
+ throw new Error(`'cssPath' must be within the current working directory (${root}).`);
43
+ }
44
+ }
45
+ let name = input.name;
46
+ if (!name) {
47
+ if (!url)
48
+ throw new Error("'name' is required when using 'cssPath'.");
49
+ name = deriveNameFromUrl(url);
50
+ }
51
+ validateThemeName(name);
52
+ const extraction = await extractBrand({ url, cssPath });
53
+ const view = buildThemeViewFromBrand(name, extraction);
54
+ const theme = JSON.parse(buildThemeManifestJson(view));
55
+ let writtenTo;
56
+ if (input.write === true) {
57
+ const outputDir = join(process.cwd(), "packages", "themes", name);
58
+ await scaffoldTheme(view, outputDir);
59
+ writtenTo = outputDir;
60
+ }
61
+ return {
62
+ theme,
63
+ source: extraction.source,
64
+ contrastAdjustments: extraction.adjustments,
65
+ // Pairs that remain below WCAG AA (4.5:1) even after the contrast pass.
66
+ // Always present so the response shape is stable; empty means fully safe.
67
+ contrastStillFailing: extraction.stillFailing,
68
+ writtenTo,
69
+ };
70
+ },
71
+ };
72
+ //# sourceMappingURL=import-brand-theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-brand-theme.js","sourceRoot":"","sources":["../../src/tools/import-brand-theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,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AAW;YAC3C,wEAAwE;YACxE,0EAA0E;YAC1E,oBAAoB,EAAE,UAAU,CAAC,YAAY;YAC7C,SAAS;SACV,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ToolDefinition } from "../server.js";
2
+ export declare const importPptxTool: ToolDefinition;
@@ -0,0 +1,136 @@
1
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
2
+ import { basename, dirname, extname, join, resolve, sep } from "node:path";
3
+ import { realpath } from "node:fs/promises";
4
+ import { pptxToDeck } from "@presentation-md/export/import";
5
+ /**
6
+ * Resolve a path under cwd using realpath on the nearest existing ancestor so
7
+ * cwd-relative symlinks cannot escape the workspace on write.
8
+ */
9
+ async function assertWritablePathInCwd(relPath, label) {
10
+ const root = await realpath(process.cwd());
11
+ const resolved = resolve(process.cwd(), relPath);
12
+ const segments = [];
13
+ let probe = resolved;
14
+ for (;;) {
15
+ try {
16
+ const real = await realpath(probe);
17
+ if (real !== root && !real.startsWith(root + sep)) {
18
+ throw new Error(`'${label}' must be within the current working directory (${root}).`);
19
+ }
20
+ const finalPath = segments.length ? join(real, ...segments.reverse()) : real;
21
+ if (finalPath !== root && !finalPath.startsWith(root + sep)) {
22
+ throw new Error(`'${label}' must be within the current working directory (${root}).`);
23
+ }
24
+ return finalPath;
25
+ }
26
+ catch (err) {
27
+ if (err instanceof Error && /must be within/.test(err.message))
28
+ throw err;
29
+ const parent = dirname(probe);
30
+ if (parent === probe) {
31
+ throw new Error(`'${label}' not found: ${relPath}`);
32
+ }
33
+ segments.push(basename(probe));
34
+ probe = parent;
35
+ }
36
+ }
37
+ }
38
+ async function assertExistingPathInCwd(relPath, label) {
39
+ const root = await realpath(process.cwd());
40
+ let resolvedPath;
41
+ try {
42
+ resolvedPath = await realpath(resolve(process.cwd(), relPath));
43
+ }
44
+ catch {
45
+ throw new Error(`'${label}' not found: ${relPath}`);
46
+ }
47
+ if (resolvedPath !== root && !resolvedPath.startsWith(root + sep)) {
48
+ throw new Error(`'${label}' must be within the current working directory (${root}).`);
49
+ }
50
+ return resolvedPath;
51
+ }
52
+ async function assertPptxPathInCwd(pptxPath) {
53
+ if (extname(pptxPath).toLowerCase() !== ".pptx") {
54
+ throw new Error("'pptx_path' must point to a .pptx file.");
55
+ }
56
+ return assertExistingPathInCwd(pptxPath, "pptx_path");
57
+ }
58
+ export const importPptxTool = {
59
+ name: "import_pptx",
60
+ description: "Import a PowerPoint (.pptx) file into a presentation-md deck JSON spec. Extracts text, tables, images, and notes, then maps them onto the structured layouts so you can theme, edit, and re-export. Prefer this whenever the user already has a .pptx and wants a deck in this pack's format.",
61
+ inputSchema: {
62
+ type: "object",
63
+ properties: {
64
+ pptx_path: {
65
+ type: "string",
66
+ description: "Path to a .pptx file within the current working directory",
67
+ },
68
+ pptx_base64: {
69
+ type: "string",
70
+ description: "Base64-encoded .pptx bytes, as an alternative to pptx_path",
71
+ },
72
+ theme: {
73
+ type: "string",
74
+ description: "Theme name to set on meta.theme (default: claude)",
75
+ },
76
+ output_path: {
77
+ type: "string",
78
+ description: "Optional path to write the deck JSON",
79
+ },
80
+ assets_dir: {
81
+ type: "string",
82
+ description: "Optional directory to write extracted images; when omitted, images become data URIs",
83
+ },
84
+ },
85
+ },
86
+ handler: async (input) => {
87
+ const pptxPath = input["pptx_path"];
88
+ const pptxBase64 = input["pptx_base64"];
89
+ if (!pptxPath && !pptxBase64)
90
+ throw new Error("Provide either 'pptx_path' or 'pptx_base64'.");
91
+ if (pptxPath && pptxBase64) {
92
+ throw new Error("Provide only one of 'pptx_path' or 'pptx_base64', not both.");
93
+ }
94
+ let buffer;
95
+ if (pptxPath) {
96
+ const safePath = await assertPptxPathInCwd(pptxPath);
97
+ buffer = await readFile(safePath);
98
+ }
99
+ else {
100
+ buffer = Buffer.from(pptxBase64, "base64");
101
+ if (buffer.length < 4 || buffer[0] !== 0x50 || buffer[1] !== 0x4b) {
102
+ throw new Error("'pptx_base64' does not look like a valid PPTX (ZIP) file.");
103
+ }
104
+ }
105
+ const theme = input["theme"];
106
+ const assetsDirInput = input["assets_dir"];
107
+ const outputPathInput = input["output_path"];
108
+ let assetsDir;
109
+ if (assetsDirInput) {
110
+ assetsDir = await assertWritablePathInCwd(assetsDirInput, "assets_dir");
111
+ await mkdir(assetsDir, { recursive: true });
112
+ }
113
+ let outputPath;
114
+ if (outputPathInput) {
115
+ outputPath = await assertWritablePathInCwd(outputPathInput, "output_path");
116
+ }
117
+ const warnings = [];
118
+ const { deck } = await pptxToDeck(buffer, {
119
+ theme,
120
+ assetsDir,
121
+ onWarn: (msg) => warnings.push(msg),
122
+ });
123
+ const result = {
124
+ deck,
125
+ warnings,
126
+ slide_count: deck.slides.length,
127
+ };
128
+ if (outputPath) {
129
+ await mkdir(dirname(outputPath), { recursive: true });
130
+ await writeFile(outputPath, JSON.stringify(deck, null, 2), "utf-8");
131
+ result.path = outputPath;
132
+ }
133
+ return result;
134
+ },
135
+ };
136
+ //# sourceMappingURL=import-pptx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-pptx.js","sourceRoot":"","sources":["../../src/tools/import-pptx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAG5D;;;GAGG;AACH,KAAK,UAAU,uBAAuB,CAAC,OAAe,EAAE,KAAa;IACnE,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC;IACjD,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cAAc,EAAE,YAAY,CAAC,CAAC;YACxE,MAAM,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,CAAC;QAED,IAAI,UAA8B,CAAC;QACnC,IAAI,eAAe,EAAE,CAAC;YACpB,UAAU,GAAG,MAAM,uBAAuB,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QAC7E,CAAC;QAED,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,UAAU,CAAC,MAAM,EAAE;YACxC,KAAK;YACL,SAAS;YACT,MAAM,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;SAC5C,CAAC,CAAC;QAEH,MAAM,MAAM,GAKR;YACF,IAAI;YACJ,QAAQ;YACR,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;SAChC,CAAC;QAEF,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACtD,MAAM,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YACpE,MAAM,CAAC,IAAI,GAAG,UAAU,CAAC;QAC3B,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ToolDefinition } from "../server.js";
2
+ export declare const listThemesTool: ToolDefinition;
@@ -0,0 +1,25 @@
1
+ import { discoverInstalledThemes } from "@presentation-md/core";
2
+ import { getBundledThemesDir } from "@presentation-md/render";
3
+ export const listThemesTool = {
4
+ name: "list_themes",
5
+ description: "List all available presentation-md themes with name, version, vibe, and description.",
6
+ inputSchema: {
7
+ type: "object",
8
+ properties: {}
9
+ },
10
+ handler: async (_) => {
11
+ const discovered = await discoverInstalledThemes({
12
+ bundledThemesDir: getBundledThemesDir(),
13
+ nodeModulesRoot: process.cwd()
14
+ });
15
+ const themes = discovered.map((d) => ({
16
+ name: d.name,
17
+ version: d.version,
18
+ description: d.manifest.description,
19
+ vibe: d.manifest.vibe,
20
+ source: d.source
21
+ }));
22
+ return { themes };
23
+ }
24
+ };
25
+ //# sourceMappingURL=list-themes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-themes.js","sourceRoot":"","sources":["../../src/tools/list-themes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAG9D,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,sFAAsF;IACxF,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,EAAE;KACf;IACD,OAAO,EAAE,KAAK,EAAE,CAA0B,EAAE,EAAE;QAC5C,MAAM,UAAU,GAAG,MAAM,uBAAuB,CAAC;YAC/C,gBAAgB,EAAE,mBAAmB,EAAE;YACvC,eAAe,EAAE,OAAO,CAAC,GAAG,EAAE;SAC/B,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACpC,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW;YACnC,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI;YACrB,MAAM,EAAE,CAAC,CAAC,MAAM;SACjB,CAAC,CAAC,CAAC;QAEJ,OAAO,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC;CACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ToolDefinition } from "../server.js";
2
+ export declare const renderDeckTool: ToolDefinition;
@@ -0,0 +1,53 @@
1
+ import { writeFile } from "node:fs/promises";
2
+ import { renderDeck, getBundledThemesDir } from "@presentation-md/render";
3
+ export const renderDeckTool = {
4
+ name: "render_deck",
5
+ description: "Render a presentation-md deck JSON spec to a self-contained HTML slide deck. Returns the HTML string and optionally writes to a file.",
6
+ inputSchema: {
7
+ type: "object",
8
+ properties: {
9
+ json: { type: "string", description: "Deck JSON string conforming to the deck schema" },
10
+ theme: { type: "string", description: "Theme name to apply (overrides meta.theme in the deck)" },
11
+ output_path: { type: "string", description: "Absolute or relative path to write the rendered HTML file" }
12
+ },
13
+ required: ["json"]
14
+ },
15
+ handler: async (input) => {
16
+ const rawJson = input["json"];
17
+ const theme = input["theme"];
18
+ const outputPath = input["output_path"];
19
+ let deckJson = rawJson;
20
+ if (theme) {
21
+ let parsed;
22
+ try {
23
+ parsed = JSON.parse(rawJson);
24
+ }
25
+ catch (err) {
26
+ throw new Error(`Invalid JSON: ${err.message}`);
27
+ }
28
+ const meta = (parsed["meta"] ?? {});
29
+ meta["theme"] = theme;
30
+ parsed["meta"] = meta;
31
+ deckJson = JSON.stringify(parsed);
32
+ }
33
+ const html = await renderDeck(deckJson, { themesDir: getBundledThemesDir() });
34
+ let deck;
35
+ try {
36
+ deck = JSON.parse(deckJson);
37
+ }
38
+ catch {
39
+ deck = {};
40
+ }
41
+ const slideCount = Array.isArray(deck.slides) ? deck.slides.length : 0;
42
+ const result = {
43
+ html,
44
+ slide_count: slideCount
45
+ };
46
+ if (outputPath) {
47
+ await writeFile(outputPath, html, "utf-8");
48
+ result.path = outputPath;
49
+ }
50
+ return result;
51
+ }
52
+ };
53
+ //# sourceMappingURL=render-deck.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-deck.js","sourceRoot":"","sources":["../../src/tools/render-deck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE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AAC;QAED,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,mBAAmB,EAAE,EAAE,CAAC,CAAC;QAE9E,IAAI,IAA4B,CAAC;QACjC,IAAI,CAAC;YACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAA2B,CAAC;QACxD,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,GAAG,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAEvE,MAAM,MAAM,GAAyD;YACnE,IAAI;YACJ,WAAW,EAAE,UAAU;SACxB,CAAC;QAEF,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;YAC3C,MAAM,CAAC,IAAI,GAAG,UAAU,CAAC;QAC3B,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@presentation-md/mcp-server",
3
+ "version": "1.0.0",
4
+ "description": "MCP server exposing presentation-md tools to any MCP-compatible AI agent.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/server.js",
8
+ "bin": {
9
+ "presentation-md-mcp": "./dist/server.js"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "dependencies": {
15
+ "@modelcontextprotocol/sdk": "^1.0.0",
16
+ "zod": "^3.23.0",
17
+ "@presentation-md/core": "1.0.0",
18
+ "@presentation-md/create-theme": "1.0.0",
19
+ "@presentation-md/export": "^1.0.0",
20
+ "@presentation-md/render": "1.0.0"
21
+ },
22
+ "devDependencies": {
23
+ "@types/node": "^20.0.0",
24
+ "typescript": "^5.4.0",
25
+ "vitest": "^1.5.0"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/isatimur/presentation-md.git"
33
+ },
34
+ "homepage": "https://presentation-md.vercel.app",
35
+ "bugs": "https://github.com/isatimur/presentation-md/issues",
36
+ "scripts": {
37
+ "build": "tsc -p tsconfig.json",
38
+ "test": "vitest run",
39
+ "lint": "eslint src",
40
+ "typecheck": "tsc --noEmit",
41
+ "start": "node dist/server.js"
42
+ }
43
+ }