"How many words is this?" Seems simple. Yet LLMs get it wrong constantly. If you are building a content assistant, writing tool, or any agent that works with text, you need deterministic text analysis tools. This guide shows you how to add accurate word counting, reading time estimation, and text statistics to your AI agent via MCP.
The Counting Problem
Ask any LLM: "How many words are in this sentence?" You will get varying answers. The famous "How many R's in strawberry?" problem extends to all counting tasks. LLMs do not count; they predict what counts should look like.
For content workflows, this matters:
- SEO requirements: Meta descriptions must be under 160 characters
- Social media limits: Tweets have exact character limits
- Content guidelines: Articles may require minimum/maximum word counts
- Reading time displays: Users expect accurate estimates
Word and Character Counting
TinyFn provides precise text counting tools:
Word Count
Tool: text/word-count
Input: {
"text": "The quick brown fox jumps over the lazy dog."
}
Result: {
"word_count": 9,
"unique_words": 9
}
Character Count
Tool: text/character-count
Input: {
"text": "Hello, World!"
}
Result: {
"characters": 13,
"characters_no_spaces": 11,
"characters_no_punctuation": 10
}
Sentence and Paragraph Count
Tool: text/sentence-count
Input: {
"text": "First sentence. Second sentence! Is this the third? Yes, it is."
}
Result: {
"sentences": 4
}
Tool: text/line-count
Input: {
"text": "Line one\nLine two\nLine three"
}
Result: {
"lines": 3,
"non_empty_lines": 3
}
Reading Time Estimation
Reading time is essential for blogs, articles, and documentation. Average adult reading speed is 200-250 words per minute:
Tool: text/reading-time
Input: {
"text": "Your 1500 word article here...",
"wpm": 238
}
Result: {
"reading_time_minutes": 6.3,
"reading_time_display": "6 min read",
"word_count": 1500,
"wpm_used": 238
}
Speaking Time
For presentations or podcasts, speaking time differs from reading time:
Tool: text/speaking-time
Input: {
"text": "Your presentation script...",
"wpm": 150
}
Result: {
"speaking_time_minutes": 10,
"speaking_time_display": "10 min",
"word_count": 1500,
"wpm_used": 150
}
| Context | Typical WPM |
|---|---|
| Silent reading | 200-250 |
| Presentations | 120-150 |
| Audiobooks | 150-160 |
| Podcasts | 140-170 |
| News broadcasts | 160-180 |
Text Statistics
For deeper content analysis, TinyFn provides comprehensive text statistics:
Tool: text/statistics
Input: {
"text": "Your content here. It can be multiple paragraphs with various sentence structures."
}
Result: {
"words": 12,
"characters": 82,
"sentences": 2,
"paragraphs": 1,
"avg_word_length": 5.8,
"avg_sentence_length": 6,
"unique_words": 12,
"vocabulary_richness": 1.0,
"reading_time_minutes": 0.05
}
Understanding the Metrics
- Average word length: Indicates vocabulary complexity
- Average sentence length: Longer sentences may indicate more complex content
- Vocabulary richness: Ratio of unique words to total words (1.0 = all unique)
Building a Content Analysis Agent
Here is how a content analysis agent workflow looks with TinyFn MCP:
User: "Analyze this blog post for SEO readiness:
[paste 800-word article]"
Agent workflow:
1. Get word count and reading time
2. Check text statistics
3. Evaluate against SEO guidelines
Tool calls:
- text/word-count { "text": "..." }
Result: { "word_count": 823, "unique_words": 412 }
- text/reading-time { "text": "...", "wpm": 238 }
Result: { "reading_time_minutes": 3.5, "reading_time_display": "4 min read" }
- text/statistics { "text": "..." }
Result: {
"sentences": 45,
"avg_sentence_length": 18.3,
"vocabulary_richness": 0.50
}
Agent response:
"**Content Analysis Results:**
Word Count: 823 words
Reading Time: 4 minutes
Sentences: 45
**SEO Assessment:**
- Word count is good (800+ words for comprehensive content)
- Reading time is appropriate for a blog post
- Average sentence length (18.3 words) is reasonable
- Vocabulary richness (50%) suggests good variety
**Recommendations:**
- Consider adding 200-400 more words for long-form SEO benefits
- Break up any sentences longer than 25 words
- Add more headers to improve scannability"
Example: Social Media Compliance
User: "Is this tweet too long?
'Excited to announce our new AI-powered content analysis tools!
Now you can get accurate word counts, reading times, and text
statistics in your applications. Try it free today!'"
Agent workflow:
1. Count characters
2. Check against Twitter limit (280)
Tool call:
- text/character-count { "text": "..." }
Result: { "characters": 198, "characters_no_spaces": 167 }
Agent response:
"Your tweet is 198 characters, well within Twitter's 280-character limit.
You have 82 characters remaining if you want to add hashtags or a link."
MCP Setup
Add TinyFn text analysis tools to your AI agent:
{
"mcpServers": {
"tinyfn-text": {
"url": "https://api.tinyfn.io/mcp/text",
"headers": {
"X-API-Key": "your-api-key"
}
}
}
}
Available Text Tools
| Tool | Description |
|---|---|
text/word-count |
Count words in text |
text/character-count |
Count characters with/without spaces |
text/sentence-count |
Count sentences in text |
text/line-count |
Count lines/paragraphs |
text/reading-time |
Estimate reading time |
text/speaking-time |
Estimate speaking/presentation time |
text/statistics |
Comprehensive text statistics |
text/reverse |
Reverse text string |
text/truncate |
Truncate text to length |
Use Cases
- Content management systems: Enforce article length requirements
- Writing assistants: Show real-time word counts
- SEO tools: Verify meta description lengths
- Social media managers: Check character limits
- Documentation tools: Estimate reading times
- Translation services: Quote based on word count
Add Text Analysis to Your AI Agent
Get your free API key and give your agent accurate text counting capabilities.
Get Free API Key