# Path set difference

`path-set-difference` · version 1.0.0 · File paths (lexical) · free, no key needed

Compute the set difference (A \ B) of two path collections using lexical path equivalence.

**Use when you need to: path set difference · set subtraction paths · diff path sets.**

## Supported

- path set difference
- set subtraction paths
- diff path sets

## Not supported

- stat file
- filesystem access

## Behavior

- Returns paths in a that are not in b, using normalized lexical equivalence. Preserves input order from a. Output paths are original (un-normalized) strings from a.

## Input

- `a` (array of string, required): max items 10000
- `b` (array of string, required): max items 10000
- `format` (one of "posix", "windows", "auto", optional)
- `case_sensitive` (boolean, optional)
- `normalize` (boolean, optional)

## Output

- `difference` (array of string, optional)
- `count` (integer, optional)
- `format` (string, optional)

## Limits

- max paths: 10000
- max path bytes: 4096

## Example

Request input:

```json
{
  "a": [
    "a/b.ts",
    "a/c.ts",
    "d/e.ts"
  ],
  "b": [
    "a/c.ts",
    "d/e.ts"
  ]
}
```

Response:

```json
{
  "result": {
    "difference": [
      "a/b.ts"
    ],
    "count": 1,
    "format": "posix"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "path-set-difference",
  "version": "1.0.0",
  "input": {
    "a": [
      "a/b.ts",
      "a/c.ts",
      "d/e.ts"
    ],
    "b": [
      "a/c.ts",
      "d/e.ts"
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/path-set-difference/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"a":["a/b.ts","a/c.ts","d/e.ts"],"b":["a/c.ts","d/e.ts"]}'
```

The machine-readable contract is at [/v1/tools/path-set-difference/versions/1.0.0](/v1/tools/path-set-difference/versions/1.0.0).

### CLI

```sh
node cli.mjs run path-set-difference 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Path set intersection](/tools/path-set-intersection): Compute the set intersection of multiple path collections using lexical path equivalence.
- [Path set union](/tools/path-set-union): Compute the set union of multiple path collections, normalized and deterministically sorted.
- [Path set classify](/tools/path-set-classify): Classify an array of file paths by file extension, depth histogram, and path format.
- [Path set dedupe](/tools/path-set-dedupe): Deduplicate an array of paths based on lexical equivalence while preserving first or last seen order.
- [Path set glob filter](/tools/path-set-glob-filter): Filter an array of paths against glob patterns with inclusion and exclusion rules lexically without filesystem access.
- [Path set hierarchy tree](/tools/path-set-hierarchy-tree): Transform a flat array of file paths into a nested deterministic directory tree structure.
