Skip to content

Commit 2c72864

Browse files
authored
refactor: remove recursive schema (#170)
* refactor: remove recursive schema * fix: schema typo of treemap * chore: update the data for hierarchical structure
1 parent 8a9e486 commit 2c72864

File tree

9 files changed

+245
-113
lines changed

9 files changed

+245
-113
lines changed

__tests__/charts/fishbone-diagram.json

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"name": "generate_fishbone_diagram",
33
"description": "Generate a fishbone diagram chart to uses a fish skeleton, like structure to display the causes or effects of a core problem, with the problem as the fish head and the causes/effects as the fish bones. It suits problems that can be split into multiple related factors.",
44
"inputSchema": {
5-
"$schema": "http://json-schema.org/draft-07/schema#",
65
"type": "object",
76
"properties": {
87
"data": {
@@ -14,54 +13,73 @@
1413
"children": {
1514
"type": "array",
1615
"items": {
16+
"type": "object",
1717
"properties": {
1818
"name": {
1919
"type": "string"
2020
},
2121
"children": {
2222
"type": "array",
2323
"items": {
24-
"$ref": "#/properties/data/properties/children/items"
24+
"type": "object",
25+
"properties": {
26+
"name": {
27+
"type": "string"
28+
},
29+
"children": {
30+
"type": "array",
31+
"items": {
32+
"type": "object",
33+
"properties": {
34+
"name": {
35+
"type": "string"
36+
}
37+
},
38+
"required": ["name"]
39+
}
40+
}
41+
},
42+
"required": ["name"]
2543
}
2644
}
2745
},
28-
"required": ["name"],
29-
"type": "object"
46+
"required": ["name"]
3047
}
3148
}
3249
},
3350
"required": ["name"],
34-
"description": "Data for fishbone diagram chart, such as, { name: 'main topic', children: [{ name: 'topic 1', children: [{ name: 'subtopic 1-1' }] }."
51+
"description": "Data for fishbone diagram chart which is a hierarchical structure, such as, { name: 'main topic', children: [{ name: 'topic 1', children: [{ name: 'subtopic 1-1' }] }] }, and the maximum depth is 3."
3552
},
3653
"style": {
37-
"description": "Custom style configuration for the chart.",
54+
"type": "object",
3855
"properties": {
3956
"texture": {
40-
"default": "default",
41-
"description": "Set the texture for the chart, optional, default is 'default'. 'rough' refers to hand-drawn style.",
57+
"type": "string",
4258
"enum": ["default", "rough"],
43-
"type": "string"
59+
"default": "default",
60+
"description": "Set the texture for the chart, optional, default is 'default'. 'rough' refers to hand-drawn style."
4461
}
4562
},
46-
"type": "object"
63+
"description": "Custom style configuration for the chart."
4764
},
4865
"theme": {
66+
"type": "string",
4967
"default": "default",
5068
"description": "Set the theme for the chart, optional, default is 'default'.",
51-
"enum": ["default", "academy", "dark"],
52-
"type": "string"
69+
"enum": ["default", "academy", "dark"]
5370
},
5471
"width": {
5572
"type": "number",
56-
"description": "Set the width of chart, default is 600.",
57-
"default": 600
73+
"default": 600,
74+
"description": "Set the width of chart, default is 600."
5875
},
5976
"height": {
6077
"type": "number",
61-
"description": "Set the height of chart, default is 400.",
62-
"default": 400
78+
"default": 400,
79+
"description": "Set the height of chart, default is 400."
6380
}
6481
},
65-
"required": ["data"]
82+
"required": ["data"],
83+
"$schema": "http://json-schema.org/draft-07/schema#"
6684
}
6785
}

