# Interval union

`interval_union` · version 1.0.0 · Numbers & math · free, no key needed

Merge overlapping or adjacent numeric intervals.

**Use when you need to: interval union.**

## Supported

- interval union

## Not supported

- filesystem access
- network access

## Behavior

- Deterministic pure computation over the supplied JSON input.
- How requests are recorded is described in the privacy policy: https://computefirst.net/privacy.

## Input

- `intervals` (array of object, required)

## Output

- object

## Limits

- max input bytes: 262144

## Example

Request input:

```json
{
  "intervals": [
    {
      "start": 1,
      "end": 3
    },
    {
      "start": 3,
      "end": 5
    }
  ]
}
```

Response:

```json
{
  "result": {
    "union": [
      {
        "start": 1,
        "end": 5
      }
    ]
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "interval_union",
  "version": "1.0.0",
  "input": {
    "intervals": [
      {
        "start": 1,
        "end": 3
      },
      {
        "start": 3,
        "end": 5
      }
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/interval_union/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"intervals":[{"start":1,"end":3},{"start":3,"end":5}]}'
```

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

### CLI

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

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

## Related tools

- [Interval contains](/tools/interval_contains): Test whether a numeric interval contains a point or interval.
- [Interval difference](/tools/interval_difference): Compute the portion of interval a outside interval b.
- [Interval intersection](/tools/interval_intersection): Compute the closed intersection of two numeric intervals.
- [Interval overlap](/tools/interval_overlap): Test whether two numeric intervals overlap.
- [Angle DMS convert](/tools/angle-dms-convert): Convert a signed integer angle between degrees, arcminutes, and arcseconds as an exact rational.
- [Array integer adjacent diff](/tools/array-integer-adjacent-diff): Replace an array of canonical integer strings with consecutive first differences.
