npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@discourse/create-site

v0.1.1

Published

Agent-friendly CLI wizard to provision hosted Discourse communities via Discourse ID device flow

Readme

@discourse/create-site

Agent-friendly CLI wizard to provision hosted Discourse communities via Discourse ID OAuth 2.0 Device Authorization Grant (RFC 8628).

Designed primarily for LLM coding agents (--json mode with structured exit code 2 handoffs and zero secret leakage) while also supporting a minimal interactive TTY wizard for humans.

Quick Start (Interactive)

npx -y @discourse/create-site

Agent Workflow (--json)

In --json or non-TTY mode, the CLI never blocks waiting for stdin and never prints access_token or device_code to stdout. Credentials are stored per host with 0600 permissions in ~/.config/discourse-create-site/state.json.

Exit Codes

  • 0: Success
  • 1: Fatal or configuration error (invalid_arguments, invalid_input, provisioning_disabled, expired_token, access_denied, network/API error)
  • 2: Action required from the end user (auth_required, authorization_pending, missing_input, terms_required, subdomain_taken)

Step-by-Step Agent Flow

  1. Check session & plans (or start device login if unauthenticated):

    discourse-create-site create --json

    If unauthenticated, exits 2 with:

    {
      "ok": false,
      "status": "action_required",
      "code": "auth_required",
      "user_code": "ABCD-EFGH",
      "verification_uri": "https://id.discourse.com/oauth/device",
      "verification_uri_complete": "https://id.discourse.com/oauth/device?user_code=ABCD-EFGH",
      "expires_in": 600,
      "interval": 5
    }

    Ask the user to open verification_uri_complete and confirm user_code. Pass --signup if the user needs to create a new Discourse ID account first.

  2. Complete device authorization:

    discourse-create-site auth poll --json

    (Or use --no-wait for a single non-blocking poll returning exit 2 authorization_pending while waiting.)

  3. Step 1 — Collect community name & plan: Running create --json with missing inputs exits 2 (step: 1, code: "missing_input") returning available_plans. Ask the user ONLY for their community name and desired plan (subdomain is auto-generated from the name unless they explicitly request --subdomain; region defaults to global unless overridden with --region).

  4. Step 2 — Show plan-specific terms & provision: Run with --name and --plan (without --accept-terms yet):

    discourse-create-site create --name "My Community" --plan free --json

    This exits 2 (step: 2, code: "terms_required") with the exact terms_urls for that plan (free-terms or trial-terms, plus user 18+ terms if needed). After the user confirms, re-run with acceptance flags:

    discourse-create-site create \
      --name "My Community" \
      --plan free \
      --accept-terms \
      --accept-account-terms \
      --json

    Pass --subdomain <slug> and --region <global|eu> only if requested (or --customize in interactive TTY mode to be prompted for them). On completion, exits 0 with redirect_url (one-time admin sign-in invite link), user_handoff guidance (share ONLY redirect_url directly with the user, not the bare site URL), and mcp_setup tailored to the detected agent client or generic Streamable HTTP MCP configuration.

Commands

  • discourse-create-site [create] [options] — Provision a new community (default command)
  • discourse-create-site auth [options] — Interactive device auth + poll
  • discourse-create-site auth start [--signup] [--open] [--json] — Start device auth without blocking
  • discourse-create-site auth poll [--no-wait] [--timeout <s>] [--json] — Poll for token completion
  • discourse-create-site auth status [--json] — Check active token status
  • discourse-create-site auth logout [--all] [--json] — Remove stored credentials
  • discourse-create-site info [--json] — Show account details, terms status, and available plans
  • discourse-create-site status <token> [--wait] [--json] — Check or wait for site readiness

Configuration

| Flag | Environment Variable | Description | Default | | --- | --- | --- | --- | | --id-url | DISCOURSE_ID_URL | Discourse ID base URL | https://id.discourse.com | | --client-id | DISCOURSE_ID_CLIENT_ID | Non-confidential OAuth client_id | Built-in default for https://id.discourse.com | | --config-dir | DISCOURSE_CREATE_SITE_CONFIG_DIR | Credential storage dir | $XDG_CONFIG_HOME/discourse-create-site or ~/.config/discourse-create-site | | --token | DISCOURSE_ID_TOKEN | Explicit Bearer access token | Stored host token |

Post-Provisioning MCP Setup

Newly provisioned sites do not enable Discourse's built-in MCP server by default yet. Once the user opens redirect_url directly and finishes admin sign-in:

  1. Visit <site_origin>/admin/config/mcp/settings and enable MCP (mcp_server_enabled).
  2. Reply "now add mcp support" inside your AI agent session so the agent configures <site_origin>/mcp (Streamable HTTP, OAuth discovery at <site_origin>/.well-known/oauth-protected-resource/mcp) for you without needing to run an external CLI command.
  3. After MCP setup is confirmed: Restart your coding agents after the setup. Most agents read their skills directory and MCP configuration at startup.

mcp_setup in --json output includes admin_mcp_url, user_prompt_suggestion ("now add mcp support"), agent_instructions, post_setup_note, and client_instructions as a reference for the detected agent client (or generic Streamable HTTP configuration).

Development

npm install
npm run typecheck
npm test