@openfairygui/mcp 0.2.0-alpha.0 → 0.2.0-alpha.2
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/bin/ofgui-mcp.cjs +0 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +26 -2
- package/dist/index.d.mts +27 -3
- package/dist/index.mjs +1 -1
- package/dist/{stdio-BDHxauin.cjs → stdio-Ckmxm29z.cjs} +29 -2
- package/dist/{stdio-ByGWerIG.mjs → stdio-DT1cUPJ3.mjs} +29 -2
- package/dist/stdio.cjs +1 -1
- package/dist/stdio.mjs +1 -1
- package/package.json +84 -84
- package/src/server.ts +3 -2
- package/src/tool-definitions.ts +16 -0
- package/src/tool-handler.ts +8 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OpenFairyGUI Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/bin/ofgui-mcp.cjs
CHANGED
|
File without changes
|
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-Ckmxm29z.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
|
@@ -14,9 +14,9 @@ declare function createOpenFairyGuiMcpServer(options?: CreateOpenFairyGuiMcpServ
|
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/tool-definitions.d.ts
|
|
16
16
|
declare const OPENFAIRYGUI_BACKEND_TOOL_PREFIX = "openfairygui_backend_";
|
|
17
|
-
declare const OPENFAIRYGUI_BACKEND_TOOL_NAMES: readonly ["openfairygui_backend_get_capabilities", "openfairygui_backend_open_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"];
|
|
17
|
+
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"];
|
|
18
18
|
type OpenFairyGuiBackendToolName = typeof OPENFAIRYGUI_BACKEND_TOOL_NAMES[number];
|
|
19
|
-
type BackendMethodName = 'getCapabilities' | 'openSession' | 'getSession' | 'applyTransaction' | 'saveSession' | 'closeSession' | 'getEvents' | 'getJob' | 'listJobs' | 'cancelJob' | 'getCacheSnapshot' | 'refreshCache';
|
|
19
|
+
type BackendMethodName = 'getCapabilities' | 'openSession' | 'openProjectSession' | 'getSession' | 'applyTransaction' | 'saveSession' | 'closeSession' | 'getEvents' | 'getJob' | 'listJobs' | 'cancelJob' | 'getCacheSnapshot' | 'refreshCache';
|
|
20
20
|
interface OpenFairyGuiBackendToolDefinition {
|
|
21
21
|
name: OpenFairyGuiBackendToolName;
|
|
22
22
|
backendMethod: BackendMethodName;
|
|
@@ -79,6 +79,30 @@ declare const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS: readonly [{
|
|
|
79
79
|
readonly idempotentHint: false;
|
|
80
80
|
readonly openWorldHint: false;
|
|
81
81
|
};
|
|
82
|
+
}, {
|
|
83
|
+
readonly name: "openfairygui_backend_open_project_session";
|
|
84
|
+
readonly backendMethod: "openProjectSession";
|
|
85
|
+
readonly title: "Open Project Session";
|
|
86
|
+
readonly description: "Open a browser-safe backend session from an already loaded UAM project without filesystem access.";
|
|
87
|
+
readonly inputSchema: z.ZodObject<{
|
|
88
|
+
project: z.ZodUnknown;
|
|
89
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
90
|
+
canonicalProjectPath: z.ZodOptional<z.ZodString>;
|
|
91
|
+
canonicalPathKey: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strip>;
|
|
93
|
+
readonly outputSchema: z.ZodObject<{
|
|
94
|
+
backendResult: z.ZodObject<{
|
|
95
|
+
ok: z.ZodBoolean;
|
|
96
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
97
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
98
|
+
meta: z.ZodOptional<z.ZodUnknown>;
|
|
99
|
+
}, z.core.$loose>;
|
|
100
|
+
}, z.core.$strip>;
|
|
101
|
+
readonly annotations: {
|
|
102
|
+
readonly readOnlyHint: false;
|
|
103
|
+
readonly idempotentHint: false;
|
|
104
|
+
readonly openWorldHint: false;
|
|
105
|
+
};
|
|
82
106
|
}, {
|
|
83
107
|
readonly name: "openfairygui_backend_get_session";
|
|
84
108
|
readonly backendMethod: "getSession";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { connectOpenFairyGuiMcpStdio } from "./stdio.mjs";
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
-
import { BackendRuntime } from "@openfairygui/backend";
|
|
4
3
|
import { z } from "zod";
|
|
4
|
+
import { BackendRuntime } from "@openfairygui/backend";
|
|
5
5
|
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
6
6
|
|
|
7
7
|
//#region src/server.d.ts
|
|
@@ -14,9 +14,9 @@ declare function createOpenFairyGuiMcpServer(options?: CreateOpenFairyGuiMcpServ
|
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/tool-definitions.d.ts
|
|
16
16
|
declare const OPENFAIRYGUI_BACKEND_TOOL_PREFIX = "openfairygui_backend_";
|
|
17
|
-
declare const OPENFAIRYGUI_BACKEND_TOOL_NAMES: readonly ["openfairygui_backend_get_capabilities", "openfairygui_backend_open_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"];
|
|
17
|
+
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"];
|
|
18
18
|
type OpenFairyGuiBackendToolName = typeof OPENFAIRYGUI_BACKEND_TOOL_NAMES[number];
|
|
19
|
-
type BackendMethodName = 'getCapabilities' | 'openSession' | 'getSession' | 'applyTransaction' | 'saveSession' | 'closeSession' | 'getEvents' | 'getJob' | 'listJobs' | 'cancelJob' | 'getCacheSnapshot' | 'refreshCache';
|
|
19
|
+
type BackendMethodName = 'getCapabilities' | 'openSession' | 'openProjectSession' | 'getSession' | 'applyTransaction' | 'saveSession' | 'closeSession' | 'getEvents' | 'getJob' | 'listJobs' | 'cancelJob' | 'getCacheSnapshot' | 'refreshCache';
|
|
20
20
|
interface OpenFairyGuiBackendToolDefinition {
|
|
21
21
|
name: OpenFairyGuiBackendToolName;
|
|
22
22
|
backendMethod: BackendMethodName;
|
|
@@ -79,6 +79,30 @@ declare const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS: readonly [{
|
|
|
79
79
|
readonly idempotentHint: false;
|
|
80
80
|
readonly openWorldHint: false;
|
|
81
81
|
};
|
|
82
|
+
}, {
|
|
83
|
+
readonly name: "openfairygui_backend_open_project_session";
|
|
84
|
+
readonly backendMethod: "openProjectSession";
|
|
85
|
+
readonly title: "Open Project Session";
|
|
86
|
+
readonly description: "Open a browser-safe backend session from an already loaded UAM project without filesystem access.";
|
|
87
|
+
readonly inputSchema: z.ZodObject<{
|
|
88
|
+
project: z.ZodUnknown;
|
|
89
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
90
|
+
canonicalProjectPath: z.ZodOptional<z.ZodString>;
|
|
91
|
+
canonicalPathKey: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strip>;
|
|
93
|
+
readonly outputSchema: z.ZodObject<{
|
|
94
|
+
backendResult: z.ZodObject<{
|
|
95
|
+
ok: z.ZodBoolean;
|
|
96
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
97
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
98
|
+
meta: z.ZodOptional<z.ZodUnknown>;
|
|
99
|
+
}, z.core.$loose>;
|
|
100
|
+
}, z.core.$strip>;
|
|
101
|
+
readonly annotations: {
|
|
102
|
+
readonly readOnlyHint: false;
|
|
103
|
+
readonly idempotentHint: false;
|
|
104
|
+
readonly openWorldHint: false;
|
|
105
|
+
};
|
|
82
106
|
}, {
|
|
83
107
|
readonly name: "openfairygui_backend_get_session";
|
|
84
108
|
readonly backendMethod: "getSession";
|
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-DT1cUPJ3.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,5 +1,5 @@
|
|
|
1
1
|
let _modelcontextprotocol_sdk_server_mcp_js = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
2
|
-
let
|
|
2
|
+
let _openfairygui_backend_node = require("@openfairygui/backend/node");
|
|
3
3
|
let zod = require("zod");
|
|
4
4
|
let _modelcontextprotocol_sdk_server_stdio_js = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
5
5
|
let node_url = require("node:url");
|
|
@@ -148,6 +148,14 @@ async function callOpenFairyGuiBackendTool(runtime, name, input) {
|
|
|
148
148
|
case "openfairygui_backend_open_session":
|
|
149
149
|
result = await runtime.openSession({ projectPath: String(input.projectPath) });
|
|
150
150
|
break;
|
|
151
|
+
case "openfairygui_backend_open_project_session":
|
|
152
|
+
result = runtime.openProjectSession({
|
|
153
|
+
project: input.project,
|
|
154
|
+
sessionId: input.sessionId === void 0 ? void 0 : String(input.sessionId),
|
|
155
|
+
canonicalProjectPath: input.canonicalProjectPath === void 0 ? void 0 : String(input.canonicalProjectPath),
|
|
156
|
+
canonicalPathKey: input.canonicalPathKey === void 0 ? void 0 : String(input.canonicalPathKey)
|
|
157
|
+
});
|
|
158
|
+
break;
|
|
151
159
|
case "openfairygui_backend_get_session":
|
|
152
160
|
result = runtime.getSession({ sessionId: String(input.sessionId) });
|
|
153
161
|
break;
|
|
@@ -214,6 +222,7 @@ const OPENFAIRYGUI_BACKEND_TOOL_PREFIX = "openfairygui_backend_";
|
|
|
214
222
|
const OPENFAIRYGUI_BACKEND_TOOL_NAMES = [
|
|
215
223
|
"openfairygui_backend_get_capabilities",
|
|
216
224
|
"openfairygui_backend_open_session",
|
|
225
|
+
"openfairygui_backend_open_project_session",
|
|
217
226
|
"openfairygui_backend_get_session",
|
|
218
227
|
"openfairygui_backend_apply_transaction",
|
|
219
228
|
"openfairygui_backend_save_session",
|
|
@@ -262,6 +271,24 @@ const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS = [
|
|
|
262
271
|
openWorldHint: false
|
|
263
272
|
}
|
|
264
273
|
},
|
|
274
|
+
{
|
|
275
|
+
name: "openfairygui_backend_open_project_session",
|
|
276
|
+
backendMethod: "openProjectSession",
|
|
277
|
+
title: "Open Project Session",
|
|
278
|
+
description: "Open a browser-safe backend session from an already loaded UAM project without filesystem access.",
|
|
279
|
+
inputSchema: zod.z.object({
|
|
280
|
+
project: zod.z.unknown(),
|
|
281
|
+
sessionId: zod.z.string().min(1).optional(),
|
|
282
|
+
canonicalProjectPath: zod.z.string().min(1).optional(),
|
|
283
|
+
canonicalPathKey: zod.z.string().min(1).optional()
|
|
284
|
+
}),
|
|
285
|
+
outputSchema: OPENFAIRYGUI_BACKEND_TOOL_OUTPUT_SCHEMA,
|
|
286
|
+
annotations: {
|
|
287
|
+
readOnlyHint: false,
|
|
288
|
+
idempotentHint: false,
|
|
289
|
+
openWorldHint: false
|
|
290
|
+
}
|
|
291
|
+
},
|
|
265
292
|
{
|
|
266
293
|
name: "openfairygui_backend_get_session",
|
|
267
294
|
backendMethod: "getSession",
|
|
@@ -437,7 +464,7 @@ const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS = [
|
|
|
437
464
|
//#region src/server.ts
|
|
438
465
|
const PACKAGE_VERSION = process.env.npm_package_version ?? "0.2.0-alpha.0";
|
|
439
466
|
function createOpenFairyGuiMcpServer(options = {}) {
|
|
440
|
-
const runtime = options.runtime ??
|
|
467
|
+
const runtime = options.runtime ?? (0, _openfairygui_backend_node.createNodeBackendRuntime)();
|
|
441
468
|
const server = new _modelcontextprotocol_sdk_server_mcp_js.McpServer({
|
|
442
469
|
name: options.name ?? "openfairygui-mcp",
|
|
443
470
|
version: options.version ?? PACKAGE_VERSION
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import {
|
|
2
|
+
import { createNodeBackendRuntime } from "@openfairygui/backend/node";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
@@ -148,6 +148,14 @@ async function callOpenFairyGuiBackendTool(runtime, name, input) {
|
|
|
148
148
|
case "openfairygui_backend_open_session":
|
|
149
149
|
result = await runtime.openSession({ projectPath: String(input.projectPath) });
|
|
150
150
|
break;
|
|
151
|
+
case "openfairygui_backend_open_project_session":
|
|
152
|
+
result = runtime.openProjectSession({
|
|
153
|
+
project: input.project,
|
|
154
|
+
sessionId: input.sessionId === void 0 ? void 0 : String(input.sessionId),
|
|
155
|
+
canonicalProjectPath: input.canonicalProjectPath === void 0 ? void 0 : String(input.canonicalProjectPath),
|
|
156
|
+
canonicalPathKey: input.canonicalPathKey === void 0 ? void 0 : String(input.canonicalPathKey)
|
|
157
|
+
});
|
|
158
|
+
break;
|
|
151
159
|
case "openfairygui_backend_get_session":
|
|
152
160
|
result = runtime.getSession({ sessionId: String(input.sessionId) });
|
|
153
161
|
break;
|
|
@@ -214,6 +222,7 @@ const OPENFAIRYGUI_BACKEND_TOOL_PREFIX = "openfairygui_backend_";
|
|
|
214
222
|
const OPENFAIRYGUI_BACKEND_TOOL_NAMES = [
|
|
215
223
|
"openfairygui_backend_get_capabilities",
|
|
216
224
|
"openfairygui_backend_open_session",
|
|
225
|
+
"openfairygui_backend_open_project_session",
|
|
217
226
|
"openfairygui_backend_get_session",
|
|
218
227
|
"openfairygui_backend_apply_transaction",
|
|
219
228
|
"openfairygui_backend_save_session",
|
|
@@ -262,6 +271,24 @@ const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS = [
|
|
|
262
271
|
openWorldHint: false
|
|
263
272
|
}
|
|
264
273
|
},
|
|
274
|
+
{
|
|
275
|
+
name: "openfairygui_backend_open_project_session",
|
|
276
|
+
backendMethod: "openProjectSession",
|
|
277
|
+
title: "Open Project Session",
|
|
278
|
+
description: "Open a browser-safe backend session from an already loaded UAM project without filesystem access.",
|
|
279
|
+
inputSchema: z.object({
|
|
280
|
+
project: z.unknown(),
|
|
281
|
+
sessionId: z.string().min(1).optional(),
|
|
282
|
+
canonicalProjectPath: z.string().min(1).optional(),
|
|
283
|
+
canonicalPathKey: z.string().min(1).optional()
|
|
284
|
+
}),
|
|
285
|
+
outputSchema: OPENFAIRYGUI_BACKEND_TOOL_OUTPUT_SCHEMA,
|
|
286
|
+
annotations: {
|
|
287
|
+
readOnlyHint: false,
|
|
288
|
+
idempotentHint: false,
|
|
289
|
+
openWorldHint: false
|
|
290
|
+
}
|
|
291
|
+
},
|
|
265
292
|
{
|
|
266
293
|
name: "openfairygui_backend_get_session",
|
|
267
294
|
backendMethod: "getSession",
|
|
@@ -437,7 +464,7 @@ const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS = [
|
|
|
437
464
|
//#region src/server.ts
|
|
438
465
|
const PACKAGE_VERSION = process.env.npm_package_version ?? "0.2.0-alpha.0";
|
|
439
466
|
function createOpenFairyGuiMcpServer(options = {}) {
|
|
440
|
-
const runtime = options.runtime ??
|
|
467
|
+
const runtime = options.runtime ?? createNodeBackendRuntime();
|
|
441
468
|
const server = new McpServer({
|
|
442
469
|
name: options.name ?? "openfairygui-mcp",
|
|
443
470
|
version: options.version ?? PACKAGE_VERSION
|
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-DT1cUPJ3.mjs";
|
|
2
2
|
export { connectOpenFairyGuiMcpStdio };
|
package/package.json
CHANGED
|
@@ -1,85 +1,85 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
2
|
+
"name": "@openfairygui/mcp",
|
|
3
|
+
"version": "0.2.0-alpha.2",
|
|
4
|
+
"description": "FairyGUI Headless Authoring SDK - MCP server adapter for the backend runtime.",
|
|
5
|
+
"author": "OpenFairyGUI Contributors",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/OpenFairyGUI/OpenFairyGUI.git",
|
|
10
|
+
"directory": "packages/mcp"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/OpenFairyGUI/OpenFairyGUI#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/OpenFairyGUI/OpenFairyGUI/issues"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"main": "./dist/index.cjs",
|
|
19
|
+
"module": "./dist/index.mjs",
|
|
20
|
+
"types": "./dist/index.d.mts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"require": {
|
|
24
|
+
"types": "./dist/index.d.cts",
|
|
25
|
+
"default": "./dist/index.cjs"
|
|
26
|
+
},
|
|
27
|
+
"default": {
|
|
28
|
+
"types": "./dist/index.d.mts",
|
|
29
|
+
"default": "./dist/index.mjs"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"./stdio": {
|
|
33
|
+
"require": {
|
|
34
|
+
"types": "./dist/stdio.d.cts",
|
|
35
|
+
"default": "./dist/stdio.cjs"
|
|
36
|
+
},
|
|
37
|
+
"default": {
|
|
38
|
+
"types": "./dist/stdio.d.mts",
|
|
39
|
+
"default": "./dist/stdio.mjs"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"bin": {
|
|
44
|
+
"ofgui-mcp": "bin/ofgui-mcp.cjs"
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"dist/",
|
|
48
|
+
"bin/",
|
|
49
|
+
"src/"
|
|
50
|
+
],
|
|
51
|
+
"keywords": [
|
|
52
|
+
"fairygui",
|
|
53
|
+
"mcp",
|
|
54
|
+
"model-context-protocol",
|
|
55
|
+
"backend",
|
|
56
|
+
"authoring"
|
|
57
|
+
],
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
60
|
+
"zod": "^4.3.6",
|
|
61
|
+
"@openfairygui/backend": "0.2.0-alpha.2"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"ava": "^7.0.0",
|
|
65
|
+
"tsx": "^4.0.0",
|
|
66
|
+
"@openfairygui/core": "0.2.0-alpha.2"
|
|
67
|
+
},
|
|
68
|
+
"ava": {
|
|
69
|
+
"extensions": {
|
|
70
|
+
"ts": "module"
|
|
71
|
+
},
|
|
72
|
+
"nodeArguments": [
|
|
73
|
+
"--import",
|
|
74
|
+
"tsx/esm"
|
|
75
|
+
],
|
|
76
|
+
"files": [
|
|
77
|
+
"test/**/*.test.ts"
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
"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 --env.PACKAGE_VERSION=$npm_package_version",
|
|
82
|
+
"build:watch": "tsdown src/index.ts src/stdio.ts --watch --format esm,cjs --platform node --env.PACKAGE_VERSION=$npm_package_version",
|
|
83
|
+
"test": "ava test/**/*.test.ts --no-worker-threads"
|
|
84
|
+
}
|
|
85
|
+
}
|
package/src/server.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { BackendRuntime } from '@openfairygui/backend';
|
|
2
|
+
import type { BackendRuntime } from '@openfairygui/backend';
|
|
3
|
+
import { createNodeBackendRuntime } from '@openfairygui/backend/node';
|
|
3
4
|
import { registerOpenFairyGuiBackendPrompts } from './prompt-definitions.js';
|
|
4
5
|
import { registerOpenFairyGuiBackendResources } from './resource-definitions.js';
|
|
5
6
|
import { callOpenFairyGuiBackendTool } from './tool-handler.js';
|
|
@@ -17,7 +18,7 @@ export interface CreateOpenFairyGuiMcpServerOptions {
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export function createOpenFairyGuiMcpServer(options: CreateOpenFairyGuiMcpServerOptions = {}): McpServer {
|
|
20
|
-
const runtime = options.runtime ??
|
|
21
|
+
const runtime = options.runtime ?? createNodeBackendRuntime();
|
|
21
22
|
const server = new McpServer({
|
|
22
23
|
name: options.name ?? 'openfairygui-mcp',
|
|
23
24
|
version: options.version ?? PACKAGE_VERSION,
|
package/src/tool-definitions.ts
CHANGED
|
@@ -5,6 +5,7 @@ export const OPENFAIRYGUI_BACKEND_TOOL_PREFIX = 'openfairygui_backend_';
|
|
|
5
5
|
export const OPENFAIRYGUI_BACKEND_TOOL_NAMES = [
|
|
6
6
|
'openfairygui_backend_get_capabilities',
|
|
7
7
|
'openfairygui_backend_open_session',
|
|
8
|
+
'openfairygui_backend_open_project_session',
|
|
8
9
|
'openfairygui_backend_get_session',
|
|
9
10
|
'openfairygui_backend_apply_transaction',
|
|
10
11
|
'openfairygui_backend_save_session',
|
|
@@ -22,6 +23,7 @@ export type OpenFairyGuiBackendToolName = typeof OPENFAIRYGUI_BACKEND_TOOL_NAMES
|
|
|
22
23
|
export type BackendMethodName =
|
|
23
24
|
| 'getCapabilities'
|
|
24
25
|
| 'openSession'
|
|
26
|
+
| 'openProjectSession'
|
|
25
27
|
| 'getSession'
|
|
26
28
|
| 'applyTransaction'
|
|
27
29
|
| 'saveSession'
|
|
@@ -83,6 +85,20 @@ export const OPENFAIRYGUI_BACKEND_TOOL_DEFINITIONS = [
|
|
|
83
85
|
outputSchema: OPENFAIRYGUI_BACKEND_TOOL_OUTPUT_SCHEMA,
|
|
84
86
|
annotations: { readOnlyHint: false, idempotentHint: false, openWorldHint: false },
|
|
85
87
|
},
|
|
88
|
+
{
|
|
89
|
+
name: 'openfairygui_backend_open_project_session',
|
|
90
|
+
backendMethod: 'openProjectSession',
|
|
91
|
+
title: 'Open Project Session',
|
|
92
|
+
description: 'Open a browser-safe backend session from an already loaded UAM project without filesystem access.',
|
|
93
|
+
inputSchema: z.object({
|
|
94
|
+
project: z.unknown(),
|
|
95
|
+
sessionId: z.string().min(1).optional(),
|
|
96
|
+
canonicalProjectPath: z.string().min(1).optional(),
|
|
97
|
+
canonicalPathKey: z.string().min(1).optional(),
|
|
98
|
+
}),
|
|
99
|
+
outputSchema: OPENFAIRYGUI_BACKEND_TOOL_OUTPUT_SCHEMA,
|
|
100
|
+
annotations: { readOnlyHint: false, idempotentHint: false, openWorldHint: false },
|
|
101
|
+
},
|
|
86
102
|
{
|
|
87
103
|
name: 'openfairygui_backend_get_session',
|
|
88
104
|
backendMethod: 'getSession',
|
package/src/tool-handler.ts
CHANGED
|
@@ -39,6 +39,14 @@ export async function callOpenFairyGuiBackendTool(
|
|
|
39
39
|
projectPath: String(input.projectPath),
|
|
40
40
|
});
|
|
41
41
|
break;
|
|
42
|
+
case 'openfairygui_backend_open_project_session':
|
|
43
|
+
result = runtime.openProjectSession({
|
|
44
|
+
project: input.project as Parameters<BackendRuntime['openProjectSession']>[0]['project'],
|
|
45
|
+
sessionId: input.sessionId === undefined ? undefined : String(input.sessionId),
|
|
46
|
+
canonicalProjectPath: input.canonicalProjectPath === undefined ? undefined : String(input.canonicalProjectPath),
|
|
47
|
+
canonicalPathKey: input.canonicalPathKey === undefined ? undefined : String(input.canonicalPathKey),
|
|
48
|
+
});
|
|
49
|
+
break;
|
|
42
50
|
case 'openfairygui_backend_get_session':
|
|
43
51
|
result = runtime.getSession({
|
|
44
52
|
sessionId: String(input.sessionId),
|