Extracts the last n elements from any array with deterministic results. Call via MCP in Cursor or Windsurf, or use REST endpoint `/v1/array/last`. Perfect for getting recent items, tail operations, or pagination boundaries. Returns empty array if n exceeds array length, making it safe for dynamic data processing.
curl "https://tinyfn.io/v1/array/last" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/array/last', {
headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests
response = requests.get('https://tinyfn.io/v1/array/last',
headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)
Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's array tools:
{
"mcpServers": {
"tinyfn-array": {
"url": "https://tinyfn.io/mcp/array",
"headers": {
"X-API-Key": "YOUR_API_KEY"
}
}
}
}
Pass your array and set n=3. For array [1,2,3,4,5], it returns [3,4,5]. Works with any data type including strings, objects, or mixed arrays.
Array Last returns the entire array without errors. Requesting last 10 items from a 5-item array simply returns all 5 items in their original order.
Yes, AI agents frequently use it for analyzing recent data points, extracting tail elements for pattern recognition, or implementing sliding window operations on datasets.
Absolutely. Elements maintain their sequential order from the source array. It's not a reverse operation—just extraction of the final n elements.
Array Last provides a clean, parameterized interface optimized for tail operations. Unlike manual slicing, it handles edge cases automatically and works consistently across MCP and REST environments.