@gavdi/cap-mcp 1.3.0 → 1.3.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/README.md +2 -0
- package/cds-plugin.js +1 -1
- package/lib/annotations/parser.js +0 -2
- package/lib/mcp/factory.js +3 -1
- package/lib/mcp.js +35 -0
- package/package.json +8 -4
package/README.md
CHANGED
package/cds-plugin.js
CHANGED
|
@@ -133,11 +133,9 @@ function constructResourceAnnotation(serviceName, target, annotations, definitio
|
|
|
133
133
|
const computedFields = new Set(Object.entries(model.definitions?.[entityTarget].elements ?? {})
|
|
134
134
|
.filter(([_, v]) => new Map(Object.entries(v).map(([key, value]) => [key.toLowerCase(), value])).get("@core.computed"))
|
|
135
135
|
.map(([k, _]) => k));
|
|
136
|
-
console.log("I AM TRYING TO PARSE", model.definitions);
|
|
137
136
|
const omittedFields = new Set(Object.entries(model.definitions?.[entityTarget].elements ?? {})
|
|
138
137
|
.filter(([_, v]) => v[constants_1.MCP_OMIT_PROP_KEY])
|
|
139
138
|
.map(([k, _]) => k));
|
|
140
|
-
console.log("OMITTED FIELDS", omittedFields);
|
|
141
139
|
const { properties, resourceKeys, propertyHints } = (0, utils_1.parseResourceElements)(definition, model);
|
|
142
140
|
const restrictions = (0, utils_1.parseCdsRestrictions)(annotations.restrict, annotations.requires);
|
|
143
141
|
return new structures_1.McpResourceAnnotation(annotations.name, annotations.description, target, serviceName, functionalities, properties, resourceKeys, foreignKeys, annotations.wrap, restrictions, computedFields, propertyHints, omittedFields);
|
package/lib/mcp/factory.js
CHANGED
|
@@ -24,8 +24,10 @@ function createMcpServer(config, annotations) {
|
|
|
24
24
|
const server = new mcp_js_1.McpServer({
|
|
25
25
|
name: config.name,
|
|
26
26
|
version: config.version,
|
|
27
|
+
}, {
|
|
28
|
+
instructions: (0, instructions_1.getMcpInstructions)(config),
|
|
27
29
|
capabilities: config.capabilities,
|
|
28
|
-
}
|
|
30
|
+
});
|
|
29
31
|
if (!annotations) {
|
|
30
32
|
logger_1.LOGGER.debug("No annotations provided, skipping registration...");
|
|
31
33
|
return server;
|
package/lib/mcp.js
CHANGED
|
@@ -25,6 +25,8 @@ class McpPlugin {
|
|
|
25
25
|
config;
|
|
26
26
|
expressApp;
|
|
27
27
|
annotations;
|
|
28
|
+
static _instance;
|
|
29
|
+
static isInitializing = false;
|
|
28
30
|
/**
|
|
29
31
|
* Creates a new MCP plugin instance with configuration and session management
|
|
30
32
|
*/
|
|
@@ -168,5 +170,38 @@ class McpPlugin {
|
|
|
168
170
|
}
|
|
169
171
|
});
|
|
170
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Get McpPlugin Instance
|
|
175
|
+
*
|
|
176
|
+
* @description Double Lock singleton initialization.
|
|
177
|
+
* @returns McpPlugin
|
|
178
|
+
*/
|
|
179
|
+
static getInstance() {
|
|
180
|
+
if (!McpPlugin._instance) {
|
|
181
|
+
if (!McpPlugin.isInitializing) {
|
|
182
|
+
McpPlugin.isInitializing = true;
|
|
183
|
+
if (!McpPlugin._instance) {
|
|
184
|
+
McpPlugin._instance = new McpPlugin();
|
|
185
|
+
}
|
|
186
|
+
McpPlugin.isInitializing = false;
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
/**
|
|
190
|
+
* Busy Wait if it is initializing
|
|
191
|
+
*/
|
|
192
|
+
while (McpPlugin.isInitializing) { }
|
|
193
|
+
/**
|
|
194
|
+
* check if not init, call again.
|
|
195
|
+
*/
|
|
196
|
+
if (!McpPlugin._instance) {
|
|
197
|
+
return McpPlugin.getInstance();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return McpPlugin._instance;
|
|
202
|
+
}
|
|
203
|
+
static resetInstance() {
|
|
204
|
+
McpPlugin._instance = undefined;
|
|
205
|
+
}
|
|
171
206
|
}
|
|
172
207
|
exports.default = McpPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gavdi/cap-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "MCP Plugin for CAP",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MCP",
|
|
@@ -38,14 +38,16 @@
|
|
|
38
38
|
"format": "prettier --check ./src",
|
|
39
39
|
"format:fix": "prettier --write ./src \"**/*.json\"",
|
|
40
40
|
"build:watch": "tsc --watch",
|
|
41
|
-
"release": "release-it"
|
|
41
|
+
"release": "release-it",
|
|
42
|
+
"docs:serve": "docsify serve docs",
|
|
43
|
+
"docs:links": "markdown-link-check docs/**/*.md"
|
|
42
44
|
},
|
|
43
45
|
"peerDependencies": {
|
|
44
|
-
"@sap/cds": "
|
|
46
|
+
"@sap/cds": ">=9",
|
|
45
47
|
"express": "^4"
|
|
46
48
|
},
|
|
47
49
|
"dependencies": {
|
|
48
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
50
|
+
"@modelcontextprotocol/sdk": "^1.23.0",
|
|
49
51
|
"@sap/xssec": "^4.9.1",
|
|
50
52
|
"cors": "^2.8.5",
|
|
51
53
|
"helmet": "^8.1.0",
|
|
@@ -61,10 +63,12 @@
|
|
|
61
63
|
"@types/node": "^24.0.3",
|
|
62
64
|
"@types/sinon": "^17.0.4",
|
|
63
65
|
"@types/supertest": "^6.0.2",
|
|
66
|
+
"docsify-cli": "^4.4.4",
|
|
64
67
|
"eslint": "^9.29.0",
|
|
65
68
|
"husky": "^9.1.7",
|
|
66
69
|
"jest": "^29.7.0",
|
|
67
70
|
"lint-staged": "^16.1.2",
|
|
71
|
+
"markdown-link-check": "^3.14.1",
|
|
68
72
|
"prettier": "^3.5.3",
|
|
69
73
|
"release-it": "^19.0.4",
|
|
70
74
|
"sinon": "^21.0.0",
|