slugify
Convert strings to URL-friendly slugs by removing special characters, replacing spaces with hyphens, and converting to lowercase for clean web addresses.
Instructions
Convert a string to a URL-friendly slug. Removes special characters, replaces spaces with hyphens, and lowercases everything.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | The string to slugify |
Implementation Reference
- src/tools/text.ts:185-202 (handler)Implementation of the 'slugify' MCP tool, which converts an input string into a URL-friendly slug.
// Slugify server.tool( "slugify", "Convert a string to a URL-friendly slug. Removes special characters, replaces spaces with hyphens, and lowercases everything.", { input: z.string().describe("The string to slugify") }, async ({ input }) => { const slug = input .toLowerCase() .normalize("NFD") .replace(/[\u0300-\u036f]/g, "") // Remove diacritics .replace(/[^a-z0-9\s-]/g, "") // Remove special chars .replace(/\s+/g, "-") // Spaces to hyphens .replace(/-+/g, "-") // Collapse hyphens .replace(/^-+|-+$/g, ""); // Trim hyphens return { content: [{ type: "text" as const, text: slug }] }; } );