Skip to content
Open
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
6 changes: 6 additions & 0 deletions .changeset/cli-context7-alias-add-winget.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"ctx7": minor
"@upstash/context7-mcp": minor
---

Add memorable `context7` CLI bin alias, `ctx7 add` / `submit` for library indexing, MCP `add-library` tool, and Windows portable/WinGet packaging scaffolding.
107 changes: 107 additions & 0 deletions .github/workflows/cli-portable-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: CLI portable release (Windows / winget)

# Builds a portable Windows zip for the Context7 CLI and attaches it to a GitHub
# Release. Optionally submits/updates the WinGet package when WINGET_TOKEN is set.
#
# Trigger manually after a ctx7 npm publish, or on published GitHub Releases.
# Maintainers: set repository secret WINGET_TOKEN (PAT that can open PRs against
# a fork of microsoft/winget-pkgs) to enable auto-submit.

on:
workflow_dispatch:
inputs:
version:
description: "CLI version to package (defaults to packages/cli/package.json)"
required: false
type: string
release:
types: [published]

permissions:
contents: write

jobs:
portable-windows:
name: Build Windows portable zip
runs-on: windows-latest
outputs:
version: ${{ steps.meta.outputs.version }}
asset_name: ${{ steps.meta.outputs.asset_name }}
steps:
- name: Checkout
uses: actions/checkout@v7

- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: "20"

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Resolve version
id: meta
shell: pwsh
run: |
$pkg = Get-Content packages/cli/package.json | ConvertFrom-Json
$version = if ("${{ inputs.version }}") { "${{ inputs.version }}" } else { $pkg.version }
$asset = "context7-$version-win-portable.zip"
"version=$version" >> $env:GITHUB_OUTPUT
"asset_name=$asset" >> $env:GITHUB_OUTPUT
Write-Host "Packaging CLI version $version"

- name: Build portable zip
shell: pwsh
run: node packages/cli/scripts/build-win-portable.mjs

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: context7-win-portable
path: packages/cli/dist-portable/${{ steps.meta.outputs.asset_name }}

- name: Attach to GitHub Release (if release event)
if: github.event_name == 'release'
shell: pwsh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload "${{ github.event.release.tag_name }}" `
"packages/cli/dist-portable/${{ steps.meta.outputs.asset_name }}" `
--clobber

winget:
name: Submit WinGet package
needs: portable-windows
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- name: Checkout
uses: actions/checkout@v7

- name: Skip when WINGET_TOKEN is unset
id: gate
env:
WINGET_TOKEN: ${{ secrets.WINGET_TOKEN }}
run: |
if [ -z "$WINGET_TOKEN" ]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "WINGET_TOKEN not configured; skipping WinGet submission."
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi

