Miscellaneous Utilities

Count Items

Count Items tallies occurrences of each unique element in a dataset. Use it via MCP in Cursor or Windsurf, or call GET /v1/misc/count with your data. Pass an array like ["apple", "banana", "apple"] and get back {"apple": 2, "banana": 1}. Handles strings, numbers, and mixed data types reliably.

API Endpoint

GET /v1/misc/count

Code Examples

curl "https://tinyfn.io/v1/misc/count" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/misc/count', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/misc/count',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's miscellaneous tools:

{
  "mcpServers": {
    "tinyfn-misc": {
      "url": "https://tinyfn.io/mcp/misc",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I count items in an array using MCP?

Call the count_items tool with your array as input. It returns a frequency map showing how many times each unique item appears.

What data types can Count Items handle?

It processes strings, numbers, booleans, and mixed arrays. Each unique value gets counted separately, so '1' and 1 are treated as different items.

Can I count items in nested arrays or objects?

No, it counts top-level array elements only. Nested structures are treated as single items and compared by reference.

How does Count Items handle empty or null values?

Empty strings, null, and undefined values are counted as distinct items. Each gets its own count in the returned frequency map.

What's the performance limit for counting large datasets?

The tool handles arrays efficiently but very large datasets (100k+ items) may hit API timeout limits. Consider chunking massive data.

Try Count Items Now

Get your free API key and start using Count Items in seconds.

Get Free API Key