# Publish a package to QZ

If the user asked you to publish a specific package, use that request as authorization. Ask only about details that affect what goes public and that you cannot infer. If the user only asked you to read this guide, summarize it and wait for a package request.

1. Start with the package directory the user named. If they asked for a new package, create it in its own directory. Keep all file inspection and commands inside that directory unless a dependency requires otherwise. Run any requested local checks from that directory.
2. Use QZ 0.6.0 or later. If needed, download the [standalone CLI](https://qzpkg.com/cli/qz.cjs) and verify it against the [SHA-256 digest](https://qzpkg.com/cli/qz.cjs.sha256). With Node.js 22 or later, `node path/to/qz.cjs` is equivalent to `qz` in the commands below.
3. Run `qz agent login` once. Show the user the link and code it prints. Ask them to sign in to QZ if prompted, enter the code on that page, and tell you when it says **Successfully linked**. Pause here. Do not collect their password or start a background wait. The link expires in ten minutes.
4. When the user says they are linked, run `qz agent status` to collect the publishing token and identify the account. If it says pending, tell the user and wait. Generate a new link only if the first one expired. Publishing access expires after eight hours and can be revoked at https://qzpkg.com/agents/.
5. Set the name to `@username/package` using the QZ username from step 4. Keep files inside the package directory and review the `files` allowlist before uploading. Use a valid version, description, and JavaScript entry point.
6. Run `qz agent preview` (or `qz publish --preview --tag beta` for a prerelease). Give the user the URL to review the exact name, version, files, and tarball. Let them click Publish release. After they confirm, check the release and share its install command.

Run `qz agent delete <name> <version>` to get a browser confirmation link for an owned release. The owner confirms the deletion in QZ. Deleted versions cannot be reused.

## MCP

Connect a Streamable HTTP client to https://qzpkg.com/mcp. The tools include `qz_preview`, `qz_package`, `qz_whoami`, `qz_publish`, and `qz_delete`. Lookup is public. Publishing and creating deletion links use the browser-approved bearer token. The CLI stores and sends the token for you. For direct client setup, see https://qzpkg.com/docs/#agent-mcp.
