Skip to main content
Glama
paladini

devutils-mcp-server

text_stats

Analyze text to calculate character, word, line, sentence, paragraph counts and reading time for content assessment.

Instructions

Analyze text and return detailed statistics: character count, word count, line count, sentence count, paragraph count, and reading time.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYesThe text to analyze

Implementation Reference

  • The handler function for the text_stats tool that calculates various text metrics and returns them as a JSON string.
    async ({ input }) => {
      const chars = input.length;
      const charsNoSpaces = input.replace(/\s/g, "").length;
      const words = input.trim() === "" ? 0 : input.trim().split(/\s+/).length;
      const lines = input === "" ? 0 : input.split(/\r?\n/).length;
      const sentences = input.trim() === ""
        ? 0
        : input.split(/[.!?]+/).filter((s) => s.trim().length > 0).length;
      const paragraphs = input.trim() === ""
        ? 0
        : input.split(/\n\s*\n/).filter((p) => p.trim().length > 0).length;
      const readingTimeMinutes = Math.ceil(words / 200);
    
      const result = {
        characters: chars,
        characters_no_spaces: charsNoSpaces,
        words,
        lines,
        sentences,
        paragraphs,
        reading_time_minutes: readingTimeMinutes,
        avg_word_length:
          words > 0
            ? +(charsNoSpaces / words).toFixed(1)
            : 0,
      };
    
      return {
        content: [
          { type: "text" as const, text: JSON.stringify(result, null, 2) },
        ],
      };
    }
  • src/tools/text.ts:6-9 (registration)
    Registration of the text_stats tool using the MCP server instance.
    server.tool(
      "text_stats",
      "Analyze text and return detailed statistics: character count, word count, line count, sentence count, paragraph count, and reading time.",
      { input: z.string().describe("The text to analyze") },

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