@endiagram/mcp 0.1.17 → 0.2.1

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 (3) hide show
  1. package/README.md +24 -18
  2. package/dist/index.js +32 -7
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # @endiagram/mcp
2
2
 
3
- MCP server for [EN Diagram](https://endiagram.com) — structural analysis powered by deterministic graph algorithms.
4
-
5
- Write your system in plain text. Get back structural facts: bottlenecks, blast radius, flow landmarks, concurrency groups, and more. No AI inside the computation — every result is deterministic.
3
+ MCP server for [EN Diagram](https://endiagram.com) — deterministic structural analysis powered by graph theory. Every result is backed by a named mathematical theorem. No AI inside the computation.
6
4
 
7
5
  ## Installation
8
6
 
@@ -80,25 +78,34 @@ smithery mcp add dushyant30suthar/endiagram
80
78
 
81
79
  | Tool | Description |
82
80
  |------|-------------|
83
- | `analyze_system` | Structural signal computes topology, roles, antipatterns from EN source |
84
- | `render` | Render a dependency graph as publication-quality SVG |
85
- | `detail` | Deep structural analysis — concurrency, flow landmarks, resilience, dominator tree, min-cuts |
86
- | `distance` | Shortest path between two nodes with subsystem crossing annotations |
87
- | `diff` | Structural diff between two systems — topology, role, and subsystem changes |
88
- | `trace` | Follow directed flow from node A to node B with role and subsystem annotations |
89
- | `extract` | Extract a named subsystem as standalone EN source code |
90
- | `impact` | Blast radius — remove a node and see what disconnects |
91
- | `evolve` | Dry-run architectural changes — apply a patch and see the structural delta |
92
- | `between` | Betweenness centrality — what fraction of all shortest paths flow through a node |
81
+ | `analyze` | System overview: shape, node roles, single points of failure, failure threshold, flow hotspots |
82
+ | `detail` | Concurrency, critical path, flow landmarks, resilience, dependency chains, dominator tree |
93
83
  | `categorize` | Auto-discover subsystem boundaries from dependency structure |
94
- | `compose` | Merge two EN graphs into one with entity linking |
84
+ | `distance` | Structural distance between two nodes with the path between them |
85
+ | `diff` | Compare two systems — what changed structurally |
86
+ | `trace` | Follow directed flow from A to B, optional defense node coverage check |
87
+ | `between` | How much of the system flows through a specific node |
88
+ | `extract` | Extract a subsystem as standalone EN source |
89
+ | `impact` | What changes if a node is removed, includes propagation |
90
+ | `evolve` | Dry-run a structural change before making it |
91
+ | `compose` | Merge two systems into one by linking shared entities |
92
+ | `conserve` | Structural invariants, deadlock analysis, complexity, resilience |
93
+ | `render` | SVG diagram |
95
94
 
96
95
  ## EN Syntax
97
96
 
97
+ One statement per line:
98
+
98
99
  ```
99
- Customer do: place order needs: menu yields: order
100
- Kitchen do: prepare food needs: order yields: meal
101
- Waiter do: deliver needs: meal yields: served customer
100
+ actor do: action needs: input1, input2 yields: output1, output2
101
+ ```
102
+
103
+ Shared names between yields and needs create connections automatically:
104
+
105
+ ```
106
+ customer do: place order needs: menu yields: order
107
+ kitchen do: prepare food needs: order yields: meal
108
+ waiter do: deliver needs: meal yields: served customer
102
109
  ```
103
110
 
104
111
  Learn more at [endiagram.com](https://endiagram.com).
@@ -106,4 +113,3 @@ Learn more at [endiagram.com](https://endiagram.com).
106
113
  ## License
107
114
 
108
115
  MIT
109
-
package/dist/index.js CHANGED
@@ -2,6 +2,8 @@
2
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
4
  import { z } from "zod";
5
+ import { writeFileSync, mkdirSync, existsSync } from "node:fs";
6
+ import { join } from "node:path";
5
7
  const EN_API_URL = process.env.EN_API_URL ?? "https://api.endiagram.com";
6
8
  async function callApi(toolName, args) {
7
9
  try {
@@ -10,14 +12,24 @@ async function callApi(toolName, args) {
10
12
  headers: { "Content-Type": "application/json" },
11
13
  body: JSON.stringify(args),
12
14
  });
13
- const text = await response.text();
15
+ const body = await response.text();
14
16
  if (!response.ok) {
15
17
  return {
16
- text: `API error (${response.status}): ${text}`,
18
+ text: `API error (${response.status}): ${body}`,
17
19
  isError: true,
18
20
  };
19
21
  }
20
- return { text, isError: false };
22
+ try {
23
+ const parsed = JSON.parse(body);
24
+ return {
25
+ text: parsed.text ?? body,
26
+ isError: parsed.isError ?? false,
27
+ svg: parsed.svg ?? undefined,
28
+ };
29
+ }
30
+ catch {
31
+ return { text: body, isError: false };
32
+ }
21
33
  }
22
34
  catch (error) {
23
35
  const message = error instanceof Error ? error.message : "Unknown error";
@@ -36,7 +48,9 @@ Shared names between yields and needs create connections automatically. Multi-wo
36
48
 
37
49
  The engine computes structural truth from the description — the tool outputs are raw mathematical findings. Translate them into clear, practical insights relevant to what the user is trying to achieve.
38
50
 
39
- How to use these tools effectively: model the system first, then explore. The first tool call reveals the structure — but the real insights come from following up. A node labeled HUB that should be simple? Dig into it with between or impact. A surprising subsystem boundary? Extract it and analyze deeper. An unexpected dependency chain? Trace it. A proposed change? Evolve it and diff. The tools are designed to chain — each finding opens a question that another tool can answer. Don't stop at one call. Explore, tinker, compare, and let the math surface what no one expected.`;
51
+ How to use these tools effectively: model the system first, then explore. The first tool call reveals the structure — but the real insights come from following up. A node labeled HUB that should be simple? Dig into it with between or impact. A surprising subsystem boundary? Extract it and analyze deeper. An unexpected dependency chain? Trace it. A proposed change? Evolve it and diff. The tools are designed to chain — each finding opens a question that another tool can answer. Don't stop at one call. Explore, tinker, compare, and let the math surface what no one expected.
52
+
53
+ Go deep, not wide. When a finding catches your attention — a surprising hub, an unexpected bottleneck, a structural anomaly — lock onto it. Use one tool to surface it, then chain the next tool to explain it, then the next to stress-test it. Keep narrowing until you reach the root. One thread, followed to the end, beats ten shallow observations. Only call render when the user explicitly asks to visualize.`;
40
54
  const server = new McpServer({
41
55
  name: "endiagram",
42
56
  version: "0.2.0",
@@ -196,7 +210,7 @@ server.tool("conserve", "Structural invariants, deadlock analysis, complexity, a
196
210
  };
197
211
  });
198
212
  // --- render ---
199
- server.tool("render", "SVG diagram. Only when user asks to visualize.", {
213
+ server.tool("render", "SVG diagram. Only call when user explicitly asks to visualize. Saves SVG to a local file — no SVG content enters the conversation.", {
200
214
  source: z.string().describe("EN source code describing the system"),
201
215
  theme: z
202
216
  .enum(["dark", "light"])
@@ -208,9 +222,20 @@ server.tool("render", "SVG diagram. Only when user asks to visualize.", {
208
222
  .describe("Output quality"),
209
223
  }, async ({ source, theme, quality }) => {
210
224
  const result = await callApi("render", { source, theme, quality });
225
+ if (result.isError || !result.svg) {
226
+ return {
227
+ content: [{ type: "text", text: result.text }],
228
+ isError: result.isError,
229
+ };
230
+ }
231
+ const outDir = join(process.cwd(), ".endiagram");
232
+ if (!existsSync(outDir))
233
+ mkdirSync(outDir, { recursive: true });
234
+ const filePath = join(outDir, `en-${Date.now()}.svg`);
235
+ writeFileSync(filePath, result.svg);
211
236
  return {
212
- content: [{ type: "text", text: result.text }],
213
- isError: result.isError,
237
+ content: [{ type: "text", text: `SVG saved: ${filePath}` }],
238
+ isError: false,
214
239
  };
215
240
  });
216
241
  // --- start server ---
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@endiagram/mcp",
3
- "version": "0.1.17",
4
- "description": "MCP server for EN Diagram — structural analysis for any system",
3
+ "version": "0.2.1",
4
+ "description": "MCP server for EN Diagram — deterministic structural analysis backed by named theorems",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "bin": {
@@ -22,8 +22,8 @@
22
22
  "zod": "^3.23.0"
23
23
  },
24
24
  "devDependencies": {
25
- "typescript": "^5.5.0",
26
- "@types/node": "^20.0.0"
25
+ "@types/node": "^20.0.0",
26
+ "typescript": "^5.9.3"
27
27
  },
28
28
  "publishConfig": {
29
29
  "access": "public"