# Email address spans

`email-address-spans` · version 1.0.0 · Communications · free, no key needed

Locate every email address occurrence in text with exact half-open code point, UTF-16 and UTF-8 offsets.

**Use when you need to: find email address positions in text · character offsets of each email in a string · highlight email addresses with start and end index.**

## Decide before calling

Read the [versioned contract](/v1/tools/email-address-spans/versions/1.0.0) and the supported scope below. Reuse `email-address-spans@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `email-address-spans@1.0.0` for find email address positions in text. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- find email address positions in text
- character offsets of each email in a string
- highlight email addresses with start and end index
- annotate every email mention with its span
- redact emails by exact offsets
- utf-8 byte offsets of email addresses in text
- מיקום כתובות אימייל בטקסט

## Not supported

- redact or rewrite the text itself
- deduplicate occurrences (use email-addresses-extract)
- parse display names, comments or group syntax
- verify that an address exists or accepts mail

## Behavior

- Uses exactly the email-addresses-extract scanner: dot-atom local-part, "@", at least two ASCII LDH labels; left to right, non-overlapping; failing candidates are skipped, never shortened.
- Every occurrence is returned in text order, duplicates included. Offsets are half-open [start, end): start/end count Unicode code points, utf16_start/utf16_end count UTF-16 code units, utf8_start/utf8_end count UTF-8 bytes.
- text is the exact source substring at the span; address is its normalized form (local-part NFC with case preserved, domain ASCII-lowercased), so text and address differ only by normalization.
- Symmetric wrappers (' ` * _ ~ { }) and trailing dots are outside the span; angle brackets, quotes, commas and parentheses are boundaries.
- More than 65536 UTF-8 bytes of text, or more than 256 occurrences, is limit_exceeded; empty text returns an empty list. Unicode classes and NFC come from the runtime Unicode version.

## Input

- `text` (string, required): Free text to scan (at most 65536 UTF-8 bytes).

## Output

- `spans` (array of object, required): max items 256
- `count` (integer, required): min 0; max 256

## Limits

- max text bytes: 65536
- max occurrences: 256

## Example

Request input:

```json
{
  "text": "Cc: <boss@nil.test>, sysservices@example.net"
}
```

Response:

```json
{
  "result": {
    "spans": [
      {
        "text": "boss@nil.test",
        "address": "boss@nil.test",
        "start": 5,
        "end": 18,
        "utf16_start": 5,
        "utf16_end": 18,
        "utf8_start": 5,
        "utf8_end": 18
      },
      {
        "text": "sysservices@example.net",
        "address": "sysservices@example.net",
        "start": 21,
        "end": 44,
        "utf16_start": 21,
        "utf16_end": 44,
        "utf8_start": 21,
        "utf8_end": 44
      }
    ],
    "count": 2
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "email-address-spans",
  "version": "1.0.0",
  "input": {
    "text": "Cc: <boss@nil.test>, sysservices@example.net"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/email-address-spans/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"text":"Cc: <boss@nil.test>, sysservices@example.net"}'
```

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

### CLI

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

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

## Related tools

- [Email addresses extract](/tools/email-addresses-extract): Extract the unique email addresses (RFC 5322 addr-spec subset) from text, normalized, in first-seen order.
- [Email address list parse](/tools/email-address-list-parse): Parse an RFC 5322 address-list into ordered mailboxes, groups, and a canonical form.
- [Email address list deduplicate](/tools/email-address-list-deduplicate): Drop duplicate mailboxes in an RFC 5322 address-list, keeping the first one.
- [Email address list validate](/tools/email-address-list-validate): Check RFC 5322 address-list syntax, including dots, quotes, comments, and groups.
- [Email address list format](/tools/email-address-list-format): Format mailboxes and groups as one deterministic RFC 5322 address-list.
- [Email address normalize](/tools/email-address-normalize): Validate one email addr-spec and return its canonical form: minimal quoting, NFC local-part, lowercase domain.
