Skip to main content
Glama
tarnover
by tarnover

vault_encrypt_string

Encrypt sensitive strings securely using Ansible Vault; specify the string, vault ID, and password file to generate encrypted output for secure storage or usage.

Instructions

Encrypt a string using Ansible Vault

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameNo
stringYes
vault_idNo
vault_password_fileNo

Implementation Reference

  • Handler function that spawns ansible-vault encrypt_string process, pipes the input string to stdin, and returns the encrypted output.
    export async function encryptString(options: VaultEncryptStringOptions): Promise<string> {
      return new Promise((resolve, reject) => {
        const args = ['encrypt_string'];
        
        // Add vault ID if specified
        if (options.vault_id) {
          args.push(`--vault-id=${options.vault_id}`);
        }
        
        // Add vault password file if specified
        if (options.vault_password_file) {
          args.push(`--vault-password-file=${options.vault_password_file}`);
        }
        
        // Add name if specified
        if (options.name) {
          args.push(`--name=${options.name}`);
        }
        
        // Add --stdin flag to read from stdin
        args.push('--stdin');
    
        console.error(`Executing: ansible-vault ${args.join(' ')} (with string piped to stdin)`);
        const vaultProcess = spawn('ansible-vault', args, { stdio: ['pipe', 'pipe', 'pipe'] });
    
        let stdoutData = '';
        let stderrData = '';
    
        vaultProcess.stdout.on('data', (data) => {
          stdoutData += data.toString();
        });
    
        vaultProcess.stderr.on('data', (data) => {
          stderrData += data.toString();
        });
    
        vaultProcess.on('close', (code) => {
          if (code === 0) {
            resolve(stdoutData.trim());
          } else {
            const errorMessage = stderrData || `ansible-vault exited with code ${code}`;
            reject(new AnsibleExecutionError(`Error encrypting string: ${errorMessage}`, stderrData));
          }
        });
    
        vaultProcess.on('error', (err) => {
          reject(new AnsibleExecutionError(`Failed to start ansible-vault: ${err.message}`));
        });
    
        // Write the string to encrypt to stdin
        vaultProcess.stdin.write(options.string);
        vaultProcess.stdin.end();
      });
    }
  • Zod schema defining input parameters for the vault_encrypt_string tool: string to encrypt, optional vault_id, vault_password_file, and name.
    export const VaultEncryptStringSchema = z.object({
      string: z.string().min(1, 'String to encrypt is required'),
      vault_id: z.string().optional(),
      vault_password_file: z.string().optional(),
      name: z.string().optional(),
    });
    
    export type VaultEncryptStringOptions = z.infer<typeof VaultEncryptStringSchema>;
  • Registration of the 'vault_encrypt_string' tool in the toolDefinitions map, linking schema and handler.
    vault_encrypt_string: {
      description: 'Encrypt a string using Ansible Vault',
      schema: VaultEncryptStringSchema,
      handler: vault.encryptString,
    },
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'encrypt' implies a write/mutation operation, the description doesn't disclose important behavioral traits: whether this requires specific permissions, what happens to the original unencrypted string, whether the encryption is reversible only via the sibling tool, what format the output takes, or any rate limits. It mentions the technology (Ansible Vault) but not how it behaves.

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 extremely concise at just 6 words, with zero wasted language. Every word earns its place: 'Encrypt' specifies the action, 'a string' specifies the target, and 'using Ansible Vault' specifies the technology. It's perfectly front-loaded with the core purpose.

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 a 4-parameter tool with no annotations, 0% schema description coverage, and no output schema, the description is inadequate. For an encryption tool that presumably produces important output, the description should explain what the tool returns, what the parameters mean, and any behavioral constraints. The current description leaves too many unanswered questions for effective tool selection and invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage and 4 parameters (only 1 required), the description provides no information about any parameters. It doesn't explain what 'name', 'vault_id', or 'vault_password_file' mean, nor does it clarify the semantics of the required 'string' parameter. The description fails to compensate for the complete lack of schema documentation.

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 action ('encrypt') and target resource ('a string using Ansible Vault'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from its sibling 'vault_decrypt_string' beyond the obvious encryption vs. decryption difference, nor does it explain what makes this tool unique among other encryption-related tools that might exist.

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 alternatives. There's no mention of prerequisites (like needing Ansible Vault configured), when encryption is appropriate, or what scenarios warrant using this specific tool over other encryption methods. The sibling tool 'vault_decrypt_string' is clearly related, but no explicit comparison is provided.

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

Related 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/tarnover/mcp-ansible'

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