Skip to main content
Glama

transform-text

Convert text to uppercase, lowercase, capitalize words, reverse strings, or count words using this text transformation tool from the Demo MCP Server.

Instructions

Transform text case and format

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesText to transform
operationYesTransformation operation to apply

Implementation Reference

  • Handler function that executes the transform-text tool logic. Takes input text and operation (uppercase, lowercase, capitalize, reverse, word-count), performs the transformation, and returns the result as text content.
    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 for the transform-text tool, validating 'text' as string and 'operation' as one of the specified enum values.
    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, including name, metadata (title, description), input schema, 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