@endiagram/mcp 0.2.1 → 0.2.3

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 (2) hide show
  1. package/dist/index.js +26 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7,25 +7,38 @@ import { join } from "node:path";
7
7
  const EN_API_URL = process.env.EN_API_URL ?? "https://api.endiagram.com";
8
8
  async function callApi(toolName, args) {
9
9
  try {
10
- const response = await fetch(`${EN_API_URL}/api/tools/${toolName}`, {
10
+ const response = await fetch(`${EN_API_URL}/mcp`, {
11
11
  method: "POST",
12
12
  headers: { "Content-Type": "application/json" },
13
- body: JSON.stringify(args),
13
+ body: JSON.stringify({
14
+ jsonrpc: "2.0",
15
+ id: Date.now(),
16
+ method: "tools/call",
17
+ params: {
18
+ name: toolName,
19
+ arguments: args,
20
+ },
21
+ }),
14
22
  });
15
23
  const body = await response.text();
16
24
  if (!response.ok) {
17
- return {
18
- text: `API error (${response.status}): ${body}`,
19
- isError: true,
20
- };
25
+ return { text: `API error (${response.status}): ${body}`, isError: true };
21
26
  }
22
27
  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
- };
28
+ const rpcResponse = JSON.parse(body);
29
+ if (rpcResponse.error) {
30
+ return { text: rpcResponse.error.message, isError: true };
31
+ }
32
+ const result = rpcResponse.result;
33
+ const content = result?.content?.[0];
34
+ const text = content?.text ?? body;
35
+ const isError = result?.isError ?? false;
36
+ // Check for SVG in second content block (render tool)
37
+ const svgContent = result?.content?.[1];
38
+ const svg = svgContent?.text?.startsWith("<svg")
39
+ ? svgContent.text
40
+ : undefined;
41
+ return { text, isError, svg, data: undefined };
29
42
  }
30
43
  catch {
31
44
  return { text: body, isError: false };
@@ -67,7 +80,7 @@ server.tool("analyze", EN_INSTRUCTIONS + " This tool gives the system overview:
67
80
  .optional()
68
81
  .describe("Set to 'true' to detect structural antipatterns"),
69
82
  }, async ({ source, invariants, detect_antipatterns }) => {
70
- const result = await callApi("analyze_system", {
83
+ const result = await callApi("analyze", {
71
84
  source,
72
85
  invariants,
73
86
  detect_antipatterns,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@endiagram/mcp",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "MCP server for EN Diagram — deterministic structural analysis backed by named theorems",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",