@svadmin/mcp 0.2.3 → 0.2.5

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.
Files changed (2) hide show
  1. package/package.json +7 -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",
3
+ "version": "0.2.5",
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.4"
19
+ "@svadmin/core": "^0.23.3"
20
20
  },
21
21
  "license": "MIT",
22
22
  "publishConfig": {
@@ -32,5 +32,10 @@
32
32
  "homepage": "https://github.com/zuohuadong/svadmin#readme",
33
33
  "bugs": {
34
34
  "url": "https://github.com/zuohuadong/svadmin/issues"
35
+ },
36
+ "peerDependenciesMeta": {
37
+ "@svadmin/core": {
38
+ "optional": true
39
+ }
35
40
  }
36
41
  }
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
- dp: DataProvider,
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.dataProvider);
350
+ const result = await handleToolCall(toolName, toolArgs, options);
345
351
  return {
346
352
  jsonrpc: '2.0',
347
353
  id,