origin-count
by jacob-adm
README.md
# origin-count
[](https://github.com/jacob-adm/origin-count/releases/latest) [](https://github.com/jacob-adm/origin-count/blob/main/pyproject.toml) [](https://github.com/jacob-adm/origin-count/blob/main/LICENSE)
An agent that researches a claim often finds one wire report republished on several sites and
counts each copy as another confirmation. origin-count takes the text or HTML of the pages the
agent has fetched and reports how many separate sources they come from. Republished copies of
one report count once, and every match is listed with the evidence for it.
It is made to be called by a coding agent or a script. It does not search and it does not
fetch, so a scan runs offline on what it is given. The same scan is a command with text output,
one JSON object with `--json`, and an MCP tool with `origin-count mcp`.
Pages from the open web may have been written to mislead the agent that reads them. No wording
from a page is in the result, so an instruction hidden in a page cannot reach the agent through
this tool. Characters and elements that do not show are removed before anything is compared,
and every input has a size limit. See [Limitations and security](https://github.com/jacob-adm/origin-count/blob/main/docs/limitations-and-security.md).
It counts sources. It does not judge whether a report is true, and it does not detect a copy
that was rewritten. See [Other tools](https://github.com/jacob-adm/origin-count/blob/main/docs/other-tools.md) for where it fits.
## Example output
Five made-up articles (the data the tests use; no outlet, person or place in them exists): a
wire report, two copies of it, another outlet's own report of the same event, and an unrelated
story.
<p align="center"><img src="https://raw.githubusercontent.com/jacob-adm/origin-count/main/docs/screenshots/origin-count.svg" alt="origin-count finding three origins among five documents"></p>
Two of them with `--json` (first lines of the result):
<p align="center"><img src="https://raw.githubusercontent.com/jacob-adm/origin-count/main/docs/screenshots/origin-count-json.svg" alt="origin-count --json output"></p>
As text:
```text
1 0,1,2 AP shared-text,same-wire
2 3 - -
3 4 - -
```
Each line is `origin TAB documents TAB wire TAB evidence`. Documents are named by their
position in the input, starting at 0, and a field with nothing to say is `-`. With `--json` the
same scan is one `origin-scan/1` object; [Commands](https://github.com/jacob-adm/origin-count/blob/main/docs/commands.md) shows it in full.
## Requirements
- Python 3.9 or later, standard library only.
- No network access and no key.
## Install
From GitHub:
```
pip install git+https://github.com/jacob-adm/origin-count
```
From a clone:
```
git clone https://github.com/jacob-adm/origin-count
cd origin-count
pip install .
```
Either way pip installs `origin-count` as a console script. Check the install:
```sh
origin-count --version
```
```text
origin-count 0.1.1
```
Without installing, it also runs from a clone as `python3 -m origin_count`.
## How it works
1. **Read each document.** From HTML it takes the paragraphs, the canonical link and the
structured data, and leaves out navigation, forms, scripts and elements a browser would not
show. Text is taken as given.
2. **Normalize.** Text is put in Unicode compatibility form and case-folded, and characters
that do not show are removed and counted.
3. **Compare.** The body becomes a set of hashes of eight-word runs. Two documents share text
when half or more of the shorter one's runs are in the other.
4. **Join on evidence.** Documents become one origin on any of four kinds of evidence, and
every join is listed.
| Evidence | Meaning |
| --- | --- |
| `shared-text` | Half or more of the shorter document's text is in the other. |
| `same-wire` | Both pages name the same wire service in a dateline or in their structured data. |
| `canonical` | One page names the other's site as its canonical address. |
| `same-site` | Both documents come from one site. |
5. **Read the result.** The command exits 0 when every document stands alone, 1 when documents
share an origin and 2 on an error. With `--json` the object is printed in all three cases.
## Commands
```
origin-count [--json] [--overlap SHARE] FILE... count the origins among files, one document each
origin-count [--json] [--overlap SHARE] --bundle FILE the same for a JSON bundle of documents (- for standard input)
origin-count mcp serve the same scan as an MCP tool over stdio
```
See [Commands](https://github.com/jacob-adm/origin-count/blob/main/docs/commands.md) for the arguments, both outputs, the result format, the MCP
tool and the exit status.
## Quick start
Saved pages, one file each:
```sh
origin-count a.html b.html c.txt
```
Pages saved by other programs can be read as they are: the HTML snapshots a reference manager
such as Zotero keeps, with their images embedded, and the Markdown notes a web clipper such as
Obsidian Web Clipper writes.
Documents an agent holds, as one object on standard input:
```sh
origin-count --json --bundle - < documents.json
```
As an MCP server, in the configuration of an agent that starts servers over stdio:
```json
{"mcpServers": {"origin-count": {"command": "origin-count", "args": ["mcp"]}}}
```
## Documentation
- [For coding agents](https://github.com/jacob-adm/origin-count/blob/main/docs/AGENTS.md): when an agent calls it, how it reads the result and what the result does not say.
- [Commands](https://github.com/jacob-adm/origin-count/blob/main/docs/commands.md): arguments, options, both outputs, the `origin-scan/1` format, the
MCP tool, exit status and errors.
- [Limitations and security](https://github.com/jacob-adm/origin-count/blob/main/docs/limitations-and-security.md): what a scan cannot see, how it treats
hostile documents, and one measurement on live pages.
- [Other tools](https://github.com/jacob-adm/origin-count/blob/main/docs/other-tools.md): corroborate-mcp, and where each of the two fits.
- [Contributing](https://github.com/jacob-adm/origin-count/blob/main/CONTRIBUTING.md): running the tests and contributing a change.
- [Reporting a vulnerability](https://github.com/jacob-adm/origin-count/blob/main/SECURITY.md)
## License
Apache License 2.0; see [LICENSE](https://github.com/jacob-adm/origin-count/blob/main/LICENSE).
This server cannot be deployed
Maintenance
ActivityNo data
ResponsivenessNo recent community issues