Skip to main content
Glama

search_docs

Search Vega-Lite documentation to find information about charts, encodings, marks, and visualization specifications.

Instructions

Search through Vega-Lite documentation for information about charts, encodings, marks, and more

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query (e.g., 'bar chart', 'color encoding', 'scale domain')

Implementation Reference

  • Main handler function that loads and searches documentation from JSON files (Vega-Lite and Deneb) or uses fallback data, performs fuzzy matching, sorts by relevance, and returns top 10 results.
    export async function searchDocs(query: string): Promise<SearchResult> {
      const vegaLitePath = path.join(__dirname, "..", "data", "documentation.json");
      const denebPath = path.join(__dirname, "..", "data", "deneb-documentation.json");
    
      let allDocs: DocSection[] = [];
      const sources: string[] = [];
    
      try {
        // Try to load Vega-Lite documentation
        const vegaLiteData = await fs.readFile(vegaLitePath, "utf-8");
        const vegaLiteDocs: DocSection[] = JSON.parse(vegaLiteData);
        vegaLiteDocs.forEach(doc => doc.source = 'vega-lite');
        allDocs = allDocs.concat(vegaLiteDocs);
        sources.push('vega-lite');
      } catch (error) {
        // Vega-Lite docs not available, will use fallback
      }
    
      try {
        // Try to load Deneb documentation
        const denebData = await fs.readFile(denebPath, "utf-8");
        const denebDocs: DocSection[] = JSON.parse(denebData);
        denebDocs.forEach(doc => doc.source = 'deneb');
        allDocs = allDocs.concat(denebDocs);
        sources.push('deneb');
      } catch (error) {
        // Deneb docs not available, will use fallback
      }
    
      // If no docs loaded, use fallback
      if (allDocs.length === 0) {
        return getFallbackDocs(query);
      }
    
      // Simple text search (case-insensitive)
      const lowerQuery = query.toLowerCase();
      const results = allDocs.filter((doc) => {
        return (
          doc.title.toLowerCase().includes(lowerQuery) ||
          doc.content.toLowerCase().includes(lowerQuery) ||
          doc.category.toLowerCase().includes(lowerQuery)
        );
      });
    
      // Sort by relevance (simple: title matches first, then content matches)
      results.sort((a, b) => {
        const aTitle = a.title.toLowerCase().includes(lowerQuery);
        const bTitle = b.title.toLowerCase().includes(lowerQuery);
        if (aTitle && !bTitle) return -1;
        if (!aTitle && bTitle) return 1;
        return 0;
      });
    
      return {
        results: results.slice(0, 10), // Return top 10 results
        query,
        totalResults: results.length,
        sources,
      };
    }
  • Tool schema definition including name, description, and input schema (requires 'query' string) returned by ListTools handler.
    {
      name: "search_docs",
      description: "Search through Vega-Lite documentation for information about charts, encodings, marks, and more",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "Search query (e.g., 'bar chart', 'color encoding', 'scale domain')",
          },
        },
        required: ["query"],
        additionalProperties: false,
      },
    },
  • src/index.ts:105-118 (registration)
    Dispatch handler in CallToolRequest that validates input, calls searchDocs, and formats response as JSON text content.
    case "search_docs": {
      if (!args?.query) {
        throw new Error("Query parameter is required");
      }
      const results = await searchDocs(args.query as string);
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(results, null, 2),
          },
        ],
      };
    }
  • TypeScript interface defining the output structure of the searchDocs function.
    interface SearchResult {
      results: DocSection[];
      query: string;
      totalResults: number;
      sources: string[]; // Which sources were searched
  • TypeScript interface defining the structure of individual documentation sections used in search.
    interface DocSection {
      title: string;
      url: string;
      content: string;
      category: string;
      source?: string; // 'vega-lite' or 'deneb'
    }

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other 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/inteligencianegociosmmx/vegaLite_mcp_server'

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