@node-in-layers/mcp-server 2.0.3 → 2.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/libs.d.ts +118 -7
- package/libs.js +41 -126
- package/libs.js.map +1 -1
- package/mcp.js +23 -245
- package/mcp.js.map +1 -1
- package/models.d.ts +158 -0
- package/models.js +204 -0
- package/models.js.map +1 -0
- package/nil.d.ts +153 -0
- package/nil.js +158 -0
- package/nil.js.map +1 -0
- package/package.json +1 -1
- package/types.d.ts +1 -1
package/models.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { ValidationError } from 'functional-models';
|
|
11
|
+
import { defaultModelTypeParser, createMcpToolSave, createMcpToolRetrieve, createMcpToolDelete, createMcpToolSearch, createMcpToolBulkInsert, createMcpToolBulkDelete, } from 'functional-models-orm-mcp';
|
|
12
|
+
import { createErrorObject, isErrorObject, } from '@node-in-layers/core';
|
|
13
|
+
import { asyncMap } from 'modern-async';
|
|
14
|
+
import { isDomainHidden, areAllModelsHidden, isModelHidden, commonMcpExecute, createDomainNotFoundError, createModelsNotFoundError, createMcpResponse, createModelNotFoundError, } from './libs.js';
|
|
15
|
+
import { McpNamespace } from './types.js';
|
|
16
|
+
const describeModelMcpTool = () => {
|
|
17
|
+
return {
|
|
18
|
+
name: 'describe_model',
|
|
19
|
+
description: 'Gets the schema of a given model',
|
|
20
|
+
inputSchema: {
|
|
21
|
+
type: 'object',
|
|
22
|
+
properties: {
|
|
23
|
+
domain: { type: 'string' },
|
|
24
|
+
modelType: { type: 'string' },
|
|
25
|
+
},
|
|
26
|
+
required: ['domain', 'modelType'],
|
|
27
|
+
},
|
|
28
|
+
outputSchema: {
|
|
29
|
+
type: 'object',
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
additionalProperties: true,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
const listModelsMcpTool = () => {
|
|
36
|
+
return {
|
|
37
|
+
name: 'list_models',
|
|
38
|
+
description: 'Gets a list of models for a given domain and their description.',
|
|
39
|
+
inputSchema: {
|
|
40
|
+
type: 'object',
|
|
41
|
+
properties: {
|
|
42
|
+
domain: { type: 'string' },
|
|
43
|
+
},
|
|
44
|
+
required: ['domain'],
|
|
45
|
+
},
|
|
46
|
+
outputSchema: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {
|
|
49
|
+
models: {
|
|
50
|
+
type: 'array',
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
items: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
required: ['modelType'],
|
|
55
|
+
properties: {
|
|
56
|
+
modelType: { type: 'string' },
|
|
57
|
+
description: { type: 'string' },
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export const create = (context) => {
|
|
66
|
+
const hiddenPaths = new Set([
|
|
67
|
+
'@node-in-layers/core',
|
|
68
|
+
'@node-in-layers/data',
|
|
69
|
+
'@node-in-layers/mcp-server',
|
|
70
|
+
...(context.config[McpNamespace].hiddenPaths || []),
|
|
71
|
+
]);
|
|
72
|
+
const isDomainHiddenFunc = isDomainHidden(hiddenPaths);
|
|
73
|
+
const areAllModelsHiddenFunc = areAllModelsHidden(hiddenPaths);
|
|
74
|
+
const isModelHiddenFunc = isModelHidden(hiddenPaths);
|
|
75
|
+
const listModels = () => {
|
|
76
|
+
return Object.assign(Object.assign({}, listModelsMcpTool()), { execute: commonMcpExecute((input) => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
+
const domain = input.domain;
|
|
78
|
+
if (isDomainHiddenFunc(domain) || areAllModelsHiddenFunc(domain)) {
|
|
79
|
+
return createDomainNotFoundError();
|
|
80
|
+
}
|
|
81
|
+
const models = context.features[domain].cruds;
|
|
82
|
+
if (!models) {
|
|
83
|
+
return createMcpResponse(createModelsNotFoundError());
|
|
84
|
+
}
|
|
85
|
+
const result = Object.entries(models).reduce((acc, [modelName, model]) => {
|
|
86
|
+
if (isModelHiddenFunc(domain, modelName)) {
|
|
87
|
+
return acc;
|
|
88
|
+
}
|
|
89
|
+
const description = model
|
|
90
|
+
.getModel()
|
|
91
|
+
.getModelDefinition().description;
|
|
92
|
+
return acc.concat(Object.assign({ modelType: model.getModel().getName() }, (description ? { description } : {})));
|
|
93
|
+
}, []);
|
|
94
|
+
return createMcpResponse(result);
|
|
95
|
+
})) });
|
|
96
|
+
};
|
|
97
|
+
const describe = () => {
|
|
98
|
+
return Object.assign(Object.assign({}, describeModelMcpTool()), { execute: commonMcpExecute((input) => __awaiter(void 0, void 0, void 0, function* () {
|
|
99
|
+
const domain = input.domain;
|
|
100
|
+
if (isDomainHiddenFunc(domain)) {
|
|
101
|
+
return createDomainNotFoundError();
|
|
102
|
+
}
|
|
103
|
+
const { modelName } = defaultModelTypeParser(input.modelType);
|
|
104
|
+
const model = context.features[domain].cruds[modelName];
|
|
105
|
+
if (!model ||
|
|
106
|
+
isModelHiddenFunc(domain, modelName) ||
|
|
107
|
+
areAllModelsHiddenFunc(domain)) {
|
|
108
|
+
return createModelNotFoundError();
|
|
109
|
+
}
|
|
110
|
+
const schema = model.getModel().getModelDefinition().schema;
|
|
111
|
+
return createMcpResponse(schema);
|
|
112
|
+
})) });
|
|
113
|
+
};
|
|
114
|
+
const _createMcpModelFunc = (modelFunc) => {
|
|
115
|
+
return commonMcpExecute((input) => __awaiter(void 0, void 0, void 0, function* () {
|
|
116
|
+
const modelType = input.modelType;
|
|
117
|
+
const { domain, modelName } = defaultModelTypeParser(modelType);
|
|
118
|
+
if (isDomainHiddenFunc(domain)) {
|
|
119
|
+
return createDomainNotFoundError();
|
|
120
|
+
}
|
|
121
|
+
const model = context.features[domain].cruds[modelName];
|
|
122
|
+
if (!model ||
|
|
123
|
+
isModelHiddenFunc(domain, modelName) ||
|
|
124
|
+
areAllModelsHiddenFunc(domain)) {
|
|
125
|
+
return createModelNotFoundError();
|
|
126
|
+
}
|
|
127
|
+
const result = yield modelFunc(input, model.getModel()).catch(e => {
|
|
128
|
+
if (e instanceof ValidationError) {
|
|
129
|
+
return createErrorObject('VALIDATION_ERROR', 'Validation Error', {
|
|
130
|
+
details: {
|
|
131
|
+
keysToErrors: e.keysToErrors,
|
|
132
|
+
modelName: e.modelName,
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return createErrorObject('UNCAUGHT_EXCEPTION', 'An uncaught exception occurred while executing the feature.', e);
|
|
137
|
+
});
|
|
138
|
+
if (isErrorObject(result)) {
|
|
139
|
+
return createMcpResponse(result, { isError: true });
|
|
140
|
+
}
|
|
141
|
+
return createMcpResponse(result);
|
|
142
|
+
}));
|
|
143
|
+
};
|
|
144
|
+
const save = () => {
|
|
145
|
+
return Object.assign(Object.assign({}, createMcpToolSave()), { execute: _createMcpModelFunc((input, model) => __awaiter(void 0, void 0, void 0, function* () {
|
|
146
|
+
const data = input.instance;
|
|
147
|
+
const result = yield model.save(data).catch(e => {
|
|
148
|
+
if (e instanceof ValidationError) {
|
|
149
|
+
return createErrorObject('VALIDATION_ERROR', 'Validation Error', e);
|
|
150
|
+
}
|
|
151
|
+
return createErrorObject('UNCAUGHT_EXCEPTION', 'An uncaught exception occurred while executing the feature.', e);
|
|
152
|
+
});
|
|
153
|
+
if (isErrorObject(result)) {
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
return result.toObj();
|
|
157
|
+
})) });
|
|
158
|
+
};
|
|
159
|
+
const retrieve = () => {
|
|
160
|
+
return Object.assign(Object.assign({}, createMcpToolRetrieve()), { execute: _createMcpModelFunc((input, model) => __awaiter(void 0, void 0, void 0, function* () {
|
|
161
|
+
const result = yield model.retrieve(input.id);
|
|
162
|
+
if (!result) {
|
|
163
|
+
return createModelNotFoundError();
|
|
164
|
+
}
|
|
165
|
+
return result.toObj();
|
|
166
|
+
})) });
|
|
167
|
+
};
|
|
168
|
+
const deleteFunc = () => {
|
|
169
|
+
return Object.assign(Object.assign({}, createMcpToolDelete()), { execute: _createMcpModelFunc((input, model) => __awaiter(void 0, void 0, void 0, function* () {
|
|
170
|
+
yield model.delete(input.id);
|
|
171
|
+
return null;
|
|
172
|
+
})) });
|
|
173
|
+
};
|
|
174
|
+
const search = () => {
|
|
175
|
+
return Object.assign(Object.assign({}, createMcpToolSearch()), { execute: _createMcpModelFunc((input, model) => __awaiter(void 0, void 0, void 0, function* () {
|
|
176
|
+
const result = yield model.search(input.query);
|
|
177
|
+
const instances = yield asyncMap(result.instances, i => i.toObj());
|
|
178
|
+
return { instances, page: result.page };
|
|
179
|
+
})) });
|
|
180
|
+
};
|
|
181
|
+
const bulkInsert = () => {
|
|
182
|
+
return Object.assign(Object.assign({}, createMcpToolBulkInsert()), { execute: _createMcpModelFunc((input, model) => __awaiter(void 0, void 0, void 0, function* () {
|
|
183
|
+
yield model.bulkInsert(input.items);
|
|
184
|
+
return null;
|
|
185
|
+
})) });
|
|
186
|
+
};
|
|
187
|
+
const bulkDelete = () => {
|
|
188
|
+
return Object.assign(Object.assign({}, createMcpToolBulkDelete()), { execute: _createMcpModelFunc((input, model) => __awaiter(void 0, void 0, void 0, function* () {
|
|
189
|
+
yield model.bulkDelete(input.ids);
|
|
190
|
+
return null;
|
|
191
|
+
})) });
|
|
192
|
+
};
|
|
193
|
+
return {
|
|
194
|
+
listModels,
|
|
195
|
+
describe,
|
|
196
|
+
save,
|
|
197
|
+
retrieve,
|
|
198
|
+
delete: deleteFunc,
|
|
199
|
+
search,
|
|
200
|
+
bulkInsert,
|
|
201
|
+
bulkDelete,
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
//# sourceMappingURL=models.js.map
|
package/models.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAsB,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACvE,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAEL,iBAAiB,EAEjB,aAAa,GAGd,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,YAAY,EAAmB,MAAM,YAAY,CAAA;AAE1D,MAAM,oBAAoB,GAAG,GAAY,EAAE;IACzC,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,WAAW,EAAE,kCAAkC;QAC/C,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC1B,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;aAC9B;YACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC;SAClC;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,aAAa;YACb,oBAAo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uBAAuB,EAAE,KAC5B,OAAO,EAAE,mBAAmB,CAAC,CAAO,KAAU,EAAE,KAAK,EAAE,EAAE;gBACvD,MAAM,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;gBACnC,OAAO,IAAI,CAAA;YACb,CAAC,CAAA,CAAC,IACH;IACH,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,GAAe,EAAE;QAClC,uCACK,uBAAuB,EAAE,KAC5B,OAAO,EAAE,mBAAmB,CAAC,CAAO,KAAU,EAAE,KAAK,EAAE,EAAE;gBACvD,MAAM,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;gBACjC,OAAO,IAAI,CAAA;YACb,CAAC,CAAA,CAAC,IACH;IACH,CAAC,CAAA;IAED,OAAO;QACL,UAAU;QACV,QAAQ;QACR,IAAI;QACJ,QAAQ;QACR,MAAM,EAAE,UAAU;QAClB,MAAM;QACN,UAAU;QACV,UAAU;KACX,CAAA;AACH,CAAC,CAAA"}
|
package/nil.d.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { LayerContext } from '@node-in-layers/core';
|
|
2
|
+
import { ServerTool } from '@l4t/mcp-ai/simple-server/types.js';
|
|
3
|
+
export declare const create: <TConfig extends Readonly<{
|
|
4
|
+
"@node-in-layers/mcp-server": {
|
|
5
|
+
name?: string | undefined;
|
|
6
|
+
version?: string | undefined;
|
|
7
|
+
stateless?: boolean | undefined;
|
|
8
|
+
server: {
|
|
9
|
+
connection: Readonly<{
|
|
10
|
+
server: Readonly<{
|
|
11
|
+
connection: Readonly<{
|
|
12
|
+
type: "http";
|
|
13
|
+
url: string;
|
|
14
|
+
port?: number | undefined;
|
|
15
|
+
headers?: Readonly<Record<string, string>> | undefined;
|
|
16
|
+
timeout?: number | undefined;
|
|
17
|
+
retry?: Readonly<{
|
|
18
|
+
attempts: number;
|
|
19
|
+
backoff: number;
|
|
20
|
+
}> | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
path?: string | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
}> | Readonly<{
|
|
25
|
+
server: Readonly<{
|
|
26
|
+
connection: {
|
|
27
|
+
type: "cli";
|
|
28
|
+
};
|
|
29
|
+
}>;
|
|
30
|
+
}> | Readonly<{
|
|
31
|
+
server: Readonly<{
|
|
32
|
+
connection: Readonly<{
|
|
33
|
+
type: "sse";
|
|
34
|
+
url: string;
|
|
35
|
+
port?: number | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
path?: string | undefined;
|
|
38
|
+
messagesPath?: string | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
}> | Readonly<{
|
|
41
|
+
server: Readonly<{
|
|
42
|
+
connection: Readonly<{
|
|
43
|
+
type: "http";
|
|
44
|
+
url: string;
|
|
45
|
+
port?: number | undefined;
|
|
46
|
+
headers?: Readonly<Record<string, string>> | undefined;
|
|
47
|
+
timeout?: number | undefined;
|
|
48
|
+
retry?: Readonly<{
|
|
49
|
+
attempts: number;
|
|
50
|
+
backoff: number;
|
|
51
|
+
}> | undefined;
|
|
52
|
+
}>;
|
|
53
|
+
path?: string | undefined;
|
|
54
|
+
}>;
|
|
55
|
+
stateless: true;
|
|
56
|
+
}>;
|
|
57
|
+
};
|
|
58
|
+
hiddenPaths?: string[] | undefined;
|
|
59
|
+
logging?: {
|
|
60
|
+
requestLogLevel?: import("@node-in-layers/core/types.js").LogLevelNames | undefined;
|
|
61
|
+
responseLogLevel?: import("@node-in-layers/core/types.js").LogLevelNames | undefined;
|
|
62
|
+
requestLogGetData?: ((req: Request) => Record<string, any>) | undefined;
|
|
63
|
+
responseLogGetData?: ((req: Request) => Record<string, any>) | undefined;
|
|
64
|
+
} | undefined;
|
|
65
|
+
};
|
|
66
|
+
}> & Readonly<{
|
|
67
|
+
systemName: string;
|
|
68
|
+
environment: string;
|
|
69
|
+
"@node-in-layers/core": Readonly<{
|
|
70
|
+
logging: {
|
|
71
|
+
logLevel: import("@node-in-layers/core/types.js").LogLevelNames;
|
|
72
|
+
logFormat: import("@node-in-layers/core/types.js").LogFormat | readonly import("@node-in-layers/core/types.js").LogFormat[];
|
|
73
|
+
maxLogSizeInCharacters?: number | undefined;
|
|
74
|
+
tcpLoggingOptions?: Readonly<{
|
|
75
|
+
url: string;
|
|
76
|
+
headers?: Record<string, string | object> | undefined;
|
|
77
|
+
}> | undefined;
|
|
78
|
+
customLogger?: Readonly<{
|
|
79
|
+
getLogger: (context: Readonly<{
|
|
80
|
+
config: Readonly<any>;
|
|
81
|
+
rootLogger: Readonly<any>;
|
|
82
|
+
constants: {
|
|
83
|
+
environment: string;
|
|
84
|
+
workingDirectory: string;
|
|
85
|
+
runtimeId: string;
|
|
86
|
+
};
|
|
87
|
+
}>, props?: {
|
|
88
|
+
ids?: readonly Readonly<Record<string, string>>[] | undefined;
|
|
89
|
+
data?: Record<string, any> | undefined;
|
|
90
|
+
} | undefined) => import("@node-in-layers/core/types.js").HighLevelLogger;
|
|
91
|
+
}> | undefined;
|
|
92
|
+
getFunctionWrapLogLevel?: ((layerName: string, functionName?: string | undefined) => import("@node-in-layers/core/types.js").LogLevelNames) | undefined;
|
|
93
|
+
ignoreLayerFunctions?: Record<string, boolean | Record<string, boolean | Record<string, boolean>>> | undefined;
|
|
94
|
+
};
|
|
95
|
+
layerOrder: readonly import("@node-in-layers/core/types.js").LayerDescription[];
|
|
96
|
+
apps: readonly Readonly<{
|
|
97
|
+
name: string;
|
|
98
|
+
description?: string | undefined;
|
|
99
|
+
services?: Readonly<{
|
|
100
|
+
create: (context: any) => import("@node-in-layers/core/types.js").MaybePromise<object>;
|
|
101
|
+
}> | undefined;
|
|
102
|
+
features?: Readonly<{
|
|
103
|
+
create: (context: any) => import("@node-in-layers/core/types.js").MaybePromise<object>;
|
|
104
|
+
}> | undefined;
|
|
105
|
+
globals?: Readonly<{
|
|
106
|
+
create: (context: Readonly<{
|
|
107
|
+
config: Readonly<any>;
|
|
108
|
+
rootLogger: Readonly<{
|
|
109
|
+
getLogger: (context: Readonly<{
|
|
110
|
+
config: Readonly<any>;
|
|
111
|
+
rootLogger: Readonly<any>;
|
|
112
|
+
constants: {
|
|
113
|
+
environment: string;
|
|
114
|
+
workingDirectory: string;
|
|
115
|
+
runtimeId: string;
|
|
116
|
+
};
|
|
117
|
+
}>, props?: {
|
|
118
|
+
ids?: readonly Readonly<Record<string, string>>[] | undefined;
|
|
119
|
+
data?: Record<string, any> | undefined;
|
|
120
|
+
} | undefined) => import("@node-in-layers/core/types.js").HighLevelLogger;
|
|
121
|
+
}>;
|
|
122
|
+
constants: {
|
|
123
|
+
environment: string;
|
|
124
|
+
workingDirectory: string;
|
|
125
|
+
runtimeId: string;
|
|
126
|
+
};
|
|
127
|
+
}>) => Promise<any>;
|
|
128
|
+
}> | undefined;
|
|
129
|
+
models?: Record<string, Readonly<{
|
|
130
|
+
create: <T extends Readonly<{
|
|
131
|
+
[s: string]: any;
|
|
132
|
+
}>, TModelExtensions extends object = object, TModelInstanceExtensions extends object = object>(modelProps: Readonly<{
|
|
133
|
+
Model: import("functional-models/types.js").ModelFactory<object, object>;
|
|
134
|
+
fetcher: import("functional-models/types.js").ModelInstanceFetcher<object, object>;
|
|
135
|
+
getModel: <T_1 extends Readonly<{
|
|
136
|
+
[s: string]: any;
|
|
137
|
+
}>>(namespace: string, modelName: string) => () => import("functional-models/types.js").ModelType<T_1, object, object>;
|
|
138
|
+
}>) => import("functional-models/types.js").ModelType<T, TModelExtensions, TModelInstanceExtensions>;
|
|
139
|
+
}>> | undefined;
|
|
140
|
+
}>[];
|
|
141
|
+
modelFactory?: string | undefined;
|
|
142
|
+
modelCruds?: boolean | undefined;
|
|
143
|
+
customModelFactory?: {
|
|
144
|
+
[x: string]: {
|
|
145
|
+
[x: string]: string | [string, string] | [string, string, any[]];
|
|
146
|
+
};
|
|
147
|
+
} | undefined;
|
|
148
|
+
}>;
|
|
149
|
+
}>>(context: any) => {
|
|
150
|
+
listDomains: () => ServerTool;
|
|
151
|
+
describeFeature: () => ServerTool;
|
|
152
|
+
listFeatures: () => ServerTool;
|
|
153
|
+
};
|
package/nil.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { createDomainNotFoundError, createMcpResponse, createFeatureNotFoundError, isNilAnnotatedFunction, nilAnnotatedFunctionToOpenApi, createOpenApiForNonNilAnnotatedFunction, isDomainHidden, isFeatureHidden, commonMcpExecute, } from './libs.js';
|
|
11
|
+
import { McpNamespace } from './types.js';
|
|
12
|
+
const describeFeatureMcpTool = () => {
|
|
13
|
+
return {
|
|
14
|
+
name: 'describe_feature',
|
|
15
|
+
description: 'Gets the schema of a given feature',
|
|
16
|
+
inputSchema: {
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
domain: { type: 'string' },
|
|
20
|
+
featureName: { type: 'string' },
|
|
21
|
+
},
|
|
22
|
+
required: ['domain', 'featureName'],
|
|
23
|
+
},
|
|
24
|
+
outputSchema: {
|
|
25
|
+
type: 'object',
|
|
26
|
+
properties: {
|
|
27
|
+
schema: { type: 'object' },
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const listFeaturesMcpTool = () => {
|
|
33
|
+
return {
|
|
34
|
+
name: 'list_features',
|
|
35
|
+
description: 'Gets a list of features for a given domain',
|
|
36
|
+
inputSchema: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: {
|
|
39
|
+
domain: { type: 'string' },
|
|
40
|
+
},
|
|
41
|
+
required: ['domain'],
|
|
42
|
+
},
|
|
43
|
+
outputSchema: {
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
features: {
|
|
47
|
+
type: 'array',
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
items: {
|
|
50
|
+
type: 'object',
|
|
51
|
+
required: ['name'],
|
|
52
|
+
properties: {
|
|
53
|
+
name: { type: 'string' },
|
|
54
|
+
description: { type: 'string' },
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
const listDomainsMcpTool = () => {
|
|
63
|
+
return {
|
|
64
|
+
name: 'list_domains',
|
|
65
|
+
description: 'Gets a list of domains on the system, including their descriptions.',
|
|
66
|
+
inputSchema: {
|
|
67
|
+
type: 'object',
|
|
68
|
+
properties: {},
|
|
69
|
+
},
|
|
70
|
+
outputSchema: {
|
|
71
|
+
type: 'object',
|
|
72
|
+
properties: {
|
|
73
|
+
domains: {
|
|
74
|
+
type: 'array',
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
items: {
|
|
77
|
+
type: 'object',
|
|
78
|
+
required: ['name'],
|
|
79
|
+
properties: {
|
|
80
|
+
name: { type: 'string' },
|
|
81
|
+
description: { type: 'string' },
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
export const create = (context) => {
|
|
90
|
+
const hiddenPaths = new Set([
|
|
91
|
+
'@node-in-layers/core',
|
|
92
|
+
'@node-in-layers/data',
|
|
93
|
+
'@node-in-layers/mcp-server',
|
|
94
|
+
...(context.config[McpNamespace].hiddenPaths || []),
|
|
95
|
+
]);
|
|
96
|
+
const isDomainHiddenFunc = isDomainHidden(hiddenPaths);
|
|
97
|
+
const isFeatureHiddenFunc = isFeatureHidden(hiddenPaths);
|
|
98
|
+
const _listDomainsTool = () => {
|
|
99
|
+
return Object.assign(Object.assign({}, listDomainsMcpTool()), { execute: commonMcpExecute(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
100
|
+
const domains = Object.entries(context.features).reduce((acc, [domainName]) => {
|
|
101
|
+
var _a;
|
|
102
|
+
if (isDomainHiddenFunc(domainName)) {
|
|
103
|
+
return acc;
|
|
104
|
+
}
|
|
105
|
+
const description = (_a = context.config['@node-in-layers/core'].apps.find(app => app.name === domainName)) === null || _a === void 0 ? void 0 : _a.description;
|
|
106
|
+
return acc.concat(Object.assign({ name: domainName }, (description ? { description } : {})));
|
|
107
|
+
}, []);
|
|
108
|
+
return createMcpResponse(domains);
|
|
109
|
+
})) });
|
|
110
|
+
};
|
|
111
|
+
const _describeFeatureTool = () => {
|
|
112
|
+
return Object.assign(Object.assign({}, describeFeatureMcpTool()), { execute: commonMcpExecute((input) => __awaiter(void 0, void 0, void 0, function* () {
|
|
113
|
+
var _a;
|
|
114
|
+
const domain = input.domain;
|
|
115
|
+
const featureName = input.featureName;
|
|
116
|
+
const feature = (_a = context[domain]) === null || _a === void 0 ? void 0 : _a[featureName];
|
|
117
|
+
if (!feature ||
|
|
118
|
+
isDomainHiddenFunc(domain) ||
|
|
119
|
+
isFeatureHiddenFunc(domain, featureName)) {
|
|
120
|
+
return createFeatureNotFoundError();
|
|
121
|
+
}
|
|
122
|
+
const openapi = isNilAnnotatedFunction(feature)
|
|
123
|
+
? nilAnnotatedFunctionToOpenApi(feature.name, feature)
|
|
124
|
+
: createOpenApiForNonNilAnnotatedFunction(feature.name);
|
|
125
|
+
return createMcpResponse(openapi);
|
|
126
|
+
})) });
|
|
127
|
+
};
|
|
128
|
+
const _listFeaturesTool = () => {
|
|
129
|
+
return Object.assign(Object.assign({}, listFeaturesMcpTool()), { execute: commonMcpExecute((input) => __awaiter(void 0, void 0, void 0, function* () {
|
|
130
|
+
const domain = input.domain;
|
|
131
|
+
if (isDomainHiddenFunc(domain)) {
|
|
132
|
+
return createDomainNotFoundError();
|
|
133
|
+
}
|
|
134
|
+
const features = domain.features;
|
|
135
|
+
const result = Object.entries(features).reduce((acc, [featureName, feature]) => {
|
|
136
|
+
var _a;
|
|
137
|
+
if (typeof feature !== 'function') {
|
|
138
|
+
return acc;
|
|
139
|
+
}
|
|
140
|
+
if (isFeatureHiddenFunc(domain, featureName)) {
|
|
141
|
+
return acc;
|
|
142
|
+
}
|
|
143
|
+
const obj = Object.assign({ name: featureName }, (((_a = feature.schema) === null || _a === void 0 ? void 0 : _a.description)
|
|
144
|
+
? // @ts-ignore
|
|
145
|
+
{ description: feature.schema.description }
|
|
146
|
+
: {}));
|
|
147
|
+
return acc.concat(obj);
|
|
148
|
+
}, []);
|
|
149
|
+
return createMcpResponse(result);
|
|
150
|
+
})) });
|
|
151
|
+
};
|
|
152
|
+
return {
|
|
153
|
+
listDomains: _listDomainsTool,
|
|
154
|
+
describeFeature: _describeFeatureTool,
|
|
155
|
+
listFeatures: _listFeaturesTool,
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=nil.js.map
|
package/nil.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nil.js","sourceRoot":"","sources":["../src/nil.ts"],"names":[],"mappings":";;;;;;;;;AAGA,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EACjB,0BAA0B,EAC1B,sBAAsB,EACtB,6BAA6B,EAC7B,uCAAuC,EACvC,cAAc,EACd,eAAe,EACf,gBAAgB,GACjB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,YAAY,EAAmB,MAAM,YAAY,CAAA;AAE1D,MAAM,sBAAsB,GAAG,GAAY,EAAE;IAC3C,OAAO;QACL,IAAI,EAAE,kBAAkB;QACxB,WAAW,EAAE,oCAAoC;QACjD,WAAW,EAAE;YACX,IAAI,EAAE,QAA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G,MAAM,CAAC,QAAQ,CAAA;gBAChC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAC5C,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,EAAE,EAAE;;oBAC9B,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;wBAClC,OAAO,GAAG,CAAA;oBACZ,CAAC;oBACD,IAAI,mBAAmB,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,CAAC;wBAC7C,OAAO,GAAG,CAAA;oBACZ,CAAC;oBACD,MAAM,GAAG,mBACP,IAAI,EAAE,WAAW,IAEd,CAAC,CAAA,MAAA,OAAO,CAAC,MAAM,0CAAE,WAAW;wBAC7B,CAAC,CAAC,aAAa;4BACb,EAAE,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE;wBAC7C,CAAC,CAAC,EAAE,CAAC,CACR,CAAA;oBACD,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;gBACxB,CAAC,EACD,EAA8C,CAC/C,CAAA;gBACD,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAA;YAClC,CAAC,CAAA,CAAC,IACH;IACH,CAAC,CAAA;IAED,OAAO;QACL,WAAW,EAAE,gBAAgB;QAC7B,eAAe,EAAE,oBAAoB;QACrC,YAAY,EAAE,iBAAiB;KAChC,CAAA;AACH,CAAC,CAAA"}
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export type McpServerConfig = Readonly<{
|
|
|
66
66
|
}>;
|
|
67
67
|
export declare const McpNamespace = "@node-in-layers/mcp-server";
|
|
68
68
|
export type McpServerMcp = Readonly<{
|
|
69
|
-
start: (options?: AppOptions) => Promise<void>;
|
|
69
|
+
start: <T extends McpServerConfig & Config>(systemContext: LayerContext<T, any>, options?: AppOptions) => Promise<void>;
|
|
70
70
|
addTool: (tool: ServerTool) => void;
|
|
71
71
|
getApp: (options?: AppOptions) => Express;
|
|
72
72
|
set: (key: string, value: any) => void;
|