@diagrampilot/mcp 0.2.9
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 +21 -0
- package/README.md +19 -0
- package/dist/cli.d.ts +5 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +29 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/registry.d.ts +6 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +156 -0
- package/dist/registry.js.map +1 -0
- package/dist/runtime.d.ts +6 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +275 -0
- package/dist/runtime.js.map +1 -0
- package/dist/server.d.ts +5 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +114 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +70 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DiagramPilot 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
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @diagrampilot/mcp
|
|
2
|
+
|
|
3
|
+
Model Context Protocol server for DiagramPilot.
|
|
4
|
+
|
|
5
|
+
Most users should launch MCP through the `diagrampilot mcp` command. Use this
|
|
6
|
+
package when an MCP client expects a dedicated package-level executable:
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
diagrampilot-mcp
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
MCP support is alpha. The server exposes read-only DiagramPilot resources,
|
|
13
|
+
tools, and prompts for AI coding agents working in local repositories.
|
|
14
|
+
|
|
15
|
+
Public documentation:
|
|
16
|
+
|
|
17
|
+
- https://diagrampilot.com/docs/agents/mcp.md
|
|
18
|
+
- https://diagrampilot.com/docs/agents/quickstart.md
|
|
19
|
+
- https://diagrampilot.com/docs/agents/spec.md
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAqChD,wBAAsB,SAAS,CAC7B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,EAAE,aAAa,EACtB,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GACrC,OAAO,CAAC,MAAM,CAAC,CAKjB"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { mcpHelpText } from "./runtime.js";
|
|
2
|
+
import { runStdioMcpServer } from "./server.js";
|
|
3
|
+
function showHelp(streams, commandName) {
|
|
4
|
+
streams.stdout.write(mcpHelpText(commandName));
|
|
5
|
+
return 0;
|
|
6
|
+
}
|
|
7
|
+
async function startServer() {
|
|
8
|
+
await runStdioMcpServer();
|
|
9
|
+
return 0;
|
|
10
|
+
}
|
|
11
|
+
function rejectUnexpectedArgs(streams, commandName) {
|
|
12
|
+
streams.stderr.write([
|
|
13
|
+
"DiagramPilot MCP server requires an MCP client stdio connection.",
|
|
14
|
+
`Run \`${commandName} --help\` for usage.`,
|
|
15
|
+
"",
|
|
16
|
+
].join("\n"));
|
|
17
|
+
return 1;
|
|
18
|
+
}
|
|
19
|
+
const cliHandlers = new Map([
|
|
20
|
+
[undefined, () => startServer()],
|
|
21
|
+
["--help", showHelp],
|
|
22
|
+
["-h", showHelp],
|
|
23
|
+
]);
|
|
24
|
+
export async function runMcpCli(args, streams, options = {}) {
|
|
25
|
+
const commandName = options.commandName ?? "diagrampilot-mcp";
|
|
26
|
+
const handler = cliHandlers.get(args[0]) ?? rejectUnexpectedArgs;
|
|
27
|
+
return handler(streams, commandName);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAQhD,SAAS,QAAQ,CAAC,OAAsB,EAAE,WAAmB;IAC3D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/C,OAAO,CAAC,CAAC;AACX,CAAC;AAED,KAAK,UAAU,WAAW;IACxB,MAAM,iBAAiB,EAAE,CAAC;IAC1B,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,oBAAoB,CAC3B,OAAsB,EACtB,WAAmB;IAEnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB;QACE,kEAAkE;QAClE,SAAS,WAAW,sBAAsB;QAC1C,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IACF,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,WAAW,GAAG,IAAI,GAAG,CAAiC;IAC1D,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;IAChC,CAAC,QAAQ,EAAE,QAAQ,CAAC;IACpB,CAAC,IAAI,EAAE,QAAQ,CAAC;CACjB,CAAC,CAAC;AAEH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,IAAuB,EACvB,OAAsB,EACtB,UAAoC,EAAE;IAEtC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,kBAAkB,CAAC;IAC9D,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,oBAAoB,CAAC;IAEjE,OAAO,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AACvC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAOA,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { runMcpCli } from "./cli.js";
|
|
6
|
+
export * from "./cli.js";
|
|
7
|
+
export * from "./registry.js";
|
|
8
|
+
export * from "./runtime.js";
|
|
9
|
+
export * from "./server.js";
|
|
10
|
+
export * from "./types.js";
|
|
11
|
+
function realpathIfPresent(filePath) {
|
|
12
|
+
try {
|
|
13
|
+
return realpathSync(filePath);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return path.resolve(filePath);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const directEntryPath = process.argv[1] === undefined ? undefined : realpathIfPresent(process.argv[1]);
|
|
20
|
+
if (directEntryPath === fileURLToPath(import.meta.url)) {
|
|
21
|
+
process.exitCode = await runMcpCli(process.argv.slice(2), {
|
|
22
|
+
stdout: process.stdout,
|
|
23
|
+
stderr: process.stderr,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAE3B,SAAS,iBAAiB,CAAC,QAAgB;IACzC,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED,MAAM,eAAe,GACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAEjF,IAAI,eAAe,KAAK,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACvD,OAAO,CAAC,QAAQ,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;QACxD,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DiagramPilotMcpPrompt, DiagramPilotMcpResource, DiagramPilotMcpTool } from "./types.js";
|
|
2
|
+
export declare const DIAGRAMPILOT_MCP_PACKAGE_NAME = "@diagrampilot/mcp";
|
|
3
|
+
export declare const DIAGRAMPILOT_MCP_RESOURCES: readonly DiagramPilotMcpResource[];
|
|
4
|
+
export declare const DIAGRAMPILOT_MCP_TOOLS: readonly DiagramPilotMcpTool[];
|
|
5
|
+
export declare const DIAGRAMPILOT_MCP_PROMPTS: readonly DiagramPilotMcpPrompt[];
|
|
6
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,6BAA6B,sBAAsB,CAAC;AAEjE,eAAO,MAAM,0BAA0B,EAAE,SAAS,uBAAuB,EAoCxE,CAAC;AAQF,eAAO,MAAM,sBAAsB,EAAE,SAAS,mBAAmB,EA0DhE,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,SAAS,qBAAqB,EAoDpE,CAAC"}
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
export const DIAGRAMPILOT_MCP_PACKAGE_NAME = "@diagrampilot/mcp";
|
|
2
|
+
export const DIAGRAMPILOT_MCP_RESOURCES = [
|
|
3
|
+
{
|
|
4
|
+
name: "diagrampilot_schema_v1",
|
|
5
|
+
uriTemplate: "diagrampilot://schema/{version}",
|
|
6
|
+
title: "DiagramSpec v1 JSON Schema",
|
|
7
|
+
description: "Read the generated DiagramSpec v1 JSON Schema.",
|
|
8
|
+
mimeType: "application/schema+json",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
name: "diagrampilot_docs",
|
|
12
|
+
uriTemplate: "diagrampilot://docs/{page}",
|
|
13
|
+
title: "DiagramPilot Public Documentation",
|
|
14
|
+
description: "Read canonical public DiagramPilot Markdown documentation.",
|
|
15
|
+
mimeType: "text/markdown",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "diagrampilot_examples",
|
|
19
|
+
uriTemplate: "diagrampilot://examples/{name}",
|
|
20
|
+
title: "DiagramPilot Examples",
|
|
21
|
+
description: "Read DiagramPilot example sources and explanation.",
|
|
22
|
+
mimeType: "text/markdown",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "diagrampilot_discovered_sources",
|
|
26
|
+
uriTemplate: "diagrampilot://sources/{scope}",
|
|
27
|
+
title: "Discovered DiagramPilot Source Files",
|
|
28
|
+
description: "Discover DiagramPilot Source Files under a local scope.",
|
|
29
|
+
mimeType: "application/json",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "diagrampilot_check_results",
|
|
33
|
+
uriTemplate: "diagrampilot://check/{scope}",
|
|
34
|
+
title: "Repo Workflow Check Results",
|
|
35
|
+
description: "Read Repo Workflow Check results for a local scope.",
|
|
36
|
+
mimeType: "application/json",
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
const readOnlyToolAnnotations = {
|
|
40
|
+
readOnlyHint: true,
|
|
41
|
+
destructiveHint: false,
|
|
42
|
+
idempotentHint: true,
|
|
43
|
+
};
|
|
44
|
+
export const DIAGRAMPILOT_MCP_TOOLS = [
|
|
45
|
+
{
|
|
46
|
+
name: "diagrampilot_validate_source",
|
|
47
|
+
title: "Validate DiagramPilot Source",
|
|
48
|
+
description: "Validate one DiagramPilot Source File and return repairable errors.",
|
|
49
|
+
arguments: [
|
|
50
|
+
{
|
|
51
|
+
name: "source_path",
|
|
52
|
+
description: "Local path to a *.dp.yaml DiagramPilot Source File.",
|
|
53
|
+
required: true,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
annotations: readOnlyToolAnnotations,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "diagrampilot_check_repo",
|
|
60
|
+
title: "Check DiagramPilot Repo Workflow",
|
|
61
|
+
description: "Run the read-only Repo Workflow Check for a local scope.",
|
|
62
|
+
arguments: [
|
|
63
|
+
{
|
|
64
|
+
name: "scope_path",
|
|
65
|
+
description: "Local directory or DiagramPilot Source File path to check.",
|
|
66
|
+
required: false,
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
annotations: readOnlyToolAnnotations,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "diagrampilot_export_source",
|
|
73
|
+
title: "Export DiagramPilot Source",
|
|
74
|
+
description: "Export one valid DiagramPilot Source File to Mermaid, D2, or DOT text.",
|
|
75
|
+
arguments: [
|
|
76
|
+
{
|
|
77
|
+
name: "source_path",
|
|
78
|
+
description: "Local path to a *.dp.yaml DiagramPilot Source File.",
|
|
79
|
+
required: true,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "format",
|
|
83
|
+
description: "Export format: mermaid, d2, or dot.",
|
|
84
|
+
required: true,
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
annotations: readOnlyToolAnnotations,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "diagrampilot_render_source",
|
|
91
|
+
title: "Render DiagramPilot Source",
|
|
92
|
+
description: "Render one valid DiagramPilot Source File to SVG text without writing it.",
|
|
93
|
+
arguments: [
|
|
94
|
+
{
|
|
95
|
+
name: "source_path",
|
|
96
|
+
description: "Local path to a *.dp.yaml DiagramPilot Source File.",
|
|
97
|
+
required: true,
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
annotations: readOnlyToolAnnotations,
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
export const DIAGRAMPILOT_MCP_PROMPTS = [
|
|
104
|
+
{
|
|
105
|
+
name: "create_or_update_diagrampilot_source",
|
|
106
|
+
title: "Create Or Update DiagramPilot Source",
|
|
107
|
+
description: "Create or update a DiagramPilot Source File from repository context.",
|
|
108
|
+
arguments: [
|
|
109
|
+
{
|
|
110
|
+
name: "goal",
|
|
111
|
+
description: "Diagram update goal or desired diagram coverage.",
|
|
112
|
+
required: true,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "scope_path",
|
|
116
|
+
description: "Local repository scope to inspect.",
|
|
117
|
+
required: false,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "source_path",
|
|
121
|
+
description: "Existing or desired DiagramPilot Source File path.",
|
|
122
|
+
required: false,
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "repair_diagrampilot_validation_errors",
|
|
128
|
+
title: "Repair DiagramPilot Validation Errors",
|
|
129
|
+
description: "Repair validation errors in a DiagramPilot Source File.",
|
|
130
|
+
arguments: [
|
|
131
|
+
{
|
|
132
|
+
name: "source_path",
|
|
133
|
+
description: "DiagramPilot Source File path to repair.",
|
|
134
|
+
required: true,
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "validation_errors",
|
|
138
|
+
description: "Repairable validation errors returned by DiagramPilot.",
|
|
139
|
+
required: true,
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "refresh_diagrampilot_artifacts",
|
|
145
|
+
title: "Refresh DiagramPilot Derived Artifacts",
|
|
146
|
+
description: "Refresh Derived Artifacts after source changes.",
|
|
147
|
+
arguments: [
|
|
148
|
+
{
|
|
149
|
+
name: "scope_path",
|
|
150
|
+
description: "Local repository scope to check and generate.",
|
|
151
|
+
required: false,
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
];
|
|
156
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,6BAA6B,GAAG,mBAAmB,CAAC;AAEjE,MAAM,CAAC,MAAM,0BAA0B,GAAuC;IAC5E;QACE,IAAI,EAAE,wBAAwB;QAC9B,WAAW,EAAE,iCAAiC;QAC9C,KAAK,EAAE,4BAA4B;QACnC,WAAW,EAAE,gDAAgD;QAC7D,QAAQ,EAAE,yBAAyB;KACpC;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,WAAW,EAAE,4BAA4B;QACzC,KAAK,EAAE,mCAAmC;QAC1C,WAAW,EAAE,4DAA4D;QACzE,QAAQ,EAAE,eAAe;KAC1B;IACD;QACE,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EAAE,gCAAgC;QAC7C,KAAK,EAAE,uBAAuB;QAC9B,WAAW,EAAE,oDAAoD;QACjE,QAAQ,EAAE,eAAe;KAC1B;IACD;QACE,IAAI,EAAE,iCAAiC;QACvC,WAAW,EAAE,gCAAgC;QAC7C,KAAK,EAAE,sCAAsC;QAC7C,WAAW,EAAE,yDAAyD;QACtE,QAAQ,EAAE,kBAAkB;KAC7B;IACD;QACE,IAAI,EAAE,4BAA4B;QAClC,WAAW,EAAE,8BAA8B;QAC3C,KAAK,EAAE,6BAA6B;QACpC,WAAW,EAAE,qDAAqD;QAClE,QAAQ,EAAE,kBAAkB;KAC7B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AsC;QAC5C,KAAK,EAAE,sCAAsC;QAC7C,WAAW,EAAE,sEAAsE;QACnF,SAAS,EAAE;YACT;gBACE,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,kDAAkD;gBAC/D,QAAQ,EAAE,IAAI;aACf;YACD;gBACE,IAAI,EAAE,YAAY;gBAClB,WAAW,EAAE,oCAAoC;gBACjD,QAAQ,EAAE,KAAK;aAChB;YACD;gBACE,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,oDAAoD;gBACjE,QAAQ,EAAE,KAAK;aAChB;SACF;KACF;IACD;QACE,IAAI,EAAE,uCAAuC;QAC7C,KAAK,EAAE,uCAAuC;QAC9C,WAAW,EAAE,yDAAyD;QACtE,SAAS,EAAE;YACT;gBACE,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,0CAA0C;gBACvD,QAAQ,EAAE,IAAI;aACf;YACD;gBACE,IAAI,EAAE,mBAAmB;gBACzB,WAAW,EAAE,wDAAwD;gBACrE,QAAQ,EAAE,IAAI;aACf;SACF;KACF;IACD;QACE,IAAI,EAAE,gCAAgC;QACtC,KAAK,EAAE,wCAAwC;QAC/C,WAAW,EAAE,iDAAiD;QAC9D,SAAS,EAAE;YACT;gBACE,IAAI,EAAE,YAAY;gBAClB,WAAW,EAAE,+CAA+C;gBAC5D,QAAQ,EAAE,KAAK;aAChB;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DiagramPilotMcpPromptResult, DiagramPilotMcpResourceContent, DiagramPilotMcpToolDependencies, DiagramPilotMcpToolResult } from "./types.js";
|
|
2
|
+
export declare function mcpHelpText(commandName?: string): string;
|
|
3
|
+
export declare function readDiagramPilotMcpResource(uri: string): Promise<DiagramPilotMcpResourceContent>;
|
|
4
|
+
export declare function callDiagramPilotMcpTool(name: string, args: Record<string, unknown>, dependencies?: DiagramPilotMcpToolDependencies): Promise<DiagramPilotMcpToolResult>;
|
|
5
|
+
export declare function getDiagramPilotMcpPrompt(name: string, args?: Record<string, string>): DiagramPilotMcpPromptResult;
|
|
6
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EACV,2BAA2B,EAC3B,8BAA8B,EAC9B,+BAA+B,EAC/B,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AAKpB,wBAAgB,WAAW,CAAC,WAAW,SAAqB,GAAG,MAAM,CASpE;AAwMD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,8BAA8B,CAAC,CASzC;AAED,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,YAAY,GAAE,+BAAoC,GACjD,OAAO,CAAC,yBAAyB,CAAC,CAQpC;AAgID,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAChC,2BAA2B,CAoB7B"}
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { checkDiagramPilotRepoWorkflow, createDiagramSpecV1JsonSchema, createRepairableDiagnosticReport, discoverDiagramPilotSourceFiles, loadValidatedDiagramSpec, } from "@diagrampilot/core";
|
|
5
|
+
import { exportDiagramSpecToD2 } from "@diagrampilot/export-d2";
|
|
6
|
+
import { exportDiagramSpecToDot } from "@diagrampilot/export-dot";
|
|
7
|
+
import { exportDiagramSpecToMermaid } from "@diagrampilot/export-mermaid";
|
|
8
|
+
import { createSvgRendererProvenance, renderDiagramSpecToSvg, SVG_RENDERER_NAME, SVG_RENDERER_VERSION, } from "@diagrampilot/render-svg";
|
|
9
|
+
import { DIAGRAMPILOT_MCP_PROMPTS } from "./registry.js";
|
|
10
|
+
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
11
|
+
const repositoryRoot = path.resolve(packageRoot, "..", "..");
|
|
12
|
+
export function mcpHelpText(commandName = "diagrampilot-mcp") {
|
|
13
|
+
return [
|
|
14
|
+
"DiagramPilot MCP server",
|
|
15
|
+
"",
|
|
16
|
+
`Usage: ${commandName}`,
|
|
17
|
+
"",
|
|
18
|
+
"Starts the alpha DiagramPilot MCP server over stdio.",
|
|
19
|
+
"",
|
|
20
|
+
].join("\n");
|
|
21
|
+
}
|
|
22
|
+
function readRepoText(relativePath) {
|
|
23
|
+
return readFileSync(path.join(repositoryRoot, relativePath), "utf8");
|
|
24
|
+
}
|
|
25
|
+
function resourceContent(uri, mimeType, text) {
|
|
26
|
+
return { uri, mimeType, text };
|
|
27
|
+
}
|
|
28
|
+
function resourcePathParts(uri) {
|
|
29
|
+
const parsed = new URL(uri);
|
|
30
|
+
if (parsed.protocol !== "diagrampilot:") {
|
|
31
|
+
throw new Error(`Unsupported DiagramPilot MCP resource URI: ${uri}`);
|
|
32
|
+
}
|
|
33
|
+
return [
|
|
34
|
+
parsed.hostname,
|
|
35
|
+
...parsed.pathname.split("/").filter((part) => part.length > 0),
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
function decodePathPart(value, fallback) {
|
|
39
|
+
return value === undefined ? fallback : decodeURIComponent(value);
|
|
40
|
+
}
|
|
41
|
+
function docsPath(page) {
|
|
42
|
+
return page === "index" ? "docs-public/index.md" : `docs-public/agents/${page}.md`;
|
|
43
|
+
}
|
|
44
|
+
function readExample(name) {
|
|
45
|
+
if (name !== "checkout") {
|
|
46
|
+
throw new Error(`Unknown DiagramPilot example: ${name}`);
|
|
47
|
+
}
|
|
48
|
+
const source = readRepoText("demo-projects/checkout/docs/architecture.dp.yaml");
|
|
49
|
+
return [
|
|
50
|
+
"# Checkout Architecture",
|
|
51
|
+
"",
|
|
52
|
+
"Canonical checkout demo DiagramPilot Source File.",
|
|
53
|
+
"",
|
|
54
|
+
"```yaml",
|
|
55
|
+
source.trimEnd(),
|
|
56
|
+
"```",
|
|
57
|
+
"",
|
|
58
|
+
].join("\n");
|
|
59
|
+
}
|
|
60
|
+
function exportText(format, spec) {
|
|
61
|
+
if (format === "mermaid")
|
|
62
|
+
return exportDiagramSpecToMermaid(spec);
|
|
63
|
+
if (format === "d2")
|
|
64
|
+
return exportDiagramSpecToD2(spec);
|
|
65
|
+
if (format === "dot")
|
|
66
|
+
return exportDiagramSpecToDot(spec);
|
|
67
|
+
throw new Error(`Unsupported DiagramPilot export format: ${format}`);
|
|
68
|
+
}
|
|
69
|
+
function toolResult(text, structuredContent, options = {}) {
|
|
70
|
+
return {
|
|
71
|
+
content: [{ type: "text", text }],
|
|
72
|
+
structuredContent,
|
|
73
|
+
...(options.isError === true ? { isError: true } : {}),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function stringArgument(args, name, fallback) {
|
|
77
|
+
const value = args[name];
|
|
78
|
+
if (typeof value === "string" && value.length > 0)
|
|
79
|
+
return value;
|
|
80
|
+
if (fallback !== undefined)
|
|
81
|
+
return fallback;
|
|
82
|
+
throw new Error(`Missing required MCP tool argument: ${name}`);
|
|
83
|
+
}
|
|
84
|
+
function validationFailureResult(failure) {
|
|
85
|
+
const report = createRepairableDiagnosticReport(failure);
|
|
86
|
+
return toolResult(report.text, {
|
|
87
|
+
ok: false,
|
|
88
|
+
errorCount: report.errors.length,
|
|
89
|
+
errors: report.errors,
|
|
90
|
+
}, { isError: true });
|
|
91
|
+
}
|
|
92
|
+
async function schemaResource(uri, value) {
|
|
93
|
+
if (value !== "v1") {
|
|
94
|
+
throw new Error(`Unknown DiagramPilot schema resource: ${uri}`);
|
|
95
|
+
}
|
|
96
|
+
return resourceContent(uri, "application/schema+json", `${JSON.stringify(createDiagramSpecV1JsonSchema(), null, 2)}\n`);
|
|
97
|
+
}
|
|
98
|
+
async function docsResource(uri, value) {
|
|
99
|
+
return resourceContent(uri, "text/markdown", readRepoText(docsPath(decodePathPart(value, "index"))));
|
|
100
|
+
}
|
|
101
|
+
async function exampleResource(uri, value) {
|
|
102
|
+
return resourceContent(uri, "text/markdown", readExample(decodePathPart(value, "checkout")));
|
|
103
|
+
}
|
|
104
|
+
async function sourcesResource(uri, value) {
|
|
105
|
+
const scopePath = decodePathPart(value, process.cwd());
|
|
106
|
+
const discovery = await discoverDiagramPilotSourceFiles(scopePath);
|
|
107
|
+
const payload = discovery.ok
|
|
108
|
+
? {
|
|
109
|
+
ok: true,
|
|
110
|
+
scope: discovery.scope,
|
|
111
|
+
sources: discovery.sources.map((source) => ({
|
|
112
|
+
relativePath: source.relativePath,
|
|
113
|
+
})),
|
|
114
|
+
}
|
|
115
|
+
: {
|
|
116
|
+
ok: false,
|
|
117
|
+
failure: discovery.failure,
|
|
118
|
+
};
|
|
119
|
+
return resourceContent(uri, "application/json", `${JSON.stringify(payload, null, 2)}\n`);
|
|
120
|
+
}
|
|
121
|
+
async function checkResource(uri, value) {
|
|
122
|
+
const scopePath = decodePathPart(value, process.cwd());
|
|
123
|
+
const result = await checkDiagramPilotRepoWorkflow({
|
|
124
|
+
scopePath,
|
|
125
|
+
renderer: {
|
|
126
|
+
name: SVG_RENDERER_NAME,
|
|
127
|
+
version: SVG_RENDERER_VERSION,
|
|
128
|
+
},
|
|
129
|
+
exportConfiguredTextArtifact: ({ format, spec }) => exportText(format, spec),
|
|
130
|
+
});
|
|
131
|
+
return resourceContent(uri, "application/json", `${JSON.stringify(result, null, 2)}\n`);
|
|
132
|
+
}
|
|
133
|
+
const resourceHandlers = {
|
|
134
|
+
schema: schemaResource,
|
|
135
|
+
docs: docsResource,
|
|
136
|
+
examples: exampleResource,
|
|
137
|
+
sources: sourcesResource,
|
|
138
|
+
check: checkResource,
|
|
139
|
+
};
|
|
140
|
+
export async function readDiagramPilotMcpResource(uri) {
|
|
141
|
+
const [kind, value] = resourcePathParts(uri);
|
|
142
|
+
const handler = resourceHandlers[kind];
|
|
143
|
+
if (handler === undefined) {
|
|
144
|
+
throw new Error(`Unknown DiagramPilot MCP resource: ${uri}`);
|
|
145
|
+
}
|
|
146
|
+
return handler(uri, value);
|
|
147
|
+
}
|
|
148
|
+
export async function callDiagramPilotMcpTool(name, args, dependencies = {}) {
|
|
149
|
+
const handler = toolHandlers[name];
|
|
150
|
+
if (handler === undefined) {
|
|
151
|
+
throw new Error(`Unknown DiagramPilot MCP tool: ${name}`);
|
|
152
|
+
}
|
|
153
|
+
return handler(args, dependencies);
|
|
154
|
+
}
|
|
155
|
+
async function validateSourceTool(args) {
|
|
156
|
+
const sourcePath = stringArgument(args, "source_path");
|
|
157
|
+
const loaded = loadValidatedDiagramSpec(sourcePath);
|
|
158
|
+
if (!loaded.ok)
|
|
159
|
+
return validationFailureResult(loaded.failure);
|
|
160
|
+
return toolResult(`Valid ${sourcePath}\n`, {
|
|
161
|
+
ok: true,
|
|
162
|
+
errorCount: 0,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
async function checkRepoTool(args) {
|
|
166
|
+
const scopePath = stringArgument(args, "scope_path", process.cwd());
|
|
167
|
+
const result = await checkDiagramPilotRepoWorkflow({
|
|
168
|
+
scopePath,
|
|
169
|
+
renderer: {
|
|
170
|
+
name: SVG_RENDERER_NAME,
|
|
171
|
+
version: SVG_RENDERER_VERSION,
|
|
172
|
+
},
|
|
173
|
+
exportConfiguredTextArtifact: ({ format, spec }) => exportText(format, spec),
|
|
174
|
+
});
|
|
175
|
+
return toolResult(`${JSON.stringify(result, null, 2)}\n`, result);
|
|
176
|
+
}
|
|
177
|
+
async function exportSourceTool(args) {
|
|
178
|
+
const sourcePath = stringArgument(args, "source_path");
|
|
179
|
+
const format = stringArgument(args, "format");
|
|
180
|
+
const loaded = loadValidatedDiagramSpec(sourcePath);
|
|
181
|
+
if (!loaded.ok)
|
|
182
|
+
return validationFailureResult(loaded.failure);
|
|
183
|
+
return toolResult(exportText(format, loaded.spec), {
|
|
184
|
+
ok: true,
|
|
185
|
+
format,
|
|
186
|
+
sourcePath,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
async function renderSourceTool(args, dependencies) {
|
|
190
|
+
const sourcePath = stringArgument(args, "source_path");
|
|
191
|
+
const loaded = loadValidatedDiagramSpec(sourcePath);
|
|
192
|
+
if (!loaded.ok)
|
|
193
|
+
return validationFailureResult(loaded.failure);
|
|
194
|
+
const render = dependencies.renderDiagramSpecToSvg ?? renderDiagramSpecToSvg;
|
|
195
|
+
const svg = await render(loaded.spec, {
|
|
196
|
+
provenance: createSvgRendererProvenance({
|
|
197
|
+
sourcePath,
|
|
198
|
+
sourceContent: loaded.source.content,
|
|
199
|
+
}),
|
|
200
|
+
});
|
|
201
|
+
return toolResult(svg, {
|
|
202
|
+
ok: true,
|
|
203
|
+
format: "svg",
|
|
204
|
+
sourcePath,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
const toolHandlers = {
|
|
208
|
+
diagrampilot_validate_source: validateSourceTool,
|
|
209
|
+
diagrampilot_check_repo: checkRepoTool,
|
|
210
|
+
diagrampilot_export_source: exportSourceTool,
|
|
211
|
+
diagrampilot_render_source: renderSourceTool,
|
|
212
|
+
};
|
|
213
|
+
function createOrUpdatePrompt(args) {
|
|
214
|
+
const scopePath = args.scope_path ?? ".";
|
|
215
|
+
const sourcePath = args.source_path ?? "docs/architecture.dp.yaml";
|
|
216
|
+
return [
|
|
217
|
+
`Goal: ${args.goal ?? "Create or update a DiagramPilot Source File."}`,
|
|
218
|
+
"",
|
|
219
|
+
`Inspect ${scopePath} for repo context, then create or update ${sourcePath}.`,
|
|
220
|
+
"Use DiagramSpec stable IDs, preserve YAML as the source of truth, and run:",
|
|
221
|
+
"",
|
|
222
|
+
`diagrampilot validate ${sourcePath}`,
|
|
223
|
+
`diagrampilot check ${scopePath}`,
|
|
224
|
+
"",
|
|
225
|
+
].join("\n");
|
|
226
|
+
}
|
|
227
|
+
function repairValidationPrompt(args) {
|
|
228
|
+
const sourcePath = args.source_path ?? "docs/architecture.dp.yaml";
|
|
229
|
+
return [
|
|
230
|
+
`Repair DiagramPilot validation errors in ${sourcePath}.`,
|
|
231
|
+
"",
|
|
232
|
+
"Use these repairable errors as the source of truth:",
|
|
233
|
+
"",
|
|
234
|
+
args.validation_errors ?? "<paste validation errors>",
|
|
235
|
+
"",
|
|
236
|
+
`After editing, run diagrampilot validate ${sourcePath}.`,
|
|
237
|
+
"",
|
|
238
|
+
].join("\n");
|
|
239
|
+
}
|
|
240
|
+
function refreshArtifactsPrompt(args) {
|
|
241
|
+
const scopePath = args.scope_path ?? ".";
|
|
242
|
+
return [
|
|
243
|
+
`Refresh DiagramPilot Derived Artifacts under ${scopePath}.`,
|
|
244
|
+
"",
|
|
245
|
+
`First run diagrampilot check ${scopePath}.`,
|
|
246
|
+
`Then run diagrampilot generate ${scopePath} for stale or missing generated artifacts.`,
|
|
247
|
+
"Do not hand-edit generated artifacts.",
|
|
248
|
+
"",
|
|
249
|
+
].join("\n");
|
|
250
|
+
}
|
|
251
|
+
const promptTextHandlers = {
|
|
252
|
+
create_or_update_diagrampilot_source: createOrUpdatePrompt,
|
|
253
|
+
repair_diagrampilot_validation_errors: repairValidationPrompt,
|
|
254
|
+
refresh_diagrampilot_artifacts: refreshArtifactsPrompt,
|
|
255
|
+
};
|
|
256
|
+
export function getDiagramPilotMcpPrompt(name, args = {}) {
|
|
257
|
+
const prompt = DIAGRAMPILOT_MCP_PROMPTS.find((entry) => entry.name === name);
|
|
258
|
+
const promptText = promptTextHandlers[name];
|
|
259
|
+
if (prompt === undefined || promptText === undefined) {
|
|
260
|
+
throw new Error(`Unknown DiagramPilot MCP prompt: ${name}`);
|
|
261
|
+
}
|
|
262
|
+
return {
|
|
263
|
+
description: prompt.title,
|
|
264
|
+
messages: [
|
|
265
|
+
{
|
|
266
|
+
role: "user",
|
|
267
|
+
content: {
|
|
268
|
+
type: "text",
|
|
269
|
+
text: promptText(args),
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
],
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,gCAAgC,EAChC,+BAA+B,EAC/B,wBAAwB,GAGzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAQzD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AACrF,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAE7D,MAAM,UAAU,WAAW,CAAC,WAAW,GAAG,kBAAkB;IAC1D,OAAO;QACL,yBAAyB;QACzB,EAAE;QACF,UAAU,WAAW,EAAE;QACvB,EAAE;QACF,sDAAsD;QACtD,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CA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,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,MAAM,kBAAkB,GAA6D;IACnF,oCAAoC,EAAE,oBAAoB;IAC1D,qCAAqC,EAAE,sBAAsB;IAC7D,8BAA8B,EAAE,sBAAsB;CACvD,CAAC;AAEF,MAAM,UAAU,wBAAwB,CACtC,IAAY,EACZ,OAA+B,EAAE;IAEjC,MAAM,MAAM,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAC7E,MAAM,UAAU,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAE5C,IAAI,MAAM,KAAK,SAAS,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,KAAK;QACzB,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC;iBACvB;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { DiagramPilotMcpServerOptions } from "./types.js";
|
|
3
|
+
export declare function createDiagramPilotMcpServer(options?: DiagramPilotMcpServerOptions): McpServer;
|
|
4
|
+
export declare function runStdioMcpServer(options?: DiagramPilotMcpServerOptions): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAoB,MAAM,yCAAyC,CAAC;AActF,OAAO,KAAK,EAGV,4BAA4B,EAE7B,MAAM,YAAY,CAAC;AAwEpB,wBAAgB,2BAA2B,CACzC,OAAO,GAAE,4BAAiC,GACzC,SAAS,CA4EX;AAED,wBAAsB,iBAAiB,CACrC,OAAO,GAAE,4BAAiC,GACzC,OAAO,CAAC,IAAI,CAAC,CAKf"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { getDiagramPilotVersion } from "@diagrampilot/core";
|
|
2
|
+
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { DIAGRAMPILOT_MCP_PROMPTS, DIAGRAMPILOT_MCP_RESOURCES, DIAGRAMPILOT_MCP_TOOLS, } from "./registry.js";
|
|
6
|
+
import { callDiagramPilotMcpTool, getDiagramPilotMcpPrompt, readDiagramPilotMcpResource, } from "./runtime.js";
|
|
7
|
+
function templateListResource(resource) {
|
|
8
|
+
const uri = resource.uriTemplate
|
|
9
|
+
.replace("{version}", "v1")
|
|
10
|
+
.replace("{page}", "mcp")
|
|
11
|
+
.replace("{name}", "checkout")
|
|
12
|
+
.replace("{scope}", encodeURIComponent(process.cwd()));
|
|
13
|
+
return {
|
|
14
|
+
uri,
|
|
15
|
+
name: resource.name,
|
|
16
|
+
title: resource.title,
|
|
17
|
+
description: resource.description,
|
|
18
|
+
mimeType: resource.mimeType,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function toolInputSchema(tool) {
|
|
22
|
+
if (tool.name === "diagrampilot_validate_source") {
|
|
23
|
+
return {
|
|
24
|
+
source_path: z.string(),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (tool.name === "diagrampilot_check_repo") {
|
|
28
|
+
return {
|
|
29
|
+
scope_path: z.string().optional(),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (tool.name === "diagrampilot_export_source") {
|
|
33
|
+
return {
|
|
34
|
+
source_path: z.string(),
|
|
35
|
+
format: z.enum(["mermaid", "d2", "dot"]),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
source_path: z.string(),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function promptArgsSchema(prompt) {
|
|
43
|
+
if (prompt.name === "create_or_update_diagrampilot_source") {
|
|
44
|
+
return {
|
|
45
|
+
goal: z.string(),
|
|
46
|
+
scope_path: z.string().optional(),
|
|
47
|
+
source_path: z.string().optional(),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (prompt.name === "repair_diagrampilot_validation_errors") {
|
|
51
|
+
return {
|
|
52
|
+
source_path: z.string(),
|
|
53
|
+
validation_errors: z.string(),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
scope_path: z.string().optional(),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export function createDiagramPilotMcpServer(options = {}) {
|
|
61
|
+
const server = new McpServer({
|
|
62
|
+
name: "diagrampilot",
|
|
63
|
+
version: getDiagramPilotVersion(),
|
|
64
|
+
}, {
|
|
65
|
+
instructions: "Use DiagramPilot MCP tools as read-only helpers. Write DiagramPilot Source Files and Derived Artifacts through explicit repo edits and CLI commands, not through MCP read tools.",
|
|
66
|
+
});
|
|
67
|
+
for (const resource of DIAGRAMPILOT_MCP_RESOURCES) {
|
|
68
|
+
server.registerResource(resource.name, new ResourceTemplate(resource.uriTemplate, {
|
|
69
|
+
list: async () => ({
|
|
70
|
+
resources: [templateListResource(resource)],
|
|
71
|
+
}),
|
|
72
|
+
}), {
|
|
73
|
+
title: resource.title,
|
|
74
|
+
description: resource.description,
|
|
75
|
+
mimeType: resource.mimeType,
|
|
76
|
+
}, async (uri) => {
|
|
77
|
+
const content = await readDiagramPilotMcpResource(uri.href);
|
|
78
|
+
return {
|
|
79
|
+
contents: [
|
|
80
|
+
{
|
|
81
|
+
uri: content.uri,
|
|
82
|
+
mimeType: content.mimeType,
|
|
83
|
+
text: content.text,
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
for (const tool of DIAGRAMPILOT_MCP_TOOLS) {
|
|
90
|
+
server.registerTool(tool.name, {
|
|
91
|
+
title: tool.title,
|
|
92
|
+
description: tool.description,
|
|
93
|
+
inputSchema: toolInputSchema(tool),
|
|
94
|
+
annotations: {
|
|
95
|
+
title: tool.title,
|
|
96
|
+
...tool.annotations,
|
|
97
|
+
},
|
|
98
|
+
}, async (args) => callDiagramPilotMcpTool(tool.name, args, options.toolDependencies));
|
|
99
|
+
}
|
|
100
|
+
for (const prompt of DIAGRAMPILOT_MCP_PROMPTS) {
|
|
101
|
+
server.registerPrompt(prompt.name, {
|
|
102
|
+
title: prompt.title,
|
|
103
|
+
description: prompt.description,
|
|
104
|
+
argsSchema: promptArgsSchema(prompt),
|
|
105
|
+
}, (args) => getDiagramPilotMcpPrompt(prompt.name, args));
|
|
106
|
+
}
|
|
107
|
+
return server;
|
|
108
|
+
}
|
|
109
|
+
export async function runStdioMcpServer(options = {}) {
|
|
110
|
+
const server = createDiagramPilotMcpServer(options);
|
|
111
|
+
const transport = new StdioServerTransport();
|
|
112
|
+
await server.connect(transport);
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,wBAAwB,EACxB,0BA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IAAI,oBAAoB,EAAE,CAAC;IAE7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { DiagramSpec } from "@diagrampilot/core";
|
|
2
|
+
import { createSvgRendererProvenance } from "@diagrampilot/render-svg";
|
|
3
|
+
export type Writable = Pick<NodeJS.WritableStream, "write">;
|
|
4
|
+
export interface McpCliStreams {
|
|
5
|
+
stdout: Writable;
|
|
6
|
+
stderr: Writable;
|
|
7
|
+
}
|
|
8
|
+
export interface DiagramPilotMcpResource {
|
|
9
|
+
name: string;
|
|
10
|
+
uriTemplate: string;
|
|
11
|
+
title: string;
|
|
12
|
+
description: string;
|
|
13
|
+
mimeType: string;
|
|
14
|
+
}
|
|
15
|
+
export interface DiagramPilotMcpTool {
|
|
16
|
+
name: string;
|
|
17
|
+
title: string;
|
|
18
|
+
description: string;
|
|
19
|
+
arguments: readonly DiagramPilotMcpArgument[];
|
|
20
|
+
annotations: {
|
|
21
|
+
readOnlyHint: boolean;
|
|
22
|
+
destructiveHint: boolean;
|
|
23
|
+
idempotentHint: boolean;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface DiagramPilotMcpPrompt {
|
|
27
|
+
name: string;
|
|
28
|
+
title: string;
|
|
29
|
+
description: string;
|
|
30
|
+
arguments: readonly DiagramPilotMcpArgument[];
|
|
31
|
+
}
|
|
32
|
+
export interface DiagramPilotMcpArgument {
|
|
33
|
+
name: string;
|
|
34
|
+
description: string;
|
|
35
|
+
required: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface DiagramPilotMcpResourceContent {
|
|
38
|
+
uri: string;
|
|
39
|
+
mimeType: string;
|
|
40
|
+
text: string;
|
|
41
|
+
}
|
|
42
|
+
export interface DiagramPilotMcpTextContent {
|
|
43
|
+
type: "text";
|
|
44
|
+
text: string;
|
|
45
|
+
}
|
|
46
|
+
export interface DiagramPilotMcpToolResult {
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
content: [DiagramPilotMcpTextContent];
|
|
49
|
+
structuredContent: Record<string, unknown>;
|
|
50
|
+
isError?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface DiagramPilotMcpPromptResult {
|
|
53
|
+
[key: string]: unknown;
|
|
54
|
+
description: string;
|
|
55
|
+
messages: [
|
|
56
|
+
{
|
|
57
|
+
role: "user";
|
|
58
|
+
content: DiagramPilotMcpTextContent;
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
export interface DiagramPilotMcpToolDependencies {
|
|
63
|
+
renderDiagramSpecToSvg?(spec: DiagramSpec, options: {
|
|
64
|
+
provenance: ReturnType<typeof createSvgRendererProvenance>;
|
|
65
|
+
}): Promise<string>;
|
|
66
|
+
}
|
|
67
|
+
export interface DiagramPilotMcpServerOptions {
|
|
68
|
+
toolDependencies?: DiagramPilotMcpToolDependencies;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAEvE,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;AAE5D,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,EAAE,QAAQ,CAAC;CAClB;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW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sBAAsB,CAAC,CACrB,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE;QACP,UAAU,EAAE,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAAC;KAC5D,GACA,OAAO,CAAC,MAAM,CAAC,CAAC;CACpB;AAED,MAAM,WAAW,4BAA4B;IAC3C,gBAAgB,CAAC,EAAE,+BAA+B,CAAC;CACpD"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@diagrampilot/mcp",
|
|
3
|
+
"version": "0.2.9",
|
|
4
|
+
"description": "Model Context Protocol server for DiagramPilot.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/StiensWout/DiagramPilot.git",
|
|
10
|
+
"directory": "packages/mcp"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://diagrampilot.com",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/StiensWout/DiagramPilot/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"diagrampilot",
|
|
18
|
+
"diagramspec",
|
|
19
|
+
"diagram",
|
|
20
|
+
"architecture",
|
|
21
|
+
"mcp"
|
|
22
|
+
],
|
|
23
|
+
"bin": {
|
|
24
|
+
"diagrampilot-mcp": "dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist/**/*.d.ts",
|
|
36
|
+
"dist/**/*.d.ts.map",
|
|
37
|
+
"dist/**/*.js",
|
|
38
|
+
"dist/**/*.js.map",
|
|
39
|
+
"LICENSE",
|
|
40
|
+
"README.md"
|
|
41
|
+
],
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsc -b && node scripts/make-bin-executable.mjs"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@diagrampilot/core": "0.2.9",
|
|
50
|
+
"@diagrampilot/export-d2": "0.2.9",
|
|
51
|
+
"@diagrampilot/export-dot": "0.2.9",
|
|
52
|
+
"@diagrampilot/export-mermaid": "0.2.9",
|
|
53
|
+
"@diagrampilot/render-svg": "0.2.9",
|
|
54
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
55
|
+
"zod": "^4.4.3"
|
|
56
|
+
}
|
|
57
|
+
}
|