Skip to main content
Glama

aes_decrypt

Decrypt AES-encrypted text using specified keys, modes, and padding formats to restore original data securely.

Instructions

decrypt text with aes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYestext to encrypt and decrypt
keyNodecrypt key, default is your-key-0123456
paddingNopadding mode, default is Pkcs7Pkcs7
inputFormatNoinput format, default is base64base64
ivNoiv, default is your-iv-01234567
modeNomode, default is ECBECB

Implementation Reference

  • The handler function that implements the logic for the 'aes_decrypt' tool. It selects the appropriate AES decryption method based on the 'mode' parameter and returns the decrypted text.
      async ({ content, key, padding, inputFormat, iv, mode }) => {
        let result = "";
        if (mode === "ECB") {
          result = AESUtil.decryptECB(content, key ?? "your-key-0123456");
        } else if (mode === "CBC") {
          result = AESUtil.decryptCBC(
            content,
            key ?? "your-key-0123456",
            iv ?? "your-iv-01234567",
            (padding ?? "Pkcs7") as PaddingMode,
            (inputFormat ?? "base64") as OutputFormat
          );
        } else if (mode === "CFB") {
          result = AESUtil.decryptCFB(
            content,
            key ?? "your-key-0123456",
            iv ?? "your-iv-01234567",
            (padding ?? "Pkcs7") as PaddingMode,
            (inputFormat ?? "base64") as OutputFormat
          );
        } else if (mode === "OFB") {
          result = AESUtil.decryptOFB(
            content,
            key ?? "your-key-0123456",
            iv ?? "your-iv-01234567",
            (padding ?? "Pkcs7") as PaddingMode,
            (inputFormat ?? "base64") as OutputFormat
          );
        } else if (mode === "CTR") {
          result = AESUtil.decryptCTR(
            content,
            key ?? "your-key-0123456",
            iv ?? "your-iv-01234567",
            (padding ?? "Pkcs7") as PaddingMode,
            (inputFormat ?? "base64") as OutputFormat
          );
        }
        return {
          content: [
            {
              type: "text",
              text: result,
            },
          ],
        };
      }
    );
  • Zod schema defining the input parameters for the 'aes_decrypt' tool, including content, key, padding, inputFormat, iv, and mode with descriptions and defaults.
    {
      content: z.string().describe("text to encrypt and decrypt"),
      key: z
        .string()
        .optional()
        .describe("decrypt key, default is your-key-0123456"),
      padding: z
        .enum([
          "Pkcs7",
          "Iso97971",
          "AnsiX923",
          "Iso10126",
          "ZeroPadding",
          "NoPadding",
        ])
        .optional()
        .describe("padding mode, default is Pkcs7")
        .default("Pkcs7"),
      inputFormat: z
        .enum(["base64", "hex"])
        .optional()
        .describe("input format, default is base64")
        .default("base64"),
      iv: z.string().optional().describe("iv, default is your-iv-01234567"),
      mode: z
        .enum(["ECB", "CBC", "CFB", "OFB", "CTR"])
        .optional()
        .describe("mode, default is ECB")
        .default("ECB"),
    },
  • The MCP server.tool registration call for the 'aes_decrypt' tool within the registerAESTool function.
    server.tool(
      "aes_decrypt",
      "decrypt text with aes",
      {
        content: z.string().describe("text to encrypt and decrypt"),
        key: z
          .string()
          .optional()
          .describe("decrypt key, default is your-key-0123456"),
        padding: z
          .enum([
            "Pkcs7",
            "Iso97971",
            "AnsiX923",
            "Iso10126",
            "ZeroPadding",
            "NoPadding",
          ])
          .optional()
          .describe("padding mode, default is Pkcs7")
          .default("Pkcs7"),
        inputFormat: z
          .enum(["base64", "hex"])
          .optional()
          .describe("input format, default is base64")
          .default("base64"),
        iv: z.string().optional().describe("iv, default is your-iv-01234567"),
        mode: z
          .enum(["ECB", "CBC", "CFB", "OFB", "CTR"])
          .optional()
          .describe("mode, default is ECB")
          .default("ECB"),
      },
      async ({ content, key, padding, inputFormat, iv, mode }) => {
        let result = "";
        if (mode === "ECB") {
          result = AESUtil.decryptECB(content, key ?? "your-key-0123456");
        } else if (mode === "CBC") {
          result = AESUtil.decryptCBC(
            content,
            key ?? "your-key-0123456",
            iv ?? "your-iv-01234567",
            (padding ?? "Pkcs7") as PaddingMode,
            (inputFormat ?? "base64") as OutputFormat
          );
        } else if (mode === "CFB") {
          result = AESUtil.decryptCFB(
            content,
            key ?? "your-key-0123456",
            iv ?? "your-iv-01234567",
            (padding ?? "Pkcs7") as PaddingMode,
            (inputFormat ?? "base64") as OutputFormat
          );
        } else if (mode === "OFB") {
          result = AESUtil.decryptOFB(
            content,
            key ?? "your-key-0123456",
            iv ?? "your-iv-01234567",
            (padding ?? "Pkcs7") as PaddingMode,
            (inputFormat ?? "base64") as OutputFormat
          );
        } else if (mode === "CTR") {
          result = AESUtil.decryptCTR(
            content,
            key ?? "your-key-0123456",
            iv ?? "your-iv-01234567",
            (padding ?? "Pkcs7") as PaddingMode,
            (inputFormat ?? "base64") as OutputFormat
          );
        }
        return {
          content: [
            {
              type: "text",
              text: result,
            },
          ],
        };
      }
    );
  • src/index.ts:15-15 (registration)
    Top-level registration of AES tools (including aes_decrypt) by calling registerAESTool on the MCP server.
    registerAESTool(server);
  • Helper function for AES ECB mode decryption, used by the aes_decrypt handler.
    static decryptECB(
      ciphertext: string,
      key: string,
      padding: PaddingMode = "Pkcs7",
      inputFormat: OutputFormat = "base64"
    ): string {
      const keyHex = CryptoJS.enc.Utf8.parse(key);
      let decrypted;
    
      if (inputFormat === "hex") {
        const ciphertextHex = CryptoJS.enc.Hex.parse(ciphertext);
        const ciphertextParams = CryptoJS.lib.CipherParams.create({
          ciphertext: ciphertextHex,
        });
        decrypted = CryptoJS.AES.decrypt(ciphertextParams, keyHex, {
          mode: CryptoJS.mode.ECB,
          padding: CryptoJS.pad[padding],
        });
      } else {
        decrypted = CryptoJS.AES.decrypt(ciphertext, keyHex, {
          mode: CryptoJS.mode.ECB,
          padding: CryptoJS.pad[padding],
        });
      }
    
      return decrypted.toString(CryptoJS.enc.Utf8);
    }
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 decrypts text with AES but fails to describe key behavioral traits such as required permissions, error handling (e.g., for invalid keys or formats), performance characteristics, or what the output looks like (e.g., plaintext format). This is a significant gap for a cryptographic tool with no annotation coverage.

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 with a single sentence ('decrypt text with aes'), which is front-loaded and wastes no words. It efficiently communicates the core purpose without unnecessary elaboration, making it easy to parse quickly.

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 of a cryptographic decryption tool with 6 parameters, no annotations, and no output schema, the description is incomplete. It lacks essential context such as output format (e.g., plaintext string), error conditions, security implications, or dependencies on sibling tools like 'aes_encrypt'. This inadequacy could hinder an AI agent's ability to use the tool correctly.

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 all parameters (content, key, padding, inputFormat, iv, mode) with descriptions and defaults. The description adds no meaning beyond what the schema provides, merely restating the tool's function without elaborating on parameter roles or interactions. Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose3/5

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

The description 'decrypt text with aes' clearly states the verb (decrypt) and resource (text) but is vague about the specific cryptographic operation. It distinguishes from siblings like 'aes_encrypt' by indicating decryption rather than encryption, but lacks detail about what AES (Advanced Encryption Standard) entails or the scope of decryption.

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?

No explicit guidance on when to use this tool versus alternatives is provided. The description does not mention prerequisites (e.g., needing encrypted input), exclusions, or comparisons to siblings like 'des_decrypt' or encoding tools. Usage is implied only by the tool name and basic function.

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/1595901624/crypto-mcp'

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