Math Utilities

Sum Numbers

Computes the mathematical sum of any list of numbers via GET /v1/math/sum. Pass numbers as query parameters or JSON array — returns precise totals for integers, floats, or mixed datasets. Perfect for AI agents in Cursor or Claude Code that need accurate arithmetic instead of potentially incorrect LLM calculations.

API Endpoint

GET /v1/math/sum

Code Examples

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

response = requests.get('https://tinyfn.io/v1/math/sum',
    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 math tools:

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

Learn more about MCP setup →

FAQ

How do I pass multiple numbers to the sum endpoint?

Use query parameters like /v1/math/sum?numbers=1,2,3,4 or send a JSON array in the request body. Both methods return the same accurate result.

Can MCP tools in Cursor reliably calculate sums without this endpoint?

LLMs often make arithmetic errors on long number sequences or floating-point precision. This tool guarantees mathematically correct sums every time.

What's the maximum number of values I can sum at once?

The endpoint handles thousands of numbers efficiently. Practical limits depend on URL length for query params or JSON payload size for POST requests.

Does the sum tool handle negative numbers and decimals?

Yes, it correctly processes integers, floats, negative values, and mixed number types. Returns precise decimal results when needed.

What format does the sum endpoint return results in?

Returns JSON with the calculated sum value. For example: {"sum": 15} for adding 1+2+3+4+5.

Try Sum Numbers Now

Get your free API key and start using Sum Numbers in seconds.

Get Free API Key