Skip to main content
Glama
antvis

MCP Server AntV

Official
by antvis

query_antv_document

Retrieve AntV documentation, code examples, and best practices for implementation, debugging, learning, or task handling. Supports g2, g6, l7, x6, f2, s2, g, ava, adc libraries.

Instructions

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.

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.

When to use this tool:

  • Implementation & Optimization: To implement new features, modify styles, refactor code, or optimize performance in AntV solutions.

  • Debugging & Problem Solving: For troubleshooting errors, unexpected behaviors, or technical challenges in AntV projects.

  • Learning & Best Practices: To explore official documentation, code examples, design patterns, or advanced features.

  • Complex Task Handling: For multi-step tasks requiring subtask decomposition (e.g., "Build a dashboard with interactive charts").

  • Simple modifications: Even basic changes like "Change the chart's color" or "Update legend position" in AntV context.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
intentYesExtracted user intent, provided by extract_antv_topic tool or directly extracted from simple questions.
libraryYesSpecified AntV library type, intelligently identified based on user query
queryYesUser specific question or requirement description
subTasksNoDecomposed subtask list for complex tasks, supports batch processing
tokensNotokens for returned content
topicYesTechnical topic keywords (comma-separated). Provided by `extract_antv_topic` or directly extracted from simple questions.

