Skip to main content
Glama

validate_prompt

Check if provided parameters match a prompt template's requirements before rendering to ensure compatibility and prevent errors.

Instructions

Validate parameters against a prompt template without rendering

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
templateIdYesThe ID of the template
parametersYesParameters to validate

Implementation Reference

  • Core implementation of prompt parameter validation: checks template existence, required parameters using helper, and type validation for each parameter.
    validate(
      templateId: string,
      params: Record<string, unknown>
    ): { valid: boolean; errors: string[] } {
      const template = this.get(templateId);
      if (!template) {
        return { valid: false, errors: [`Template not found: ${templateId}`] };
      }
    
      const paramValidation = validateParameters(template, params);
      if (!paramValidation.valid) {
        return {
          valid: false,
          errors: [`Missing required parameters: ${paramValidation.missing.join(", ")}`],
        };
      }
    
      // Type validation
      const errors: string[] = [];
      for (const param of template.parameters) {
        const value = params[param.name];
        if (value !== undefined && !this.validateType(value, param.type)) {
          errors.push(
            `Parameter '${param.name}' should be type '${param.type}', got '${typeof value}'`
          );
        }
      }
    
      return {
        valid: errors.length === 0,
        errors,
      };
    }
  • MCP tool registration for 'validate_prompt', defining input schema with Zod and thin handler delegating to PromptManager.validate.
    server.tool(
      "validate_prompt",
      "Validate parameters against a prompt template without rendering",
      {
        templateId: z.string().describe("The ID of the template"),
        parameters: z.record(z.any()).describe("Parameters to validate"),
      },
      async (args) => {
        const validation = registry.prompts.validate(args.templateId, args.parameters);
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(validation, null, 2),
            },
          ],
        };
      }
    );
  • Helper function to check for missing required parameters in prompt templates.
    function validateParameters(
      template: PromptTemplate,
      params: Record<string, unknown>
    ): { valid: boolean; missing: string[] } {
      const required = template.parameters.filter((p) => p.required);
      const missing = required.filter((p) => !(p.name in params));
      return {
        valid: missing.length === 0,
        missing: missing.map((p) => p.name),
      };
    }
  • Private helper to validate parameter types (string, number, boolean, array, object).
    private validateType(value: unknown, expectedType: string): boolean {
      switch (expectedType) {
        case "string":
          return typeof value === "string";
        case "number":
          return typeof value === "number";
        case "boolean":
          return typeof value === "boolean";
        case "array":
          return Array.isArray(value);
        case "object":
          return typeof value === "object" && value !== null && !Array.isArray(value);
        default:
          return true;
      }
    }
  • Zod input schema for the validate_prompt tool: templateId (string), parameters (record).
    {
      templateId: z.string().describe("The ID of the template"),
      parameters: z.record(z.any()).describe("Parameters to validate"),
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool validates parameters but doesn't describe what validation entails (e.g., checking required fields, data types, constraints), what happens on success/failure (e.g., returns validation errors, boolean result), or any side effects (e.g., whether it modifies data). For a validation tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 that front-loads the core purpose ('Validate parameters against a prompt template') and adds a key constraint ('without rendering'). There is no wasted wording, and it directly communicates the tool's function in a structured manner.

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

Completeness2/5

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

Given the tool's complexity (validation with 2 parameters, no output schema, and no annotations), the description is insufficient. It lacks details on validation behavior, output format (e.g., what is returned on success/error), and how it integrates with sibling tools like 'render_prompt'. Without annotations or output schema, the description should provide more context to be complete for effective agent use.

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%, with clear descriptions for both parameters: 'templateId' as 'The ID of the template' and 'parameters' as 'Parameters to validate'. The description adds no additional semantic context beyond what the schema provides, such as explaining parameter formats or validation rules. With high schema coverage, the baseline score of 3 is appropriate as the schema adequately documents parameters.

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 parameters against a prompt template without rendering'. It specifies the verb ('validate') and resource ('parameters against a prompt template'), and distinguishes it from 'render_prompt' by emphasizing 'without rendering'. However, it doesn't explicitly differentiate from other sibling tools like 'get_prompt' or 'search_prompts' beyond the validation aspect.

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 by contrasting with 'render_prompt' through 'without rendering', suggesting this tool is for validation prior to rendering. However, it doesn't provide explicit guidance on when to use this versus alternatives like 'get_prompt' for template inspection, or mention prerequisites such as needing a valid template ID. The context is implied but not comprehensive.

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/ishuru/open-mcp'

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