__tests__/charts/mind-map.json

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"name": "generate_mind_map",
33
"description": "Generate a mind map chart to organizes and presents information in a hierarchical structure with branches radiating from a central topic, such as, a diagram showing the relationship between a main topic and its subtopics.",
44
"inputSchema": {
5-
"$schema": "http://json-schema.org/draft-07/schema#",
65
"type": "object",
76
"properties": {
87
"data": {
@@ -14,24 +13,42 @@
1413
"children": {
1514
"type": "array",
1615
"items": {
16+
"type": "object",
1717
"properties": {
18-
"children": {
19-
"items": {
20-
"$ref": "#/properties/data/properties/children/items"
21-
},
22-
"type": "array"
23-
},
2418
"name": {
2519
"type": "string"
20+
},
21+
"children": {
22+
"type": "array",
23+
"items": {
24+
"type": "object",
25+
"properties": {
26+
"name": {
27+
"type": "string"
28+
},
29+
"children": {
30+
"type": "array",
31+
"items": {
32+
"type": "object",
33+
"properties": {
34+
"name": {
35+
"type": "string"
36+
}
37+
},
38+
"required": ["name"]
39+
}
40+
}
41+
},
42+
"required": ["name"]
43+
}
2644
}
2745
},
28-
"required": ["name"],
29-
"type": "object"
46+
"required": ["name"]
3047
}
3148
}
3249
},
3350
"required": ["name"],
34-
"description": "Data for mind map chart, such as, { name: 'main topic', children: [{ name: 'topic 1', children: [{ name:'subtopic 1-1' }] }."
51+
"description": "Data for mind map chart which is a hierarchical structure, such as, { name: 'main topic', children: [{ name: 'topic 1', children: [{ name:'subtopic 1-1' }] }, and the maximum depth is 3."
3552
},
3653
"theme": {
3754
"default": "default",
@@ -40,28 +57,29 @@
4057
"type": "string"
4158
},
4259
"style": {
43-
"description": "Custom style configuration for the chart.",
60+
"type": "object",
4461
"properties": {
4562
"texture": {
46-
"default": "default",
47-
"description": "Set the texture for the chart, optional, default is 'default'. 'rough' refers to hand-drawn style.",
63+
"type": "string",
4864
"enum": ["default", "rough"],
49-
"type": "string"
65+
"default": "default",
66+
"description": "Set the texture for the chart, optional, default is 'default'. 'rough' refers to hand-drawn style."
5067
}
5168
},
52-
"type": "object"
69+
"description": "Custom style configuration for the chart."
5370
},
5471
"width": {
5572
"type": "number",
56-
"description": "Set the width of chart, default is 600.",
57-
"default": 600
73+
"default": 600,
74+
"description": "Set the width of chart, default is 600."
5875
},
5976
"height": {
6077
"type": "number",
61-
"description": "Set the height of chart, default is 400.",
62-
"default": 400
78+
"default": 400,
79+
"description": "Set the height of chart, default is 400."
6380
}
6481
},
65-
"required": ["data"]
82+
"required": ["data"],
83+
"$schema": "http://json-schema.org/draft-07/schema#"
6684
}
6785
}

