@svadmin/mcp 0.2.2 → 0.2.4
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/package.json +2 -2
- package/src/index.ts +8 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svadmin/mcp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "MCP (Model Context Protocol) server — expose svadmin DataProvider as tools for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@svadmin/core": "^0.
|
|
19
|
+
"@svadmin/core": "^0.22.1"
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"publishConfig": {
|
package/src/index.ts
CHANGED
|
@@ -200,8 +200,14 @@ function generateTools(options: MCPServerOptions): MCPTool[] {
|
|
|
200
200
|
async function handleToolCall(
|
|
201
201
|
toolName: string,
|
|
202
202
|
args: Record<string, unknown>,
|
|
203
|
-
|
|
203
|
+
options: MCPServerOptions,
|
|
204
204
|
): Promise<unknown> {
|
|
205
|
+
const resource = args.resource as string;
|
|
206
|
+
if (resource && !options.resources.includes(resource)) {
|
|
207
|
+
throw new Error(`Unauthorized resource access: ${resource} is not exposed.`);
|
|
208
|
+
}
|
|
209
|
+
const dp = options.dataProvider;
|
|
210
|
+
|
|
205
211
|
switch (toolName) {
|
|
206
212
|
case 'svadmin_getList': {
|
|
207
213
|
const resource = args.resource as string;
|
|
@@ -341,7 +347,7 @@ export function createMCPServer(options: MCPServerOptions): MCPServer {
|
|
|
341
347
|
};
|
|
342
348
|
}
|
|
343
349
|
|
|
344
|
-
const result = await handleToolCall(toolName, toolArgs, options
|
|
350
|
+
const result = await handleToolCall(toolName, toolArgs, options);
|
|
345
351
|
return {
|
|
346
352
|
jsonrpc: '2.0',
|
|
347
353
|
id,
|