# Path set dedupe

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

Deduplicate an array of paths based on lexical equivalence while preserving first or last seen order.

**Use when you need to: deduplicate paths · path dedup · remove duplicate paths.**

## Supported

- deduplicate paths
- path dedup
- remove duplicate paths

## Not supported

- stat file
- filesystem access

## Behavior

- Remove duplicate paths using normalized lexical equivalence. keep:"first" keeps first occurrence; keep:"last" keeps last. Output preserves original strings.

## Input

- `paths` (array of string, required): max items 10000
- `format` (one of "posix", "windows", "auto", optional)
- `case_sensitive` (boolean, optional)
- `normalize` (boolean, optional)
- `keep` (one of "first", "last", optional)

## Output

- `deduped` (array of string, optional)
- `removed` (integer, optional)
- `format` (string, optional)

## Limits

- max paths: 10000
- max path bytes: 4096

## Example

Request input:

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

Response:

```json
{
  "result": {
    "deduped": [
      "a/b.ts",
      "c.ts"
    ],
    "removed": 1,
    "format": "posix"
  }
}
```

## How to call it

### MCP

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

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

### HTTP (no key)

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

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

### CLI

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

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

## Related tools

- [Path set prefix strip](/tools/path-set-prefix-strip): Strip a common directory prefix or base path from an array of paths lexically.
- [Path set classify](/tools/path-set-classify): Classify an array of file paths by file extension, depth histogram, and path format.
- [Path set difference](/tools/path-set-difference): Compute the set difference (A \ B) of two path collections using lexical path equivalence.
- [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.
- [Path set ignore filter](/tools/path-set-ignore-filter): Filter paths against gitignore-style rule lines (negation, comments, directory trailing slashes) lexically.
