Skip to main content
Glama

validate_schema

Validate JSON-LD schemas by checking required fields, proper @context, valid @type, and identifying common issues to ensure schema compliance.

Instructions

Validate an existing JSON-LD schema. Checks for required fields, proper @context, valid @type, and common issues.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
jsonYesJSON-LD string to validate

Implementation Reference

  • The 'validateSchema' function implements the validation logic for the 'validate_schema' tool, checking for JSON format, '@context', '@type', and type-specific fields.
    function validateSchema(jsonString: string): {
      valid: boolean;
      errors: string[];
      warnings: string[];
    } {
      const errors: string[] = [];
      const warnings: string[] = [];
    
      let parsed: unknown;
      try {
        parsed = JSON.parse(jsonString);
      } catch {
        return {
          valid: false,
          errors: ["Invalid JSON: unable to parse the provided string"],
          warnings: [],
        };
      }
    
      if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
        return {
          valid: false,
          errors: ["JSON-LD must be a JSON object (not an array or primitive)"],
          warnings: [],
        };
      }
    
      const schema = parsed as Record<string, unknown>;
    
      if (!schema["@context"]) {
        errors.push('Missing required field: @context (should be "https://schema.org")');
      } else if (schema["@context"] !== "https://schema.org") {
        warnings.push(
          `@context is "${schema["@context"]}" — recommended value is "https://schema.org"`
        );
      }
    
      if (!schema["@type"]) {
        errors.push("Missing required field: @type");
      } else {
        const type = schema["@type"] as string;
        const supportedTypes = Object.keys(SCHEMA_TYPES);
        if (!supportedTypes.includes(type)) {
          warnings.push(
            `@type "${type}" is not in the commonly supported types: ${supportedTypes.join(", ")}`
          );
        }
    
        // Type-specific required field checks
        if (type === "Person" && !schema.name) {
          errors.push("Person schema requires a 'name' field");
        }
  • Registration of the 'validate_schema' tool, which wraps the 'validateSchema' handler function and takes 'json' as an input parameter.
    server.tool(
      "validate_schema",
      "Validate an existing JSON-LD schema. Checks for required fields, proper @context, valid @type, and common issues.",
      {
        json: z
          .string()
          .describe("JSON-LD string to validate"),
      },
      async ({ json }) => {
        const result = validateSchema(json);
Behavior2/5

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

With no annotations provided, the description carries full burden. It mentions what the tool checks but doesn't disclose behavioral traits like whether validation is read-only, what happens on failure (e.g., error details), or performance considerations. It adds some context but lacks critical operational details.

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 appropriately sized and front-loaded: one clear sentence stating the purpose and specific checks. Every word earns its place with zero waste or redundancy.

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?

Given no annotations and no output schema, the description is minimally adequate for a simple validation tool but lacks details on return values, error handling, or validation scope. It covers the basics but leaves gaps in operational context.

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?

Schema description coverage is 100%, so the schema already documents the 'json' parameter. The description adds no additional parameter semantics beyond what the schema provides (e.g., format expectations, examples). Baseline 3 is appropriate when schema does the heavy lifting.

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 tool's purpose: 'Validate an existing JSON-LD schema' with specific checks listed (required fields, @context, @type, common issues). It distinguishes from sibling tools (which generate schemas) by focusing on validation, though it doesn't explicitly name alternatives.

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

Usage Guidelines3/5

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

The description implies usage context (validating JSON-LD schemas) but doesn't provide explicit guidance on when to use this vs. alternatives like generate_schema or list_schema_types. No prerequisites or exclusions are mentioned.

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/sharozdawa/schema-gen'

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