@svadmin/mcp 0.2.10 → 0.3.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/package.json +2 -2
- package/src/index.ts +42 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svadmin/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "MCP (Model Context Protocol) server — expose svadmin DataProvider as tools for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@svadmin/core": "^0.
|
|
23
|
+
"@svadmin/core": "^0.45.0"
|
|
24
24
|
},
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"publishConfig": {
|
package/src/index.ts
CHANGED
|
@@ -51,6 +51,12 @@ export interface MCPTool {
|
|
|
51
51
|
properties: Record<string, MCPPropertySchema>;
|
|
52
52
|
required?: string[];
|
|
53
53
|
};
|
|
54
|
+
/** 显式声明是否为只读操作(只读操作可并发执行,无持久化副作用) */
|
|
55
|
+
readOnly?: boolean;
|
|
56
|
+
/** 显式声明是否支持并发调用 */
|
|
57
|
+
concurrent?: boolean;
|
|
58
|
+
/** 显式声明是否具有高风险/破坏性 */
|
|
59
|
+
destructive?: boolean;
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
export interface MCPPropertySchema {
|
|
@@ -105,6 +111,9 @@ function generateTools(options: MCPServerOptions): MCPTool[] {
|
|
|
105
111
|
tools.push({
|
|
106
112
|
name: 'svadmin_getList',
|
|
107
113
|
description: 'Fetch a paginated list of records from a resource. Supports filtering and sorting.',
|
|
114
|
+
readOnly: true,
|
|
115
|
+
concurrent: true,
|
|
116
|
+
destructive: false,
|
|
108
117
|
inputSchema: {
|
|
109
118
|
type: 'object',
|
|
110
119
|
properties: {
|
|
@@ -123,6 +132,9 @@ function generateTools(options: MCPServerOptions): MCPTool[] {
|
|
|
123
132
|
tools.push({
|
|
124
133
|
name: 'svadmin_getOne',
|
|
125
134
|
description: 'Fetch a single record by ID from a resource.',
|
|
135
|
+
readOnly: true,
|
|
136
|
+
concurrent: true,
|
|
137
|
+
destructive: false,
|
|
126
138
|
inputSchema: {
|
|
127
139
|
type: 'object',
|
|
128
140
|
properties: {
|
|
@@ -137,6 +149,9 @@ function generateTools(options: MCPServerOptions): MCPTool[] {
|
|
|
137
149
|
tools.push({
|
|
138
150
|
name: 'svadmin_getMany',
|
|
139
151
|
description: 'Fetch multiple records by their IDs from a resource.',
|
|
152
|
+
readOnly: true,
|
|
153
|
+
concurrent: true,
|
|
154
|
+
destructive: false,
|
|
140
155
|
inputSchema: {
|
|
141
156
|
type: 'object',
|
|
142
157
|
properties: {
|
|
@@ -152,6 +167,9 @@ function generateTools(options: MCPServerOptions): MCPTool[] {
|
|
|
152
167
|
tools.push({
|
|
153
168
|
name: 'svadmin_create',
|
|
154
169
|
description: 'Create a new record in a resource.',
|
|
170
|
+
readOnly: false,
|
|
171
|
+
concurrent: false,
|
|
172
|
+
destructive: false,
|
|
155
173
|
inputSchema: {
|
|
156
174
|
type: 'object',
|
|
157
175
|
properties: {
|
|
@@ -166,6 +184,9 @@ function generateTools(options: MCPServerOptions): MCPTool[] {
|
|
|
166
184
|
tools.push({
|
|
167
185
|
name: 'svadmin_update',
|
|
168
186
|
description: 'Update an existing record by ID in a resource.',
|
|
187
|
+
readOnly: false,
|
|
188
|
+
concurrent: false,
|
|
189
|
+
destructive: false,
|
|
169
190
|
inputSchema: {
|
|
170
191
|
type: 'object',
|
|
171
192
|
properties: {
|
|
@@ -181,6 +202,9 @@ function generateTools(options: MCPServerOptions): MCPTool[] {
|
|
|
181
202
|
tools.push({
|
|
182
203
|
name: 'svadmin_delete',
|
|
183
204
|
description: 'Delete a record by ID from a resource.',
|
|
205
|
+
readOnly: false,
|
|
206
|
+
concurrent: false,
|
|
207
|
+
destructive: true,
|
|
184
208
|
inputSchema: {
|
|
185
209
|
type: 'object',
|
|
186
210
|
properties: {
|
|
@@ -298,6 +322,24 @@ async function handleToolCall(
|
|
|
298
322
|
* });
|
|
299
323
|
* ```
|
|
300
324
|
*/
|
|
325
|
+
/**
|
|
326
|
+
* 投影 MCP 工具为标准白名单 Schema,确保元数据与安全标记正确保留。
|
|
327
|
+
*/
|
|
328
|
+
export function projectMCPToolSchema(tool: MCPTool): MCPTool {
|
|
329
|
+
return {
|
|
330
|
+
name: tool.name,
|
|
331
|
+
description: tool.description,
|
|
332
|
+
inputSchema: {
|
|
333
|
+
type: tool.inputSchema.type,
|
|
334
|
+
properties: { ...tool.inputSchema.properties },
|
|
335
|
+
...(tool.inputSchema.required ? { required: [...tool.inputSchema.required] } : {}),
|
|
336
|
+
},
|
|
337
|
+
...(tool.readOnly !== undefined ? { readOnly: tool.readOnly } : {}),
|
|
338
|
+
...(tool.concurrent !== undefined ? { concurrent: tool.concurrent } : {}),
|
|
339
|
+
...(tool.destructive !== undefined ? { destructive: tool.destructive } : {}),
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
|
|
301
343
|
export function createMCPServer(options: MCPServerOptions): MCPServer {
|
|
302
344
|
const serverName = options.name ?? '@svadmin/mcp';
|
|
303
345
|
const serverVersion = options.version ?? '0.1.0';
|