Skip to main content
Glama

aes_encrypt

Encrypt text using AES algorithm with customizable cipher mode, padding scheme, key, initialization vector, and output format (base64 or hex) for flexible data security.

Instructions

encrypt text with aes

Input Schema

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

Implementation Reference

  • Registration of the 'aes_encrypt' MCP tool. Calls server.tool('aes_encrypt', ...) with the schema definition and handler.
    export function registerAESTool(server: McpServer) {
      // AES Encrypt
      server.tool(
        "aes_encrypt",
        "encrypt text with aes",
        {
          content: z.string().describe("text to encrypt and decrypt"),
          key: z
            .string()
            .optional()
            .describe("encrypt key, default is your-key-0123456"),
          padding: z
            .enum([
              "Pkcs7",
              "Iso97971",
              "AnsiX923",
              "Iso10126",
              "ZeroPadding",
              "NoPadding",
            ])
            .optional()
            .describe("padding mode, default is Pkcs7")
            .default("Pkcs7"),
          outputFormat: z
            .enum(["base64", "hex"])
            .optional()
            .describe("output format, default is base64")
            .default("base64"),
          iv: z
            .string()
            .optional()
            .describe("iv, default is your-iv-01234567")
            .default("your-iv-01234567"),
          mode: z
            .string()
            .optional()
            .describe("mode, default is ECB")
            .default("ECB"),
        },
        async ({ content, key, padding, outputFormat, iv, mode }) => {
          let result = "";
          if (mode === "ECB") {
            result = AESUtil.encryptECB(
              content,
              key ?? "your-key-0123456",
              (padding ?? "Pkcs7") as PaddingMode,
              (outputFormat ?? "base64") as OutputFormat
            );
          } else if (mode === "CBC") {
            result = AESUtil.encryptCBC(
              content,
              key ?? "your-key-0123456",
              iv ?? "your-iv-01234567",
              (padding ?? "Pkcs7") as PaddingMode,
              (outputFormat ?? "base64") as OutputFormat
            );
          } else if (mode === "CFB") {
            result = AESUtil.encryptCFB(
              content,
              key ?? "your-key-0123456",
              iv ?? "your-iv-01234567",
              (padding ?? "Pkcs7") as PaddingMode,
              (outputFormat ?? "base64") as OutputFormat
            );
          } else if (mode === "OFB") {
            result = AESUtil.encryptOFB(
              content,
              key ?? "your-key-0123456",
              iv ?? "your-iv-01234567",
              (padding ?? "Pkcs7") as PaddingMode,
              (outputFormat ?? "base64") as OutputFormat
            );
          } else if (mode === "CTR") {
            result = AESUtil.encryptCTR(
              content,
              key ?? "your-key-0123456",
              iv ?? "your-iv-01234567",
              (padding ?? "Pkcs7") as PaddingMode,
              (outputFormat ?? "base64") as OutputFormat
            );
          } else {
            throw new McpError(ErrorCode.InvalidParams, "Unknown mode");
          }
          return {
            content: [
              {
                type: "text",
                text: result,
              },
            ],
          };
        }
      );
  • Input schema for aes_encrypt tool, defining content, key, padding, outputFormat, iv, and mode parameters using Zod.
    {
      content: z.string().describe("text to encrypt and decrypt"),
      key: z
        .string()
        .optional()
        .describe("encrypt key, default is your-key-0123456"),
      padding: z
        .enum([
          "Pkcs7",
          "Iso97971",
          "AnsiX923",
          "Iso10126",
          "ZeroPadding",
          "NoPadding",
        ])
        .optional()
        .describe("padding mode, default is Pkcs7")
        .default("Pkcs7"),
      outputFormat: z
        .enum(["base64", "hex"])
        .optional()
        .describe("output format, default is base64")
        .default("base64"),
      iv: z
        .string()
        .optional()
        .describe("iv, default is your-iv-01234567")
        .default("your-iv-01234567"),
      mode: z
        .string()
        .optional()
        .describe("mode, default is ECB")
        .default("ECB"),
    },
  • Handler function for aes_encrypt. Dispatches to the appropriate AESUtil encryption method based on the mode parameter (ECB, CBC, CFB, OFB, CTR).
    async ({ content, key, padding, outputFormat, iv, mode }) => {
      let result = "";
      if (mode === "ECB") {
        result = AESUtil.encryptECB(
          content,
          key ?? "your-key-0123456",
          (padding ?? "Pkcs7") as PaddingMode,
          (outputFormat ?? "base64") as OutputFormat
        );
      } else if (mode === "CBC") {
        result = AESUtil.encryptCBC(
          content,
          key ?? "your-key-0123456",
          iv ?? "your-iv-01234567",
          (padding ?? "Pkcs7") as PaddingMode,
          (outputFormat ?? "base64") as OutputFormat
        );
      } else if (mode === "CFB") {
        result = AESUtil.encryptCFB(
          content,
          key ?? "your-key-0123456",
          iv ?? "your-iv-01234567",
          (padding ?? "Pkcs7") as PaddingMode,
          (outputFormat ?? "base64") as OutputFormat
        );
      } else if (mode === "OFB") {
        result = AESUtil.encryptOFB(
          content,
          key ?? "your-key-0123456",
          iv ?? "your-iv-01234567",
          (padding ?? "Pkcs7") as PaddingMode,
          (outputFormat ?? "base64") as OutputFormat
        );
      } else if (mode === "CTR") {
        result = AESUtil.encryptCTR(
          content,
          key ?? "your-key-0123456",
          iv ?? "your-iv-01234567",
          (padding ?? "Pkcs7") as PaddingMode,
          (outputFormat ?? "base64") as OutputFormat
        );
      } else {
        throw new McpError(ErrorCode.InvalidParams, "Unknown mode");
      }
      return {
        content: [
          {
            type: "text",
            text: result,
          },
        ],
      };
    }
  • ECB encryption branch handler - calls AESUtil.encryptECB with default key if not provided.
    if (mode === "ECB") {
      result = AESUtil.encryptECB(
        content,
        key ?? "your-key-0123456",
        (padding ?? "Pkcs7") as PaddingMode,
        (outputFormat ?? "base64") as OutputFormat
      );
  • src/index.ts:3-3 (registration)
    Import of registerAESTool from the aes module, called in the main entry point to register all AES tools including aes_encrypt.
    import { registerAESTool } from "./service/aes.js";
Behavior2/5

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

With no annotations, the description carries full burden for behavioral disclosure. It fails to mention that the tool uses default key and IV values, defaults to ECB mode (which has security implications), or that the same parameter 'content' is described for both encryption and decryption despite the tool name suggesting encryption only. The lack of security notes or behavior details is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

At only three words, the description is overly concise for a tool with six parameters and crypto operations. It fails to front-load key information such as default values or important options, making it less helpful than a slightly longer description that summarizes the configurable aspects.

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 AES encryption (six parameters, no output schema, no annotations), the description is incomplete. It omits crucial context like default mode (ECB), default key/IV, and the fact that the tool can also decrypt (as implied by the content parameter description). The agent would need to read the entire schema to understand tool behavior.

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 each parameter having a clear description. The tool description adds no additional meaning beyond the schema, so it meets the baseline expectation for high coverage without providing extra context.

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 'encrypt text with aes' clearly indicates the action (encrypt) and resource (text with aes), distinguishing it from siblings like aes_decrypt. However, it is minimal and does not specify the AES variant (e.g., AES-128, AES-256) or that the algorithm details are configurable via parameters, which would improve clarity.

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 guidance is provided on when to use this tool versus siblings such as aes_decrypt, base64_encode, or hash functions. The description does not mention appropriate contexts, prerequisites (e.g., key length requirements), or when not to use the tool, leaving the agent to infer solely from the name.

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