__tests__/charts/organization-chart.json

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,31 @@
2727
"children": {
2828
"type": "array",
2929
"items": {
30-
"$ref": "#/properties/data/properties/children/items"
30+
"type": "object",
31+
"properties": {
32+
"name": {
33+
"type": "string"
34+
},
35+
"description": {
36+
"type": "string"
37+
},
38+
"children": {
39+
"type": "array",
40+
"items": {
41+
"type": "object",
42+
"properties": {
43+
"name": {
44+
"type": "string"
45+
},
46+
"description": {
47+
"type": "string"
48+
}
49+
},
50+
"required": ["name"]
51+
}
52+
}
53+
},
54+
"required": ["name"]
3155
}
3256
}
3357
},
@@ -36,7 +60,7 @@
3660
}
3761
},
3862
"required": ["name"],
39-
"description": "Data for organization chart, such as, { name: 'CEO', description: 'Chief Executive Officer', children: [{ name: 'CTO', description: 'Chief Technology Officer', children: [{ name: 'Dev Manager', description: 'Development Manager' }] }] }."
63+
"description": "Data for organization chart which is a hierarchical structure, such as, { name: 'CEO', description: 'Chief Executive Officer', children: [{ name: 'CTO', description: 'Chief Technology Officer', children: [{ name: 'Dev Manager', description: 'Development Manager' }] }] }, and the maximum depth is 3."
4064
},
4165
"orient": {
4266
"type": "string",
@@ -51,16 +75,16 @@
5175
"description": "Set the theme for the chart, optional, default is 'default'."
5276
},
5377
"style": {
54-
"description": "Custom style configuration for the chart.",
78+
"type": "object",
5579
"properties": {
5680
"texture": {
57-
"default": "default",
58-
"description": "Set the texture for the chart, optional, default is 'default'. 'rough' refers to hand-drawn style.",
81+
"type": "string",
5982
"enum": ["default", "rough"],
60-
"type": "string"
83+
"default": "default",
84+
"description": "Set the texture for the chart, optional, default is 'default'. 'rough' refers to hand-drawn style."
6185
}
6286
},
63-
"type": "object"
87+
"description": "Custom style configuration for the chart."
6488
},
6589
"width": {
6690
"type": "number",

__tests__/charts/treemap.json

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
"name": "generate_treemap_chart",
33
"description": "Generate a treemap chart to display hierarchical data and can intuitively show comparisons between items at the same level, such as, show disk space usage with treemap.",
44
"inputSchema": {
5-
"$schema": "http://json-schema.org/draft-07/schema#",
65
"type": "object",
76
"properties": {
87
"data": {
98
"type": "array",
10-
"minItems": 1,
119
"items": {
1210
"type": "object",
1311
"properties": {
@@ -20,59 +18,85 @@
2018
"children": {
2119
"type": "array",
2220
"items": {
23-
"$ref": "#/properties/data/items"
21+
"type": "object",
22+
"properties": {
23+
"name": {
24+
"type": "string"
25+
},
26+
"value": {
27+
"type": "number"
28+
},
29+
"children": {
30+
"type": "array",
31+
"items": {
32+
"type": "object",
33+
"properties": {
34+
"name": {
35+
"type": "string"
36+
},
37+
"value": {
38+
"type": "number"
39+
}
40+
},
41+
"required": ["name", "value"]
42+
}
43+
}
44+
},
45+
"required": ["name", "value"]
2446
}
2547
}
2648
},
2749
"required": ["name", "value"]
2850
},
29-
"description": "Data for treemap chart, such as, [{ name: 'Design', value: 70, children: [{ name: 'Tech', value: 20 }] }]."
30-
},
31-
"theme": {
32-
"default": "default",
33-
"description": "Set the theme for the chart, optional, default is 'default'.",
34-
"enum": ["default", "academy", "dark"],
35-
"type": "string"
51+
"minItems": 1,
52+
"description": "Data for treemap chart which is a hierarchical structure, such as, [{ name: 'Design', value: 70, children: [{ name: 'Tech', value: 20 }] }], and the maximum depth is 3."
3653
},
3754
"style": {
38-
"description": "Custom style configuration for the chart.",
55+
"type": "object",
3956
"properties": {
4057
"backgroundColor": {
41-
"description": "Background color of the chart, such as, '#fff'.",
42-
"type": "string"
58+
"type": "string",
59+
"description": "Background color of the chart, such as, '#fff'."
4360
},
4461
"palette": {
45-
"description": "Color palette for the chart, it is a collection of colors.",
62+
"type": "array",
4663
"items": {
4764
"type": "string"
4865
},
49-
"type": "array"
66+
"description": "Color palette for the chart, it is a collection of colors."
5067
},
5168
"texture": {
52-
"default": "default",
53-
"description": "Set the texture for the chart, optional, default is 'default'. 'rough' refers to hand-drawn style.",
69+
"type": "string",
5470
"enum": ["default", "rough"],
55-
"type": "string"
71+
"default": "default",
72+
"description": "Set the texture for the chart, optional, default is 'default'. 'rough' refers to hand-drawn style."
5673
}
5774
},
58-
"type": "object"
75+
"description": "Custom style configuration for the chart."
76+
},
77+
"theme": {
78+
"type": "string",
79+
"enum": ["default", "academy", "dark"],
80+
"default": "default",
81+
"description": "Set the theme for the chart, optional, default is 'default'."
5982
},
6083
"width": {
6184
"type": "number",
62-
"description": "Set the width of chart, default is 600.",
63-
"default": 600
85+
"default": 600,
86+
"description": "Set the width of chart, default is 600."
6487
},
6588
"height": {
6689
"type": "number",
67-
"description": "Set the height of chart, default is 400.",
68-
"default": 400
90+
"default": 400,
91+
"description": "Set the height of chart, default is 400."
6992
},
7093
"title": {
7194
"type": "string",
7295
"default": "",
7396
"description": "Set the title of chart."
7497
}
7598
},
76-
"required": ["data"]
99+
"required": ["data"],
100+
"$schema": "http://json-schema.org/draft-07/schema#"
77101
}
78102
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@antv/mcp-server-chart",
33
"description": "A Model Context Protocol server for generating charts using AntV. This is a TypeScript-based MCP server that provides chart generation capabilities. It allows you to create various types of charts through MCP tools.",
4-
"version": "0.8.1",
4+
"version": "0.8.2",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",
77
"exports": {

0 commit comments

Comments
 (0)