@openfairygui/mcp 0.2.0-alpha.3 → 0.2.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/dist/index.cjs +1 -1
- package/dist/index.d.cts +31 -4
- package/dist/index.d.mts +31 -4
- package/dist/index.mjs +1 -1
- package/dist/{stdio-DT1cUPJ3.mjs → stdio-AonL7fG4.mjs} +51 -4
- package/dist/{stdio-Ckmxm29z.cjs → stdio-eqd_tVeJ.cjs} +51 -4
- package/dist/stdio.cjs +1 -1
- package/dist/stdio.mjs +1 -1
- package/package.json +6 -5
- package/src/server.ts +24 -1
- package/src/tool-definitions.ts +19 -1
- package/src/tool-handler.ts +11 -0
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_stdio = require("./stdio-
|
|
2
|
+
const require_stdio = require("./stdio-eqd_tVeJ.cjs");
|
|
3
3
|
exports.OPENFAIRYGUI_BACKEND_CAPABILITIES_RESOURCE_URI = require_stdio.OPENFAIRYGUI_BACKEND_CAPABILITIES_RESOURCE_URI;
|
|
4
4
|
exports.OPENFAIRYGUI_BACKEND_PROMPT_DEFINITIONS = require_stdio.OPENFAIRYGUI_BACKEND_PROMPT_DEFINITIONS;
|
|
5
5
|
exports.OPENFAIRYGUI_BACKEND_PROMPT_NAMES = require_stdio.OPENFAIRYGUI_BACKEND_PROMPT_NAMES;
|
package/dist/index.d.cts
CHANGED
|
@@ -6,9 +6,9 @@ import { z } from "zod";
|
|
|
6
6
|
|
|
7
7
|
//#region src/tool-definitions.d.ts
|
|
8
8
|
declare const OPENFAIRYGUI_BACKEND_TOOL_PREFIX = "openfairygui_backend_";
|
|
9
|
-
declare const OPENFAIRYGUI_BACKEND_TOOL_NAMES: readonly ["openfairygui_backend_get_capabilities", "openfairygui_backend_open_session", "openfairygui_backend_open_project_session", "openfairygui_backend_get_session", "openfairygui_backend_apply_transaction", "openfairygui_backend_save_session", "openfairygui_backend_close_session", "openfairygui_backend_get_events", "openfairygui_backend_get_job", "openfairygui_backend_list_jobs", "openfairygui_backend_cancel_job", "openfairygui_backend_get_cache_snapshot", "openfairygui_backend_refresh_cache"];
|
|
9
|
+
declare const OPENFAIRYGUI_BACKEND_TOOL_NAMES: readonly ["openfairygui_backend_get_capabilities", "openfairygui_backend_open_session", "openfairygui_backend_open_project_session", "openfairygui_backend_get_session", "openfairygui_backend_apply_transaction", "openfairygui_backend_save_session", "openfairygui_backend_materialize_session", "openfairygui_backend_close_session", "openfairygui_backend_get_events", "openfairygui_backend_get_job", "openfairygui_backend_list_jobs", "openfairygui_backend_cancel_job", "openfairygui_backend_get_cache_snapshot", "openfairygui_backend_refresh_cache"];
|
|
10
10
|
type OpenFairyGuiBackendToolName = typeof OPENFAIRYGUI_BACKEND_TOOL_NAMES[number];
|
|
11
|
-
type BackendMethodName = 'getCapabilities' | 'openSession' | 'openProjectSession' | 'getSession' | 'applyTransaction' | 'saveSession' | 'closeSession' | 'getEvents' | 'getJob' | 'listJobs' | 'cancelJob' | 'getCacheSnapshot' | 'refreshCache';
|
|
11
|
+
type BackendMethodName = 'getCapabilities' | 'openSession' | 'openProjectSession' | 'getSession' | 'applyTransaction' | 'saveSession' | 'materializeSession' | 'closeSession' | 'getEvents' | 'getJob' | 'listJobs' | 'cancelJob' | 'getCacheSnapshot' | 'refreshCache';
|
|
12
12
|
interface OpenFairyGuiBackendToolDefinition {
|
|
13
13
|
name: OpenFairyGuiBackendToolName;
|
|
14
14
|
backendMethod: BackendMethodName;
|
|
@@ -149,6 +149,33 @@ declare const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS: readonly [{
|
|
|
149
149
|
sessionId: z.ZodString;
|
|
150
150
|
expectedRevision: z.ZodOptional<z.ZodNumber>;
|
|
151
151
|
targetPath: z.ZodOptional<z.ZodString>;
|
|
152
|
+
force: z.ZodOptional<z.ZodBoolean>;
|
|
153
|
+
mode: z.ZodOptional<z.ZodLiteral<"materializeCleanSession">>;
|
|
154
|
+
}, z.core.$strip>;
|
|
155
|
+
readonly outputSchema: z.ZodObject<{
|
|
156
|
+
backendResult: z.ZodObject<{
|
|
157
|
+
ok: z.ZodBoolean;
|
|
158
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
159
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
160
|
+
meta: z.ZodOptional<z.ZodUnknown>;
|
|
161
|
+
}, z.core.$loose>;
|
|
162
|
+
}, z.core.$strip>;
|
|
163
|
+
readonly annotations: {
|
|
164
|
+
readonly readOnlyHint: false;
|
|
165
|
+
readonly destructiveHint: true;
|
|
166
|
+
readonly idempotentHint: false;
|
|
167
|
+
readonly openWorldHint: false;
|
|
168
|
+
};
|
|
169
|
+
}, {
|
|
170
|
+
readonly name: "openfairygui_backend_materialize_session";
|
|
171
|
+
readonly backendMethod: "materializeSession";
|
|
172
|
+
readonly title: "Materialize Backend Session";
|
|
173
|
+
readonly description: "Force materialize the current backend session project through the configured project storage without requiring a dirty edit revision.";
|
|
174
|
+
readonly inputSchema: z.ZodObject<{
|
|
175
|
+
sessionId: z.ZodString;
|
|
176
|
+
expectedRevision: z.ZodOptional<z.ZodNumber>;
|
|
177
|
+
mode: z.ZodOptional<z.ZodLiteral<"fullProject">>;
|
|
178
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
152
179
|
}, z.core.$strip>;
|
|
153
180
|
readonly outputSchema: z.ZodObject<{
|
|
154
181
|
backendResult: z.ZodObject<{
|
|
@@ -168,7 +195,7 @@ declare const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS: readonly [{
|
|
|
168
195
|
readonly name: "openfairygui_backend_close_session";
|
|
169
196
|
readonly backendMethod: "closeSession";
|
|
170
197
|
readonly title: "Close Backend Session";
|
|
171
|
-
readonly description: "Close a backend session and release its backend-local
|
|
198
|
+
readonly description: "Close a backend session and release its backend-local session lock.";
|
|
172
199
|
readonly inputSchema: z.ZodObject<{
|
|
173
200
|
sessionId: z.ZodString;
|
|
174
201
|
}, z.core.$strip>;
|
|
@@ -334,7 +361,7 @@ declare const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS: readonly [{
|
|
|
334
361
|
}];
|
|
335
362
|
//#endregion
|
|
336
363
|
//#region src/tool-handler.d.ts
|
|
337
|
-
type OpenFairyGuiBackendRuntime = Pick<BackendRuntime, 'getCapabilities' | 'openSession' | 'openProjectSession' | 'getSession' | 'applyTransaction' | 'saveSession' | 'closeSession' | 'getEvents' | 'getJob' | 'listJobs' | 'cancelJob' | 'getCacheSnapshot' | 'refreshCache'>;
|
|
364
|
+
type OpenFairyGuiBackendRuntime = Pick<BackendRuntime, 'getCapabilities' | 'openSession' | 'openProjectSession' | 'getSession' | 'applyTransaction' | 'saveSession' | 'materializeSession' | 'closeSession' | 'getEvents' | 'getJob' | 'listJobs' | 'cancelJob' | 'getCacheSnapshot' | 'refreshCache'>;
|
|
338
365
|
declare function callOpenFairyGuiBackendTool(runtime: OpenFairyGuiBackendRuntime, name: OpenFairyGuiBackendToolName, input: Record<string, unknown>): Promise<CallToolResult>;
|
|
339
366
|
//#endregion
|
|
340
367
|
//#region src/server.d.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -6,9 +6,9 @@ import { BackendRuntime } from "@openfairygui/backend";
|
|
|
6
6
|
|
|
7
7
|
//#region src/tool-definitions.d.ts
|
|
8
8
|
declare const OPENFAIRYGUI_BACKEND_TOOL_PREFIX = "openfairygui_backend_";
|
|
9
|
-
declare const OPENFAIRYGUI_BACKEND_TOOL_NAMES: readonly ["openfairygui_backend_get_capabilities", "openfairygui_backend_open_session", "openfairygui_backend_open_project_session", "openfairygui_backend_get_session", "openfairygui_backend_apply_transaction", "openfairygui_backend_save_session", "openfairygui_backend_close_session", "openfairygui_backend_get_events", "openfairygui_backend_get_job", "openfairygui_backend_list_jobs", "openfairygui_backend_cancel_job", "openfairygui_backend_get_cache_snapshot", "openfairygui_backend_refresh_cache"];
|
|
9
|
+
declare const OPENFAIRYGUI_BACKEND_TOOL_NAMES: readonly ["openfairygui_backend_get_capabilities", "openfairygui_backend_open_session", "openfairygui_backend_open_project_session", "openfairygui_backend_get_session", "openfairygui_backend_apply_transaction", "openfairygui_backend_save_session", "openfairygui_backend_materialize_session", "openfairygui_backend_close_session", "openfairygui_backend_get_events", "openfairygui_backend_get_job", "openfairygui_backend_list_jobs", "openfairygui_backend_cancel_job", "openfairygui_backend_get_cache_snapshot", "openfairygui_backend_refresh_cache"];
|
|
10
10
|
type OpenFairyGuiBackendToolName = typeof OPENFAIRYGUI_BACKEND_TOOL_NAMES[number];
|
|
11
|
-
type BackendMethodName = 'getCapabilities' | 'openSession' | 'openProjectSession' | 'getSession' | 'applyTransaction' | 'saveSession' | 'closeSession' | 'getEvents' | 'getJob' | 'listJobs' | 'cancelJob' | 'getCacheSnapshot' | 'refreshCache';
|
|
11
|
+
type BackendMethodName = 'getCapabilities' | 'openSession' | 'openProjectSession' | 'getSession' | 'applyTransaction' | 'saveSession' | 'materializeSession' | 'closeSession' | 'getEvents' | 'getJob' | 'listJobs' | 'cancelJob' | 'getCacheSnapshot' | 'refreshCache';
|
|
12
12
|
interface OpenFairyGuiBackendToolDefinition {
|
|
13
13
|
name: OpenFairyGuiBackendToolName;
|
|
14
14
|
backendMethod: BackendMethodName;
|
|
@@ -149,6 +149,33 @@ declare const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS: readonly [{
|
|
|
149
149
|
sessionId: z.ZodString;
|
|
150
150
|
expectedRevision: z.ZodOptional<z.ZodNumber>;
|
|
151
151
|
targetPath: z.ZodOptional<z.ZodString>;
|
|
152
|
+
force: z.ZodOptional<z.ZodBoolean>;
|
|
153
|
+
mode: z.ZodOptional<z.ZodLiteral<"materializeCleanSession">>;
|
|
154
|
+
}, z.core.$strip>;
|
|
155
|
+
readonly outputSchema: z.ZodObject<{
|
|
156
|
+
backendResult: z.ZodObject<{
|
|
157
|
+
ok: z.ZodBoolean;
|
|
158
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
159
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
160
|
+
meta: z.ZodOptional<z.ZodUnknown>;
|
|
161
|
+
}, z.core.$loose>;
|
|
162
|
+
}, z.core.$strip>;
|
|
163
|
+
readonly annotations: {
|
|
164
|
+
readonly readOnlyHint: false;
|
|
165
|
+
readonly destructiveHint: true;
|
|
166
|
+
readonly idempotentHint: false;
|
|
167
|
+
readonly openWorldHint: false;
|
|
168
|
+
};
|
|
169
|
+
}, {
|
|
170
|
+
readonly name: "openfairygui_backend_materialize_session";
|
|
171
|
+
readonly backendMethod: "materializeSession";
|
|
172
|
+
readonly title: "Materialize Backend Session";
|
|
173
|
+
readonly description: "Force materialize the current backend session project through the configured project storage without requiring a dirty edit revision.";
|
|
174
|
+
readonly inputSchema: z.ZodObject<{
|
|
175
|
+
sessionId: z.ZodString;
|
|
176
|
+
expectedRevision: z.ZodOptional<z.ZodNumber>;
|
|
177
|
+
mode: z.ZodOptional<z.ZodLiteral<"fullProject">>;
|
|
178
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
152
179
|
}, z.core.$strip>;
|
|
153
180
|
readonly outputSchema: z.ZodObject<{
|
|
154
181
|
backendResult: z.ZodObject<{
|
|
@@ -168,7 +195,7 @@ declare const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS: readonly [{
|
|
|
168
195
|
readonly name: "openfairygui_backend_close_session";
|
|
169
196
|
readonly backendMethod: "closeSession";
|
|
170
197
|
readonly title: "Close Backend Session";
|
|
171
|
-
readonly description: "Close a backend session and release its backend-local
|
|
198
|
+
readonly description: "Close a backend session and release its backend-local session lock.";
|
|
172
199
|
readonly inputSchema: z.ZodObject<{
|
|
173
200
|
sessionId: z.ZodString;
|
|
174
201
|
}, z.core.$strip>;
|
|
@@ -334,7 +361,7 @@ declare const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS: readonly [{
|
|
|
334
361
|
}];
|
|
335
362
|
//#endregion
|
|
336
363
|
//#region src/tool-handler.d.ts
|
|
337
|
-
type OpenFairyGuiBackendRuntime = Pick<BackendRuntime, 'getCapabilities' | 'openSession' | 'openProjectSession' | 'getSession' | 'applyTransaction' | 'saveSession' | 'closeSession' | 'getEvents' | 'getJob' | 'listJobs' | 'cancelJob' | 'getCacheSnapshot' | 'refreshCache'>;
|
|
364
|
+
type OpenFairyGuiBackendRuntime = Pick<BackendRuntime, 'getCapabilities' | 'openSession' | 'openProjectSession' | 'getSession' | 'applyTransaction' | 'saveSession' | 'materializeSession' | 'closeSession' | 'getEvents' | 'getJob' | 'listJobs' | 'cancelJob' | 'getCacheSnapshot' | 'refreshCache'>;
|
|
338
365
|
declare function callOpenFairyGuiBackendTool(runtime: OpenFairyGuiBackendRuntime, name: OpenFairyGuiBackendToolName, input: Record<string, unknown>): Promise<CallToolResult>;
|
|
339
366
|
//#endregion
|
|
340
367
|
//#region src/server.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as OPENFAIRYGUI_BACKEND_TOOL_OUTPUT_SCHEMA, c as OPENFAIRYGUI_BACKEND_CAPABILITIES_RESOURCE_URI, d as OPENFAIRYGUI_BACKEND_PROMPT_NAMES, i as OPENFAIRYGUI_BACKEND_TOOL_NAMES, l as OPENFAIRYGUI_BACKEND_RESOURCE_TEMPLATES, n as createOpenFairyGuiMcpServer, o as OPENFAIRYGUI_BACKEND_TOOL_PREFIX, r as OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS, s as callOpenFairyGuiBackendTool, t as connectOpenFairyGuiMcpStdio, u as OPENFAIRYGUI_BACKEND_PROMPT_DEFINITIONS } from "./stdio-
|
|
1
|
+
import { a as OPENFAIRYGUI_BACKEND_TOOL_OUTPUT_SCHEMA, c as OPENFAIRYGUI_BACKEND_CAPABILITIES_RESOURCE_URI, d as OPENFAIRYGUI_BACKEND_PROMPT_NAMES, i as OPENFAIRYGUI_BACKEND_TOOL_NAMES, l as OPENFAIRYGUI_BACKEND_RESOURCE_TEMPLATES, n as createOpenFairyGuiMcpServer, o as OPENFAIRYGUI_BACKEND_TOOL_PREFIX, r as OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS, s as callOpenFairyGuiBackendTool, t as connectOpenFairyGuiMcpStdio, u as OPENFAIRYGUI_BACKEND_PROMPT_DEFINITIONS } from "./stdio-AonL7fG4.mjs";
|
|
2
2
|
export { OPENFAIRYGUI_BACKEND_CAPABILITIES_RESOURCE_URI, OPENFAIRYGUI_BACKEND_PROMPT_DEFINITIONS, OPENFAIRYGUI_BACKEND_PROMPT_NAMES, OPENFAIRYGUI_BACKEND_RESOURCE_TEMPLATES, OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS, OPENFAIRYGUI_BACKEND_TOOL_NAMES, OPENFAIRYGUI_BACKEND_TOOL_OUTPUT_SCHEMA, OPENFAIRYGUI_BACKEND_TOOL_PREFIX, callOpenFairyGuiBackendTool, connectOpenFairyGuiMcpStdio, createOpenFairyGuiMcpServer };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
1
2
|
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
3
|
import { createNodeBackendRuntime } from "@openfairygui/backend/node";
|
|
3
4
|
import { z } from "zod";
|
|
@@ -170,7 +171,17 @@ async function callOpenFairyGuiBackendTool(runtime, name, input) {
|
|
|
170
171
|
result = await runtime.saveSession({
|
|
171
172
|
sessionId: String(input.sessionId),
|
|
172
173
|
expectedRevision: input.expectedRevision === void 0 ? void 0 : Number(input.expectedRevision),
|
|
173
|
-
targetPath: input.targetPath === void 0 ? void 0 : String(input.targetPath)
|
|
174
|
+
targetPath: input.targetPath === void 0 ? void 0 : String(input.targetPath),
|
|
175
|
+
force: input.force === void 0 ? void 0 : Boolean(input.force),
|
|
176
|
+
mode: input.mode
|
|
177
|
+
});
|
|
178
|
+
break;
|
|
179
|
+
case "openfairygui_backend_materialize_session":
|
|
180
|
+
result = await runtime.materializeSession({
|
|
181
|
+
sessionId: String(input.sessionId),
|
|
182
|
+
expectedRevision: input.expectedRevision === void 0 ? void 0 : Number(input.expectedRevision),
|
|
183
|
+
mode: input.mode,
|
|
184
|
+
reason: input.reason === void 0 ? void 0 : String(input.reason)
|
|
174
185
|
});
|
|
175
186
|
break;
|
|
176
187
|
case "openfairygui_backend_close_session":
|
|
@@ -226,6 +237,7 @@ const OPENFAIRYGUI_BACKEND_TOOL_NAMES = [
|
|
|
226
237
|
"openfairygui_backend_get_session",
|
|
227
238
|
"openfairygui_backend_apply_transaction",
|
|
228
239
|
"openfairygui_backend_save_session",
|
|
240
|
+
"openfairygui_backend_materialize_session",
|
|
229
241
|
"openfairygui_backend_close_session",
|
|
230
242
|
"openfairygui_backend_get_events",
|
|
231
243
|
"openfairygui_backend_get_job",
|
|
@@ -328,7 +340,28 @@ const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS = [
|
|
|
328
340
|
inputSchema: z.object({
|
|
329
341
|
sessionId,
|
|
330
342
|
expectedRevision: expectedRevision.optional(),
|
|
331
|
-
targetPath: z.string().min(1).optional()
|
|
343
|
+
targetPath: z.string().min(1).optional(),
|
|
344
|
+
force: z.boolean().optional(),
|
|
345
|
+
mode: z.literal("materializeCleanSession").optional()
|
|
346
|
+
}),
|
|
347
|
+
outputSchema: OPENFAIRYGUI_BACKEND_TOOL_OUTPUT_SCHEMA,
|
|
348
|
+
annotations: {
|
|
349
|
+
readOnlyHint: false,
|
|
350
|
+
destructiveHint: true,
|
|
351
|
+
idempotentHint: false,
|
|
352
|
+
openWorldHint: false
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
name: "openfairygui_backend_materialize_session",
|
|
357
|
+
backendMethod: "materializeSession",
|
|
358
|
+
title: "Materialize Backend Session",
|
|
359
|
+
description: "Force materialize the current backend session project through the configured project storage without requiring a dirty edit revision.",
|
|
360
|
+
inputSchema: z.object({
|
|
361
|
+
sessionId,
|
|
362
|
+
expectedRevision: expectedRevision.optional(),
|
|
363
|
+
mode: z.literal("fullProject").optional(),
|
|
364
|
+
reason: z.string().min(1).optional()
|
|
332
365
|
}),
|
|
333
366
|
outputSchema: OPENFAIRYGUI_BACKEND_TOOL_OUTPUT_SCHEMA,
|
|
334
367
|
annotations: {
|
|
@@ -342,7 +375,7 @@ const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS = [
|
|
|
342
375
|
name: "openfairygui_backend_close_session",
|
|
343
376
|
backendMethod: "closeSession",
|
|
344
377
|
title: "Close Backend Session",
|
|
345
|
-
description: "Close a backend session and release its backend-local
|
|
378
|
+
description: "Close a backend session and release its backend-local session lock.",
|
|
346
379
|
inputSchema: z.object({ sessionId }),
|
|
347
380
|
outputSchema: OPENFAIRYGUI_BACKEND_TOOL_OUTPUT_SCHEMA,
|
|
348
381
|
annotations: {
|
|
@@ -462,7 +495,21 @@ const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS = [
|
|
|
462
495
|
];
|
|
463
496
|
//#endregion
|
|
464
497
|
//#region src/server.ts
|
|
465
|
-
const
|
|
498
|
+
const require = createRequire(import.meta.url);
|
|
499
|
+
function getInjectedPackageVersion() {
|
|
500
|
+
const version = "0.2.0";
|
|
501
|
+
return typeof version === "string" && true ? version : null;
|
|
502
|
+
}
|
|
503
|
+
function readPackageVersion() {
|
|
504
|
+
const injectedVersion = getInjectedPackageVersion();
|
|
505
|
+
if (injectedVersion) return injectedVersion;
|
|
506
|
+
try {
|
|
507
|
+
const pkg = require("../package.json");
|
|
508
|
+
if (typeof pkg.version === "string" && pkg.version.length > 0) return pkg.version;
|
|
509
|
+
} catch {}
|
|
510
|
+
return "0.0.0-dev";
|
|
511
|
+
}
|
|
512
|
+
const PACKAGE_VERSION = readPackageVersion();
|
|
466
513
|
function createOpenFairyGuiMcpServer(options = {}) {
|
|
467
514
|
const runtime = options.runtime ?? createNodeBackendRuntime();
|
|
468
515
|
const server = new McpServer({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
let _modelcontextprotocol_sdk_server_mcp_js = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
2
2
|
let _openfairygui_backend_node = require("@openfairygui/backend/node");
|
|
3
|
+
let node_module = require("node:module");
|
|
3
4
|
let zod = require("zod");
|
|
4
5
|
let _modelcontextprotocol_sdk_server_stdio_js = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
5
6
|
let node_url = require("node:url");
|
|
@@ -170,7 +171,17 @@ async function callOpenFairyGuiBackendTool(runtime, name, input) {
|
|
|
170
171
|
result = await runtime.saveSession({
|
|
171
172
|
sessionId: String(input.sessionId),
|
|
172
173
|
expectedRevision: input.expectedRevision === void 0 ? void 0 : Number(input.expectedRevision),
|
|
173
|
-
targetPath: input.targetPath === void 0 ? void 0 : String(input.targetPath)
|
|
174
|
+
targetPath: input.targetPath === void 0 ? void 0 : String(input.targetPath),
|
|
175
|
+
force: input.force === void 0 ? void 0 : Boolean(input.force),
|
|
176
|
+
mode: input.mode
|
|
177
|
+
});
|
|
178
|
+
break;
|
|
179
|
+
case "openfairygui_backend_materialize_session":
|
|
180
|
+
result = await runtime.materializeSession({
|
|
181
|
+
sessionId: String(input.sessionId),
|
|
182
|
+
expectedRevision: input.expectedRevision === void 0 ? void 0 : Number(input.expectedRevision),
|
|
183
|
+
mode: input.mode,
|
|
184
|
+
reason: input.reason === void 0 ? void 0 : String(input.reason)
|
|
174
185
|
});
|
|
175
186
|
break;
|
|
176
187
|
case "openfairygui_backend_close_session":
|
|
@@ -226,6 +237,7 @@ const OPENFAIRYGUI_BACKEND_TOOL_NAMES = [
|
|
|
226
237
|
"openfairygui_backend_get_session",
|
|
227
238
|
"openfairygui_backend_apply_transaction",
|
|
228
239
|
"openfairygui_backend_save_session",
|
|
240
|
+
"openfairygui_backend_materialize_session",
|
|
229
241
|
"openfairygui_backend_close_session",
|
|
230
242
|
"openfairygui_backend_get_events",
|
|
231
243
|
"openfairygui_backend_get_job",
|
|
@@ -328,7 +340,28 @@ const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS = [
|
|
|
328
340
|
inputSchema: zod.z.object({
|
|
329
341
|
sessionId,
|
|
330
342
|
expectedRevision: expectedRevision.optional(),
|
|
331
|
-
targetPath: zod.z.string().min(1).optional()
|
|
343
|
+
targetPath: zod.z.string().min(1).optional(),
|
|
344
|
+
force: zod.z.boolean().optional(),
|
|
345
|
+
mode: zod.z.literal("materializeCleanSession").optional()
|
|
346
|
+
}),
|
|
347
|
+
outputSchema: OPENFAIRYGUI_BACKEND_TOOL_OUTPUT_SCHEMA,
|
|
348
|
+
annotations: {
|
|
349
|
+
readOnlyHint: false,
|
|
350
|
+
destructiveHint: true,
|
|
351
|
+
idempotentHint: false,
|
|
352
|
+
openWorldHint: false
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
name: "openfairygui_backend_materialize_session",
|
|
357
|
+
backendMethod: "materializeSession",
|
|
358
|
+
title: "Materialize Backend Session",
|
|
359
|
+
description: "Force materialize the current backend session project through the configured project storage without requiring a dirty edit revision.",
|
|
360
|
+
inputSchema: zod.z.object({
|
|
361
|
+
sessionId,
|
|
362
|
+
expectedRevision: expectedRevision.optional(),
|
|
363
|
+
mode: zod.z.literal("fullProject").optional(),
|
|
364
|
+
reason: zod.z.string().min(1).optional()
|
|
332
365
|
}),
|
|
333
366
|
outputSchema: OPENFAIRYGUI_BACKEND_TOOL_OUTPUT_SCHEMA,
|
|
334
367
|
annotations: {
|
|
@@ -342,7 +375,7 @@ const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS = [
|
|
|
342
375
|
name: "openfairygui_backend_close_session",
|
|
343
376
|
backendMethod: "closeSession",
|
|
344
377
|
title: "Close Backend Session",
|
|
345
|
-
description: "Close a backend session and release its backend-local
|
|
378
|
+
description: "Close a backend session and release its backend-local session lock.",
|
|
346
379
|
inputSchema: zod.z.object({ sessionId }),
|
|
347
380
|
outputSchema: OPENFAIRYGUI_BACKEND_TOOL_OUTPUT_SCHEMA,
|
|
348
381
|
annotations: {
|
|
@@ -462,7 +495,21 @@ const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS = [
|
|
|
462
495
|
];
|
|
463
496
|
//#endregion
|
|
464
497
|
//#region src/server.ts
|
|
465
|
-
const
|
|
498
|
+
const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
499
|
+
function getInjectedPackageVersion() {
|
|
500
|
+
const version = "0.2.0";
|
|
501
|
+
return typeof version === "string" && true ? version : null;
|
|
502
|
+
}
|
|
503
|
+
function readPackageVersion() {
|
|
504
|
+
const injectedVersion = getInjectedPackageVersion();
|
|
505
|
+
if (injectedVersion) return injectedVersion;
|
|
506
|
+
try {
|
|
507
|
+
const pkg = require$1("../package.json");
|
|
508
|
+
if (typeof pkg.version === "string" && pkg.version.length > 0) return pkg.version;
|
|
509
|
+
} catch {}
|
|
510
|
+
return "0.0.0-dev";
|
|
511
|
+
}
|
|
512
|
+
const PACKAGE_VERSION = readPackageVersion();
|
|
466
513
|
function createOpenFairyGuiMcpServer(options = {}) {
|
|
467
514
|
const runtime = options.runtime ?? (0, _openfairygui_backend_node.createNodeBackendRuntime)();
|
|
468
515
|
const server = new _modelcontextprotocol_sdk_server_mcp_js.McpServer({
|
package/dist/stdio.cjs
CHANGED
package/dist/stdio.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as connectOpenFairyGuiMcpStdio } from "./stdio-
|
|
1
|
+
import { t as connectOpenFairyGuiMcpStdio } from "./stdio-AonL7fG4.mjs";
|
|
2
2
|
export { connectOpenFairyGuiMcpStdio };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfairygui/mcp",
|
|
3
|
-
"version": "0.2.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "FairyGUI Headless Authoring SDK - MCP server adapter for the backend runtime.",
|
|
5
5
|
"author": "OpenFairyGUI Contributors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,12 +58,13 @@
|
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
60
60
|
"zod": "^4.3.6",
|
|
61
|
-
"@openfairygui/backend": "0.2.0
|
|
61
|
+
"@openfairygui/backend": "0.2.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"ava": "^7.0.0",
|
|
65
65
|
"tsx": "^4.0.0",
|
|
66
|
-
"@openfairygui/
|
|
66
|
+
"@openfairygui/test-utils": "0.2.0-alpha.10",
|
|
67
|
+
"@openfairygui/core": "0.2.0"
|
|
67
68
|
},
|
|
68
69
|
"ava": {
|
|
69
70
|
"extensions": {
|
|
@@ -78,8 +79,8 @@
|
|
|
78
79
|
]
|
|
79
80
|
},
|
|
80
81
|
"scripts": {
|
|
81
|
-
"build": "tsdown src/index.ts src/stdio.ts --format esm,cjs --platform node --external node:fs --external node:path --external node:fs/promises
|
|
82
|
-
"build:watch": "tsdown src/index.ts src/stdio.ts --watch --format esm,cjs --platform node
|
|
82
|
+
"build": "tsdown src/index.ts src/stdio.ts --format esm,cjs --platform node --external node:fs --external node:path --external node:fs/promises",
|
|
83
|
+
"build:watch": "tsdown src/index.ts src/stdio.ts --watch --format esm,cjs --platform node",
|
|
83
84
|
"test": "ava test/**/*.test.ts --no-worker-threads"
|
|
84
85
|
}
|
|
85
86
|
}
|
package/src/server.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { createNodeBackendRuntime } from '@openfairygui/backend/node';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
3
4
|
import { registerOpenFairyGuiBackendPrompts } from './prompt-definitions.js';
|
|
4
5
|
import { registerOpenFairyGuiBackendResources } from './resource-definitions.js';
|
|
5
6
|
import { callOpenFairyGuiBackendTool, type OpenFairyGuiBackendRuntime } from './tool-handler.js';
|
|
@@ -8,7 +9,29 @@ import {
|
|
|
8
9
|
type OpenFairyGuiBackendToolName,
|
|
9
10
|
} from './tool-definitions.js';
|
|
10
11
|
|
|
11
|
-
const
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
13
|
+
declare const __OPENFAIRYGUI_PACKAGE_VERSION__: string | undefined;
|
|
14
|
+
|
|
15
|
+
function getInjectedPackageVersion(): string | null {
|
|
16
|
+
const version = typeof __OPENFAIRYGUI_PACKAGE_VERSION__ === 'string' ? __OPENFAIRYGUI_PACKAGE_VERSION__ : null;
|
|
17
|
+
return typeof version === 'string' && version.length > 0 ? version : null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function readPackageVersion(): string {
|
|
21
|
+
const injectedVersion = getInjectedPackageVersion();
|
|
22
|
+
if (injectedVersion) return injectedVersion;
|
|
23
|
+
try {
|
|
24
|
+
const pkg = require('../package.json') as { version?: unknown };
|
|
25
|
+
if (typeof pkg.version === 'string' && pkg.version.length > 0) {
|
|
26
|
+
return pkg.version;
|
|
27
|
+
}
|
|
28
|
+
} catch {
|
|
29
|
+
// Keep the MCP server usable when executed from a bundled artifact missing package.json.
|
|
30
|
+
}
|
|
31
|
+
return '0.0.0-dev';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const PACKAGE_VERSION = readPackageVersion();
|
|
12
35
|
|
|
13
36
|
export interface CreateOpenFairyGuiMcpServerOptions {
|
|
14
37
|
runtime?: OpenFairyGuiBackendRuntime;
|
package/src/tool-definitions.ts
CHANGED
|
@@ -9,6 +9,7 @@ export const OPENFAIRYGUI_BACKEND_TOOL_NAMES = [
|
|
|
9
9
|
'openfairygui_backend_get_session',
|
|
10
10
|
'openfairygui_backend_apply_transaction',
|
|
11
11
|
'openfairygui_backend_save_session',
|
|
12
|
+
'openfairygui_backend_materialize_session',
|
|
12
13
|
'openfairygui_backend_close_session',
|
|
13
14
|
'openfairygui_backend_get_events',
|
|
14
15
|
'openfairygui_backend_get_job',
|
|
@@ -27,6 +28,7 @@ export type BackendMethodName =
|
|
|
27
28
|
| 'getSession'
|
|
28
29
|
| 'applyTransaction'
|
|
29
30
|
| 'saveSession'
|
|
31
|
+
| 'materializeSession'
|
|
30
32
|
| 'closeSession'
|
|
31
33
|
| 'getEvents'
|
|
32
34
|
| 'getJob'
|
|
@@ -130,6 +132,22 @@ export const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS = [
|
|
|
130
132
|
sessionId,
|
|
131
133
|
expectedRevision: expectedRevision.optional(),
|
|
132
134
|
targetPath: z.string().min(1).optional(),
|
|
135
|
+
force: z.boolean().optional(),
|
|
136
|
+
mode: z.literal('materializeCleanSession').optional(),
|
|
137
|
+
}),
|
|
138
|
+
outputSchema: OPENFAIRYGUI_BACKEND_TOOL_OUTPUT_SCHEMA,
|
|
139
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: 'openfairygui_backend_materialize_session',
|
|
143
|
+
backendMethod: 'materializeSession',
|
|
144
|
+
title: 'Materialize Backend Session',
|
|
145
|
+
description: 'Force materialize the current backend session project through the configured project storage without requiring a dirty edit revision.',
|
|
146
|
+
inputSchema: z.object({
|
|
147
|
+
sessionId,
|
|
148
|
+
expectedRevision: expectedRevision.optional(),
|
|
149
|
+
mode: z.literal('fullProject').optional(),
|
|
150
|
+
reason: z.string().min(1).optional(),
|
|
133
151
|
}),
|
|
134
152
|
outputSchema: OPENFAIRYGUI_BACKEND_TOOL_OUTPUT_SCHEMA,
|
|
135
153
|
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
|
|
@@ -138,7 +156,7 @@ export const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS = [
|
|
|
138
156
|
name: 'openfairygui_backend_close_session',
|
|
139
157
|
backendMethod: 'closeSession',
|
|
140
158
|
title: 'Close Backend Session',
|
|
141
|
-
description: 'Close a backend session and release its backend-local
|
|
159
|
+
description: 'Close a backend session and release its backend-local session lock.',
|
|
142
160
|
inputSchema: z.object({ sessionId }),
|
|
143
161
|
outputSchema: OPENFAIRYGUI_BACKEND_TOOL_OUTPUT_SCHEMA,
|
|
144
162
|
annotations: { readOnlyHint: false, idempotentHint: false, openWorldHint: false },
|
package/src/tool-handler.ts
CHANGED
|
@@ -10,6 +10,7 @@ export type OpenFairyGuiBackendRuntime = Pick<
|
|
|
10
10
|
| 'getSession'
|
|
11
11
|
| 'applyTransaction'
|
|
12
12
|
| 'saveSession'
|
|
13
|
+
| 'materializeSession'
|
|
13
14
|
| 'closeSession'
|
|
14
15
|
| 'getEvents'
|
|
15
16
|
| 'getJob'
|
|
@@ -81,6 +82,16 @@ export async function callOpenFairyGuiBackendTool(
|
|
|
81
82
|
sessionId: String(input.sessionId),
|
|
82
83
|
expectedRevision: input.expectedRevision === undefined ? undefined : Number(input.expectedRevision),
|
|
83
84
|
targetPath: input.targetPath === undefined ? undefined : String(input.targetPath),
|
|
85
|
+
force: input.force === undefined ? undefined : Boolean(input.force),
|
|
86
|
+
mode: input.mode as Parameters<BackendRuntime['saveSession']>[0]['mode'],
|
|
87
|
+
});
|
|
88
|
+
break;
|
|
89
|
+
case 'openfairygui_backend_materialize_session':
|
|
90
|
+
result = await runtime.materializeSession({
|
|
91
|
+
sessionId: String(input.sessionId),
|
|
92
|
+
expectedRevision: input.expectedRevision === undefined ? undefined : Number(input.expectedRevision),
|
|
93
|
+
mode: input.mode as Parameters<BackendRuntime['materializeSession']>[0]['mode'],
|
|
94
|
+
reason: input.reason === undefined ? undefined : String(input.reason),
|
|
84
95
|
});
|
|
85
96
|
break;
|
|
86
97
|
case 'openfairygui_backend_close_session':
|