Skip to main content
Glama

transform-text

Modify text case, format, or structure by applying operations like uppercase, lowercase, capitalize, reverse, or word count. Ideal for processing and transforming text efficiently.

Instructions

Transform text case and format

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
operationYesTransformation operation to apply
textYesText to transform

Implementation Reference

  • The asynchronous handler function that executes the text transformation logic based on the specified operation (uppercase, lowercase, capitalize, reverse, or word-count).
    async ({ text, operation }) => { let result: string; switch (operation) { case "uppercase": result = text.toUpperCase(); break; case "lowercase": result = text.toLowerCase(); break; case "capitalize": result = text.split(" ") .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) .join(" "); break; case "reverse": result = text.split("").reverse().join(""); break; case "word-count": const wordCount = text.trim().split(/\s+/).filter(word => word.length > 0).length; result = `Word count: ${wordCount}`; break; default: result = "Unknown operation"; } return { content: [ { type: "text", text: result } ] }; }
  • Zod-based input schema defining the parameters for the transform-text tool: text (string) and operation (enum of transformation types).
    inputSchema: { text: z.string().describe("Text to transform"), operation: z.enum([ "uppercase", "lowercase", "capitalize", "reverse", "word-count" ]).describe("Transformation operation to apply") } },
  • Registration of the 'transform-text' tool on the MCP server, specifying name, metadata (title, description, inputSchema), and handler function.
    server.registerTool( "transform-text", { title: "Text Transformer", description: "Transform text case and format", inputSchema: { text: z.string().describe("Text to transform"), operation: z.enum([ "uppercase", "lowercase", "capitalize", "reverse", "word-count" ]).describe("Transformation operation to apply") } }, async ({ text, operation }) => { let result: string; switch (operation) { case "uppercase": result = text.toUpperCase(); break; case "lowercase": result = text.toLowerCase(); break; case "capitalize": result = text.split(" ") .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) .join(" "); break; case "reverse": result = text.split("").reverse().join(""); break; case "word-count": const wordCount = text.trim().split(/\s+/).filter(word => word.length > 0).length; result = `Word count: ${wordCount}`; break; default: result = "Unknown operation"; } return { content: [ { type: "text", text: result } ] }; } );

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/kylekanouse/Test-MCP---DEMO-MCP-Dev-1'

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