- name: Submit to winget-pkgs
if: steps.gate.outputs.skip == 'false'
uses: vedantmgoyal9/winget-releaser@v2
with:
identifier: Upstash.Context7
version: ${{ needs.portable-windows.outputs.version }}
release-tag: ${{ github.event.release.tag_name }}
installers-regex: 'context7-.*-win-portable\.zip$'
token: ${{ secrets.WINGET_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,6 @@ prompt.txt
reports
reports-old
src/test/questions*

dist-portable

47 changes: 45 additions & 2 deletions docs/clients/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ title: CLI
description: The ctx7 CLI — fetch library documentation and configure Context7 MCP from your terminal
---

The `ctx7` CLI is the command-line interface for Context7. It does two things:
The `ctx7` CLI (also installed as `context7`) is the command-line interface for Context7. It does three things:

- **Fetch library documentation** — resolve any library by name and query its up-to-date docs directly in your terminal, without opening a browser
- **Submit documentation sources** — add public Git repos, websites, OpenAPI specs, or `llms.txt` files to the Context7 index (`ctx7 add`)
- **Configure your AI coding agent** — set up the Context7 MCP server (or a CLI-based `docs` skill) for Claude Code, Cursor, OpenCode, and more with a single command

The CLI is useful both as a standalone tool (fetching docs while you code) and as a setup utility (wiring up Context7 for your AI coding agent).
Expand All @@ -30,11 +31,29 @@ Requires Node.js 18 or later.
```bash
npm install -g ctx7

# Verify installation
# Verify installation (both names work)
ctx7 --version
context7 --version
```

</Tab>
<Tab title="Homebrew">
```bash
brew install ctx7
```

</Tab>
<Tab title="WinGet (Windows)">
After the WinGet package is published:

```powershell
winget install Upstash.Context7
context7 --version
```

Until then, use `npm install -g ctx7`. See `packages/cli/packaging/README.md` in the repo for packaging details.

</Tab>
</Tabs>

---
Expand Down Expand Up @@ -103,6 +122,30 @@ ctx7 docs /vercel/next.js "How to add middleware for route protection" | grep -A

---

## Submit a library — ctx7 add

Submit a public documentation source for indexing. Useful for agents that discover missing libraries while researching.

Requires authentication (`CONTEXT7_API_KEY` or `ctx7 login`).

```bash
# GitHub / GitLab / Bitbucket (auto-detected)
ctx7 add https://github.com/owner/repo
context7 add https://gitlab.com/owner/repo --json

# Website / OpenAPI / llms.txt
ctx7 add https://docs.example.com --type website
ctx7 add https://api.example.com/openapi.json --type openapi
ctx7 add https://docs.example.com/llms.txt

# Private repo (Pro/Enterprise)
ctx7 add https://github.com/owner/private-repo --private --git-token "$GIT_TOKEN"
```

`--json` prints a stable payload (`libraryName`, `message`, `alreadyExists`, `status`) for scripting. Duplicate submissions (`409`) are treated as idempotent success so agents can safely retry.

---

## Setup

Configure Context7 for your AI coding agent. On first run, prompts you to choose between two modes:
Expand Down
20 changes: 17 additions & 3 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
# ctx7
# ctx7 / context7

CLI for [Context7](https://context7.com) - query up-to-date library documentation and configure Context7 for AI coding agents.
CLI for [Context7](https://context7.com) - query up-to-date library documentation, submit sources for indexing, and configure Context7 for AI coding agents.

## Installation

```bash
# Run directly with npx (no install needed)
npx ctx7

# Or install globally
# Or install globally (exposes both `ctx7` and `context7`)
npm install -g ctx7

# Homebrew
brew install ctx7

# WinGet (when published)
winget install Upstash.Context7
```

## Quick Start
Expand Down Expand Up @@ -39,6 +45,14 @@ ctx7 docs /facebook/react "useEffect cleanup"
ctx7 docs /vercel/next.js "middleware"
```

### Submit a library

```bash
# Requires CONTEXT7_API_KEY or `ctx7 login`
context7 add https://github.com/owner/repo
ctx7 add https://docs.example.com --type website --json
```

## Usage

### Find a library
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
"description": "Context7 CLI - Fetch documentation context and configure Context7",
"type": "module",
"bin": {
"ctx7": "./dist/index.js"
"ctx7": "./dist/index.js",
"context7": "./dist/index.js"
},
"files": [
"dist"
],
"scripts": {
"build": "tsup",
"build:portable": "node ./scripts/build-win-portable.mjs",
"dev": "tsup --watch",
"typecheck": "tsc --noEmit",
"lint": "eslint src --fix",
Expand Down
27 changes: 27 additions & 0 deletions packages/cli/packaging/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Windows packaging (winget)

Context7 CLI is published to npm as [`ctx7`](https://www.npmjs.com/package/ctx7) and already available via Homebrew (`brew install ctx7`). Windows users historically had to use Node/`npx`.

## Portable zip + WinGet

This package ships:

- `packages/cli/scripts/build-win-portable.mjs` — builds `context7-<version>-win-portable.zip`
- `packages/cli/packaging/winget/` — WinGet manifest templates (`Upstash.Context7`)
- `.github/workflows/cli-portable-release.yml` — builds the zip and optionally submits to [microsoft/winget-pkgs](https://github.com/microsoft/winget-pkgs)

The portable package depends on **Node.js LTS** (`OpenJS.NodeJS.LTS`) and exposes both `context7` and `ctx7` commands.

### Maintainer checklist

1. Publish the CLI via the existing changesets/npm release flow.
2. Create a GitHub Release (or run **CLI portable release** via `workflow_dispatch`) so the portable zip is attached.
3. Set repository secret `WINGET_TOKEN` (classic PAT that can open PRs against a fork of `microsoft/winget-pkgs`) to enable automatic WinGet submission.
4. Verify: `winget install Upstash.Context7` then `context7 --version` / `ctx7 --version`.

Until the first WinGet package lands, Windows users can still:

```powershell
npm install -g ctx7
context7 --help
```
27 changes: 27 additions & 0 deletions packages/cli/packaging/winget/Upstash.Context7.installer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Upstash.Context7.installer
# Placeholders {{PACKAGE_VERSION}}, {{INSTALLER_URL}}, {{INSTALLER_SHA256}} are filled by CI.
PackageIdentifier: Upstash.Context7
PackageVersion: "{{PACKAGE_VERSION}}"
Platform:
- Windows.Desktop
MinimumOSVersion: 10.0.17763.0
InstallerType: zip
NestedInstallerType: portable
NestedInstallerFiles:
- RelativeFilePath: context7-win-portable\context7.cmd
PortableCommandAlias: context7
- RelativeFilePath: context7-win-portable\ctx7.cmd
PortableCommandAlias: ctx7
Dependencies:
PackageDependencies:
- PackageIdentifier: OpenJS.NodeJS.LTS
InstallModes:
- silent
UpgradeBehavior: uninstallPrevious
ReleaseDate: "{{RELEASE_DATE}}"
Installers:
- Architecture: neutral
InstallerUrl: "{{INSTALLER_URL}}"
InstallerSha256: "{{INSTALLER_SHA256}}"
ManifestType: installer
ManifestVersion: 1.9.0
29 changes: 29 additions & 0 deletions packages/cli/packaging/winget/Upstash.Context7.locale.en-US.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Upstash.Context7.locale.en-US
PackageIdentifier: Upstash.Context7
PackageVersion: "{{PACKAGE_VERSION}}"
PackageLocale: en-US
Publisher: Upstash
PublisherUrl: https://upstash.com
PublisherSupportUrl: https://github.com/upstash/context7/issues
Author: Upstash
PackageName: Context7 CLI
PackageUrl: https://context7.com
License: MIT
LicenseUrl: https://github.com/upstash/context7/blob/master/LICENSE
Copyright: Copyright (c) Upstash
ShortDescription: Context7 CLI — fetch library docs and submit sources for AI coding agents
Description: >
Official Context7 command-line interface. Query up-to-date library documentation,
configure Context7 MCP/skills for AI coding agents, and submit documentation sources
for indexing. Provides both `context7` and `ctx7` commands.
Moniker: context7
Tags:
- ai
- cli
- context7
- documentation
- mcp
- ctx7
ReleaseNotesUrl: https://github.com/upstash/context7/releases
ManifestType: defaultLocale
ManifestVersion: 1.9.0
9 changes: 9 additions & 0 deletions packages/cli/packaging/winget/Upstash.Context7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Upstash.Context7
# Version: {{PACKAGE_VERSION}}
# Publisher: Upstash
# PackageVersion: {{PACKAGE_VERSION}}
PackageIdentifier: Upstash.Context7
PackageVersion: "{{PACKAGE_VERSION}}"
DefaultLocale: en-US
ManifestType: version
ManifestVersion: 1.9.0
Loading