Skip to main content
Glama
keywaysh

Keyway MCP Server

by keywaysh

keyway_validate

Validate required secrets exist in a specified environment for pre-deployment checks. Use auto-detection to scan codebases or manually list secrets to verify availability.

Instructions

Validate that required secrets exist in an environment. Useful for pre-deployment checks.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
environmentYesEnvironment to validate (e.g., "production")
requiredNoList of required secret names to check
autoDetectNoAuto-detect required secrets from codebase (default: false)
pathNoPath to scan for auto-detection (default: current directory)

Implementation Reference

  • The `validate` function implements the core logic for the 'keyway_validate' tool, which scans for environment variable references and checks if they exist in a repository environment.
    export async function validate(args: ValidateArgs): Promise<CallToolResult> {
      const { environment, required = [], autoDetect = false, path = process.cwd() } = args;
    
      if (!environment) {
        return {
          content: [{ type: 'text', text: 'Error: Environment is required' }],
          isError: true,
        };
      }
    
      try {
        const token = await getToken();
        const repository = getRepository();
    
        // Get required secrets list
        let requiredSecrets: string[] = [...required];
    
        // Auto-detect from codebase if requested
        if (autoDetect) {
          const detected = scanDirectoryForEnvVars(path);
          const filtered = filterNonSecrets(detected);
          requiredSecrets = [...new Set([...requiredSecrets, ...filtered])];
        }
    
        if (requiredSecrets.length === 0) {
          return {
            content: [
              {
                type: 'text',
                text: 'Error: No required secrets specified. Provide a "required" array or set "autoDetect: true"',
              },
            ],
            isError: true,
          };
        }
    
        // Pull existing secrets
        let existingSecrets: Record<string, string> = {};
        try {
          const content = await pullSecrets(repository, environment, token);
          existingSecrets = parseEnvContent(content);
        } catch {
          // Environment might not exist
        }
    
        const existingKeys = new Set(Object.keys(existingSecrets));
    
        // Categorize secrets
        const missing: string[] = [];
        const present: string[] = [];
    
        for (const secret of requiredSecrets) {
          if (existingKeys.has(secret)) {
            present.push(secret);
          } else {
            missing.push(secret);
          }
        }
    
        // Find extra secrets (in vault but not required)
        const requiredSet = new Set(requiredSecrets);
        const extra = Array.from(existingKeys)
          .filter((k) => !requiredSet.has(k))
          .sort();
    
        const coverage =
          requiredSecrets.length > 0
            ? ((present.length / requiredSecrets.length) * 100).toFixed(1)
            : '100.0';
    
        const result: ValidationResult = {
          valid: missing.length === 0,
          environment,
          repository,
          required: requiredSecrets.sort(),
          missing: missing.sort(),
          present: present.sort(),
          extra,
          stats: {
            requiredCount: requiredSecrets.length,
            presentCount: present.length,
            missingCount: missing.length,
            coverage: `${coverage}%`,
          },
        };
    
        // Add helpful message
        let message: string;
        if (result.valid) {
          message = `✓ All ${requiredSecrets.length} required secrets are present in "${environment}"`;
        } else {
          message = `✗ Missing ${missing.length} required secret${missing.length > 1 ? 's' : ''} in "${environment}": ${missing.join(', ')}`;
        }
    
        const response = {
          ...result,
          message,
        };
    
        return {
          content: [{ type: 'text', text: JSON.stringify(response, null, 2) }],
          isError: false,
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : 'Unknown error';
        return {
          content: [{ type: 'text', text: `Error validating secrets: ${errorMessage}` }],
          isError: true,
        };
      }
    }
  • Schema definition for the arguments expected by the 'keyway_validate' tool.
    interface ValidateArgs {
      environment: string;
      required?: string[];
      autoDetect?: boolean;
      path?: string;
    }
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 mentions validation and pre-deployment checks, but doesn't describe what happens during validation (e.g., whether it returns a list of missing secrets, throws errors, or logs results), permissions needed, rate limits, or side effects. This is a significant gap for a tool that likely interacts with sensitive data like secrets.

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 very concise and front-loaded: two sentences that directly state the purpose and usage. There is no wasted text, and every sentence adds value by explaining what the tool does and when it's useful, making it efficient and well-structured.

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 complexity (validating secrets, which is a sensitive operation), no annotations, and no output schema, the description is incomplete. It doesn't explain the return values, error handling, or behavioral details needed for safe and effective use. The description alone is insufficient for an agent to fully understand how to invoke and interpret results from this tool.

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 schema description coverage is 100%, meaning all parameters are documented in the schema. The description adds no specific parameter semantics beyond the general purpose, so it relies entirely on the schema. According to the rules, with high schema coverage (>80%), the baseline is 3 even with no param info in the description, which applies here.

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 that required secrets exist in an environment.' It specifies the verb ('validate') and resource ('required secrets'), and distinguishes it from siblings like keyway_list_secrets or keyway_set_secret by focusing on validation. However, it doesn't explicitly differentiate from keyway_scan or keyway_diff, which might also involve checking secrets, so it's not a perfect 5.

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 provides some usage context: 'Useful for pre-deployment checks.' This implies when to use it (before deployment) but doesn't explicitly state when not to use it or name alternatives among siblings. For example, it doesn't clarify if this should be used instead of keyway_scan for validation purposes, leaving some ambiguity.

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/keywaysh/keyway-mcp'

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