Skip to content

Commit 2de22d6

Browse files
feat: add library (#14)
* feat: add library * fix: fix ci * fix: fix ci
1 parent 984692b commit 2de22d6

7 files changed

Lines changed: 34 additions & 8 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
<img width="768" alt="mcp-server-antv Technical Architecture" src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*WHSOR7L8U0YAAAAATjAAAAgAemJ7AQ/fmt.webp" />
66

7-
Supports **G2**, **G6**, and **F2** libraries for declarative visualization workflows, and **S2**, **X6**, and **L7** on the way~
7+
Supports **G2**, **G6**, and **F2** libraries for declarative visualization workflows, with **S2**, **X6**, **L7**, and more (including **AVA**, **ADC**, and **G**) coming soon.
88

99
## ✨ Features
1010

__tests__/constant.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { describe, expect, it } from 'vitest';
22
import {
3-
getLibraryConfig,
43
ANTV_LIBRARY_META,
54
CONTEXT7_TOKENS,
65
} from '../src/constant';
@@ -18,11 +17,14 @@ describe('context7', () => {
1817
expect(isValidLibrary('g6')).toBe(true);
1918
expect(isValidLibrary('x6')).toBe(true);
2019
expect(isValidLibrary('l7')).toBe(true);
20+
expect(isValidLibrary('ava')).toBe(true);
21+
expect(isValidLibrary('adc')).toBe(true);
22+
expect(isValidLibrary('g')).toBe(true);
2123
expect(isValidLibrary('unknown')).toBe(false);
2224
});
2325

2426
it('ANTV_LIBRARY_META', () => {
25-
expect(Object.values(ANTV_LIBRARY_META).length).toBe(6);
27+
expect(Object.values(ANTV_LIBRARY_META).length).toBe(9);
2628
});
2729

2830
it('CONTEXT7_TOKENS', () => {

__tests__/tools/extract_antv_topic.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "extract_antv_topic",
3-
"description": "AntV Intelligent Assistant Preprocessing Tool - Specifically designed to handle any user queries related to AntV visualization libraries.\n This tool is the first step in processing AntV technology stack issues, responsible for intelligently identifying, parsing, and structuring user visualization requirements.\n\n**MANDATORY: Must be called for ANY new AntV-related queries, including simple questions. Always precedes query_antv_document tool.**\n\nWhen to use this tool:\n- **AntV-related queries**: Questions about g2/g6/l7/x6/f2/s2 libraries.\n- **Visualization tasks**: Creating charts, graphs, maps, or other visualizations.\n- **Problem solving**: Debugging errors, performance issues, or compatibility problems.\n- **Learning & implementation**: Understanding concepts or requesting code examples.\n\nKey features:\n- **Smart Library Detection**: Scans installed AntV libraries and recommends the best fit based on query and project dependencies.\n- **Topic & Intent Extraction**: Intelligently extracts technical topics and determines user intent (learn/implement/solve).\n- **Task Complexity Handling**: Detects complex tasks and decomposes them into manageable subtasks.\n- **Seamless Integration**: Prepares structured data for the query_antv_document tool to provide precise solutions.",
3+
"description": "AntV Intelligent Assistant Preprocessing Tool - Specifically designed to handle any user queries related to AntV visualization libraries.\n This tool is the first step in processing AntV technology stack issues, responsible for intelligently identifying, parsing, and structuring user visualization requirements.\n\n**MANDATORY: Must be called for ANY new AntV-related queries, including simple questions. Always precedes query_antv_document tool.**\n\nWhen to use this tool:\n- **AntV-related queries**: Questions about g2/g6/l7/x6/f2/s2/g/ava/adc libraries.\n- **Visualization tasks**: Creating charts, graphs, maps, or other visualizations.\n- **Problem solving**: Debugging errors, performance issues, or compatibility problems.\n- **Learning & implementation**: Understanding concepts or requesting code examples.\n\nKey features:\n- **Smart Library Detection**: Scans installed AntV libraries and recommends the best fit based on query and project dependencies.\n- **Topic & Intent Extraction**: Intelligently extracts technical topics and determines user intent (learn/implement/solve).\n- **Task Complexity Handling**: Detects complex tasks and decomposes them into manageable subtasks.\n- **Seamless Integration**: Prepares structured data for the query_antv_document tool to provide precise solutions.",
44
"inputSchema": {
55
"$schema": "http://json-schema.org/draft-07/schema#",
66
"type": "object",
@@ -12,7 +12,7 @@
1212
},
1313
"library": {
1414
"type": "string",
15-
"enum": ["g2", "g6", "l7", "x6", "f2", "s2"],
15+
"enum": ["g2", "g6", "l7", "x6", "f2", "s2", "g", "ava", "adc"],
1616
"description": "AntV library name (optional) - If not specified, tool will automatically detect project dependencies and intelligently recommend"
1717
},
1818
"maxTopics": {

__tests__/tools/query_antv_document.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "query_antv_document",
3-
"description": "AntV Context Retrieval Assistant - Fetches relevant documentation, code examples, and best practices from official AntV resources. Supports g2, g6, l7, x6, f2, s2 libraries, and handles subtasks iterative queries.\n\n**MANDATORY: Must be called for ANY AntV-related query (g2, g6, l7, x6, f2, s2), regardless of task complexity. No exceptions for simple tasks.**\n\nWhen to use this tool:\n- **Implementation & Optimization**: To implement new features, modify styles, refactor code, or optimize performance in AntV solutions.\n- **Debugging & Problem Solving**: For troubleshooting errors, unexpected behaviors, or technical challenges in AntV projects.\n- **Learning & Best Practices**: To explore official documentation, code examples, design patterns, or advanced features.\n- **Complex Task Handling**: For multi-step tasks requiring subtask decomposition (e.g., \"Build a dashboard with interactive charts\").\n- **Simple modifications**: Even basic changes like \"Change the chart's color\" or \"Update legend position\" in AntV context.",
3+
"description": "AntV Context Retrieval Assistant - Fetches relevant documentation, code examples, and best practices from official AntV resources. Supports g2, g6, l7, x6, f2, s2, g, ava, adc libraries, and handles subtasks iterative queries.\n\n**MANDATORY: Must be called for ANY AntV-related query (g2, g6, l7, x6, f2, s2, g, ava, adc), regardless of task complexity. No exceptions for simple tasks.**\n\nWhen to use this tool:\n- **Implementation & Optimization**: To implement new features, modify styles, refactor code, or optimize performance in AntV solutions.\n- **Debugging & Problem Solving**: For troubleshooting errors, unexpected behaviors, or technical challenges in AntV projects.\n- **Learning & Best Practices**: To explore official documentation, code examples, design patterns, or advanced features.\n- **Complex Task Handling**: For multi-step tasks requiring subtask decomposition (e.g., \"Build a dashboard with interactive charts\").\n- **Simple modifications**: Even basic changes like \"Change the chart's color\" or \"Update legend position\" in AntV context.",
44
"inputSchema": {
55
"$schema": "http://json-schema.org/draft-07/schema#",
66
"type": "object",
77
"properties": {
88
"library": {
99
"type": "string",
10-
"enum": ["g2", "g6", "l7", "x6", "f2", "s2"],
10+
"enum": ["g2", "g6", "l7", "x6", "f2", "s2", "g", "ava", "adc"],
1111
"description": "Specified AntV library type, intelligently identified based on user query"
1212
},
1313
"query": {

src/constant.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,29 @@ export const ANTV_LIBRARY_META = {
8383
keywords: '',
8484
codeStyle: '',
8585
},
86+
g: {
87+
id: 'g' as AntVLibrary,
88+
name: 'G',
89+
description: 'AntV Grammar of Graphics runtime and specification',
90+
keywords: '',
91+
codeStyle: '',
92+
},
93+
ava: {
94+
id: 'ava' as AntVLibrary,
95+
name: 'AVA',
96+
description:
97+
'Automated Visual Analytics: chart advisor, insight, narrative',
98+
keywords: '',
99+
codeStyle: '',
100+
},
101+
adc: {
102+
id: 'adc' as AntVLibrary,
103+
name: 'ADC',
104+
description:
105+
'Ant Design Charts built on G2 for React and modern frameworks',
106+
keywords: '',
107+
codeStyle: '',
108+
},
86109
};
87110

88111
export const CONTEXT7_TOKENS = {

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Defines the available libraries in the AntV ecosystem.
88
* These libraries are used to fetch documentation and provide context for the AntV Assistant tool.
99
*/
10-
export type AntVLibrary = 'g2' | 'g6' | 'l7' | 'x6' | 'f2' | 's2';
10+
export type AntVLibrary = 'g2' | 'g6' | 'l7' | 'x6' | 'f2' | 's2' | 'g' | 'ava' | 'adc';
1111

1212
export type AntVConfig = {
1313
id: AntVLibrary;

src/utils/context7.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ async function fetchContext7Library(url: string): Promise<string | null> {
6262
* Get the Context7 library ID corresponding to the AntV organization.
6363
*/
6464
export function getLibraryId(library: AntVLibrary): string {
65+
if (library === 'adc') return '/ant-design/ant-design-charts';
6566
return `/antvis/${library}`;
6667
}
6768

0 commit comments

Comments
 (0)