@opentiny/tiny-vue-mcp 0.0.1 → 0.0.3

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/dist/index.d.ts CHANGED
@@ -15,7 +15,9 @@ export declare const getTinyVueMcpConfig: ({ t }?: {
15
15
  version: string;
16
16
  components: {
17
17
  Grid: import('./src/utils/defineComponentTool').RealComponentTool;
18
+ Tree: import('./src/utils/defineComponentTool').RealComponentTool;
18
19
  BaseSelect: import('./src/utils/defineComponentTool').RealComponentTool;
19
20
  Button: import('./src/utils/defineComponentTool').RealComponentTool;
21
+ Form: import('./src/utils/defineComponentTool').RealComponentTool;
20
22
  };
21
23
  };
package/dist/index.js CHANGED
@@ -1,25 +1,29 @@
1
- import { defineTool as i } from "./src/utils/defineTool.js";
2
- import { default as x } from "./src/lang/zh-CN.js";
3
- import { default as T } from "./src/lang/en.js";
4
- import { getGridConfig as f } from "./src/grid/index.js";
5
- import { getBaseSelectConfig as m } from "./src/base-select/index.js";
1
+ import { defineTool as m } from "./src/utils/defineTool.js";
2
+ import { default as y } from "./src/lang/zh-CN.js";
3
+ import { default as G } from "./src/lang/en.js";
4
+ import { getGridConfig as n } from "./src/grid/index.js";
5
+ import { getTreeConfig as f } from "./src/tree/index.js";
6
+ import { getBaseSelectConfig as p } from "./src/base-select/index.js";
6
7
  import { i18n as e } from "./src/utils/locale.js";
7
- import { getButtonConfig as p } from "./src/button/index.js";
8
- const l = (o, { server: t, business: r }, n) => {
9
- i({ business: r, componentMcpConfig: n, instance: o, server: t });
10
- }, d = ({ t: o } = {}) => (e && o && (e.t = o), {
8
+ import { getButtonConfig as g } from "./src/button/index.js";
9
+ import { getFormConfig as c } from "./src/form/index.js";
10
+ const B = (o, { server: t, business: r }, i) => {
11
+ m({ business: r, componentMcpConfig: i, instance: o, server: t });
12
+ }, x = ({ t: o } = {}) => (e && o && (e.t = o), {
11
13
  name: "tiny-vue-mcp",
12
14
  version: "0.0.1",
13
15
  components: {
14
- Grid: f(),
15
- BaseSelect: m(),
16
- Button: p()
16
+ Grid: n(),
17
+ Tree: f(),
18
+ BaseSelect: p(),
19
+ Button: g(),
20
+ Form: c()
17
21
  }
18
22
  });
19
23
  export {
20
- l as createMcpTools,
21
- T as enUS,
22
- d as getTinyVueMcpConfig,
24
+ B as createMcpTools,
25
+ G as enUS,
26
+ x as getTinyVueMcpConfig,
23
27
  e as i18n,
24
- x as zhCN
28
+ y as zhCN
25
29
  };
@@ -0,0 +1,5 @@
1
+ export declare const resources: {
2
+ zh: any;
3
+ en: any;
4
+ };
5
+ export declare const getFormConfig: () => import('../utils/defineComponentTool').RealComponentTool;
@@ -0,0 +1,44 @@
1
+ import { z as i } from "zod";
2
+ import { defineComponentTool as o } from "../utils/defineComponentTool.js";
3
+ import { t as a } from "../utils/locale.js";
4
+ const d = () => o({
5
+ name: "form_component_tools",
6
+ description: a("ai.form.description"),
7
+ tools: {
8
+ resetFields: {
9
+ paramsSchema: i.boolean().optional().describe(a("ai.form.resetFields")),
10
+ cb: (e) => (e.resetFields(), { type: "text", text: "success" })
11
+ },
12
+ clearValidate: {
13
+ paramsSchema: i.string().optional().describe(a("ai.form.clearValidate")),
14
+ cb: (e, t) => {
15
+ if (typeof t == "string" && t) {
16
+ const r = t.split(",");
17
+ r.length > 0 ? e.clearValidate(r) : e.clearValidate(t);
18
+ }
19
+ return { type: "text", text: "success" };
20
+ }
21
+ },
22
+ clearValidateAll: {
23
+ paramsSchema: i.boolean().optional().describe(a("ai.form.clearValidateAll")),
24
+ cb: (e) => (e.clearValidate(), { type: "text", text: "success" })
25
+ },
26
+ validate: {
27
+ paramsSchema: i.boolean().optional().describe(a("ai.form.validate")),
28
+ cb: async (e) => ({ type: "text", text: await e.validate() ? "success" : "fail" })
29
+ },
30
+ validateField: {
31
+ paramsSchema: i.string().optional().describe(a("ai.form.validateField")),
32
+ cb: (e, t) => {
33
+ if (typeof t == "string" && t) {
34
+ const r = t.split(",");
35
+ r.length > 0 ? e.validateField(r) : e.validateField(t);
36
+ }
37
+ return { type: "text", text: "success" };
38
+ }
39
+ }
40
+ }
41
+ });
42
+ export {
43
+ d as getFormConfig
44
+ };
@@ -1,61 +1,74 @@
1
- import { z as o } from "zod";
1
+ import { z as r } from "zod";
2
2
  import { defineComponentTool as s } from "../utils/defineComponentTool.js";
3
- import { t as r } from "../utils/locale.js";
4
- const b = () => s({
3
+ import { t as a } from "../utils/locale.js";
4
+ const p = () => s({
5
5
  name: "grid_component_tools",
6
- description: r("ai.grid.description"),
6
+ description: a("ai.grid.description"),
7
7
  tools: {
8
8
  scrollToRow: {
9
- paramsSchema: o.number().optional().describe(r("ai.grid.scrollToRow")),
10
- cb: (t, e) => {
11
- const a = t.getTableData().tableData[e];
12
- if (a)
13
- return t.scrollToRow(a), { type: "text", text: "success" };
9
+ paramsSchema: r.record(r.any()).optional().describe(a("ai.grid.scrollToRow")),
10
+ cb: (e, t) => {
11
+ const o = e.getRowById(t._RID);
12
+ if (o)
13
+ return e.scrollToRow(o), { type: "text", text: "success" };
14
+ }
15
+ },
16
+ getColumns: {
17
+ paramsSchema: r.boolean().optional().describe(a("ai.grid.getColumns")),
18
+ cb: (e) => {
19
+ const o = e.getColumns().filter((i) => i.property && i.title).map((i) => ({
20
+ property: i.property,
21
+ title: i.title
22
+ }));
23
+ return { type: "text", text: JSON.stringify(o) };
14
24
  }
15
25
  },
16
26
  getTableData: {
17
- paramsSchema: o.boolean().optional().describe(r("ai.grid.getTableData")),
18
- cb: (t) => {
19
- const e = t.getTableData().tableData;
20
- return { type: "text", text: JSON.stringify(e) };
27
+ paramsSchema: r.boolean().optional().describe(a("ai.grid.getTableData")),
28
+ cb: (e) => {
29
+ const t = e.getTableData().tableData;
30
+ return { type: "text", text: JSON.stringify(t) };
21
31
  }
22
32
  },
23
33
  setSelection: {
24
- paramsSchema: o.number().optional().describe(r("ai.grid.setSelection")),
25
- cb: (t, e) => {
26
- const a = t.getTableData().tableData[e];
27
- if (a)
28
- return t.setSelection(a, !0), { type: "text", text: "success" };
34
+ paramsSchema: r.record(r.any()).optional().describe(a("ai.grid.setSelection")),
35
+ cb: (e, t) => {
36
+ const o = e.getRowById(t._RID);
37
+ if (o)
38
+ return e.scrollToRow(o), e.setSelection(o, !0), { type: "text", text: "success" };
29
39
  }
30
40
  },
31
41
  setAllSelection: {
32
- paramsSchema: o.boolean().optional().describe(r("ai.grid.setAllSelection")),
33
- cb: (t, e) => (t.setAllSelection(e), { type: "text", text: "success" })
42
+ paramsSchema: r.boolean().optional().describe(a("ai.grid.setAllSelection")),
43
+ cb: (e, t) => (e.setAllSelection(t), { type: "text", text: "success" })
34
44
  },
35
45
  insertRow: {
36
- paramsSchema: o.record(o.any()).optional().describe(r("ai.grid.insertRow")),
37
- cb: (t, e) => (t.insert(e), { type: "text", text: "success" })
46
+ paramsSchema: r.record(r.any()).optional().describe(a("ai.grid.insertRow")),
47
+ cb: (e, t) => (e.insert(t), { type: "text", text: "success" })
38
48
  },
39
49
  updateRow: {
40
- paramsSchema: o.record(o.any()).optional().describe(r("ai.grid.updateRow")),
41
- cb: (t, e) => {
42
- if (e && typeof e.tiny_mcp_index == "number") {
43
- const a = t.getTableData().tableData[e.tiny_mcp_index];
44
- if (a)
45
- return Object.assign(a, e), { type: "text", text: "success" };
50
+ paramsSchema: r.record(r.any()).optional().describe(a("ai.grid.updateRow")),
51
+ cb: (e, t) => {
52
+ if (t) {
53
+ const o = e.getRowById(t._RID);
54
+ if (o)
55
+ return Object.assign(o, t), { type: "text", text: "success" };
46
56
  }
47
57
  return { type: "text", text: "failed" };
48
58
  }
49
59
  },
50
60
  removeRow: {
51
- paramsSchema: o.number().optional().describe(r("ai.grid.removeRow")),
52
- cb: (t, e) => {
53
- const a = t.getTableData().tableData[e];
54
- return a ? (t.remove(a), { type: "text", text: "success" }) : { type: "text", text: "failed" };
61
+ paramsSchema: r.record(r.any()).optional().describe(a("ai.grid.removeRow")),
62
+ cb: (e, t) => {
63
+ if (t) {
64
+ const o = e.getRowById(t._RID);
65
+ return e.remove(o), { type: "text", text: "success" };
66
+ }
67
+ return { type: "text", text: "failed" };
55
68
  }
56
69
  }
57
70
  }
58
71
  });
59
72
  export {
60
- b as getGridConfig
73
+ p as getGridConfig
61
74
  };
@@ -4,6 +4,7 @@ declare const _default: {
4
4
  description: string;
5
5
  scrollToRow: string;
6
6
  getTableData: string;
7
+ getColumns: string;
7
8
  setSelection: string;
8
9
  setAllSelection: string;
9
10
  insertRow: string;
@@ -21,6 +22,24 @@ declare const _default: {
21
22
  description: string;
22
23
  triggerClick: string;
23
24
  };
25
+ tree: {
26
+ description: string;
27
+ getTreeData: string;
28
+ setCurrentKey: string;
29
+ expandHlNode: string;
30
+ collapseHlNode: string;
31
+ removeNode: string;
32
+ insertBefore: string;
33
+ insertAfter: string;
34
+ };
35
+ form: {
36
+ description: string;
37
+ resetFields: string;
38
+ clearValidate: string;
39
+ clearValidateAll: string;
40
+ validate: string;
41
+ validateField: string;
42
+ };
24
43
  };
25
44
  };
26
45
  export default _default;
@@ -1,25 +1,44 @@
1
1
  const e = {
2
2
  ai: {
3
3
  grid: {
4
- description: "Grid component related tool set, including scrolling to the specified row, table full selection, etc.",
5
- scrollToRow: "Scroll to the specified row,need to get the table data first,then scroll to the row according to the index of the data in the table data",
6
- getTableData: "Get the table data",
7
- setSelection: "Select the specified row,need to get the table data first,then select the data according to the index of the data in the table data,requirement:scroll to the selected row before selecting",
8
- setAllSelection: "Set the table all selection status,true:all selection,false:cancel all selection,requirement:scroll to the selected row before selecting",
9
- insertRow: "Insert or add a row of data,need to get the table data first,then add the corresponding data according to the format of the table data",
10
- updateRow: 'Update the specified row data in the table,need to get the table data first,then update the corresponding data according to the index of the data in the table data,requirement:the index of the data in the table data is passed in as the "tiny_mcp_index" field',
11
- removeRow: "Remove the specified row in the table,need to get the table data first,then remove the corresponding data according to the index of the data in the table data"
4
+ description: "Grid component related tool set, including scrolling to specified row, table full selection and other functions",
5
+ scrollToRow: 'Scroll to specified row, need to pass the data of the row to scroll to, requirement: the data must contain the "_RID" field',
6
+ getTableData: "Get table data",
7
+ getColumns: 'Get table column configuration, "property" field represents the field property of table data, "title" represents the column title',
8
+ setSelection: 'Select a row in the table, need to pass the data to be selected, requirement: the data must contain the "_RID" field',
9
+ setAllSelection: "Set table full selection status, true: select all, false: cancel all selection",
10
+ insertRow: "Insert or add a row of data, need to get table data first, then add corresponding data according to the table data format",
11
+ updateRow: 'Update specified row data in the table, need to pass the data to be updated, requirement: the data must contain the "_RID" field',
12
+ removeRow: 'Remove specified row in the table, need to pass the data to be removed, requirement: the data must contain the "_RID" field'
12
13
  },
13
14
  baseSelect: {
14
- description: "Base select component related tool set, including opening the drop-down panel,set selected value or clear selected value and get selected options",
15
- openMenu: "Open the drop-down panel",
16
- selectByLabel: "update select value by label",
17
- clearValue: "clear select value,remove value",
18
- getOptions: "get all options of the select component"
15
+ description: "Dropdown component related tool set, including getting dropdown data, selecting dropdown data, clearing selected value and other functions",
16
+ openMenu: "Open dropdown panel",
17
+ selectByLabel: "Select dropdown data by label",
18
+ clearValue: "Clear dropdown value",
19
+ getOptions: "Query all option values of the dropdown select"
19
20
  },
20
21
  button: {
21
22
  description: "Button component related tool set",
22
- triggerClick: "trigger button click,click self"
23
+ triggerClick: "Button click, click the button"
24
+ },
25
+ tree: {
26
+ description: "Collection of Tools Related to Tree Control Components",
27
+ getTreeData: "Obtain table data",
28
+ setCurrentKey: "Please enter the ID value to set the current selected state of a node",
29
+ expandHlNode: "Please enter the ID value to set the current deployment status of a node",
30
+ collapseHlNode: "Please enter the ID value to set the collapsed state of a node",
31
+ removeNode: "Please enter the ID value to delete a node",
32
+ insertBefore: "Add a node in front of a node",
33
+ insertAfter: "Add a node after a node"
34
+ },
35
+ form: {
36
+ description: "Form component related tool set, including getting form validation, resetting form and other functions",
37
+ resetFields: "Reset the entire form, resetting all field values to their initial values and removing validation results",
38
+ clearValidate: "Remove the validation results of the form item, you can pass in the prop of the form item to be removed, or an array of props, if not passed in, the validation results of the entire form will be removed",
39
+ clearValidateAll: "Remove the validation results of the entire form",
40
+ validate: "Validate the entire form, the parameter is a callback function (the callback function will be called after the validation is completed and passed two parameters: 1, whether the validation is successful 2, the fields that failed validation) returns a Promise object",
41
+ validateField: "Validate the specified field by passing in the prop of the form item to be validated, or separating the props with commas"
23
42
  }
24
43
  }
25
44
  };
@@ -4,6 +4,7 @@ declare const _default: {
4
4
  description: string;
5
5
  scrollToRow: string;
6
6
  getTableData: string;
7
+ getColumns: string;
7
8
  setSelection: string;
8
9
  setAllSelection: string;
9
10
  insertRow: string;
@@ -21,6 +22,24 @@ declare const _default: {
21
22
  description: string;
22
23
  triggerClick: string;
23
24
  };
25
+ tree: {
26
+ description: string;
27
+ getTreeData: string;
28
+ setCurrentKey: string;
29
+ expandHlNode: string;
30
+ collapseHlNode: string;
31
+ removeNode: string;
32
+ insertBefore: string;
33
+ insertAfter: string;
34
+ };
35
+ form: {
36
+ description: string;
37
+ resetFields: string;
38
+ clearValidate: string;
39
+ clearValidateAll: string;
40
+ validate: string;
41
+ validateField: string;
42
+ };
24
43
  };
25
44
  };
26
45
  export default _default;
@@ -2,13 +2,14 @@ const e = {
2
2
  ai: {
3
3
  grid: {
4
4
  description: "表格组件相关工具集合,包含滚动到指定行、表格全选等功能",
5
- scrollToRow: "滚动到指定行,要先获取表格数据,然后根据表格数据中的数组下标索引确定滚动行",
5
+ scrollToRow: '滚动到指定行,需要传递需要滚动的行的数据,要求数据中包含"_RID"字段',
6
6
  getTableData: "获取表格数据",
7
- setSelection: "选中或者选择表格一条数据,需要先获取表格数据,然后根据表格数据中的数组下标索引选中或者选择数据,要求:选中之前先滚动到选中行",
7
+ getColumns: '获取表格列配置,"property" 字段代表表格数据的字段属性,"title" 代表表格列的标题',
8
+ setSelection: '选中或者选择表格一条数据,需要传递需要选中的数据,要求数据中包含"_RID"字段',
8
9
  setAllSelection: "用来设置表格全选状态,true:全选,false:取消全选",
9
10
  insertRow: "插入或者新增一行数据,需要先获取表格数据,根据表格数据的格式新增对应的数据",
10
- updateRow: '更新修改表格中指定行数据,需要先获取表格数据,根据表格数据中的数组下标索引更新对应的数据,要求:将更新数据的数组下标以"tiny_mcp_index"字段传入',
11
- removeRow: "删除表格中指定行,需要先获取表格数据,根据表格数据中的数组下标索引删除对应的数据"
11
+ updateRow: '更新修改表格中指定行数据,需要传递需要更新的数据,要求数据中包含"_RID"字段',
12
+ removeRow: '删除表格中指定行,需要传递需要删除的数据,要求数据中包含"_RID"字段'
12
13
  },
13
14
  baseSelect: {
14
15
  description: "下拉组件相关工具集合,包含获取下拉数据、选中下拉数据,清除选中值等功能",
@@ -20,6 +21,24 @@ const e = {
20
21
  button: {
21
22
  description: "按钮组件相关工具集合",
22
23
  triggerClick: "按钮点击,点击按钮"
24
+ },
25
+ tree: {
26
+ description: "树形控件组件相关工具集合",
27
+ getTreeData: "获取表格数据",
28
+ setCurrentKey: '设置节点的选中状态,要求数据中包含"id"字段',
29
+ expandHlNode: '设置节点的展开状态,要求数据中包含"id"字段',
30
+ collapseHlNode: '设置节点的收起状态,要求数据中包含"id"字段',
31
+ removeNode: '删除某个节点,要求数据中包含"id"字段',
32
+ insertBefore: '在一个节点的前面增加一个节点,要求数据中包含"id"字段',
33
+ insertAfter: '在一个节点的后面增加一个节点,要求数据中包含"id"字段'
34
+ },
35
+ form: {
36
+ description: "表单组件相关工具集合,包含获取表单校验、重置表单等功能",
37
+ resetFields: "对整个表单进行重置,将所有字段值重置为初始值并移除校验结果",
38
+ clearValidate: "移除表单项的校验结果,可传入待移除的表单项的 prop ,或者 prop 用逗号隔开,如不传则移除整个表单的校验结果",
39
+ clearValidateAll: "移除整个表单的校验结果",
40
+ validate: "对整个表单进行校验的方法,参数为一个回调函数(该回调函数会在校验结束后被调用,并传入两个参数:1、是否校验成功 2、未通过校验的字段)返回一个 Promise对象",
41
+ validateField: "对指定字段进行校验,可传入待校验的表单项的 prop ,或者 prop 用逗号隔开"
23
42
  }
24
43
  }
25
44
  };
@@ -0,0 +1,5 @@
1
+ export declare const resources: {
2
+ zh: any;
3
+ en: any;
4
+ };
5
+ export declare const getTreeConfig: () => import('../utils/defineComponentTool').RealComponentTool;
@@ -0,0 +1,49 @@
1
+ import { z as r } from "zod";
2
+ import { defineComponentTool as a } from "../utils/defineComponentTool.js";
3
+ import { t as o } from "../utils/locale.js";
4
+ const p = () => a({
5
+ name: "tree_component_tools",
6
+ description: o("ai.tree.description"),
7
+ tools: {
8
+ setCurrentKey: {
9
+ paramsSchema: r.string().optional().describe(o("ai.tree.setCurrentKey")),
10
+ cb: (t, e) => (t.showCheckbox ? t.setCheckedKeys([e]) : t.setCurrentKey(e), { type: "text", text: "success" })
11
+ },
12
+ getTreeData: {
13
+ paramsSchema: r.boolean().optional().describe(o("ai.tree.getTreeData")),
14
+ cb: (t) => {
15
+ const e = t.data;
16
+ return { type: "text", text: JSON.stringify(e) };
17
+ }
18
+ },
19
+ expandHlNode: {
20
+ paramsSchema: r.string().optional().describe(o("ai.tree.expandHlNode")),
21
+ cb: (t, e) => (t.getNode(e).expand(), { type: "text", text: "success" })
22
+ },
23
+ collapseHlNode: {
24
+ paramsSchema: r.string().optional().describe(o("ai.tree.collapseHlNode")),
25
+ cb: (t, e) => (t.getNode(e).collapse(), { type: "text", text: "success" })
26
+ },
27
+ removeNode: {
28
+ paramsSchema: r.string().optional().describe(o("ai.tree.removeNode")),
29
+ cb: (t, e) => (t.remove(e), { type: "text", text: "success" })
30
+ },
31
+ insertBefore: {
32
+ paramsSchema: r.record(r.any()).optional().describe(o("ai.tree.insertBefore")),
33
+ cb: (t, e) => {
34
+ let s = 1e3;
35
+ return t.insertBefore({ id: s, label: e.label }, e.id), s++, { type: "text", text: "success" };
36
+ }
37
+ },
38
+ insertAfter: {
39
+ paramsSchema: r.record(r.any()).optional().describe(o("ai.tree.insertAfter")),
40
+ cb: (t, e) => {
41
+ let s = 1e3;
42
+ return t.insertAfter({ id: s, label: e.label }, e.id), s++, { type: "text", text: "success" };
43
+ }
44
+ }
45
+ }
46
+ });
47
+ export {
48
+ p as getTreeConfig
49
+ };
@@ -1,7 +1,7 @@
1
- const $ = ({ componentMcpConfig: a, instance: t, server: e, business: r }) => {
2
- const s = `${r.id}_${a.name}`, c = `${r.description}-${a.description}`, d = a.paramsSchema || {}, i = (o) => a.cb(t, o);
3
- e.tool(s, c, d, i);
1
+ const o = ({ componentMcpConfig: e, instance: a, server: s, business: t }) => {
2
+ const r = `${t.id}_${e.name}`, c = `${t.description}-${e.description}`, i = e.paramsSchema || {}, d = (m) => e.cb(a, m);
3
+ s.registerTool(r, { title: r, description: c, inputSchema: i }, d);
4
4
  };
5
5
  export {
6
- $ as defineTool
6
+ o as defineTool
7
7
  };
package/index.ts CHANGED
@@ -4,9 +4,11 @@ import type { Business, ComponentMcpConfig } from './src/utils/defineTool'
4
4
  import zhCN from './src/lang/zh-CN'
5
5
  import enUS from './src/lang/en'
6
6
  import { getGridConfig } from './src/grid'
7
+ import { getTreeConfig } from './src/tree'
7
8
  import { getBaseSelectConfig } from './src/base-select'
8
9
  import { i18n } from './src/utils/locale'
9
10
  import { getButtonConfig } from './src/button'
11
+ import { getFormConfig } from './src/form'
10
12
 
11
13
  export { zhCN, enUS, i18n }
12
14
 
@@ -28,8 +30,10 @@ export const getTinyVueMcpConfig = ({ t }: { t?: ((path: string) => string) | nu
28
30
  version: '0.0.1',
29
31
  components: {
30
32
  Grid: getGridConfig(),
33
+ Tree: getTreeConfig(),
31
34
  BaseSelect: getBaseSelectConfig(),
32
- Button: getButtonConfig()
35
+ Button: getButtonConfig(),
36
+ Form: getFormConfig()
33
37
  }
34
38
  }
35
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentiny/tiny-vue-mcp",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "ISC",
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "zod": "^3.25.23",
15
- "@modelcontextprotocol/sdk": "^1.11.0"
15
+ "@modelcontextprotocol/sdk": "^1.17.0"
16
16
  },
17
17
  "devDependencies": {
18
18
  "vite": "^6.3.1",
@@ -0,0 +1,67 @@
1
+ import { z } from 'zod'
2
+ import { defineComponentTool } from '../utils/defineComponentTool'
3
+ import resourcesZh from './resouces.zh.md?raw'
4
+ import resourcesEn from './resouces.en.md?raw'
5
+ import { t } from '../utils/locale'
6
+
7
+ export const resources = {
8
+ zh: resourcesZh,
9
+ en: resourcesEn
10
+ }
11
+
12
+ export const getFormConfig = () =>
13
+ defineComponentTool({
14
+ name: 'form_component_tools',
15
+ description: t('ai.form.description'),
16
+ tools: {
17
+ resetFields: {
18
+ paramsSchema: z.boolean().optional().describe(t('ai.form.resetFields')),
19
+ cb: (instance) => {
20
+ instance.resetFields()
21
+ return { type: 'text', text: 'success' }
22
+ }
23
+ },
24
+ clearValidate: {
25
+ paramsSchema: z.string().optional().describe(t('ai.form.clearValidate')),
26
+ cb: (instance, value) => {
27
+ if (typeof value === 'string' && value) {
28
+ const arr = value.split(',')
29
+ if(arr.length > 0) {
30
+ instance.clearValidate(arr)
31
+ }else {
32
+ instance.clearValidate(value)
33
+ }
34
+ }
35
+ return { type: 'text', text: 'success' }
36
+ }
37
+ },
38
+ clearValidateAll: {
39
+ paramsSchema: z.boolean().optional().describe(t('ai.form.clearValidateAll')),
40
+ cb: (instance) => {
41
+ instance.clearValidate()
42
+ return { type: 'text', text: 'success' }
43
+ }
44
+ },
45
+ validate: {
46
+ paramsSchema: z.boolean().optional().describe(t('ai.form.validate')),
47
+ cb: async (instance) => {
48
+ const result = await instance.validate()
49
+ return { type: 'text', text: result ? 'success' : 'fail' }
50
+ }
51
+ },
52
+ validateField: {
53
+ paramsSchema: z.string().optional().describe(t('ai.form.validateField')),
54
+ cb: (instance, value) => {
55
+ if (typeof value === 'string' && value) {
56
+ const arr = value.split(',')
57
+ if(arr.length > 0) {
58
+ instance.validateField(arr)
59
+ }else {
60
+ instance.validateField(value)
61
+ }
62
+ }
63
+ return { type: 'text', text: 'success' }
64
+ }
65
+ }
66
+ }
67
+ })
@@ -0,0 +1,3 @@
1
+ # Form Component
2
+
3
+ Composed of buttons, input boxes, selectors, radio buttons, multiple-choice boxes, and other controls, used for collecting, verifying, and submitting data.
@@ -0,0 +1,3 @@
1
+ # Form 表单
2
+
3
+ 由按钮、输入框、选择器、单选框、多选框等控件组成,用以收集、校验、提交数据。
package/src/grid/index.ts CHANGED
@@ -15,16 +15,28 @@ export const getGridConfig = () =>
15
15
  description: t('ai.grid.description'),
16
16
  tools: {
17
17
  scrollToRow: {
18
- paramsSchema: z.number().optional().describe(t('ai.grid.scrollToRow')),
18
+ paramsSchema: z.record(z.any()).optional().describe(t('ai.grid.scrollToRow')),
19
19
  cb: (instance, value) => {
20
- const tableData = instance.getTableData().tableData
21
- const targetRow = tableData[value]
20
+ const targetRow = instance.getRowById(value._RID)
22
21
  if (targetRow) {
23
22
  instance.scrollToRow(targetRow)
24
23
  return { type: 'text', text: 'success' }
25
24
  }
26
25
  }
27
26
  },
27
+ getColumns: {
28
+ paramsSchema: z.boolean().optional().describe(t('ai.grid.getColumns')),
29
+ cb: (instance) => {
30
+ const columns = instance.getColumns()
31
+ const result = columns
32
+ .filter((col: any) => col.property && col.title)
33
+ .map((column: any) => ({
34
+ property: column.property,
35
+ title: column.title
36
+ }))
37
+ return { type: 'text', text: JSON.stringify(result) }
38
+ }
39
+ },
28
40
  getTableData: {
29
41
  paramsSchema: z.boolean().optional().describe(t('ai.grid.getTableData')),
30
42
  cb: (instance) => {
@@ -34,11 +46,11 @@ export const getGridConfig = () =>
34
46
  }
35
47
  },
36
48
  setSelection: {
37
- paramsSchema: z.number().optional().describe(t('ai.grid.setSelection')),
49
+ paramsSchema: z.record(z.any()).optional().describe(t('ai.grid.setSelection')),
38
50
  cb: (instance, value) => {
39
- const tableData = instance.getTableData().tableData
40
- const targetRow = tableData[value]
51
+ const targetRow = instance.getRowById(value._RID)
41
52
  if (targetRow) {
53
+ instance.scrollToRow(targetRow)
42
54
  instance.setSelection(targetRow, true)
43
55
  return { type: 'text', text: 'success' }
44
56
  }
@@ -61,9 +73,8 @@ export const getGridConfig = () =>
61
73
  updateRow: {
62
74
  paramsSchema: z.record(z.any()).optional().describe(t('ai.grid.updateRow')),
63
75
  cb: (instance, value) => {
64
- if (value && typeof value.tiny_mcp_index === 'number') {
65
- const tableData = instance.getTableData().tableData
66
- const targetRow = tableData[value.tiny_mcp_index]
76
+ if (value) {
77
+ const targetRow = instance.getRowById(value._RID)
67
78
  if (targetRow) {
68
79
  Object.assign(targetRow, value)
69
80
  return { type: 'text', text: 'success' }
@@ -73,12 +84,11 @@ export const getGridConfig = () =>
73
84
  }
74
85
  },
75
86
  removeRow: {
76
- paramsSchema: z.number().optional().describe(t('ai.grid.removeRow')),
87
+ paramsSchema: z.record(z.any()).optional().describe(t('ai.grid.removeRow')),
77
88
  cb: (instance, value) => {
78
- const tableData = instance.getTableData().tableData
79
- const targetRow = tableData[value]
80
- if (targetRow) {
81
- instance.remove(targetRow)
89
+ if (value) {
90
+ const row = instance.getRowById(value._RID)
91
+ instance.remove(row)
82
92
  return { type: 'text', text: 'success' }
83
93
  }
84
94
  return { type: 'text', text: 'failed' }
package/src/lang/en.ts CHANGED
@@ -2,32 +2,56 @@ export default {
2
2
  ai: {
3
3
  grid: {
4
4
  description:
5
- 'Grid component related tool set, including scrolling to the specified row, table full selection, etc.',
5
+ 'Grid component related tool set, including scrolling to specified row, table full selection and other functions',
6
6
  scrollToRow:
7
- 'Scroll to the specified row,need to get the table data first,then scroll to the row according to the index of the data in the table data',
8
- getTableData: 'Get the table data',
7
+ 'Scroll to specified row, need to pass the data of the row to scroll to, requirement: the data must contain the "_RID" field',
8
+ getTableData: 'Get table data',
9
+ getColumns:
10
+ 'Get table column configuration, "property" field represents the field property of table data, "title" represents the column title',
9
11
  setSelection:
10
- 'Select the specified row,need to get the table data first,then select the data according to the index of the data in the table data,requirement:scroll to the selected row before selecting',
11
- setAllSelection:
12
- 'Set the table all selection status,true:all selection,false:cancel all selection,requirement:scroll to the selected row before selecting',
12
+ 'Select a row in the table, need to pass the data to be selected, requirement: the data must contain the "_RID" field',
13
+ setAllSelection: 'Set table full selection status, true: select all, false: cancel all selection',
13
14
  insertRow:
14
- 'Insert or add a row of data,need to get the table data first,then add the corresponding data according to the format of the table data',
15
+ 'Insert or add a row of data, need to get table data first, then add corresponding data according to the table data format',
15
16
  updateRow:
16
- 'Update the specified row data in the table,need to get the table data first,then update the corresponding data according to the index of the data in the table data,requirement:the index of the data in the table data is passed in as the "tiny_mcp_index" field',
17
+ 'Update specified row data in the table, need to pass the data to be updated, requirement: the data must contain the "_RID" field',
17
18
  removeRow:
18
- 'Remove the specified row in the table,need to get the table data first,then remove the corresponding data according to the index of the data in the table data'
19
+ 'Remove specified row in the table, need to pass the data to be removed, requirement: the data must contain the "_RID" field'
19
20
  },
20
21
  baseSelect: {
21
22
  description:
22
- 'Base select component related tool set, including opening the drop-down panel,set selected value or clear selected value and get selected options',
23
- openMenu: 'Open the drop-down panel',
24
- selectByLabel: 'update select value by label',
25
- clearValue: 'clear select value,remove value',
26
- getOptions: 'get all options of the select component'
23
+ 'Dropdown component related tool set, including getting dropdown data, selecting dropdown data, clearing selected value and other functions',
24
+ openMenu: 'Open dropdown panel',
25
+ selectByLabel: 'Select dropdown data by label',
26
+ clearValue: 'Clear dropdown value',
27
+ getOptions: 'Query all option values of the dropdown select'
27
28
  },
28
29
  button: {
29
30
  description: 'Button component related tool set',
30
- triggerClick: 'trigger button click,click self'
31
+ triggerClick: 'Button click, click the button'
32
+ },
33
+ tree: {
34
+ description: 'Collection of Tools Related to Tree Control Components',
35
+ getTreeData: 'Obtain table data',
36
+ setCurrentKey: 'Please enter the ID value to set the current selected state of a node',
37
+ expandHlNode: 'Please enter the ID value to set the current deployment status of a node',
38
+ collapseHlNode: 'Please enter the ID value to set the collapsed state of a node',
39
+ removeNode: 'Please enter the ID value to delete a node',
40
+ insertBefore: 'Add a node in front of a node',
41
+ insertAfter: 'Add a node after a node'
42
+ },
43
+ form: {
44
+ description:
45
+ 'Form component related tool set, including getting form validation, resetting form and other functions',
46
+ resetFields:
47
+ 'Reset the entire form, resetting all field values to their initial values and removing validation results',
48
+ clearValidate:
49
+ 'Remove the validation results of the form item, you can pass in the prop of the form item to be removed, or an array of props, if not passed in, the validation results of the entire form will be removed',
50
+ clearValidateAll: 'Remove the validation results of the entire form',
51
+ validate:
52
+ 'Validate the entire form, the parameter is a callback function (the callback function will be called after the validation is completed and passed two parameters: 1, whether the validation is successful 2, the fields that failed validation) returns a Promise object',
53
+ validateField:
54
+ 'Validate the specified field by passing in the prop of the form item to be validated, or separating the props with commas'
31
55
  }
32
56
  }
33
57
  }
package/src/lang/zh-CN.ts CHANGED
@@ -2,15 +2,14 @@ export default {
2
2
  ai: {
3
3
  grid: {
4
4
  description: '表格组件相关工具集合,包含滚动到指定行、表格全选等功能',
5
- scrollToRow: '滚动到指定行,要先获取表格数据,然后根据表格数据中的数组下标索引确定滚动行',
5
+ scrollToRow: '滚动到指定行,需要传递需要滚动的行的数据,要求数据中包含"_RID"字段',
6
6
  getTableData: '获取表格数据',
7
- setSelection:
8
- '选中或者选择表格一条数据,需要先获取表格数据,然后根据表格数据中的数组下标索引选中或者选择数据,要求:选中之前先滚动到选中行',
7
+ getColumns: '获取表格列配置,"property" 字段代表表格数据的字段属性,"title" 代表表格列的标题',
8
+ setSelection: '选中或者选择表格一条数据,需要传递需要选中的数据,要求数据中包含"_RID"字段',
9
9
  setAllSelection: '用来设置表格全选状态,true:全选,false:取消全选',
10
10
  insertRow: '插入或者新增一行数据,需要先获取表格数据,根据表格数据的格式新增对应的数据',
11
- updateRow:
12
- '更新修改表格中指定行数据,需要先获取表格数据,根据表格数据中的数组下标索引更新对应的数据,要求:将更新数据的数组下标以"tiny_mcp_index"字段传入',
13
- removeRow: '删除表格中指定行,需要先获取表格数据,根据表格数据中的数组下标索引删除对应的数据'
11
+ updateRow: '更新修改表格中指定行数据,需要传递需要更新的数据,要求数据中包含"_RID"字段',
12
+ removeRow: '删除表格中指定行,需要传递需要删除的数据,要求数据中包含"_RID"字段'
14
13
  },
15
14
  baseSelect: {
16
15
  description: '下拉组件相关工具集合,包含获取下拉数据、选中下拉数据,清除选中值等功能',
@@ -22,6 +21,26 @@ export default {
22
21
  button: {
23
22
  description: '按钮组件相关工具集合',
24
23
  triggerClick: '按钮点击,点击按钮'
24
+ },
25
+ tree: {
26
+ description: '树形控件组件相关工具集合',
27
+ getTreeData: '获取表格数据',
28
+ setCurrentKey: '设置节点的选中状态,要求数据中包含"id"字段',
29
+ expandHlNode: '设置节点的展开状态,要求数据中包含"id"字段',
30
+ collapseHlNode: '设置节点的收起状态,要求数据中包含"id"字段',
31
+ removeNode: '删除某个节点,要求数据中包含"id"字段',
32
+ insertBefore: '在一个节点的前面增加一个节点,要求数据中包含"id"字段',
33
+ insertAfter: '在一个节点的后面增加一个节点,要求数据中包含"id"字段'
34
+ },
35
+ form: {
36
+ description: '表单组件相关工具集合,包含获取表单校验、重置表单等功能',
37
+ resetFields: '对整个表单进行重置,将所有字段值重置为初始值并移除校验结果',
38
+ clearValidate:
39
+ '移除表单项的校验结果,可传入待移除的表单项的 prop ,或者 prop 用逗号隔开,如不传则移除整个表单的校验结果',
40
+ clearValidateAll: '移除整个表单的校验结果',
41
+ validate:
42
+ '对整个表单进行校验的方法,参数为一个回调函数(该回调函数会在校验结束后被调用,并传入两个参数:1、是否校验成功 2、未通过校验的字段)返回一个 Promise对象',
43
+ validateField: '对指定字段进行校验,可传入待校验的表单项的 prop ,或者 prop 用逗号隔开'
25
44
  }
26
45
  }
27
46
  }
@@ -0,0 +1,77 @@
1
+ import { z } from 'zod'
2
+ import { defineComponentTool } from '../utils/defineComponentTool'
3
+ import resourcesZh from './resouces.zh.md?raw'
4
+ import resourcesEn from './resouces.en.md?raw'
5
+ import { t } from '../utils/locale'
6
+
7
+ export const resources = {
8
+ zh: resourcesZh,
9
+ en: resourcesEn
10
+ }
11
+
12
+ export const getTreeConfig = () =>
13
+ defineComponentTool({
14
+ name: 'tree_component_tools',
15
+ description: t('ai.tree.description'),
16
+ tools: {
17
+ setCurrentKey: {
18
+ paramsSchema: z.string().optional().describe(t('ai.tree.setCurrentKey')),
19
+ cb: (instance, value) => {
20
+ if(instance.showCheckbox){
21
+ instance.setCheckedKeys([value])
22
+ }else{
23
+ instance.setCurrentKey(value)
24
+ }
25
+ return { type: 'text', text: 'success' }
26
+ }
27
+ },
28
+ getTreeData: {
29
+ paramsSchema: z.boolean().optional().describe(t('ai.tree.getTreeData')),
30
+ cb: (instance) => {
31
+ const treeData = instance.data
32
+ return { type: 'text', text: JSON.stringify(treeData) }
33
+ }
34
+ },
35
+ expandHlNode: {
36
+ paramsSchema: z.string().optional().describe(t('ai.tree.expandHlNode')),
37
+ cb: (instance, value) => {
38
+ const node = instance.getNode(value)
39
+ node.expand()
40
+ return { type: 'text', text: 'success' }
41
+ }
42
+ },
43
+ collapseHlNode: {
44
+ paramsSchema: z.string().optional().describe(t('ai.tree.collapseHlNode')),
45
+ cb: (instance, value) => {
46
+ const node = instance.getNode(value)
47
+ node.collapse()
48
+ return { type: 'text', text: 'success' }
49
+ }
50
+ },
51
+ removeNode: {
52
+ paramsSchema: z.string().optional().describe(t('ai.tree.removeNode')),
53
+ cb: (instance, value) => {
54
+ instance.remove(value)
55
+ return { type: 'text', text: 'success' }
56
+ }
57
+ },
58
+ insertBefore: {
59
+ paramsSchema: z.record(z.any()).optional().describe(t('ai.tree.insertBefore')),
60
+ cb: (instance, value) => {
61
+ let id = 1000
62
+ instance.insertBefore({ id, label: value.label }, value.id)
63
+ id++
64
+ return { type: 'text', text: 'success' }
65
+ }
66
+ },
67
+ insertAfter: {
68
+ paramsSchema: z.record(z.any()).optional().describe(t('ai.tree.insertAfter')),
69
+ cb: (instance, value) => {
70
+ let id = 1000
71
+ instance.insertAfter({ id, label: value.label }, value.id)
72
+ id++
73
+ return { type: 'text', text: 'success' }
74
+ }
75
+ },
76
+ }
77
+ })
@@ -0,0 +1,3 @@
1
+ # Tree Component
2
+
3
+ It can display data with parent-child hierarchy, and supports functions such as selecting, dragging, and editing nodes.
@@ -0,0 +1,3 @@
1
+ # Tree 树形控件
2
+
3
+ 可进行展示有父子层级的数据,支持选择,拖拽和编辑节点等功能。
@@ -37,5 +37,5 @@ export const defineTool = ({ componentMcpConfig, instance, server, business }: D
37
37
  return componentMcpConfig.cb(instance, args)
38
38
  }
39
39
 
40
- server.tool(name, description, paramsSchema, cb)
40
+ server.registerTool(name, { title: name, description, inputSchema: paramsSchema }, cb)
41
41
  }