Array Utilities

Array Intersection

Finds common elements between two arrays with deterministic results. Use via MCP in Cursor or Windsurf, or call GET /v1/array/intersection directly. Returns [2, 3] for arrays [1, 2, 3] and [2, 3, 4]. Preserves order from the first array and handles duplicates predictably.

API Endpoint

GET /v1/array/intersection

Code Examples

curl "https://tinyfn.io/v1/array/intersection" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/array/intersection', {
  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/intersection',
    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 array tools:

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

Learn more about MCP setup →

FAQ

How does array intersection handle duplicate values?

Returns each intersecting element only once, even if it appears multiple times in either input array. Order follows the first array's sequence.

What happens when arrays have no common elements?

Returns an empty array []. No errors or null values — just an empty result set.

Can I use this MCP tool with nested arrays or objects?

Works with primitive values (strings, numbers, booleans). For nested structures, elements must match exactly including deep equality.

How is this different from array union or difference operations?

Intersection finds shared elements between arrays. Union combines all unique elements, difference finds elements in first array but not second.

Does the REST API preserve array element order?

Yes, intersection results maintain the order of elements as they appear in the first input array. Deterministic output every time.

Try Array Intersection Now

Get your free API key and start using Array Intersection in seconds.

Get Free API Key