Implementation Reference

  • The main tool definition including name, description, schema reference, and the async run handler function that fetches AntV documentation based on query parameters, handles simple and complex (sub)tasks, generates responses with guidance.
    export const QueryAntVDocumentTool = {
      name: 'query_antv_document',
      description: `AntV Context Retrieval Assistant - Fetches relevant documentation, code examples, and best practices from official AntV resources. Supports ${Object.keys(ANTV_LIBRARY_META).join(', ')} libraries, and handles subtasks iterative queries.
    
    **MANDATORY: Must be called for ANY AntV-related query (${Object.keys(ANTV_LIBRARY_META).join(', ')}), regardless of task complexity. No exceptions for simple tasks.**
    
    When to use this tool:
    - **Implementation & Optimization**: To implement new features, modify styles, refactor code, or optimize performance in AntV solutions.
    - **Debugging & Problem Solving**: For troubleshooting errors, unexpected behaviors, or technical challenges in AntV projects.
    - **Learning & Best Practices**: To explore official documentation, code examples, design patterns, or advanced features.
    - **Complex Task Handling**: For multi-step tasks requiring subtask decomposition (e.g., "Build a dashboard with interactive charts").
    - **Simple modifications**: Even basic changes like "Change the chart's color" or "Update legend position" in AntV context.`,
      inputSchema: QueryAntVDocumentInputSchema,
      async run(args: QueryAntVDocumentArgs) {
        const startTime = Date.now();
        try {
          const libraryId = getLibraryId(args.library);
          let response: string;
          let hasDocumentation = false;
    
          if (args.subTasks && args.subTasks.length > 0) {
            // Handle complex task with subtasks
            const result = await handleComplexTask(args, libraryId, args.subTasks);
            response = result.response;
            hasDocumentation = result.hasDocumentation;
          } else {
            // Handle simple query
            const { documentation, error } = await fetchLibraryDocumentation(
              libraryId,
              args.topic,
              args.tokens,
            );
            hasDocumentation =
              documentation !== null && documentation.trim() !== '';
            response = generateSimpleResponse(args, documentation, error);
          }
    
          const processingTime = Date.now() - startTime;
          return {
            content: [{ type: 'text', text: response }],
            _meta: {
              topic: args.topic.split(',').map((t: string) => t.trim()),
              intent: args.intent,
              library: args.library,
              hasDocumentation,
              processingTime,
            },
          };
        } catch (error) {
          logger.error('Failed to execute query tool:', error);
          const processingTime = Date.now() - startTime;
    
          return {
            content: [
              {
                type: 'text',
                text: `❌ Processing failed: ${
                  error instanceof Error ? error.message : 'Unknown error'
                }`,
              },
            ],
            isError: true,
            _meta: {
              topic: args.topic ? args.topic.split(',').map((t) => t.trim()) : [],
              intent: args.intent,
              library: args.library,
              hasDocumentation: false,
              processingTime,
              error: error instanceof Error ? error.message : 'Unknown error',
            },
          };
        }
      },
    };
  • Zod input schema defining parameters: library, query, topic, intent, tokens, optional subTasks.
    const QueryAntVDocumentInputSchema = z.object({
      library: z
        .enum(Object.keys(ANTV_LIBRARY_META) as [AntVLibrary, ...AntVLibrary[]])
        .describe(
          'Specified AntV library type, intelligently identified based on user query',
        ),
      query: z
        .string()
        .min(1)
        .describe('User specific question or requirement description'),
      topic: z
        .string()
        .min(1)
        .describe(
          'Technical topic keywords (comma-separated). Provided by `extract_antv_topic` or directly extracted from simple questions.',
        ),
      intent: z
        .string()
        .min(1)
        .describe(
          'Extracted user intent, provided by extract_antv_topic tool or directly extracted from simple questions.',
        ),
      tokens: z
        .number()
        .int()
        .min(CONTEXT7_TOKENS.min)
        .max(CONTEXT7_TOKENS.max)
        .default(CONTEXT7_TOKENS.default)
        .describe('tokens for returned content'),
      subTasks: z
        .array(
          z.object({
            query: z.string().min(1).describe('Subtask query'),
            topic: z.string().min(1).describe('Subtask topic'),
          }),
        )
        .optional()
        .describe(
          'Decomposed subtask list for complex tasks, supports batch processing',
        ),
    });
  • src/index.ts:17-29 (registration)
    Registration of QueryAntVDocumentTool (and ExtractAntVTopicTool) in the MCP server using server.tool() with schema validation wrapper.
    [ExtractAntVTopicTool, QueryAntVDocumentTool].forEach((tool) => {
      const { name, description, inputSchema, run } = tool;
      this.server.tool(name, description, inputSchema.shape, (async (
        args: any,
      ) => {
        const { success, errorMessage } = validateSchema(inputSchema, args);
        if (success) {
          return await run(args);
        } else {
          throw new Error(errorMessage);
        }
      }) as any);
    });
  • Helper function for handling complex queries by processing multiple subtasks in parallel and compiling results into a comprehensive response.
      args: QueryAntVDocumentArgs,
      libraryId: string,
      subTasks: Array<{ query: string; topic: string }>,
    ): Promise<{ response: string; hasDocumentation: boolean }> {
      const libraryConfig = getLibraryConfig(args.library);
      const tokenPerSubTask = Math.min(
        Math.floor(args.tokens / subTasks.length),
        1000,
      );
    
      let response = `# ${libraryConfig.name} Complex Task Solution\n\n`;
      response += `**Question**: ${args.query}\n`;
      response += `**Complexity**: Decomposed into ${subTasks.length} subtasks\n\n---\n\n`;
    
      const subTaskPromises = subTasks.map(async (subTask, index) => {
        try {
          logger.info(
            `Processing subtask ${index + 1}/${subTasks.length}: ${subTask.topic}`,
          );
          const { documentation, error } = await fetchLibraryDocumentation(
            libraryId,
            subTask.topic,
            tokenPerSubTask,
          );
          return { task: subTask, documentation, error };
        } catch (error) {
          logger.error(`Failed to process subtask ${index + 1}:`, error);
          return {
            task: subTask,
            documentation: null,
            error: error instanceof Error ? error.message : String(error),
          };
        }
      });
    
      const results = await Promise.all(subTaskPromises);
      const hasDocumentation = results.some(
        (r) => r.documentation !== null && r.documentation.trim() !== '',
      );
    
      // Generate subtask responses
      for (const [index, result] of results.entries()) {
        response += `## 📋 Subtask ${index + 1}: ${result.task.query}\n\n`;
        response += `**Subtask Topic**: ${result.task.topic}\n\n`;
        if (result.documentation) {
          response += `${result.documentation}\n\n`;
        } else {
          response += `⚠️ No relevant documentation found for this subtask.\n`;
          if (result.error) {
            response += `Error: ${result.error}\n`;
          }
        }
        response += `---\n\n`;
      }
    
      // Add integration summary
      const successCount = results.filter((r) => r.documentation).length;
      response += `## 🎯 Integration Summary\n\n`;
    
      if (successCount === results.length) {
        response += `✅ **Complete Solution**: Found documentation for all ${successCount} subtasks.\n\n`;
        response += `**Next Steps**: Combine the solutions above into your implementation.\n\n`;
      } else if (successCount > 0) {
        response += `⚠️ **Partial Solution**: Found documentation for ${successCount}/${results.length} subtasks.\n\n`;
        response += `**Recommendations**:\n`;
        response += `- Implement features with available documentation first\n`;
        response += `- For missing parts, check official examples or community resources\n\n`;
      } else {
        response += `❌ **Limited Results**: No documentation found for the subtasks.\n\n`;
        response += `**Suggestions**:\n`;
        response += `- Try refining the query with more specific keywords\n`;
        response += `- Check the official ${libraryConfig.name} documentation directly\n\n`;
      }
    
      response += generateImplementationGuidance(args.intent, args.library);
      response += generateFollowUpNotice();
    
      return { response, hasDocumentation };
    }
  • Helper function to generate response for simple (non-subtask) queries.
      args: QueryAntVDocumentArgs,
      documentation: string | null,
      error?: string,
    ): string {
      const libraryConfig = getLibraryConfig(args.library);
    
      if (!documentation) {
        return (
          `# ${libraryConfig.name} Query Result\n\n` +
          `**Question**: ${args.query}\n\n` +
          `❌ **No Documentation Found**\n\n` +
          `${error ? `Error: ${error}\n\n` : ''}` +
          `**Suggestions**:\n` +
          `- Try refining your search terms\n` +
          `- Check the official ${libraryConfig.name} documentation\n` +
          `- Ensure you're using the correct library for your use case\n\n` +
          generateFollowUpNotice()
        );
      }
    
      let response = `# ${libraryConfig.name} Solution\n\n`;
      response += `**User Question**: ${args.query}\n`;
      response += `**Search Topic**: ${args.topic}\n`;
      response += `${documentation}\n\n`;
      response += generateImplementationGuidance(args.intent, args.library);
      response += generateFollowUpNotice();
    
      return response;
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and delivers substantial behavioral context. It discloses the tool's scope (supports 9 specific libraries), capability (handles subtasks iterative queries), and mandatory nature. However, it doesn't mention rate limits, authentication needs, or potential side effects, leaving some behavioral aspects unspecified.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately front-loaded with the core purpose, but contains some redundancy (repeating the library list and emphasizing mandatory usage multiple times). The bulleted usage guidelines are well-structured but could be more concise. Overall, it's comprehensive but could benefit from tighter editing.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (6 parameters, no annotations, no output schema), the description provides substantial context about when and how to use it, its scope, and relationship with sibling tools. However, it doesn't describe what the tool returns (format, structure, or content), which is a significant gap since there's no output schema to compensate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the baseline is 3. The description adds some context by mentioning 'supports subtasks iterative queries' which relates to the 'subTasks' parameter, and references 'extract_antv_topic' for parameter extraction, but doesn't provide significant additional parameter semantics beyond what's already documented in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('fetches relevant documentation, code examples, and best practices') and resources ('from official AntV resources'). It explicitly distinguishes from its sibling tool 'extract_antv_topic' by mentioning it as a source for parameters, establishing a clear functional relationship.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit, comprehensive usage guidelines with a mandatory directive ('Must be called for ANY AntV-related query') and detailed when-to-use scenarios across five categories (implementation, debugging, learning, complex tasks, simple modifications). It clearly distinguishes from alternatives by making this the required tool for all AntV contexts.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/antvis/mcp-server-antv'

If you have feedback or need assistance with the MCP directory API, please join our Discord server