Array Utilities

Is Subset

Determines if one array is a subset of another by checking that all elements in array1 exist in array2. Access via GET /v1/array/is-subset or through MCP in Cursor and other AI coding tools. Returns a boolean result — useful for permission checks, feature validation, or data filtering logic where you need precise subset verification rather than guessed comparisons.

API Endpoint

GET /v1/array/is-subset

Code Examples

curl "https://tinyfn.io/v1/array/is-subset" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/array/is-subset', {
  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/is-subset',
    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 subset checking work with duplicate elements?

Each element in array1 must exist at least once in array2, but duplicates don't affect the result. [1,2,2] is a subset of [1,2,3] even though array2 has fewer 2's.

What data types can I check for subsets in arrays?

Works with strings, numbers, booleans, and null values. Mixed-type arrays are supported — [1, "hello", true] can be checked as a subset of [1, 2, "hello", true, null].

Can I use this MCP tool to validate user permissions in Claude Code?

Yes, perfect for checking if a user's permissions array is a subset of required permissions. Your AI agent gets a definitive true/false instead of hallucinating permission logic.

Does order matter when checking if arrays are subsets?

No, element order is irrelevant. [3,1,2] is a subset of [1,2,3,4,5]. Only the presence of elements matters, not their position.

What happens when checking empty arrays or arrays with undefined values?

An empty array is always a subset of any array. Arrays containing undefined values are handled correctly — undefined must exist in both arrays for subset validation.

Try Is Subset Now

Get your free API key and start using Is Subset in seconds.

Get Free API Key