@zivis/mcp 0.1.10 → 0.1.12
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/dist/http-probe/capture.d.ts +51 -0
- package/dist/http-probe/capture.js +96 -0
- package/dist/http-probe/compare.d.ts +43 -0
- package/dist/http-probe/compare.js +117 -0
- package/dist/http-probe/index.d.ts +2 -0
- package/dist/http-probe/index.js +2 -0
- package/dist/pattern-packs/zivis-public-0.2.0/manifest.json +1 -1
- package/dist/redact.d.ts +30 -0
- package/dist/redact.js +164 -0
- package/dist/scanners/index.d.ts +3 -0
- package/dist/scanners/index.js +2 -0
- package/dist/scanners/normalize.d.ts +6 -0
- package/dist/scanners/normalize.js +181 -0
- package/dist/scanners/run.d.ts +27 -0
- package/dist/scanners/run.js +142 -0
- package/dist/scanners/types.d.ts +40 -0
- package/dist/scanners/types.js +1 -0
- package/dist/server.js +0 -5
- package/dist/tools/create-diagram.d.ts +3 -73
- package/dist/tools/create-diagram.js +8 -100
- package/dist/tools/get-diagram.d.ts +1 -1
- package/dist/tools/get-diagram.js +2 -52
- package/dist/tools/list-diagrams.d.ts +1 -1
- package/dist/tools/list-diagrams.js +2 -3
- package/dist/tools/manage-diagram.d.ts +1 -64
- package/dist/tools/manage-diagram.js +2 -211
- package/dist/tools/update-mermaid-source.d.ts +1 -1
- package/dist/tools/update-mermaid-source.js +1 -3
- package/package.json +5 -2
- package/dist/tools/generate-diagram.d.ts +0 -30
- package/dist/tools/generate-diagram.js +0 -161
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { readFile } from "fs/promises";
|
|
3
|
-
import { join, relative, resolve } from "path";
|
|
4
|
-
import { sanitizeResponse } from "../sanitize.js";
|
|
5
|
-
function resolveWithinProjectDir(projectDir, candidate) {
|
|
6
|
-
const base = resolve(projectDir);
|
|
7
|
-
const target = resolve(base, candidate);
|
|
8
|
-
const rel = relative(base, target);
|
|
9
|
-
if (rel.startsWith(".."))
|
|
10
|
-
return null;
|
|
11
|
-
return target;
|
|
12
|
-
}
|
|
13
|
-
export const GENERATE_DIAGRAM_NAME = "zivis_generate_diagram";
|
|
14
|
-
export const GENERATE_DIAGRAM_DESCRIPTION = `Generate a visual architecture diagram from a Docker Compose file.
|
|
15
|
-
|
|
16
|
-
Reads a local docker-compose.yml and sends it to the ZIVIS platform to generate
|
|
17
|
-
a positioned canvas diagram with:
|
|
18
|
-
- Services mapped to color-coded nodes (database, cache, app, proxy, etc.)
|
|
19
|
-
- Docker networks mapped to boundary groups
|
|
20
|
-
- depends_on relationships mapped to connections
|
|
21
|
-
- Auto-positioned grid layout grouped by network
|
|
22
|
-
|
|
23
|
-
The diagram is saved to your organization and can be viewed/edited in the diagram editor.
|
|
24
|
-
|
|
25
|
-
Supported formats: docker-compose (docker-compose.yml, compose.yml)
|
|
26
|
-
Coming soon: Kubernetes manifests, Terraform configs`;
|
|
27
|
-
export const GENERATE_DIAGRAM_SCHEMA = {
|
|
28
|
-
file_path: z
|
|
29
|
-
.string()
|
|
30
|
-
.optional()
|
|
31
|
-
.describe("Path to the infrastructure file (e.g., docker-compose.yml). " +
|
|
32
|
-
"If not provided, searches the current directory for docker-compose.yml, " +
|
|
33
|
-
"docker-compose.yaml, compose.yml, or compose.yaml."),
|
|
34
|
-
source_format: z
|
|
35
|
-
.enum(["docker-compose"])
|
|
36
|
-
.default("docker-compose")
|
|
37
|
-
.describe("The format of the source file. Currently only docker-compose is supported."),
|
|
38
|
-
name: z
|
|
39
|
-
.string()
|
|
40
|
-
.optional()
|
|
41
|
-
.describe("Custom name for the generated diagram. Defaults to 'Docker Compose Architecture'."),
|
|
42
|
-
project_dir: z
|
|
43
|
-
.string()
|
|
44
|
-
.optional()
|
|
45
|
-
.describe("Project directory to search for compose files. Defaults to current working directory."),
|
|
46
|
-
};
|
|
47
|
-
const COMPOSE_FILE_CANDIDATES = [
|
|
48
|
-
"docker-compose.yml",
|
|
49
|
-
"docker-compose.yaml",
|
|
50
|
-
"compose.yml",
|
|
51
|
-
"compose.yaml",
|
|
52
|
-
];
|
|
53
|
-
export function createGenerateDiagramHandler(apiClient) {
|
|
54
|
-
return async (params) => {
|
|
55
|
-
const projectDir = params.project_dir || process.cwd();
|
|
56
|
-
const sourceFormat = params.source_format || "docker-compose";
|
|
57
|
-
let filePath = params.file_path;
|
|
58
|
-
let content = null;
|
|
59
|
-
if (filePath) {
|
|
60
|
-
const resolved = resolveWithinProjectDir(projectDir, filePath);
|
|
61
|
-
if (!resolved) {
|
|
62
|
-
return {
|
|
63
|
-
content: [
|
|
64
|
-
{
|
|
65
|
-
type: "text",
|
|
66
|
-
text: `Error: file_path must resolve inside project_dir (got: ${filePath})`,
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
isError: true,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
try {
|
|
73
|
-
content = await readFile(resolved, "utf-8");
|
|
74
|
-
}
|
|
75
|
-
catch {
|
|
76
|
-
return {
|
|
77
|
-
content: [
|
|
78
|
-
{
|
|
79
|
-
type: "text",
|
|
80
|
-
text: `Error: File not found: ${resolved}`,
|
|
81
|
-
},
|
|
82
|
-
],
|
|
83
|
-
isError: true,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
for (const candidate of COMPOSE_FILE_CANDIDATES) {
|
|
89
|
-
try {
|
|
90
|
-
content = await readFile(join(projectDir, candidate), "utf-8");
|
|
91
|
-
filePath = candidate;
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (!content) {
|
|
98
|
-
return {
|
|
99
|
-
content: [
|
|
100
|
-
{
|
|
101
|
-
type: "text",
|
|
102
|
-
text: "Error: No docker-compose file found. Searched for: " +
|
|
103
|
-
COMPOSE_FILE_CANDIDATES.join(", "),
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
|
-
isError: true,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (content.length > 500 * 1024) {
|
|
111
|
-
return {
|
|
112
|
-
content: [
|
|
113
|
-
{
|
|
114
|
-
type: "text",
|
|
115
|
-
text: "Error: File too large (max 500KB)",
|
|
116
|
-
},
|
|
117
|
-
],
|
|
118
|
-
isError: true,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
try {
|
|
122
|
-
const data = await apiClient.post("/api/diagrams/generate", {
|
|
123
|
-
content,
|
|
124
|
-
sourceFormat,
|
|
125
|
-
name: params.name,
|
|
126
|
-
});
|
|
127
|
-
const summary = {
|
|
128
|
-
diagram_id: data.id,
|
|
129
|
-
name: data.name,
|
|
130
|
-
type: data.diagramType,
|
|
131
|
-
source_file: filePath,
|
|
132
|
-
stats: {
|
|
133
|
-
nodes: data.nodes?.length || 0,
|
|
134
|
-
connections: data.connections?.length || 0,
|
|
135
|
-
boundaries: data.boundaries?.length || 0,
|
|
136
|
-
},
|
|
137
|
-
nodes: (data.nodes || []).map((n) => ({
|
|
138
|
-
name: n.name,
|
|
139
|
-
tags: n.tags,
|
|
140
|
-
})),
|
|
141
|
-
boundaries: (data.boundaries || []).map((b) => b.label),
|
|
142
|
-
};
|
|
143
|
-
const sanitized = sanitizeResponse(summary);
|
|
144
|
-
return {
|
|
145
|
-
content: [
|
|
146
|
-
{
|
|
147
|
-
type: "text",
|
|
148
|
-
text: JSON.stringify(sanitized, null, 2),
|
|
149
|
-
},
|
|
150
|
-
],
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
catch (err) {
|
|
154
|
-
const message = err instanceof Error ? err.message : "Failed to generate diagram";
|
|
155
|
-
return {
|
|
156
|
-
content: [{ type: "text", text: `Error: ${message}` }],
|
|
157
|
-
isError: true,
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
}
|