Skip to main content
Glama

get_example

Retrieve Vega-Lite visualization examples by category or search term to help users find and implement chart specifications for data visualization projects.

Instructions

Retrieve Vega-Lite example specifications by category or type

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYesExample category (e.g., 'bar', 'line', 'scatter', 'area', 'histogram', 'heatmap', 'interactive')
searchNoOptional search term to filter examples within the category

Implementation Reference

  • The primary handler function for the 'get_example' tool. It loads Vega-Lite examples from a JSON file (if exists), filters by category and optional search term, or falls back to predefined examples.
    export async function getExample(
      category: string,
      search?: string
    ): Promise<ExampleResult> {
      const dataPath = path.join(__dirname, "..", "data", "examples.json");
    
      try {
        // Try to load examples data
        const data = await fs.readFile(dataPath, "utf-8");
        const allExamples: VegaLiteExample[] = JSON.parse(data);
    
        // Filter by category
        let examples = allExamples.filter(
          (ex) => ex.category.toLowerCase() === category.toLowerCase()
        );
    
        // Apply search filter if provided
        if (search) {
          const lowerSearch = search.toLowerCase();
          examples = examples.filter(
            (ex) =>
              ex.name.toLowerCase().includes(lowerSearch) ||
              ex.description.toLowerCase().includes(lowerSearch)
          );
        }
    
        return {
          category,
          examples,
          totalExamples: examples.length,
        };
      } catch (error) {
        // If examples data doesn't exist yet, return fallback examples
        if (error instanceof Error && "code" in error && (error as any).code === "ENOENT") {
          return getFallbackExamples(category);
        }
        throw error;
      }
    }
  • Input schema definition for the 'get_example' tool, defining the expected parameters: required 'category' string and optional 'search' string.
    inputSchema: {
      type: "object",
      properties: {
        category: {
          type: "string",
          description: "Example category (e.g., 'bar', 'line', 'scatter', 'area', 'histogram', 'heatmap', 'interactive')",
        },
        search: {
          type: "string",
          description: "Optional search term to filter examples within the category",
        },
      },
      required: ["category"],
      additionalProperties: false,
    },
  • src/index.ts:47-65 (registration)
    Registration of the 'get_example' tool in the ListToolsRequestSchema handler, providing name, description, and input schema.
    {
      name: "get_example",
      description: "Retrieve Vega-Lite example specifications by category or type",
      inputSchema: {
        type: "object",
        properties: {
          category: {
            type: "string",
            description: "Example category (e.g., 'bar', 'line', 'scatter', 'area', 'histogram', 'heatmap', 'interactive')",
          },
          search: {
            type: "string",
            description: "Optional search term to filter examples within the category",
          },
        },
        required: ["category"],
        additionalProperties: false,
      },
    },
  • src/index.ts:120-136 (registration)
    Dispatch handler in CallToolRequestSchema that validates input, calls the getExample function, and formats the response as MCP content.
    case "get_example": {
      if (!args?.category) {
        throw new Error("Category parameter is required");
      }
      const examples = await getExample(
        args.category as string,
        args.search as string | undefined
      );
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(examples, null, 2),
          },
        ],
      };
    }
  • TypeScript interfaces defining the structure of individual examples (VegaLiteExample) and the function return type (ExampleResult).
    interface VegaLiteExample {
      name: string;
      description: string;
      category: string;
      spec: Record<string, unknown>;
      url: string;
    }
    
    interface ExampleResult {
      category: string;
      examples: VegaLiteExample[];
      totalExamples: number;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic operation. It doesn't disclose important behavioral traits like whether this is a read-only operation, if it requires authentication, rate limits, what format the examples are returned in, or how many examples might be retrieved. The description is minimal and lacks operational context.

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

Conciseness5/5

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

The description is a single, efficient sentence with zero wasted words. It's appropriately sized for a simple retrieval tool and front-loads the core purpose immediately.

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

Completeness3/5

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

For a simple 2-parameter retrieval tool with no output schema, the description is minimally complete but lacks important context. It doesn't explain what format the examples are returned in, whether this is a filtered list or single example, or how results are structured. The absence of annotations means more behavioral disclosure would be helpful.

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?

The description mentions parameters ('by category or type') but doesn't add meaningful semantics beyond what the 100% schema coverage already provides. The schema fully documents both parameters with clear descriptions and examples, so the description's minimal parameter mention doesn't add value, meeting the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the verb ('Retrieve') and resource ('Vega-Lite example specifications'), making the purpose unambiguous. However, it doesn't differentiate this tool from its siblings (get_schema_info, search_docs, validate_spec) which handle different types of Vega-Lite-related operations.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus its siblings. It doesn't mention alternatives like search_docs for documentation or validate_spec for validation, nor does it specify when this retrieval tool is appropriate versus other options.

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

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