@granoflow/mcp-server 0.1.0
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 +203 -0
- package/dist/api.d.ts +26 -0
- package/dist/api.js +98 -0
- package/dist/api.js.map +1 -0
- package/dist/config.d.ts +40 -0
- package/dist/config.js +148 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/metadata.d.ts +2 -0
- package/dist/metadata.js +3 -0
- package/dist/metadata.js.map +1 -0
- package/dist/setup.d.ts +126 -0
- package/dist/setup.js +363 -0
- package/dist/setup.js.map +1 -0
- package/dist/tools.d.ts +11 -0
- package/dist/tools.js +268 -0
- package/dist/tools.js.map +1 -0
- package/package.json +54 -0
package/dist/setup.d.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { type WriteConfigInput } from "./config.js";
|
|
2
|
+
type CommandRunResult = {
|
|
3
|
+
exitCode: number;
|
|
4
|
+
stdout: string;
|
|
5
|
+
stderr: string;
|
|
6
|
+
};
|
|
7
|
+
type CommandRunner = (command: string, args: string[]) => Promise<CommandRunResult>;
|
|
8
|
+
export interface SetupOptions {
|
|
9
|
+
env?: NodeJS.ProcessEnv;
|
|
10
|
+
fetch?: typeof fetch;
|
|
11
|
+
runCommand?: CommandRunner;
|
|
12
|
+
}
|
|
13
|
+
export interface LocalApiDetectionInput {
|
|
14
|
+
ports?: number[];
|
|
15
|
+
timeoutMs?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface OpenAppInput {
|
|
18
|
+
appPath?: string;
|
|
19
|
+
appName?: string;
|
|
20
|
+
dryRun?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare function getSetupStatus(options?: SetupOptions): Promise<{
|
|
23
|
+
configPath: string;
|
|
24
|
+
configExists: boolean;
|
|
25
|
+
configError: string | undefined;
|
|
26
|
+
apiBaseUrl: string;
|
|
27
|
+
apiBaseUrlSource: "env" | "config" | "default";
|
|
28
|
+
apiToken: {
|
|
29
|
+
present: boolean;
|
|
30
|
+
source: "env" | "none";
|
|
31
|
+
};
|
|
32
|
+
health: {
|
|
33
|
+
appProcess: Record<string, unknown>;
|
|
34
|
+
ok: boolean;
|
|
35
|
+
code: string;
|
|
36
|
+
data?: unknown;
|
|
37
|
+
error?: {
|
|
38
|
+
message: string;
|
|
39
|
+
};
|
|
40
|
+
httpStatus?: number;
|
|
41
|
+
runtime: {
|
|
42
|
+
apiBaseUrl: string;
|
|
43
|
+
apiBaseUrlSource: import("./config.js").RuntimeResolution["apiBaseUrlSource"];
|
|
44
|
+
apiToken: {
|
|
45
|
+
present: boolean;
|
|
46
|
+
source: import("./config.js").RuntimeResolution["apiTokenSource"];
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
version: import("./api.js").ApiResult;
|
|
51
|
+
warnings: Record<string, unknown>[];
|
|
52
|
+
nextActions: string[];
|
|
53
|
+
appProcess?: undefined;
|
|
54
|
+
} | {
|
|
55
|
+
configPath: string;
|
|
56
|
+
configExists: boolean;
|
|
57
|
+
configError: string | undefined;
|
|
58
|
+
apiBaseUrl: string;
|
|
59
|
+
apiBaseUrlSource: "env" | "config" | "default";
|
|
60
|
+
apiToken: {
|
|
61
|
+
present: boolean;
|
|
62
|
+
source: "env" | "none";
|
|
63
|
+
};
|
|
64
|
+
health: import("./api.js").ApiResult;
|
|
65
|
+
version: import("./api.js").ApiResult;
|
|
66
|
+
appProcess: Record<string, unknown>;
|
|
67
|
+
warnings: Record<string, unknown>[];
|
|
68
|
+
nextActions: string[];
|
|
69
|
+
}>;
|
|
70
|
+
export declare function detectLocalApi(input?: LocalApiDetectionInput, options?: SetupOptions): Promise<{
|
|
71
|
+
checked: string[];
|
|
72
|
+
candidates: Record<string, unknown>[];
|
|
73
|
+
nextActions: string[];
|
|
74
|
+
}>;
|
|
75
|
+
export declare function writeSetupConfig(input: WriteConfigInput, options?: SetupOptions): Promise<import("./config.js").WriteConfigResult>;
|
|
76
|
+
export declare function openGranoflowApp(input?: OpenAppInput, options?: SetupOptions): Promise<{
|
|
77
|
+
ok: boolean;
|
|
78
|
+
dryRun: boolean;
|
|
79
|
+
appName: string;
|
|
80
|
+
error: string;
|
|
81
|
+
nextActions: string[];
|
|
82
|
+
appPath?: undefined;
|
|
83
|
+
command?: undefined;
|
|
84
|
+
attempts?: undefined;
|
|
85
|
+
} | {
|
|
86
|
+
ok: boolean;
|
|
87
|
+
dryRun: true;
|
|
88
|
+
appName: string;
|
|
89
|
+
appPath: string | null;
|
|
90
|
+
command: string;
|
|
91
|
+
attempts: {
|
|
92
|
+
kind: string;
|
|
93
|
+
args: string[];
|
|
94
|
+
}[];
|
|
95
|
+
nextActions: string[];
|
|
96
|
+
error?: undefined;
|
|
97
|
+
} | {
|
|
98
|
+
ok: boolean;
|
|
99
|
+
dryRun: false;
|
|
100
|
+
appName: string;
|
|
101
|
+
appPath: string | null;
|
|
102
|
+
command: string;
|
|
103
|
+
attempts: {
|
|
104
|
+
kind: string;
|
|
105
|
+
args: string[];
|
|
106
|
+
exitCode: number;
|
|
107
|
+
stderr: string;
|
|
108
|
+
}[];
|
|
109
|
+
nextActions: string[];
|
|
110
|
+
error?: undefined;
|
|
111
|
+
}>;
|
|
112
|
+
export declare function openSetupConfig(input?: {
|
|
113
|
+
createIfMissing?: boolean;
|
|
114
|
+
open?: boolean;
|
|
115
|
+
}, options?: SetupOptions): Promise<{
|
|
116
|
+
configPath: string;
|
|
117
|
+
exists: boolean;
|
|
118
|
+
created: boolean;
|
|
119
|
+
open: {
|
|
120
|
+
attempted: boolean;
|
|
121
|
+
error?: string;
|
|
122
|
+
};
|
|
123
|
+
configError: string | undefined;
|
|
124
|
+
nextActions: string[];
|
|
125
|
+
}>;
|
|
126
|
+
export {};
|
package/dist/setup.js
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
|
+
import { dirname } from "node:path";
|
|
4
|
+
import { requestGranoflowApi } from "./api.js";
|
|
5
|
+
import { configFileExists, getMcpConfigPath, readMcpConfig, resolveMcpRuntime, writeMcpConfig, } from "./config.js";
|
|
6
|
+
const DEFAULT_PORTS = [56789, 47631, 38080];
|
|
7
|
+
const MAX_PORT_CANDIDATES = 20;
|
|
8
|
+
const PROBE_PATHS = ["/health", "/api/capabilities", "/v1/health"];
|
|
9
|
+
const GRANOFLOW_JSON_KEYS = ["ok", "status", "capabilities", "tools", "version", "service"];
|
|
10
|
+
function safeError(error) {
|
|
11
|
+
return error instanceof Error ? error.message : String(error);
|
|
12
|
+
}
|
|
13
|
+
function isObject(value) {
|
|
14
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15
|
+
}
|
|
16
|
+
function validatePorts(ports) {
|
|
17
|
+
if (ports.length > MAX_PORT_CANDIDATES) {
|
|
18
|
+
throw new Error(`ports must contain at most ${MAX_PORT_CANDIDATES} candidates.`);
|
|
19
|
+
}
|
|
20
|
+
for (const port of ports) {
|
|
21
|
+
if (!Number.isInteger(port) || port < 1 || port > 65_535) {
|
|
22
|
+
throw new Error("ports must be integers between 1 and 65535.");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function looksLikeGranoflowJson(value) {
|
|
27
|
+
if (!isObject(value)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return GRANOFLOW_JSON_KEYS.some((key) => key in value);
|
|
31
|
+
}
|
|
32
|
+
function isLocalApiBaseUrl(apiBaseUrl) {
|
|
33
|
+
if (!apiBaseUrl) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const url = new URL(apiBaseUrl);
|
|
38
|
+
return ["localhost", "127.0.0.1", "::1", "[::1]"].includes(url.hostname);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async function fetchWithTimeout(fetchImpl, url, timeoutMs) {
|
|
45
|
+
const controller = new AbortController();
|
|
46
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
47
|
+
try {
|
|
48
|
+
return await fetchImpl(url, { signal: controller.signal });
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
clearTimeout(timer);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async function openPath(path) {
|
|
55
|
+
if (process.platform !== "darwin" && process.platform !== "linux") {
|
|
56
|
+
return { attempted: false, error: "Opening config files is only implemented for macOS/Linux." };
|
|
57
|
+
}
|
|
58
|
+
const command = process.platform === "darwin" ? "open" : "xdg-open";
|
|
59
|
+
return await new Promise((resolve) => {
|
|
60
|
+
const child = spawn(command, [path], { stdio: "ignore", detached: true });
|
|
61
|
+
child.on("error", (error) => resolve({ attempted: true, error: safeError(error) }));
|
|
62
|
+
child.on("spawn", () => {
|
|
63
|
+
child.unref();
|
|
64
|
+
resolve({ attempted: true });
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async function runCommand(command, args) {
|
|
69
|
+
return await new Promise((resolve, reject) => {
|
|
70
|
+
const child = spawn(command, args, { stdio: ["ignore", "pipe", "pipe"] });
|
|
71
|
+
let stdout = "";
|
|
72
|
+
let stderr = "";
|
|
73
|
+
child.stdout.setEncoding("utf8");
|
|
74
|
+
child.stderr.setEncoding("utf8");
|
|
75
|
+
child.stdout.on("data", (chunk) => {
|
|
76
|
+
stdout += chunk;
|
|
77
|
+
});
|
|
78
|
+
child.stderr.on("data", (chunk) => {
|
|
79
|
+
stderr += chunk;
|
|
80
|
+
});
|
|
81
|
+
child.on("error", reject);
|
|
82
|
+
child.on("close", (exitCode) => {
|
|
83
|
+
resolve({ exitCode: exitCode ?? 1, stdout, stderr });
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
async function checkGranoflowProcess(runCommandImpl) {
|
|
88
|
+
if (process.platform !== "darwin" && process.platform !== "linux") {
|
|
89
|
+
return {
|
|
90
|
+
checked: false,
|
|
91
|
+
running: null,
|
|
92
|
+
reason: "Process check is only implemented for macOS/Linux.",
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
const result = await runCommandImpl("pgrep", ["-ifl", "granoflow"]);
|
|
97
|
+
const matches = result.exitCode === 0
|
|
98
|
+
? result.stdout
|
|
99
|
+
.split("\n")
|
|
100
|
+
.filter(Boolean)
|
|
101
|
+
.filter((line) => !line.toLowerCase().includes("granoflow-mcp-server"))
|
|
102
|
+
: [];
|
|
103
|
+
return {
|
|
104
|
+
checked: true,
|
|
105
|
+
running: matches.length > 0,
|
|
106
|
+
count: matches.length,
|
|
107
|
+
matches: matches.map((line) => line.trim()),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
return {
|
|
112
|
+
checked: false,
|
|
113
|
+
running: null,
|
|
114
|
+
error: safeError(error),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export async function getSetupStatus(options = {}) {
|
|
119
|
+
const env = options.env ?? process.env;
|
|
120
|
+
const runCommandImpl = options.runCommand ?? runCommand;
|
|
121
|
+
const runtime = await resolveMcpRuntime(env);
|
|
122
|
+
const health = await requestGranoflowApi({ path: "/v1/health" }, env);
|
|
123
|
+
const version = await requestGranoflowApi({ path: "/v1/version" }, env);
|
|
124
|
+
const warnings = [];
|
|
125
|
+
const appProcess = isLocalApiBaseUrl(runtime.apiBaseUrl)
|
|
126
|
+
? await checkGranoflowProcess(runCommandImpl)
|
|
127
|
+
: {
|
|
128
|
+
checked: false,
|
|
129
|
+
running: null,
|
|
130
|
+
reason: "Process check is only run for local API base URLs.",
|
|
131
|
+
};
|
|
132
|
+
if (!health.ok && isLocalApiBaseUrl(runtime.apiBaseUrl)) {
|
|
133
|
+
if (appProcess.running === false) {
|
|
134
|
+
warnings.push({
|
|
135
|
+
code: "granoflow_app_not_running",
|
|
136
|
+
message: "The configured Granoflow API is local, but the API is unreachable and no Granoflow app process was found.",
|
|
137
|
+
apiBaseUrl: runtime.apiBaseUrl,
|
|
138
|
+
nextActions: [
|
|
139
|
+
"Ask the user whether they want to open Granoflow.",
|
|
140
|
+
"Call granoflow_setup_open_app with dryRun=true before opening the app.",
|
|
141
|
+
],
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
else if (appProcess.running === true) {
|
|
145
|
+
warnings.push({
|
|
146
|
+
code: "local_api_unreachable_app_running",
|
|
147
|
+
message: "A Granoflow process appears to be running, but the configured local API is unreachable.",
|
|
148
|
+
apiBaseUrl: runtime.apiBaseUrl,
|
|
149
|
+
nextActions: [
|
|
150
|
+
"Ask the user to verify that the Granoflow Local HTTP API is enabled.",
|
|
151
|
+
"Call granoflow_setup_detect_local_api to check bounded localhost candidates.",
|
|
152
|
+
],
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
configPath: runtime.configPath,
|
|
157
|
+
configExists: runtime.configExists,
|
|
158
|
+
configError: runtime.configError,
|
|
159
|
+
apiBaseUrl: runtime.apiBaseUrl,
|
|
160
|
+
apiBaseUrlSource: runtime.apiBaseUrlSource,
|
|
161
|
+
apiToken: {
|
|
162
|
+
present: runtime.hasApiToken,
|
|
163
|
+
source: runtime.apiTokenSource,
|
|
164
|
+
},
|
|
165
|
+
health: {
|
|
166
|
+
...health,
|
|
167
|
+
appProcess,
|
|
168
|
+
},
|
|
169
|
+
version,
|
|
170
|
+
warnings,
|
|
171
|
+
nextActions: warnings.some((warning) => warning.code === "granoflow_app_not_running")
|
|
172
|
+
? [
|
|
173
|
+
"Ask the user whether they want to open Granoflow.",
|
|
174
|
+
"Call granoflow_setup_open_app with dryRun=true before opening the app.",
|
|
175
|
+
]
|
|
176
|
+
: [
|
|
177
|
+
"Verify the Granoflow Local HTTP API is enabled.",
|
|
178
|
+
"Call granoflow_setup_detect_local_api to check bounded localhost candidates.",
|
|
179
|
+
],
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
configPath: runtime.configPath,
|
|
184
|
+
configExists: runtime.configExists,
|
|
185
|
+
configError: runtime.configError,
|
|
186
|
+
apiBaseUrl: runtime.apiBaseUrl,
|
|
187
|
+
apiBaseUrlSource: runtime.apiBaseUrlSource,
|
|
188
|
+
apiToken: {
|
|
189
|
+
present: runtime.hasApiToken,
|
|
190
|
+
source: runtime.apiTokenSource,
|
|
191
|
+
},
|
|
192
|
+
health,
|
|
193
|
+
version,
|
|
194
|
+
appProcess,
|
|
195
|
+
warnings,
|
|
196
|
+
nextActions: health.ok
|
|
197
|
+
? ["Granoflow Local HTTP API is reachable."]
|
|
198
|
+
: [
|
|
199
|
+
"Start Granoflow and enable the Local HTTP API.",
|
|
200
|
+
"Call granoflow_setup_detect_local_api to look for a local Granoflow API.",
|
|
201
|
+
],
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
export async function detectLocalApi(input = {}, options = {}) {
|
|
205
|
+
const ports = input.ports ?? DEFAULT_PORTS;
|
|
206
|
+
const timeoutMs = input.timeoutMs ?? 300;
|
|
207
|
+
validatePorts(ports);
|
|
208
|
+
const fetchImpl = options.fetch ?? fetch;
|
|
209
|
+
const candidates = [];
|
|
210
|
+
const checked = [];
|
|
211
|
+
for (const port of [...new Set(ports)]) {
|
|
212
|
+
for (const path of PROBE_PATHS) {
|
|
213
|
+
const apiBaseUrl = `http://127.0.0.1:${port}`;
|
|
214
|
+
const url = `${apiBaseUrl}${path}`;
|
|
215
|
+
checked.push(url);
|
|
216
|
+
try {
|
|
217
|
+
const response = await fetchWithTimeout(fetchImpl, url, timeoutMs);
|
|
218
|
+
if (response.status === 401 || response.status === 403) {
|
|
219
|
+
candidates.push({
|
|
220
|
+
apiBaseUrl,
|
|
221
|
+
path,
|
|
222
|
+
confidence: "low",
|
|
223
|
+
authRequired: true,
|
|
224
|
+
evidence: `HTTP ${response.status} from fixed Granoflow candidate path.`,
|
|
225
|
+
});
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (response.status !== 200) {
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
let json = null;
|
|
232
|
+
try {
|
|
233
|
+
json = await response.json();
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
json = null;
|
|
237
|
+
}
|
|
238
|
+
if (looksLikeGranoflowJson(json)) {
|
|
239
|
+
candidates.push({
|
|
240
|
+
apiBaseUrl,
|
|
241
|
+
path,
|
|
242
|
+
confidence: "high",
|
|
243
|
+
authRequired: false,
|
|
244
|
+
evidence: "HTTP 200 JSON contains Granoflow-shaped keys.",
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
// Timeouts and connection refusals are expected while probing bounded localhost ports.
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
checked,
|
|
255
|
+
candidates,
|
|
256
|
+
nextActions: candidates.length > 0
|
|
257
|
+
? [
|
|
258
|
+
"Review the candidate API URL.",
|
|
259
|
+
"Call granoflow_setup_write_config with dryRun=true before writing config.",
|
|
260
|
+
]
|
|
261
|
+
: [
|
|
262
|
+
"Start Granoflow and enable the Local HTTP API.",
|
|
263
|
+
"If Granoflow is already running, open the config manually with granoflow_setup_open_config.",
|
|
264
|
+
],
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
export async function writeSetupConfig(input, options = {}) {
|
|
268
|
+
return await writeMcpConfig(input, options.env);
|
|
269
|
+
}
|
|
270
|
+
export async function openGranoflowApp(input = {}, options = {}) {
|
|
271
|
+
const runCommandImpl = options.runCommand ?? runCommand;
|
|
272
|
+
const appName = input.appName ?? "Granoflow";
|
|
273
|
+
const dryRun = input.dryRun !== false;
|
|
274
|
+
if (process.platform !== "darwin") {
|
|
275
|
+
return {
|
|
276
|
+
ok: false,
|
|
277
|
+
dryRun,
|
|
278
|
+
appName,
|
|
279
|
+
error: "Opening the installed Granoflow app is only implemented for macOS in this MCP server.",
|
|
280
|
+
nextActions: ["Open Granoflow manually, then call granoflow_setup_status again."],
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
const command = "open";
|
|
284
|
+
const attempts = [
|
|
285
|
+
...(input.appPath ? [{ kind: "path", args: [input.appPath] }] : []),
|
|
286
|
+
{ kind: "path", args: ["/Applications/granoflow.app"] },
|
|
287
|
+
{ kind: "path", args: ["/Applications/Granoflow.app"] },
|
|
288
|
+
{ kind: "appName", args: ["-a", appName] },
|
|
289
|
+
{ kind: "appName", args: ["-a", "granoflow"] },
|
|
290
|
+
];
|
|
291
|
+
if (dryRun) {
|
|
292
|
+
return {
|
|
293
|
+
ok: true,
|
|
294
|
+
dryRun,
|
|
295
|
+
appName,
|
|
296
|
+
appPath: input.appPath ?? null,
|
|
297
|
+
command,
|
|
298
|
+
attempts,
|
|
299
|
+
nextActions: [
|
|
300
|
+
"Ask the user to confirm opening Granoflow.",
|
|
301
|
+
"Call this tool again with dryRun=false only after the user approves.",
|
|
302
|
+
],
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
const results = [];
|
|
306
|
+
for (const attempt of attempts) {
|
|
307
|
+
const result = await runCommandImpl(command, attempt.args);
|
|
308
|
+
results.push({
|
|
309
|
+
kind: attempt.kind,
|
|
310
|
+
args: attempt.args,
|
|
311
|
+
exitCode: result.exitCode,
|
|
312
|
+
stderr: result.stderr.trim() ? "[present]" : "[empty]",
|
|
313
|
+
});
|
|
314
|
+
if (result.exitCode === 0) {
|
|
315
|
+
return {
|
|
316
|
+
ok: true,
|
|
317
|
+
dryRun,
|
|
318
|
+
appName,
|
|
319
|
+
appPath: input.appPath ?? null,
|
|
320
|
+
command,
|
|
321
|
+
attempts: results,
|
|
322
|
+
nextActions: [
|
|
323
|
+
"Wait briefly for Granoflow to start, then call granoflow_setup_status again.",
|
|
324
|
+
],
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return {
|
|
329
|
+
ok: false,
|
|
330
|
+
dryRun,
|
|
331
|
+
appName,
|
|
332
|
+
appPath: input.appPath ?? null,
|
|
333
|
+
command,
|
|
334
|
+
attempts: results,
|
|
335
|
+
nextActions: ["Open Granoflow manually, then call granoflow_setup_status again."],
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
export async function openSetupConfig(input = {}, options = {}) {
|
|
339
|
+
const env = options.env ?? process.env;
|
|
340
|
+
const configPath = getMcpConfigPath(env);
|
|
341
|
+
const exists = await configFileExists(configPath);
|
|
342
|
+
let created = false;
|
|
343
|
+
if (!exists && input.createIfMissing !== false) {
|
|
344
|
+
await mkdir(dirname(configPath), { recursive: true });
|
|
345
|
+
await writeFile(configPath, `${JSON.stringify({ apiBaseUrl: "http://127.0.0.1:56789" }, null, 2)}\n`, { mode: 0o600 });
|
|
346
|
+
created = true;
|
|
347
|
+
}
|
|
348
|
+
const readResult = await readMcpConfig(env);
|
|
349
|
+
const openResult = input.open === true ? await openPath(configPath) : { attempted: false };
|
|
350
|
+
return {
|
|
351
|
+
configPath,
|
|
352
|
+
exists: readResult.exists,
|
|
353
|
+
created,
|
|
354
|
+
open: openResult,
|
|
355
|
+
configError: readResult.error,
|
|
356
|
+
nextActions: [
|
|
357
|
+
"Edit apiBaseUrl if the default is wrong.",
|
|
358
|
+
"Keep GRANOFLOW_API_TOKEN in the MCP client environment, not in this config file.",
|
|
359
|
+
"Call granoflow_setup_status after saving changes.",
|
|
360
|
+
],
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
//# sourceMappingURL=setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,SAAS,E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AC,CAAC;QACtD,MAAM,SAAS,CACb,UAAU,EACV,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,wBAAwB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EACxE,EAAE,IAAI,EAAE,KAAK,EAAE,CAChB,CAAC;QACF,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IAE3F,OAAO;QACL,UAAU;QACV,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,OAAO;QACP,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,UAAU,CAAC,KAAK;QAC7B,WAAW,EAAE;YACX,0CAA0C;YAC1C,kFAAkF;YAClF,mDAAmD;SACpD;KACF,CAAC;AACJ,CAAC"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare function textResult(text: string): {
|
|
3
|
+
content: {
|
|
4
|
+
type: "text";
|
|
5
|
+
text: string;
|
|
6
|
+
}[];
|
|
7
|
+
};
|
|
8
|
+
export declare function registerGranoflowTools(server: {
|
|
9
|
+
tool: (name: string, description: string, schema: Record<string, z.ZodTypeAny>, handler: (args: Record<string, unknown>) => Promise<ReturnType<typeof textResult>>) => void;
|
|
10
|
+
}): void;
|
|
11
|
+
export {};
|