Extracts the first n elements from any array through GET /v1/array/first. Pass your array and count parameter to get a clean subset without array slicing complexity. Works with strings, numbers, objects — any data type. Essential for pagination, preview generation, and data sampling in MCP-enabled editors like Cursor and Windsurf.
curl "https://tinyfn.io/v1/array/first" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/array/first', {
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/first',
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"
}
}
}
}
Send GET request to /v1/array/first with your array and n=3 parameter. Returns a new array containing exactly the first 3 elements.
The function returns all available items without errors. If your array has 5 items and you request first 10, you get all 5.
Yes, it preserves all data types exactly as provided — strings, numbers, objects, nested arrays, booleans, and null values.
Functionally identical but available as a deterministic API call. Useful when you need consistent results across different environments or in MCP agents.
Absolutely. MCP integration lets Cursor call this function directly when processing arrays, ensuring reliable subset extraction without hallucinated slice operations.