--- install scripts ---
### prepare
npm run build
--- package/package.json (excerpt) ---
{
"name": "@antv/mcp-server-antv",
"version": "0.1.8",
"description": "MCP Server for AntV visualization libraries development, which provides documentation context and examples for visualization developers.",
"main": "build/index.js",
"scripts": {
"lint": "prettier --check . && tsc --noEmit",
"fix": "prettier --write .",
"prebuild": "rm -rf build/*",
"build": "tsc && tsc-alias -p tsconfig.json",
"postbuild": "chmod +x build/index.js",
"start": "npm run build && npx @modelcontextprotocol/inspector node build/index.js",
"prepare": "npm run build",
"release": "npm publish",
"test": "vitest"
},
"keywords": [
"mcp",
"mcp-server",
"antv",
"visualization",
"documentation",
"context7",
"ai-development"
],
"bin": {
"mcp-server-antv": "./build/index.js"
},
"files": [
"build",
"src",
"README.md",
"LICENSE"
],
"dependencies": {
"@modelcontextprotocol/sdk": "^1.12.0",
"eventsource": "^4.1.0",
"zod": "^3.25.75"
},
"devDependencies": {
"@modelcontextprotocol/inspector": "^0.15.0",
"@types/node": "^22.15.21",
"prettier": "^3.0.0",
"tsc-alias": "^1.8.16",
"typescript": "^5.0.0",
"vitest": "^3.1.4",
"zod-to-json-schema": "^3.24.5"
},
"engines": {
"node": ">=18.0.0"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/antvis/mcp-server-antv"
},
"author": {
"name": "AntV",
"url": "htt
--- package/src/utils/env.ts (excerpt) ---
import process from 'node:process';
/**
* Get the `LOGGER_LEVEL` from environment variables.
*/
export function getEnvLoggerLevel(): number {
const loggerLevel = process.env.LOGGER_LEVEL;
return Number.isNaN(Number(loggerLevel)) ? 1 : Number(loggerLevel);
}
--- bundled output (OSV-MAL flagged — LLM scope expansion) ---
--- build/constant.d.ts (bundled) ---
import type { AntVLibrary } from './types';
export declare const ANTV_LIBRARY_META: {
g2: {
id: AntVLibrary;
name: string;
description: string;
keywords: string;
codeStyle: string;
};
g6: {
id: AntVLibrary;
name: string;
description: string;
keywords: string;
codeStyle: string;
};
l7: {
id: AntVLibrary;
name: string;
description: string;
keywords: string;
codeStyle: string;
};
x6: {
id: AntVLibrary;
name: string;
description: string;
keywords: string;
codeStyle: string;
};
f2: {
id: AntVLibrary;
name: string;
description: string;
keywords: string;
codeStyle: string;
};
s2: {
id: AntVLibrary;
name: string;
description: string;
keywords: string;
codeStyle: string;
};
g: {
id: AntVLibrary;
name: string;
description: string;
keywords: string;
codeStyle: string;
};
ava: {
id: AntVLibrary;
name: string;
description: string;
keywords: string;
codeStyle: string;
};
adc: {
id: AntVLibrary;
name: string;
description: string;
keywords: string;
codeStyle: string;
};
};
export declare const CONTEXT7_TOKENS: {
default: number;
max: number;
min: number;
};
export declare function getLibraryConfig(library: AntVLibrary): {
id: AntVLibrary;
name: string;
description: string;
keywords: string;
codeStyle: string;
} | {
id: AntVLibrary;
name: string;
description: string;
keywords: string;
codeStyle: string;
} | {
id: AntVLibrary;
name: string;
description: string;
keywords: string;
codeStyle: string;
} | {
id: AntVLibrary;
name: string;
description: string;
keywords: string;
--- build/constant.js (bundled) ---
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CONTEXT7_TOKENS = exports.ANTV_LIBRARY_META = void 0;
exports.getLibraryConfig = getLibraryConfig;
exports.getLibraryDescription = getLibraryDescription;
exports.getLibraryKeywords = getLibraryKeywords;
// AntV Libraries Metadata
exports.ANTV_LIBRARY_META = {
g2: {
id: 'g2',
name: 'G2',
description: 'Statistical charts, data visualization, business intelligence charts',
keywords: `
- 图表 (Chart)
- 标记 (Mark)
- 比例尺 (Scale)
- 转换 (Transform)
- 坐标系 (Coordinate)
- 动画 (Animate)
- 交互 (Interaction)
- 复合 (Composition)
- 组件 (Component)
- 编码 (Encode)
- 通道 (Channel)
- 提示信息 (Tooltip)
- 坐标轴 (Axis)
- 数据标签 (Label)
- 标注(Annotation)
- 配置项 (Options)
`,
codeStyle: `
<convention>
- Prioritize using options() method to configure charts
</convention>
`,
},
g6: {
id: 'g6',
name: 'G6',
description: 'Graph analysis, network diagrams, node-link relationships',
keywords: '',
codeStyle: '',
},
l7: {
id: 'l7',
name: 'L7',
description: 'Geospatial visualization, maps, geographic data analysis',
keywords: '',
codeStyle: '',
},
x6: {
id: 'x6',
name: 'X6',
description: 'Graph editing, flowcharts, diagram creation tools',
keywords: '',
codeStyle: `<convention>
- By default, edges should connect to the node's border.
</convention>
`,
},
f2: {
id: 'f2',
name: 'F2',
description: 'Mobile-optimized charts, lightweight visualization',
keywords: `
<components>
- 文本/图片/点/标签/矩形标注 (TextGuide、ImageGuide、PointGuide、TagGuide、RectGuide)
- 自定义标注/图例 (withGuide、withLegend)
- 时间轴 (Timeline)
- 坐标轴 (Axis)
- 组件 (Component)
- 提示信息/交互 (Tooltip)
- 饼图标签 (PieLabel)
- 象形柱图 (PictorialBar)
<components>
`,
codeStyle: `
<convention>
- Use F2's components
--- build/index.d.ts (bundled) ---
#!/usr/bin/env node
export {};
--- build/index.js (bundled) ---
#!/usr/bin/env node
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
const utils_1 = require("./utils/index.js");
const tools_1 = require("./tools/index.js");
class AntVMCPServer {
constructor() {
this.server = new mcp_js_1.McpServer({
name: 'mcp-server-antv',
version: '0.1.0',
});
// Register tools with validation
[tools_1.ExtractAntVTopicTool, tools_1.QueryAntVDocumentTool].forEach((tool) => {
const { name, description, inputSchema, run } = tool;
// @ts-ignore
this.server.tool(name, description, inputSchema.shape, ((args) => __awaiter(this, void 0, void 0, function* () {
const { success, errorMessage } = (0, utils_1.validateSchema)(inputSchema, args);
if (success) {
return yield run(args);
}
else {
throw new Error(errorMessage);
}
})));
});
utils_1.logger.info('AntV MCP Server initialized successfully!');
}
runWithStdio() {
return __awaiter(this, void 0, void 0, function* ()
--- build/types.d.ts (bundled) ---
/**
* AntV MCP Server Type Definitions
*/
/**
* AntV Library Types.
* Defines the available libraries in the AntV ecosystem.
* These libraries are used to fetch documentation and provide context for the AntV Assistant tool.
*/
export type AntVLibrary = 'g2' | 'g6' | 'l7' | 'x6' | 'f2' | 's2' | 'g' | 'ava' | 'adc';
export type AntVConfig = {
id: AntVLibrary;
name: string;
description: string;
keywords: string;
codeStyle: string;
};
--- build/types.js (bundled) ---
"use strict";
/**
* AntV MCP Server Type Definitions
*/
Object.defineProperty(exports, "__esModule", { value: true });
--- build/utils/context7.d.ts (bundled) ---
/**
* Context7 service, used to get the latest documentation context for AntV.
*/
import type { AntVLibrary } from '../types';
/**
* Get the Context7 library ID corresponding to the AntV organization.
*/
export declare function getLibraryId(library: AntVLibrary): string;
/**
* Get the documentation context associated with the specified library and topic.
*/
export declare function fetchLibraryDocumentation(libraryId: string, topic: string, tokens?: number): Promise<{
documentation: string | null;
error?: string;
}>;
--- build/utils/context7.js (bundled) ---
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) :{
"name": "@antv/mcp-server-antv",
"version": "0.1.8",
"description": "MCP Server for AntV visualization libraries development, which provides documentation context and examples for visualization developers.",
"main": "build/index.js",
"scripts": {
"lint": "prettier --check . && tsc --noEmit",
"fix": "prettier --write .",
"prebuild": "rm -rf build/*",
"build": "tsc && tsc-alias -p tsconfig.json",
"postbuild": "chmod +x build/index.js",
"start": "npm run build && npx @modelcontextprotocol/inspector node build/index.js",
"prepare": "npm run build",
"release": "npm publish",
"test": "vitest"
},
"keywords": [
"mcp",
"mcp-server",
"antv",
"visualization",
"documentation",
"context7",
"ai-development"
],
"bin": {
"mcp-server-antv": "./build/index.js"
},
"files": [
"build",
"src",
"README.md",
"LICENSE"
],
"dependencies": {
"@modelcontextprotocol/sdk": "^1.12.0",
"eventsource": "^4.1.0",
"zod": "^3.25.75"
},
"devDependencies": {
"@modelcontextprotocol/inspector": "^0.15.0",
"@types/node": "^22.15.21",
"prettier": "^3.0.0",
"tsc-alias": "^1.8.16",
"typescript": "^5.0.0",
"vitest": "^3.1.4",
"zod-to-json-schema": "^3.24.5"
},
"engines": {
"node": ">=18.0.0"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/antvis/mcp-server-antv"
},
"author": {
"name": "AntV",
"url": "htt
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CONTEXT7_TOKENS = exports.ANTV_LIBRARY_META = void 0;
exports.getLibraryConfig = getLibraryConfig;
exports.getLibraryDescription = getLibraryDescription;
exports.getLibraryKeywords = getLibraryKeywords;
// AntV Libraries Metadata
exports.ANTV_LIBRARY_META = {
g2: {
id: 'g2',
name: 'G2',
description: 'Statistical charts, data visualization, business intelligence charts',
keywords: `
- 图表 (Chart)
- 标记 (Mark)
- 比例尺 (Scale)
- 转换 (Transform)
- 坐标系 (Coordinate)
- 动画 (Animate)
- 交互 (Interaction)
- 复合 (Composition)
- 组件 (Component)
- 编码 (Encode)
- 通道 (Channel)
- 提示信息 (Tooltip)
- 坐标轴 (Axis)
- 数据标签 (Label)
- 标注(Annotation)
- 配置项 (Options)
`,
codeStyle: `
<convention>
- Prioritize using options() method to configure charts
</convention>
`,
},
g6: {
id: 'g6',
name: 'G6',
description: 'Graph analysis, network diagrams, node-link relationships',
keywords: '',
codeStyle: '',
},
l7: {
id: 'l7',
name: 'L7',
description: 'Geospatial visualization, maps, geographic data analysis',
keywords: '',
codeStyle: '',
},
x6: {
id: 'x6',
name: 'X6',
description: 'Graph editing, flowcharts, diagram creation tools',
keywords: '',
codeStyle: `<convention>
- By default, edges should connect to the node's border.
</convention>
`,
},
f2: {
id: 'f2',
name: 'F2',
description: 'Mobile-optimized charts, lightweight visualization',
keywords: `
<components>
- 文本/图片/点/标签/矩形标注 (TextGuide、ImageGuide、PointGuide、TagGuide、RectGuide)
- 自定义标注/图例 (withGuide、withLegend)
- 时间轴 (Timeline)
- 坐标轴 (Axis)
- 组件 (Component)
- 提示信息/交互 (Tooltip)
- 饼图标签 (PieLabel)
- 象形柱图 (PictorialBar)
<components>
`,
codeStyle: `
<convention>
- Use F2's components