You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
componentName: z.string().describe('The name of the component.'),
18
-
props: z.object({}).describe('The props of the component.'),
19
-
children: z.array(z.lazy(()=>nodeArraySchema)).describe('The children of the component')
20
-
})
21
-
22
7
constinputSchema=z.object({
23
8
parentId: z
24
9
.string()
25
10
.optional()
26
11
.describe(
27
12
'The id of the parent node. If not provided, the new node will be added to the root. if you don\'t know the parentId, you can use the tool "get_page_schema" to get the page schema. if you want to add to page root, just don\'t provide the parentId.'
28
13
),
29
-
newNodeData: z.lazy(()=>nodeSchema).describe('The new node data.'),
14
+
newNodeData: z.object({
15
+
componentName: z.string().describe('The name of the component.'),
16
+
props: z.record(z.string(),z.any()).describe('The props of the component.'),
17
+
children: z
18
+
.array(z.record(z.string(),z.any()))
19
+
.describe('Array of child nodes; each child has the same shape as newNodeData (recursive tree).')
20
+
}),
30
21
position: z
31
22
.enum(['before','after'])
32
23
.optional()
@@ -60,11 +51,6 @@ export const addNode = {
60
51
const{ props ={}, children =[]}=newNodeData
61
52
62
53
constvalidateResult=validateParams(args,{
63
-
componentName: {
64
-
required: true,
65
-
message:
66
-
'Component name is required, if you don\'t know the component name, you can use the tool "get_component_list" to get the component detail.'
id: z.string().describe('The id of the node to change the props of.'),
5
+
id: z
6
+
.string()
7
+
.describe(
8
+
'The id of the node to change the props of. if you don\'t know the id, you can use the tool "get_current_selected_node" to get the current selected node. or you can use the tool "get_page_schema" to get the page schema. when get the page schema, you can find the id in the "id" field.'
9
+
),
6
10
props: z
7
-
.object({})
11
+
.record(z.string(),z.any())
8
12
.describe(
9
13
'The props of the component. if you don\'t know available props, you can use the "get_component_detail" tool to get component detail and available props.'
id: z.string().describe('The id of the node to delete.')
5
+
id: z
6
+
.string()
7
+
.describe(
8
+
'The id of the node to delete. if you don\'t know the id, you can use the tool "get_current_selected_node" to get the current selected node. or you can use the tool "get_page_schema" to get the page schema. when get the page schema, you can find the id in the "id" field.'
id: z.string().describe('The id of the node to query.')
5
+
id: z
6
+
.string()
7
+
.describe(
8
+
'The id of the node to query. if you don\'t know the id, you can use the tool "get_current_selected_node" to get the current selected node. or you can use the tool "get_page_schema" to get the page schema. when get the page schema, you can find the id in the "id" field.'
9
+
)
6
10
})
7
11
8
12
exportconstqueryNodeById={
@@ -29,8 +33,23 @@ export const queryNodeById = {
29
33
isError: true,
30
34
type: 'text',
31
35
text: JSON.stringify({
32
-
status: 'error',
33
-
message: 'Node not found, please check the id is correct.'
36
+
errorCode: 'NODE_NOT_FOUND',
37
+
reason: `Node not found: ${id}`,
38
+
userMessage: `Node not found: ${id}. Fetch the available node list.`,
39
+
next_action: [
40
+
{
41
+
type: 'tool_call',
42
+
name: 'get_current_selected_node',
43
+
args: {},
44
+
when: 'you want to query the current selected node'
45
+
},
46
+
{
47
+
type: 'tool_call',
48
+
name: 'get_page_schema',
49
+
args: {},
50
+
when: 'you want to query the node with the specified id'
id: z.string().describe('The id of the node to select.')
5
+
id: z
6
+
.string()
7
+
.describe(
8
+
'The id of the node to select. if you don\'t know the id, you can use the tool "get_page_schema" to get the page schema. when get the page schema, you can find the id in the "id" field.'
Copy file name to clipboardExpand all lines: packages/plugins/page/src/mcp/tools/addPage.ts
+8-4Lines changed: 8 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -3,12 +3,16 @@ import { usePage } from '@opentiny/tiny-engine-meta-register'
3
3
4
4
constinputSchema=z.object({
5
5
name: z.string().describe('The name of the page. The name must be unique and Capitalize the first letter.'),
6
-
route: z.string().describe('The route of the page'),
6
+
route: z
7
+
.string()
8
+
.describe(
9
+
'The route of the page. only allow contain english letter, number, underline, hyphen, slash, and start with english letter.'
10
+
),
7
11
parentId: z
8
12
.string()
9
13
.optional()
10
14
.describe(
11
-
'The parent id of the page, if not provided, the page will be created at the root level. if provided, the page will be created at the specified parent id.'
15
+
'The parent id of the page, if not provided, the page will be created at the root level. if provided, the page will be created at the specified parent id. if you don\'t know the parentId, you can use the tool "get_page_list" to get the page list.'
0 commit comments