Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "context7-add",
"version": "1.1.0",
"version": "1.2.0",
"description": "Index repos, docs sites, llms.txt, OpenAPI specs and files in Context7 when missing, and allow them in your teamspace policy so the Context7 MCP serves them.",
"author": {
"name": "Alex Samson",
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
test:
name: Tests (Python ${{ matrix.python }})
# Pinned: setup-python has no Python 3.8 or 3.9 builds for newer Ubuntu images.
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python }}
- name: Syntax check
run: python -m py_compile skills/context7-add/scripts/c7.py
- name: Tests (offline, API stubbed)
run: python -m unittest discover -s tests -v

skill:
name: Skill and coverage
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Install tools
run: python -m pip install "skills-ref==0.1.1" "coverage==7.17.4"
- name: Validate the skill (Agent Skills specification)
run: agentskills validate skills/context7-add
- name: Coverage
run: |
python -m coverage run --source=skills/context7-add/scripts -m unittest discover -s tests
python -m coverage report -m
python -m coverage report -m --format=markdown >> "$GITHUB_STEP_SUMMARY"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
registry.jsonl
__pycache__/
.DS_Store
.coverage
36 changes: 27 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# context7-add

[![CI](https://github.com/saalse/context7-add/actions/workflows/ci.yml/badge.svg)](https://github.com/saalse/context7-add/actions/workflows/ci.yml)
[![Python 3.8+](https://img.shields.io/badge/python-3.8%2B-blue)](skills/context7-add/scripts/c7.py)
[![License: MIT](https://img.shields.io/github/license/saalse/context7-add)](LICENSE)
[![Last commit](https://img.shields.io/github/last-commit/saalse/context7-add)](https://github.com/saalse/context7-add/commits/main)
[![Agent Skills](https://img.shields.io/badge/Agent%20Skills-spec-8A2BE2)](https://agentskills.io/specification)
[![Context7](https://img.shields.io/badge/Context7-indexed-00A86B)](https://context7.com/saalse/context7-add)

An agent skill that makes documentation available through [Context7](https://context7.com)
when it isn't yet: it **indexes** a repo, docs site, `llms.txt`, OpenAPI spec or PDF/DOCX file
if Context7 doesn't have it, and **allows** it in your teamspace policy so your API key and the
Expand Down Expand Up @@ -54,28 +61,39 @@ or your agent's skills folder.

Ask your agent, for example:

- "Add https://github.com/acme/widgets to Context7 and allow it."
- "Context7 says /acme/widgets isn't in my allowed libraries, fix it."
- "Add https://github.com/saalse/context7-add to Context7 and allow it."
- "Context7 says /saalse/context7-add isn't in my allowed libraries, fix it."
- "Make the docs at https://docs.acme.dev available in context7."

Or run the helper yourself:

```bash
C7=skills/context7-add/scripts/c7.py
python3 $C7 whoami
python3 $C7 check https://github.com/acme/widgets
python3 $C7 allow /acme/widgets # dry run
python3 $C7 allow /acme/widgets --apply
python3 $C7 add https://github.com/acme/widgets --apply
python3 $C7 wait /acme/widgets
python3 $C7 check https://github.com/saalse/context7-add
python3 $C7 allow /saalse/context7-add # dry run
python3 $C7 allow /saalse/context7-add --apply
python3 $C7 add https://github.com/saalse/context7-add --apply # already indexed: reports its id, creates nothing
python3 $C7 wait /saalse/context7-add
```

Results are JSON on stdout; errors go to stderr with a distinct exit code (bad input,
auth, not found, refused by policy, rate limited, unprocessable, timed out). See
`python3 $C7 --help`.
auth, not found, refused by policy, rate limited, unprocessable, timed out, submission
queue full, file too large). See `python3 $C7 --help`.

The skill follows the [Agent Skills specification](https://agentskills.io/specification).

## Development

The tests are offline: they stub the Context7 API, so they need no key or network.

```bash
python3 -m unittest discover -s tests -v
```

CI runs them on Python 3.8 to 3.14, validates the skill against the Agent Skills
specification, and prints a coverage report.

## Notes

- Submitting a public source adds it to Context7's public index. Use `--private` for internal
Expand Down
6 changes: 5 additions & 1 deletion context7.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
"url": "https://context7.com/saalse/context7-add",
"public_key": "pk_6NlYtGWUARfV17Y6zVg0H",
"projectTitle": "context7-add",
"description": "Agent skill that indexes repos, docs sites, llms.txt, OpenAPI specs and files in Context7 and allows them in your teamspace policy so the Context7 MCP serves them."
"description": "Agent skill that indexes repos, docs sites, llms.txt, OpenAPI specs and files in Context7 and allows them in your teamspace policy so the Context7 MCP serves them.",
"excludeFolders": [
"tests",
".github"
]
}
58 changes: 52 additions & 6 deletions docs/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ pass `--apply`.
python3 scripts/c7.py whoami
python3 scripts/c7.py check <url|/org/repo|name>...
python3 scripts/c7.py allow <entry>... [--remove] [--apply]
python3 scripts/c7.py add <url> [--type T] [--base-url URL] [--private] [--git-token-env VAR] [--apply]
python3 scripts/c7.py upload <file.pdf|.docx|openapi.yaml> [--title T] [--apply]
python3 scripts/c7.py add <url>... [--type T] [--base-url URL] [--private] [--git-token-env VAR] [--queue [--queue-timeout SEC]] [--apply]
python3 scripts/c7.py upload <file.pdf|.docx|openapi.yaml> [--title T] [--description D] [--skip-size-check] [--apply]
python3 scripts/c7.py refresh <libraryId> [--apply]
python3 scripts/c7.py wait <libraryId> [--changed] [--timeout SEC]
python3 scripts/c7.py log
Expand All @@ -23,22 +23,68 @@ python3 scripts/c7.py log
| `whoami` | plan, role, policy mode, which list admits libraries |
| `check` | state, freshness and coverage per input; guessed website ids; the site's llms.txt files; a GitHub owner's repos |
| `allow` | add or remove allowlist / wild-card entries, with a dry-run library count |
| `add` | submit a repo, website, llms.txt or OpenAPI URL; reports the existing id if Context7 already has it |
| `upload` | upload a PDF, DOCX or OpenAPI file (private to the teamspace) |
| `add` | submit one or more repo, website, llms.txt or OpenAPI URLs; reports the existing id if Context7 already has it. See [Add many sources](#add-many-sources) |
| `upload` | upload a PDF, DOCX or OpenAPI file up to ~4.5 MB (private to the teamspace). See [Upload a file](/upload) |
| `refresh` | re-crawl or re-parse a stale library (daily limit) |
| `wait` | poll until indexed; `--changed` waits until a refresh lands |
| `log` | the audit trail of applied changes |

## Add many sources

Context7 lets each user have at most **5 libraries processing or queued** at a time. A sixth
submission is refused with `400 user-has-active-task`. Pass every URL to one `add` call. In
select mode, allow public repos first: their submission is gated by the policy.

```bash
python3 scripts/c7.py allow /acme/a /acme/b --apply
python3 scripts/c7.py add https://github.com/acme/a https://github.com/acme/b https://docs.acme.dev/ --apply
```

All inputs are validated before anything is sent, and stderr gets one progress line per URL.
When the queue is full, when Context7 rate-limits you (429), or when the key is refused (401),
`add` stops: the remaining URLs would be refused too. With several URLs, the output lists what
was not submitted, starting with the URL that hit the limit:

```json
{
"results": [
{"input": "https://github.com/acme/a", "status": 200, "libraryId": "/acme/a", "...": "..."},
{"input": "https://github.com/acme/b", "status": 400,
"response": {"error": "user-has-active-task", "message": "You already have 5 libraries being processed or queued. ..."},
"meaning": "not submitted: Context7 allows 5 libraries processing or queued per user. ..."}
],
"notSubmitted": ["https://github.com/acme/b", "https://docs.acme.dev/"],
"next": "Context7's queue holds 5 libraries per user. Resubmit notSubmitted once some finish ..."
}
```

URLs refused for another reason (policy, not a documentation site, and so on) or lost to a
network error are listed in `failed`; they aren't retried, and the exit code is the first such
failure. A network error is safe to resubmit. Only when nothing
failed for real is the exit code 3 (key refused), 9 (queue full) or 6 (rate limited).

To submit everything in one go, add `--queue`. When the queue is full, `add` then waits 30 s
and retries the same URL, for up to `--queue-timeout` seconds per URL (default 1800). Indexing
takes minutes, so run it in the background. If the run is stopped (Ctrl-C or SIGTERM), it still
prints the summary so far, with `"interrupted": true` and `notSubmitted`, and exits 130,
whatever else happened before. The URL that was being sent may already have been accepted;
resubmitting it is safe, because Context7 answers `library-already-exists`.

`--type` and `--base-url` apply to one URL, so they can't be combined with several URLs; the
type is detected per URL otherwise.

## Exit codes

| Code | Meaning |
|---|---|
| 0 | success (`check`: report produced; `wait`: ready) |
| 1 | API or network error |
| 2 | bad input |
| 2 | bad input, or a file too large to upload (over ~4.5 MB, or a 413) |
| 3 | missing or invalid key, or role/plan too low |
| 4 | library not found |
| 5 | refused by the teamspace policy |
| 6 | rate limited |
| 7 | unprocessable (no or too few docs) |
| 7 | unprocessable (no or too few docs), or not a documentation website |
| 8 | `wait` timed out |
| 9 | submission queue full (5 libraries already processing). `add`: resubmit later (with several URLs, `notSubmitted` lists which) or use `--queue`; `refresh`, `upload`: try again later |
| 130 | `add`: interrupted; the partial summary lists `notSubmitted` |
2 changes: 1 addition & 1 deletion docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"navigation": {
"groups": [
{ "group": "Get started", "pages": ["index", "install"] },
{ "group": "Guide", "pages": ["usage", "commands", "gotchas"] }
{ "group": "Guide", "pages": ["usage", "commands", "upload", "gotchas"] }
]
}
}
14 changes: 10 additions & 4 deletions docs/gotchas.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ description: Context7 behaviours that contradict reasonable assumptions, found i
official source first; an RFC is `https://www.rfc-editor.org/rfc/rfcNNNN.html`, which
lives in `/websites/rfc-editor_rfc`.
- **Website ids drop parts of the URL.** `docs.` / `www.`, `.com` / `.org` / `.net` and a
`docs` path segment are removed: `nianticspatial.com/docs/scaniverse` →
`/websites/nianticspatial_scaniverse`.
`docs` path segment are removed: `docs.github.com/en` → `/websites/github_en`,
`example.com/docs/guide` → `/websites/example_guide`.
- **A domain entry is about docs sites, not repo hosts.** A `github.com` entry does not admit
GitHub repos.
- **"Already exists" is a 400, not a 409.** Submitting a site Context7 already has returns
`library-already-exists` with the id in the message, and creates nothing.
- **"Already exists" is a 400, not a 409.** Submitting a repo or site Context7 already has
returns `library-already-exists` with the id in the message, and creates nothing.
- **Exists is not the same as covered.** A library can be months old and missing pages, or
empty while a more specific sibling has the content. Refresh stale ones.
- **Crawls only follow the site's menu.** Unlinked pages stay out even after a refresh; the
Expand All @@ -25,5 +25,11 @@ description: Context7 behaviours that contradict reasonable assumptions, found i
`unprocessable`, and the failed library remains in the index.
- **The library count ignores empty libraries.** A policy dry run doesn't move for libraries
that are empty or still processing.
- **Only 5 submissions at a time.** A sixth `add` while 5 libraries are processing gets
`400 user-has-active-task`. Pass all URLs to one `add --queue` call.
- **Uploads stop at about 4.5 MB.** Larger files get `413 FUNCTION_PAYLOAD_TOO_LARGE`. Split
PDFs by pages. The library id comes from the file name, not the title, so name the file well.
- **Some sites are refused as "not documentation".** `422 not_documentation_website`
("Website score 1 below threshold 9") is final for that URL: marketing sites and blogs get it.
- **Claiming needs a Write-access key.** The management API (`/v2/teamspaces/…`) answers
`write_access_required` to a normal key; use the dashboard instead.
Loading