@meltemi/diagrams-mcp 0.0.0-stage → 1.11.16

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.
Files changed (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +52 -2
  3. package/dist/catalogue/folder.d.ts +64 -0
  4. package/dist/catalogue/folder.d.ts.map +1 -0
  5. package/dist/catalogue/folder.js +69 -0
  6. package/dist/catalogue/folder.js.map +1 -0
  7. package/dist/catalogue/index.d.ts +475 -0
  8. package/dist/catalogue/index.d.ts.map +1 -0
  9. package/dist/catalogue/index.js +34 -0
  10. package/dist/catalogue/index.js.map +1 -0
  11. package/dist/catalogue/live.d.ts +84 -0
  12. package/dist/catalogue/live.d.ts.map +1 -0
  13. package/dist/catalogue/live.js +123 -0
  14. package/dist/catalogue/live.js.map +1 -0
  15. package/dist/catalogue/preview.d.ts +72 -0
  16. package/dist/catalogue/preview.d.ts.map +1 -0
  17. package/dist/catalogue/preview.js +59 -0
  18. package/dist/catalogue/preview.js.map +1 -0
  19. package/dist/catalogue/projects.d.ts +212 -0
  20. package/dist/catalogue/projects.d.ts.map +1 -0
  21. package/dist/catalogue/projects.js +244 -0
  22. package/dist/catalogue/projects.js.map +1 -0
  23. package/dist/catalogue/sharing.d.ts +150 -0
  24. package/dist/catalogue/sharing.d.ts.map +1 -0
  25. package/dist/catalogue/sharing.js +139 -0
  26. package/dist/catalogue/sharing.js.map +1 -0
  27. package/dist/http.d.ts +26 -0
  28. package/dist/http.d.ts.map +1 -0
  29. package/dist/http.js +74 -0
  30. package/dist/http.js.map +1 -0
  31. package/dist/index.d.ts +5 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +9 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/node.d.ts +28 -0
  36. package/dist/node.d.ts.map +1 -0
  37. package/dist/node.js +78 -0
  38. package/dist/node.js.map +1 -0
  39. package/dist/preview/bounds.d.ts +13 -0
  40. package/dist/preview/bounds.d.ts.map +1 -0
  41. package/dist/preview/bounds.js +15 -0
  42. package/dist/preview/bounds.js.map +1 -0
  43. package/dist/preview/core.d.ts +46 -0
  44. package/dist/preview/core.d.ts.map +1 -0
  45. package/dist/preview/core.js +173 -0
  46. package/dist/preview/core.js.map +1 -0
  47. package/dist/preview/engine.d.ts +67 -0
  48. package/dist/preview/engine.d.ts.map +1 -0
  49. package/dist/preview/engine.js +316 -0
  50. package/dist/preview/engine.js.map +1 -0
  51. package/dist/preview/fonts.d.ts +39 -0
  52. package/dist/preview/fonts.d.ts.map +1 -0
  53. package/dist/preview/fonts.js +189 -0
  54. package/dist/preview/fonts.js.map +1 -0
  55. package/dist/preview/index.d.ts +6 -0
  56. package/dist/preview/index.d.ts.map +1 -0
  57. package/dist/preview/index.js +9 -0
  58. package/dist/preview/index.js.map +1 -0
  59. package/dist/preview/protocol.d.ts +147 -0
  60. package/dist/preview/protocol.d.ts.map +1 -0
  61. package/dist/preview/protocol.js +100 -0
  62. package/dist/preview/protocol.js.map +1 -0
  63. package/dist/preview/raster.d.ts +24 -0
  64. package/dist/preview/raster.d.ts.map +1 -0
  65. package/dist/preview/raster.js +63 -0
  66. package/dist/preview/raster.js.map +1 -0
  67. package/dist/serve.d.ts +78 -0
  68. package/dist/serve.d.ts.map +1 -0
  69. package/dist/serve.js +139 -0
  70. package/dist/serve.js.map +1 -0
  71. package/dist/shapes.d.ts +65 -0
  72. package/dist/shapes.d.ts.map +1 -0
  73. package/dist/shapes.js +108 -0
  74. package/dist/shapes.js.map +1 -0
  75. package/package.json +61 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Architecture Studio contributors
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 CHANGED
@@ -1,3 +1,53 @@
1
- # Temporary Holding Version
1
+ # @meltemi/diagrams-mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Model Context Protocol tools of Meltemi Diagrams, defined once: the catalogue of twenty-seven
4
+ tools (projects, files, versions, previews, sharing, live sessions and publishing), the wrapper
5
+ that answers every call with stable error codes, the stateless Streamable HTTP handler, and the
6
+ engine that checks a project and draws its previews. The hosted endpoint
7
+ (`https://diagrams.meltemi.dev/mcp`) and the command line's local server (`mdg mcp`) are both
8
+ built from it, so they list the same tools and draw the same pictures.
9
+
10
+ It is part of [Meltemi Diagrams](https://github.com/askenaz-dev/meltemi-diagrams#readme), diagrams as code with a canvas, motion and
11
+ exports. Every package of the product has the same version. To give an agent these tools, run
12
+ `mdg mcp` from [`@meltemi/diagrams-cli`](https://www.npmjs.com/package/@meltemi/diagrams-cli)
13
+ rather than this package.
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ npm install @meltemi/diagrams-mcp
19
+ ```
20
+
21
+ Node 22.12.0 or later. The package is an ES module with type declarations.
22
+
23
+ ## Use
24
+
25
+ ```ts
26
+ import { nodeRenderer } from "@meltemi/diagrams-mcp/node";
27
+
28
+ const renderer = nodeRenderer();
29
+ const outcome = await renderer.render({
30
+ revision: 1,
31
+ files: { "shop.meltemi": 'language "0.2"\n\ndiagram shop: flow {\n web -> api\n}\n' },
32
+ file: "shop.meltemi",
33
+ format: "png",
34
+ });
35
+ console.log(outcome.ok && outcome.contentType, outcome.ok && outcome.report.elements); // image/png 2
36
+ ```
37
+
38
+ - `@meltemi/diagrams-mcp`: `TOOLS` and `CATALOGUE`, `buildServer`, `statelessHandler`, `Refusal`
39
+ and the shapes.
40
+ - `@meltemi/diagrams-mcp/preview`: `RendererCore`, `PreviewEngine`, the rasteriser and the bounds
41
+ of a picture, with nothing of the platform.
42
+ - `@meltemi/diagrams-mcp/node`: the engine over the installed fonts, icons and resvg.
43
+
44
+ ## Documentation
45
+
46
+ - [Agents](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/docs/agents.md)
47
+ - [The command line](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/docs/cli.md)
48
+ - [All documentation](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/docs/README.md)
49
+
50
+ ## Licence
51
+
52
+ MIT. Third-party components and their licences are listed in [THIRD_PARTY_LICENSES.md](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/THIRD_PARTY_LICENSES.md).
53
+ `@resvg/resvg-wasm` (MPL-2.0) is a dependency, used unmodified.
@@ -0,0 +1,64 @@
1
+ import * as z from "zod";
2
+ /** The two tools of a folder, by name. */
3
+ export declare const FOLDER_TOOLS: {
4
+ readonly validate: import("../serve.js").ToolDefinition<z.ZodObject<{
5
+ path: z.ZodOptional<z.ZodString>;
6
+ }, z.core.$strip>, z.ZodObject<{
7
+ errors: z.ZodNumber;
8
+ warnings: z.ZodNumber;
9
+ diagnostics: z.ZodArray<z.ZodObject<{
10
+ path: z.ZodString;
11
+ code: z.ZodString;
12
+ severity: z.ZodEnum<{
13
+ error: "error";
14
+ warning: "warning";
15
+ info: "info";
16
+ }>;
17
+ message: z.ZodString;
18
+ line: z.ZodNumber;
19
+ column: z.ZodNumber;
20
+ }, z.core.$strip>>;
21
+ truncated: z.ZodBoolean;
22
+ }, z.core.$strip>>;
23
+ readonly preview: import("../serve.js").ToolDefinition<z.ZodObject<{
24
+ path: z.ZodString;
25
+ diagram: z.ZodOptional<z.ZodString>;
26
+ story: z.ZodOptional<z.ZodString>;
27
+ at: z.ZodOptional<z.ZodString>;
28
+ format: z.ZodOptional<z.ZodEnum<{
29
+ png: "png";
30
+ svg: "svg";
31
+ }>>;
32
+ width: z.ZodOptional<z.ZodNumber>;
33
+ theme: z.ZodOptional<z.ZodString>;
34
+ }, z.core.$strip>, z.ZodObject<{
35
+ format: z.ZodEnum<{
36
+ png: "png";
37
+ svg: "svg";
38
+ }>;
39
+ diagnostics: z.ZodArray<z.ZodObject<{
40
+ path: z.ZodString;
41
+ code: z.ZodString;
42
+ severity: z.ZodEnum<{
43
+ error: "error";
44
+ warning: "warning";
45
+ info: "info";
46
+ }>;
47
+ message: z.ZodString;
48
+ line: z.ZodNumber;
49
+ column: z.ZodNumber;
50
+ }, z.core.$strip>>;
51
+ width: z.ZodNumber;
52
+ height: z.ZodNumber;
53
+ elements: z.ZodNumber;
54
+ relations: z.ZodNumber;
55
+ estimatedFonts: z.ZodArray<z.ZodString>;
56
+ truncated: z.ZodBoolean;
57
+ fitted: z.ZodOptional<z.ZodBoolean>;
58
+ cached: z.ZodBoolean;
59
+ }, z.core.$strip>>;
60
+ };
61
+ export type FolderToolName = keyof typeof FOLDER_TOOLS;
62
+ /** What `initialize` answers for a folder. */
63
+ export declare function folderInstructions(): string;
64
+ //# sourceMappingURL=folder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folder.d.ts","sourceRoot":"","sources":["../../src/catalogue/folder.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAazB,0CAA0C;AAC1C,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Cf,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,YAAY,CAAC;AAEvD,8CAA8C;AAC9C,wBAAgB,kBAAkB,IAAI,MAAM,CAM3C"}
@@ -0,0 +1,69 @@
1
+ // The tools of a folder (`mcp-local-server`, "A folder with no account"): `mdg mcp --folder <dir>`
2
+ // checks and draws the `.meltemi` files of a folder on disk, with no account and no network, so an
3
+ // agent working in a repository gets the same pictures as tool results. Two tools, with the cloud
4
+ // tools' names, words and reports, without a project or a revision.
5
+ import * as z from "zod";
6
+ import { MAX_PNG_WIDTH, MIN_PNG_WIDTH } from "../preview/bounds.js";
7
+ import { define } from "../serve.js";
8
+ import { diagnosticSchema } from "../shapes.js";
9
+ import { reportSchema } from "./preview.js";
10
+ /** A file's path from the folder's root. */
11
+ const folderPathArg = z
12
+ .string()
13
+ .min(1)
14
+ .max(1024)
15
+ .describe("A file's path from the folder's root, such as `flows/checkout.meltemi`.");
16
+ /** The two tools of a folder, by name. */
17
+ export const FOLDER_TOOLS = {
18
+ validate: define({
19
+ name: "validate",
20
+ title: "Validate",
21
+ description: "The diagnostics of a file of the folder, or of the whole folder as a project, as `meltemi-diagrams validate` prints them (the layout's warnings included), read from disk now. Images and fonts are checked by preview.",
22
+ scope: "projects:read",
23
+ input: z.object({ path: folderPathArg.optional() }),
24
+ output: z.object({
25
+ errors: z.number(),
26
+ warnings: z.number(),
27
+ diagnostics: z.array(diagnosticSchema).describe("The first fifty."),
28
+ truncated: z.boolean(),
29
+ }),
30
+ annotations: { readOnlyHint: true, openWorldHint: false },
31
+ }),
32
+ preview: define({
33
+ name: "preview",
34
+ title: "Preview",
35
+ description: `A picture of a diagram (the file's first, or the one named) or of a story's frame (at \`at\`, its end by default) of the folder as it is on disk now, drawn on this machine with the command line's engine: a PNG ${MIN_PNG_WIDTH} to ${MAX_PNG_WIDTH} pixels wide (1280 by default), or with format svg the SVG as text. A report beside it says the size, the elements and relations drawn, the warnings and the fonts that were estimated, so the drawing can be judged without seeing it.`,
36
+ scope: "projects:read",
37
+ preview: true,
38
+ input: z.object({
39
+ path: folderPathArg.describe("The .meltemi file to draw."),
40
+ diagram: z.string().optional().describe("The diagram's id; the file's first when left out."),
41
+ story: z.string().optional().describe("A story's id: its frame at `at` is drawn instead."),
42
+ at: z
43
+ .string()
44
+ .optional()
45
+ .describe("The story's time, such as 2.4s or 1500ms; its end by default."),
46
+ format: z.enum(["png", "svg"]).optional(),
47
+ width: z
48
+ .number()
49
+ .int()
50
+ .optional()
51
+ .describe(`A PNG's width in pixels, ${MIN_PNG_WIDTH} to ${MAX_PNG_WIDTH}.`),
52
+ theme: z
53
+ .string()
54
+ .optional()
55
+ .describe("A theme over the diagram's own, as the command line's --theme."),
56
+ }),
57
+ output: reportSchema.omit({ revision: true }),
58
+ annotations: { readOnlyHint: true, openWorldHint: false },
59
+ }),
60
+ };
61
+ /** What `initialize` answers for a folder. */
62
+ export function folderInstructions() {
63
+ return [
64
+ "These tools check and draw the Meltemi Diagrams files of a folder on this machine, where diagrams are `.meltemi` text files: validate reports their diagnostics and preview answers a picture of a diagram or of a story's frame, read from disk at each call.",
65
+ "Write the files with your own file tools, then validate and preview to judge the drawing.",
66
+ "The language and its rules are taught by the Meltemi Diagrams skill (https://diagrams.meltemi.dev/agent-setup).",
67
+ ].join(" ");
68
+ }
69
+ //# sourceMappingURL=folder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folder.js","sourceRoot":"","sources":["../../src/catalogue/folder.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,mGAAmG;AACnG,kGAAkG;AAClG,oEAAoE;AAEpE,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;A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