store-mcp-node 0.1.0 → 0.1.1
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 +1 -1
- package/src/index.js +19 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "store-mcp-node",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "MCP (Model Context Protocol) adapter that auto-generates tool surfaces for nodejs-store schemas (schema-driven CRUD + sandboxed GQL query + optional ask), stdio transport",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
package/src/index.js
CHANGED
|
@@ -87,6 +87,12 @@ const ASK_TOOL = {
|
|
|
87
87
|
inputSchema: obj({ question: { type: 'string', description: '自然语言问题' } }, ['question']),
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
+
const DESCRIBE_TOOL = {
|
|
91
|
+
name: 'describe_schemas',
|
|
92
|
+
description: '列出可用数据模型及其字段/关系/计算列(权限过滤后的紧凑 JSON)。翻译 GQL 前先调用本工具获取 schema;无权限上下文时仅返回模型名与字段名',
|
|
93
|
+
inputSchema: obj({}, []),
|
|
94
|
+
};
|
|
95
|
+
|
|
90
96
|
/**
|
|
91
97
|
* 收集工具面(归档过滤 + x-mcp 注记 + ask 启用守卫)。
|
|
92
98
|
* @returns {{tools: object[], handlers: Map<string, Function>}}
|
|
@@ -116,6 +122,10 @@ function buildSurface(store, opts = {}) {
|
|
|
116
122
|
tools.push(QUERY_TOOL);
|
|
117
123
|
handlers.set('query', queryHandler(store, opts));
|
|
118
124
|
|
|
125
|
+
// spec/01:describe_schemas —— AI 自主翻译 GQL 前的 schema 出口(零入参;ctx 走 opts,不进 inputSchema)
|
|
126
|
+
tools.push(DESCRIBE_TOOL);
|
|
127
|
+
handlers.set('describe_schemas', describeHandler(store, opts));
|
|
128
|
+
|
|
119
129
|
// spec/01:ask 仅 opts.llm 提供时注册;配 llm 缺 ctx 装配期抛错(fail-secure)
|
|
120
130
|
if (opts.llm !== undefined && opts.llm !== null) {
|
|
121
131
|
if (opts.ctx === undefined || opts.ctx === null) {
|
|
@@ -171,6 +181,15 @@ function queryHandler(store, opts) {
|
|
|
171
181
|
};
|
|
172
182
|
}
|
|
173
183
|
|
|
184
|
+
function describeHandler(store, opts) {
|
|
185
|
+
return async () => {
|
|
186
|
+
if (typeof store.describeForAi !== 'function') {
|
|
187
|
+
throw new SkinError('planError', 'store 未提供 describeForAi(需提供该门面的 nodejs-store 宿主)');
|
|
188
|
+
}
|
|
189
|
+
return store.describeForAi(opts.ctx === undefined ? null : opts.ctx);
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
174
193
|
function askHandler(opts) {
|
|
175
194
|
return async (args) => {
|
|
176
195
|
if (typeof args.question !== 'string' || !args.question.trim()) {
|