Skip to main content
Glama
paladini

devutils-mcp-server

generate_nanoid

Create compact, URL-friendly unique identifiers for applications requiring reliable ID generation with customizable length and quantity.

Instructions

Generate a NanoID — a compact, URL-friendly unique ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
lengthNoLength of the NanoID (1-128, default: 21)
countNoNumber of IDs to generate (1-100, default: 1)

Implementation Reference

  • Handler function for generating NanoID, utilizing the nanoid library.
    async ({ length, count }) => {
      const ids = Array.from({ length: count }, () => nanoid(length));
      return {
        content: [{ type: "text" as const, text: ids.join("\n") }],
      };
    }
  • Input validation schema using Zod for length and count parameters of the NanoID tool.
    {
      length: z
        .number()
        .int()
        .min(1)
        .max(128)
        .default(21)
        .describe("Length of the NanoID (1-128, default: 21)"),
      count: z
        .number()
        .int()
        .min(1)
        .max(100)
        .default(1)
        .describe("Number of IDs to generate (1-100, default: 1)"),
    },
  • Registration of the 'generate_nanoid' tool within the McpServer instance.
    server.tool(
      "generate_nanoid",
      "Generate a NanoID — a compact, URL-friendly unique ID.",
      {
        length: z
          .number()
          .int()
          .min(1)
          .max(128)
          .default(21)
          .describe("Length of the NanoID (1-128, default: 21)"),
        count: z
          .number()
          .int()
          .min(1)
          .max(100)
          .default(1)
          .describe("Number of IDs to generate (1-100, default: 1)"),
      },
      async ({ length, count }) => {
        const ids = Array.from({ length: count }, () => nanoid(length));
        return {
          content: [{ type: "text" as const, text: ids.join("\n") }],
        };
      }
    );

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/paladini/devutils-mcp-server'

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