@umengfe/mcp-server-chart 0.0.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/LICENSE +21 -0
- package/README.md +273 -0
- package/build/charts/area.d.ts +51 -0
- package/build/charts/area.js +52 -0
- package/build/charts/bar.d.ts +49 -0
- package/build/charts/bar.js +53 -0
- package/build/charts/base.d.ts +34 -0
- package/build/charts/base.js +74 -0
- package/build/charts/boxplot.d.ts +47 -0
- package/build/charts/boxplot.js +45 -0
- package/build/charts/column.d.ts +49 -0
- package/build/charts/column.js +53 -0
- package/build/charts/district-map.d.ts +93 -0
- package/build/charts/district-map.js +85 -0
- package/build/charts/dual-axes.d.ts +47 -0
- package/build/charts/dual-axes.js +54 -0
- package/build/charts/fishbone-diagram.d.ts +28 -0
- package/build/charts/fishbone-diagram.js +55 -0
- package/build/charts/flow-diagram.d.ts +91 -0
- package/build/charts/flow-diagram.js +41 -0
- package/build/charts/funnel.d.ts +42 -0
- package/build/charts/funnel.js +37 -0
- package/build/charts/histogram.d.ts +36 -0
- package/build/charts/histogram.js +41 -0
- package/build/charts/index.d.ts +28 -0
- package/build/charts/index.js +56 -0
- package/build/charts/line.d.ts +50 -0
- package/build/charts/line.js +47 -0
- package/build/charts/liquid.d.ts +34 -0
- package/build/charts/liquid.js +42 -0
- package/build/charts/mind-map.d.ts +26 -0
- package/build/charts/mind-map.js +39 -0
- package/build/charts/network-graph.d.ts +91 -0
- package/build/charts/network-graph.js +41 -0
- package/build/charts/organization-chart.d.ts +114 -0
- package/build/charts/organization-chart.js +56 -0
- package/build/charts/path-map.d.ts +25 -0
- package/build/charts/path-map.js +25 -0
- package/build/charts/pie.d.ts +43 -0
- package/build/charts/pie.js +44 -0
- package/build/charts/pin-map.d.ts +35 -0
- package/build/charts/pin-map.js +34 -0
- package/build/charts/radar.d.ts +48 -0
- package/build/charts/radar.js +45 -0
- package/build/charts/sankey.d.ts +46 -0
- package/build/charts/sankey.js +43 -0
- package/build/charts/scatter.d.ts +47 -0
- package/build/charts/scatter.js +43 -0
- package/build/charts/treemap.d.ts +86 -0
- package/build/charts/treemap.js +55 -0
- package/build/charts/venn.d.ts +45 -0
- package/build/charts/venn.js +45 -0
- package/build/charts/violin.d.ts +47 -0
- package/build/charts/violin.js +45 -0
- package/build/charts/word-cloud.d.ts +42 -0
- package/build/charts/word-cloud.js +40 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +73 -0
- package/build/sdk.d.ts +6 -0
- package/build/sdk.js +24 -0
- package/build/server.d.ts +17 -0
- package/build/server.js +132 -0
- package/build/services/index.d.ts +3 -0
- package/build/services/index.js +9 -0
- package/build/services/sse.d.ts +2 -0
- package/build/services/sse.js +58 -0
- package/build/services/stdio.d.ts +2 -0
- package/build/services/stdio.js +21 -0
- package/build/services/streamable.d.ts +2 -0
- package/build/services/streamable.js +58 -0
- package/build/utils/callTool.d.ts +18 -0
- package/build/utils/callTool.js +130 -0
- package/build/utils/env.d.ts +12 -0
- package/build/utils/env.js +32 -0
- package/build/utils/generate.d.ts +25 -0
- package/build/utils/generate.js +68 -0
- package/build/utils/index.d.ts +3 -0
- package/build/utils/index.js +9 -0
- package/build/utils/logger.d.ts +28 -0
- package/build/utils/logger.js +57 -0
- package/build/utils/schema.d.ts +7 -0
- package/build/utils/schema.js +14 -0
- package/build/utils/validator.d.ts +34 -0
- package/build/utils/validator.js +76 -0
- package/package.json +65 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const treemap: {
|
|
3
|
+
schema: {
|
|
4
|
+
data: z.ZodArray<z.ZodObject<{
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
value: z.ZodNumber;
|
|
7
|
+
children: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
8
|
+
name: z.ZodString;
|
|
9
|
+
value: z.ZodNumber;
|
|
10
|
+
children: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
11
|
+
name: z.ZodString;
|
|
12
|
+
value: z.ZodNumber;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
value: number;
|
|
15
|
+
name: string;
|
|
16
|
+
}, {
|
|
17
|
+
value: number;
|
|
18
|
+
name: string;
|
|
19
|
+
}>, "many">>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
value: number;
|
|
22
|
+
name: string;
|
|
23
|
+
children?: {
|
|
24
|
+
value: number;
|
|
25
|
+
name: string;
|
|
26
|
+
}[] | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
value: number;
|
|
29
|
+
name: string;
|
|
30
|
+
children?: {
|
|
31
|
+
value: number;
|
|
32
|
+
name: string;
|
|
33
|
+
}[] | undefined;
|
|
34
|
+
}>, "many">>;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
value: number;
|
|
37
|
+
name: string;
|
|
38
|
+
children?: {
|
|
39
|
+
value: number;
|
|
40
|
+
name: string;
|
|
41
|
+
children?: {
|
|
42
|
+
value: number;
|
|
43
|
+
name: string;
|
|
44
|
+
}[] | undefined;
|
|
45
|
+
}[] | undefined;
|
|
46
|
+
}, {
|
|
47
|
+
value: number;
|
|
48
|
+
name: string;
|
|
49
|
+
children?: {
|
|
50
|
+
value: number;
|
|
51
|
+
name: string;
|
|
52
|
+
children?: {
|
|
53
|
+
value: number;
|
|
54
|
+
name: string;
|
|
55
|
+
}[] | undefined;
|
|
56
|
+
}[] | undefined;
|
|
57
|
+
}>, "atleastone">;
|
|
58
|
+
style: z.ZodOptional<z.ZodObject<{
|
|
59
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
60
|
+
palette: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
61
|
+
texture: z.ZodDefault<z.ZodOptional<z.ZodEnum<["default", "rough"]>>>;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
texture: "default" | "rough";
|
|
64
|
+
backgroundColor?: string | undefined;
|
|
65
|
+
palette?: string[] | undefined;
|
|
66
|
+
}, {
|
|
67
|
+
backgroundColor?: string | undefined;
|
|
68
|
+
palette?: string[] | undefined;
|
|
69
|
+
texture?: "default" | "rough" | undefined;
|
|
70
|
+
}>>;
|
|
71
|
+
theme: z.ZodDefault<z.ZodOptional<z.ZodEnum<["default", "academy", "dark"]>>>;
|
|
72
|
+
width: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
73
|
+
height: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
74
|
+
title: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
75
|
+
};
|
|
76
|
+
tool: {
|
|
77
|
+
name: string;
|
|
78
|
+
description: string;
|
|
79
|
+
inputSchema: import("zod-to-json-schema").JsonSchema7Type & {
|
|
80
|
+
$schema?: string | undefined;
|
|
81
|
+
definitions?: {
|
|
82
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
83
|
+
} | undefined;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.treemap = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const utils_1 = require("../utils/index.js");
|
|
6
|
+
const base_1 = require("./base.js");
|
|
7
|
+
// Define recursive schema for hierarchical data.
|
|
8
|
+
// The recursive schema is not supported by gemini, and other clients, so we use a non-recursive schema which can represent a tree structure with a fixed depth.
|
|
9
|
+
// Ref: https://github.com/antvis/mcp-server-chart/issues/155
|
|
10
|
+
// Ref: https://github.com/antvis/mcp-server-chart/issues/132
|
|
11
|
+
const TreeNodeSchema = zod_1.z.object({
|
|
12
|
+
name: zod_1.z.string(),
|
|
13
|
+
value: zod_1.z.number(),
|
|
14
|
+
children: zod_1.z
|
|
15
|
+
.array(zod_1.z.object({
|
|
16
|
+
name: zod_1.z.string(),
|
|
17
|
+
value: zod_1.z.number(),
|
|
18
|
+
children: zod_1.z
|
|
19
|
+
.array(zod_1.z.object({
|
|
20
|
+
name: zod_1.z.string(),
|
|
21
|
+
value: zod_1.z.number(),
|
|
22
|
+
}))
|
|
23
|
+
.optional(),
|
|
24
|
+
}))
|
|
25
|
+
.optional(),
|
|
26
|
+
});
|
|
27
|
+
// Treemap chart input schema
|
|
28
|
+
const schema = {
|
|
29
|
+
data: zod_1.z
|
|
30
|
+
.array(TreeNodeSchema)
|
|
31
|
+
.describe("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.")
|
|
32
|
+
.nonempty({ message: "Treemap chart data cannot be empty." }),
|
|
33
|
+
style: zod_1.z
|
|
34
|
+
.object({
|
|
35
|
+
backgroundColor: base_1.BackgroundColorSchema,
|
|
36
|
+
palette: base_1.PaletteSchema,
|
|
37
|
+
texture: base_1.TextureSchema,
|
|
38
|
+
})
|
|
39
|
+
.optional()
|
|
40
|
+
.describe("Style configuration for the chart with a JSON object, optional."),
|
|
41
|
+
theme: base_1.ThemeSchema,
|
|
42
|
+
width: base_1.WidthSchema,
|
|
43
|
+
height: base_1.HeightSchema,
|
|
44
|
+
title: base_1.TitleSchema,
|
|
45
|
+
};
|
|
46
|
+
// Treemap chart tool descriptor
|
|
47
|
+
const tool = {
|
|
48
|
+
name: "generate_treemap_chart",
|
|
49
|
+
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.",
|
|
50
|
+
inputSchema: (0, utils_1.zodToJsonSchema)(schema),
|
|
51
|
+
};
|
|
52
|
+
exports.treemap = {
|
|
53
|
+
schema,
|
|
54
|
+
tool,
|
|
55
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const venn: {
|
|
3
|
+
schema: {
|
|
4
|
+
data: z.ZodArray<z.ZodObject<{
|
|
5
|
+
label: z.ZodOptional<z.ZodString>;
|
|
6
|
+
value: z.ZodNumber;
|
|
7
|
+
sets: z.ZodArray<z.ZodString, "many">;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
value: number;
|
|
10
|
+
sets: string[];
|
|
11
|
+
label?: string | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
value: number;
|
|
14
|
+
sets: string[];
|
|
15
|
+
label?: string | undefined;
|
|
16
|
+
}>, "atleastone">;
|
|
17
|
+
style: z.ZodOptional<z.ZodObject<{
|
|
18
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
19
|
+
palette: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
20
|
+
texture: z.ZodDefault<z.ZodOptional<z.ZodEnum<["default", "rough"]>>>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
texture: "default" | "rough";
|
|
23
|
+
backgroundColor?: string | undefined;
|
|
24
|
+
palette?: string[] | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
backgroundColor?: string | undefined;
|
|
27
|
+
palette?: string[] | undefined;
|
|
28
|
+
texture?: "default" | "rough" | undefined;
|
|
29
|
+
}>>;
|
|
30
|
+
theme: z.ZodDefault<z.ZodOptional<z.ZodEnum<["default", "academy", "dark"]>>>;
|
|
31
|
+
width: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
32
|
+
height: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
33
|
+
title: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
34
|
+
};
|
|
35
|
+
tool: {
|
|
36
|
+
name: string;
|
|
37
|
+
description: string;
|
|
38
|
+
inputSchema: import("zod-to-json-schema").JsonSchema7Type & {
|
|
39
|
+
$schema?: string | undefined;
|
|
40
|
+
definitions?: {
|
|
41
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
42
|
+
} | undefined;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.venn = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const utils_1 = require("../utils/index.js");
|
|
6
|
+
const base_1 = require("./base.js");
|
|
7
|
+
const data = zod_1.z.object({
|
|
8
|
+
label: zod_1.z
|
|
9
|
+
.string()
|
|
10
|
+
.optional()
|
|
11
|
+
.describe("Label for the venn chart segment, such as 'A', 'B', or 'C'."),
|
|
12
|
+
value: zod_1.z
|
|
13
|
+
.number()
|
|
14
|
+
.describe("Value for the venn chart segment, such as 10, 20, or 30."),
|
|
15
|
+
sets: zod_1.z
|
|
16
|
+
.array(zod_1.z.string())
|
|
17
|
+
.describe("Array of set names that this segment belongs to, such as ['A', 'B'] for an intersection between sets A and B."),
|
|
18
|
+
});
|
|
19
|
+
const schema = {
|
|
20
|
+
data: zod_1.z
|
|
21
|
+
.array(data)
|
|
22
|
+
.describe("Data for venn chart, such as, [{ label: 'A', value: 10, sets: ['A'] }, { label: 'B', value: 20, sets: ['B'] }, { label: 'C', value: 30, sets: ['C'] }, { label: 'AB', value: 5, sets: ['A', 'B'] }].")
|
|
23
|
+
.nonempty({ message: "Venn chart data cannot be empty." }),
|
|
24
|
+
style: zod_1.z
|
|
25
|
+
.object({
|
|
26
|
+
backgroundColor: base_1.BackgroundColorSchema,
|
|
27
|
+
palette: base_1.PaletteSchema,
|
|
28
|
+
texture: base_1.TextureSchema,
|
|
29
|
+
})
|
|
30
|
+
.optional()
|
|
31
|
+
.describe("Style configuration for the chart with a JSON object, optional."),
|
|
32
|
+
theme: base_1.ThemeSchema,
|
|
33
|
+
width: base_1.WidthSchema,
|
|
34
|
+
height: base_1.HeightSchema,
|
|
35
|
+
title: base_1.TitleSchema,
|
|
36
|
+
};
|
|
37
|
+
const tool = {
|
|
38
|
+
name: "generate_venn_chart",
|
|
39
|
+
description: "Generate a Venn diagram to visualize the relationships between different sets, showing how they intersect and overlap, such as the commonalities and differences between various groups.",
|
|
40
|
+
inputSchema: (0, utils_1.zodToJsonSchema)(schema),
|
|
41
|
+
};
|
|
42
|
+
exports.venn = {
|
|
43
|
+
schema,
|
|
44
|
+
tool,
|
|
45
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const violin: {
|
|
3
|
+
schema: {
|
|
4
|
+
data: z.ZodArray<z.ZodObject<{
|
|
5
|
+
category: z.ZodString;
|
|
6
|
+
value: z.ZodNumber;
|
|
7
|
+
group: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
value: number;
|
|
10
|
+
category: string;
|
|
11
|
+
group?: string | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
value: number;
|
|
14
|
+
category: string;
|
|
15
|
+
group?: string | undefined;
|
|
16
|
+
}>, "atleastone">;
|
|
17
|
+
style: z.ZodOptional<z.ZodObject<{
|
|
18
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
19
|
+
palette: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
20
|
+
texture: z.ZodDefault<z.ZodOptional<z.ZodEnum<["default", "rough"]>>>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
texture: "default" | "rough";
|
|
23
|
+
backgroundColor?: string | undefined;
|
|
24
|
+
palette?: string[] | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
backgroundColor?: string | undefined;
|
|
27
|
+
palette?: string[] | undefined;
|
|
28
|
+
texture?: "default" | "rough" | undefined;
|
|
29
|
+
}>>;
|
|
30
|
+
theme: z.ZodDefault<z.ZodOptional<z.ZodEnum<["default", "academy", "dark"]>>>;
|
|
31
|
+
width: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
32
|
+
height: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
33
|
+
title: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
34
|
+
axisXTitle: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
35
|
+
axisYTitle: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
36
|
+
};
|
|
37
|
+
tool: {
|
|
38
|
+
name: string;
|
|
39
|
+
description: string;
|
|
40
|
+
inputSchema: import("zod-to-json-schema").JsonSchema7Type & {
|
|
41
|
+
$schema?: string | undefined;
|
|
42
|
+
definitions?: {
|
|
43
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
44
|
+
} | undefined;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.violin = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const utils_1 = require("../utils/index.js");
|
|
6
|
+
const base_1 = require("./base.js");
|
|
7
|
+
const data = zod_1.z.object({
|
|
8
|
+
category: zod_1.z
|
|
9
|
+
.string()
|
|
10
|
+
.describe("Category of the data point, such as '分类一'."),
|
|
11
|
+
value: zod_1.z.number().describe("Value of the data point, such as 10."),
|
|
12
|
+
group: zod_1.z
|
|
13
|
+
.string()
|
|
14
|
+
.optional()
|
|
15
|
+
.describe("Optional group for the data point, used for grouping in the violin chart."),
|
|
16
|
+
});
|
|
17
|
+
const schema = {
|
|
18
|
+
data: zod_1.z
|
|
19
|
+
.array(data)
|
|
20
|
+
.describe("Data for violin chart, such as, [{ category: '分类一', value: 10 }] or [{ category: '分类二', value: 20, group: '组别一' }].")
|
|
21
|
+
.nonempty({ message: "Violin chart data cannot be empty." }),
|
|
22
|
+
style: zod_1.z
|
|
23
|
+
.object({
|
|
24
|
+
backgroundColor: base_1.BackgroundColorSchema,
|
|
25
|
+
palette: base_1.PaletteSchema,
|
|
26
|
+
texture: base_1.TextureSchema,
|
|
27
|
+
})
|
|
28
|
+
.optional()
|
|
29
|
+
.describe("Style configuration for the chart with a JSON object, optional."),
|
|
30
|
+
theme: base_1.ThemeSchema,
|
|
31
|
+
width: base_1.WidthSchema,
|
|
32
|
+
height: base_1.HeightSchema,
|
|
33
|
+
title: base_1.TitleSchema,
|
|
34
|
+
axisXTitle: base_1.AxisXTitleSchema,
|
|
35
|
+
axisYTitle: base_1.AxisYTitleSchema,
|
|
36
|
+
};
|
|
37
|
+
const tool = {
|
|
38
|
+
name: "generate_violin_chart",
|
|
39
|
+
description: "Generate a violin chart to show data for statistical summaries among different categories, such as, comparing the distribution of data points across categories.",
|
|
40
|
+
inputSchema: (0, utils_1.zodToJsonSchema)(schema),
|
|
41
|
+
};
|
|
42
|
+
exports.violin = {
|
|
43
|
+
schema,
|
|
44
|
+
tool,
|
|
45
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const wordCloud: {
|
|
3
|
+
schema: {
|
|
4
|
+
data: z.ZodArray<z.ZodObject<{
|
|
5
|
+
text: z.ZodString;
|
|
6
|
+
value: z.ZodNumber;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
value: number;
|
|
9
|
+
text: string;
|
|
10
|
+
}, {
|
|
11
|
+
value: number;
|
|
12
|
+
text: string;
|
|
13
|
+
}>, "atleastone">;
|
|
14
|
+
style: z.ZodOptional<z.ZodObject<{
|
|
15
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
16
|
+
palette: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
17
|
+
texture: z.ZodDefault<z.ZodOptional<z.ZodEnum<["default", "rough"]>>>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
texture: "default" | "rough";
|
|
20
|
+
backgroundColor?: string | undefined;
|
|
21
|
+
palette?: string[] | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
backgroundColor?: string | undefined;
|
|
24
|
+
palette?: string[] | undefined;
|
|
25
|
+
texture?: "default" | "rough" | undefined;
|
|
26
|
+
}>>;
|
|
27
|
+
theme: z.ZodDefault<z.ZodOptional<z.ZodEnum<["default", "academy", "dark"]>>>;
|
|
28
|
+
width: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
29
|
+
height: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
30
|
+
title: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
31
|
+
};
|
|
32
|
+
tool: {
|
|
33
|
+
name: string;
|
|
34
|
+
description: string;
|
|
35
|
+
inputSchema: import("zod-to-json-schema").JsonSchema7Type & {
|
|
36
|
+
$schema?: string | undefined;
|
|
37
|
+
definitions?: {
|
|
38
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
39
|
+
} | undefined;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.wordCloud = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const utils_1 = require("../utils/index.js");
|
|
6
|
+
const base_1 = require("./base.js");
|
|
7
|
+
// Word cloud data schema
|
|
8
|
+
const data = zod_1.z.object({
|
|
9
|
+
text: zod_1.z.string(),
|
|
10
|
+
value: zod_1.z.number(),
|
|
11
|
+
});
|
|
12
|
+
// Word cloud input schema
|
|
13
|
+
const schema = {
|
|
14
|
+
data: zod_1.z
|
|
15
|
+
.array(data)
|
|
16
|
+
.describe("Data for word cloud chart, it should be an array of objects, each object contains a `text` field and a `value` field, such as, [{ value: 4.272, text: '形成' }].")
|
|
17
|
+
.nonempty({ message: "Word cloud chart data cannot be empty." }),
|
|
18
|
+
style: zod_1.z
|
|
19
|
+
.object({
|
|
20
|
+
backgroundColor: base_1.BackgroundColorSchema,
|
|
21
|
+
palette: base_1.PaletteSchema,
|
|
22
|
+
texture: base_1.TextureSchema,
|
|
23
|
+
})
|
|
24
|
+
.optional()
|
|
25
|
+
.describe("Style configuration for the chart with a JSON object, optional."),
|
|
26
|
+
theme: base_1.ThemeSchema,
|
|
27
|
+
width: base_1.WidthSchema,
|
|
28
|
+
height: base_1.HeightSchema,
|
|
29
|
+
title: base_1.TitleSchema,
|
|
30
|
+
};
|
|
31
|
+
// Word cloud tool descriptor
|
|
32
|
+
const tool = {
|
|
33
|
+
name: "generate_word_cloud_chart",
|
|
34
|
+
description: "Generate a word cloud chart to show word frequency or weight through text size variation, such as, analyzing common words in social media, reviews, or feedback.",
|
|
35
|
+
inputSchema: (0, utils_1.zodToJsonSchema)(schema),
|
|
36
|
+
};
|
|
37
|
+
exports.wordCloud = {
|
|
38
|
+
schema,
|
|
39
|
+
tool,
|
|
40
|
+
};
|
package/build/index.d.ts
ADDED
package/build/index.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const node_util_1 = require("node:util");
|
|
5
|
+
const server_1 = require("./server.js");
|
|
6
|
+
const logger_1 = require("./utils/logger.js");
|
|
7
|
+
// Parse command line arguments
|
|
8
|
+
const { values } = (0, node_util_1.parseArgs)({
|
|
9
|
+
options: {
|
|
10
|
+
transport: {
|
|
11
|
+
type: "string",
|
|
12
|
+
short: "t",
|
|
13
|
+
default: "stdio",
|
|
14
|
+
},
|
|
15
|
+
host: {
|
|
16
|
+
type: "string",
|
|
17
|
+
short: "h",
|
|
18
|
+
default: "localhost",
|
|
19
|
+
},
|
|
20
|
+
port: {
|
|
21
|
+
type: "string",
|
|
22
|
+
short: "p",
|
|
23
|
+
default: "1122",
|
|
24
|
+
},
|
|
25
|
+
endpoint: {
|
|
26
|
+
type: "string",
|
|
27
|
+
short: "e",
|
|
28
|
+
default: "", // We'll handle defaults per transport type
|
|
29
|
+
},
|
|
30
|
+
help: {
|
|
31
|
+
type: "boolean",
|
|
32
|
+
short: "H",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
// Display help information if requested
|
|
37
|
+
if (values.help) {
|
|
38
|
+
console.log(`
|
|
39
|
+
MCP Server Chart CLI
|
|
40
|
+
|
|
41
|
+
Options:
|
|
42
|
+
--transport, -t Specify the transport protocol: "stdio", "sse", or "streamable" (default: "stdio")
|
|
43
|
+
--host, -h Specify the host for SSE or streamable transport (default: localhost)
|
|
44
|
+
--port, -p Specify the port for SSE or streamable transport (default: 1122)
|
|
45
|
+
--endpoint, -e Specify the endpoint for the transport:
|
|
46
|
+
- For SSE: default is "/sse"
|
|
47
|
+
- For streamable: default is "/mcp"
|
|
48
|
+
--help, -H Show this help message
|
|
49
|
+
`);
|
|
50
|
+
process.exit(0);
|
|
51
|
+
}
|
|
52
|
+
// Run in the specified transport mode
|
|
53
|
+
const transport = values.transport.toLowerCase();
|
|
54
|
+
if (transport === "sse") {
|
|
55
|
+
logger_1.logger.setIsStdio(false);
|
|
56
|
+
const port = Number.parseInt(values.port, 10);
|
|
57
|
+
// Use provided endpoint or default to "/sse" for SSE
|
|
58
|
+
const endpoint = values.endpoint || "/sse";
|
|
59
|
+
const host = values.host || "localhost";
|
|
60
|
+
(0, server_1.runSSEServer)(host, port, endpoint).catch(console.error);
|
|
61
|
+
}
|
|
62
|
+
else if (transport === "streamable") {
|
|
63
|
+
logger_1.logger.setIsStdio(false);
|
|
64
|
+
const port = Number.parseInt(values.port, 10);
|
|
65
|
+
// Use provided endpoint or default to "/mcp" for streamable
|
|
66
|
+
const endpoint = values.endpoint || "/mcp";
|
|
67
|
+
const host = values.host || "localhost";
|
|
68
|
+
(0, server_1.runHTTPStreamableServer)(host, port, endpoint).catch(console.error);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
logger_1.logger.setIsStdio(true);
|
|
72
|
+
(0, server_1.runStdioServer)().catch(console.error);
|
|
73
|
+
}
|
package/build/sdk.d.ts
ADDED
package/build/sdk.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.callTool = void 0;
|
|
18
|
+
/**
|
|
19
|
+
* Exports the API for the `@antv/mcp-server-chart` package.
|
|
20
|
+
* This includes chart generation capabilities and utility functions.
|
|
21
|
+
*/
|
|
22
|
+
__exportStar(require("./charts/index.js"), exports);
|
|
23
|
+
var utils_1 = require("./utils/index.js");
|
|
24
|
+
Object.defineProperty(exports, "callTool", { enumerable: true, get: function () { return utils_1.callTool; } });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates and configures an MCP server for chart generation.
|
|
4
|
+
*/
|
|
5
|
+
export declare function createServer(): Server;
|
|
6
|
+
/**
|
|
7
|
+
* Runs the server with stdio transport.
|
|
8
|
+
*/
|
|
9
|
+
export declare function runStdioServer(): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Runs the server with SSE transport.
|
|
12
|
+
*/
|
|
13
|
+
export declare function runSSEServer(host?: string, port?: number, endpoint?: string): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Runs the server with HTTP streamable transport.
|
|
16
|
+
*/
|
|
17
|
+
export declare function runHTTPStreamableServer(host?: string, port?: number, endpoint?: string): Promise<void>;
|
package/build/server.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.createServer = createServer;
|
|
46
|
+
exports.runStdioServer = runStdioServer;
|
|
47
|
+
exports.runSSEServer = runSSEServer;
|
|
48
|
+
exports.runHTTPStreamableServer = runHTTPStreamableServer;
|
|
49
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
50
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
51
|
+
const Charts = __importStar(require("./charts/index.js"));
|
|
52
|
+
const services_1 = require("./services/index.js");
|
|
53
|
+
const callTool_1 = require("./utils/callTool.js");
|
|
54
|
+
const env_1 = require("./utils/env.js");
|
|
55
|
+
const logger_1 = require("./utils/logger.js");
|
|
56
|
+
/**
|
|
57
|
+
* Creates and configures an MCP server for chart generation.
|
|
58
|
+
*/
|
|
59
|
+
function createServer() {
|
|
60
|
+
const server = new index_js_1.Server({
|
|
61
|
+
name: "umeng-mcp-server-chart",
|
|
62
|
+
version: "0.0.1",
|
|
63
|
+
}, {
|
|
64
|
+
capabilities: {
|
|
65
|
+
tools: {},
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
setupToolHandlers(server);
|
|
69
|
+
server.onerror = (e) => {
|
|
70
|
+
logger_1.logger.error("Server encountered an error, shutting down", e);
|
|
71
|
+
};
|
|
72
|
+
process.on("SIGINT", () => __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
logger_1.logger.info("SIGINT received, shutting down server...");
|
|
74
|
+
yield server.close();
|
|
75
|
+
process.exit(0);
|
|
76
|
+
}));
|
|
77
|
+
return server;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Gets enabled tools based on environment variables.
|
|
81
|
+
*/
|
|
82
|
+
function getEnabledTools() {
|
|
83
|
+
const disabledTools = (0, env_1.getDisabledTools)();
|
|
84
|
+
const allCharts = Object.values(Charts);
|
|
85
|
+
if (disabledTools.length === 0) {
|
|
86
|
+
return allCharts;
|
|
87
|
+
}
|
|
88
|
+
return allCharts.filter((chart) => !disabledTools.includes(chart.tool.name));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Sets up tool handlers for the MCP server.
|
|
92
|
+
*/
|
|
93
|
+
function setupToolHandlers(server) {
|
|
94
|
+
logger_1.logger.info("setting up tool handlers...");
|
|
95
|
+
server.setRequestHandler(types_js_1.ListToolsRequestSchema, () => __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
return ({
|
|
97
|
+
tools: getEnabledTools().map((chart) => chart.tool),
|
|
98
|
+
});
|
|
99
|
+
}));
|
|
100
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
101
|
+
server.setRequestHandler(types_js_1.CallToolRequestSchema, (request) => __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
logger_1.logger.info("calling tool", request.params.name, request.params.arguments);
|
|
103
|
+
return yield (0, callTool_1.callTool)(request.params.name, request.params.arguments);
|
|
104
|
+
}));
|
|
105
|
+
logger_1.logger.info("tool handlers set up");
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Runs the server with stdio transport.
|
|
109
|
+
*/
|
|
110
|
+
function runStdioServer() {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
const server = createServer();
|
|
113
|
+
yield (0, services_1.startStdioMcpServer)(server);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Runs the server with SSE transport.
|
|
118
|
+
*/
|
|
119
|
+
function runSSEServer() {
|
|
120
|
+
return __awaiter(this, arguments, void 0, function* (host = "localhost", port = 1122, endpoint = "/sse") {
|
|
121
|
+
const server = createServer();
|
|
122
|
+
yield (0, services_1.startSSEMcpServer)(server, endpoint, port, host);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Runs the server with HTTP streamable transport.
|
|
127
|
+
*/
|
|
128
|
+
function runHTTPStreamableServer() {
|
|
129
|
+
return __awaiter(this, arguments, void 0, function* (host = "localhost", port = 1122, endpoint = "/mcp") {
|
|
130
|
+
yield (0, services_1.startHTTPStreamableServer)(createServer, endpoint, port, host);
|
|
131
|
+
});
|
|
132
|
+
}
|