Skip to main content
Glama

search_docs

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

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

  • The main handler function `searchDocs` that loads documentation from JSON files, performs text search, sorts results by relevance, and returns top 10 matches or fallback data.
    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, }; }
  • Input schema for the `search_docs` tool defining the required `query` string parameter.
    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:32-46 (registration)
    Registration of the `search_docs` tool in the ListToolsRequestSchema handler, including name, description, and input schema.
    { 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 logic in the CallToolRequestSchema handler that validates input, calls `searchDocs`, and formats the response as 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), }, ], }; }
  • Type definitions for DocSection and SearchResult used by the search_docs handler.
    interface DocSection { title: string; url: string; content: string; category: string; source?: string; // 'vega-lite' or 'deneb' } interface SearchResult { results: DocSection[]; query: string; totalResults: number; sources: string[]; // Which sources were searched } /** * Search through Vega-Lite and Deneb documentation */ 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, }; }

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