Use SunLicense with your AI assistant
Your coding assistant can add SunLicense to your project and test it for you. There are three levels; the first two work on every plan.
| What the assistant gets | Plans | |
|---|---|---|
| Docs for assistants | Every docs page as plain Markdown | All |
| A prompt to paste | The whole setup in one prompt: CLI, account, the check in your language, a test | All |
| MCP server | Tools to create products, issue a test license, create an API key and test a key | All (Free: 50 calls a day) |
Using claude.ai or ChatGPT in the browser instead? Connect them as a remote MCP server: no CLI and no token, you sign in once.
Docs for assistants
These docs are published in the llms.txt format, which assistants read better than web pages:
| URL | Holds |
|---|---|
| docs.sunlicense.com/llms.txt | The table of contents, with a link to each page |
| docs.sunlicense.com/llms-full.txt | Every page in one file |
docs.sunlicense.com/<page>.md | One page as Markdown, e.g. /guide/sdks.md |
Tell your assistant to read them ("use https://docs.sunlicense.com/llms.txt"), or add the URL to its docs settings (Cursor: @Docs → Add new doc).
A prompt to paste
One prompt does the whole setup, in any language and any coding agent (Claude Code, Cursor, Copilot, Codex, Windsurf, Gemini CLI, Zed, JetBrains, Cline, Aider…). The agent installs the CLI, runs sunlicense init (a guest account if you aren't signed in), adds the check with the official SDK or the HTTP API, proves it works (valid, suspended and refused, reinstated), sets up the MCP server and ends with a short guide. It never asks you anything. The same prompt, with a Copy button: sunlicense.com/prompt (plain text: sunlicense.com/prompt.txt).
Set up SunLicense in this project (license check, advanced analytics, core unlock, ownership notice, tamper reports, manage licenses by AI) and prove each part works. Do it all yourself: don't ask me anything. Where you must choose, pick a sensible default and list it at the end.
SunLicense checks license keys for software people sell. Docs for AI agents: https://docs.sunlicense.com/llms.txt
Rules:
- Never put a full license key or API key in source code, logs, commits or your messages. They live in the gitignored .env file that step 3 writes; only a built release carries the API key, written in by the build (step 4). In messages show keys masked (first 4 characters).
- With an SDK, create no id, marker or cache files of your own: it keeps its state (machine id, unlock cache, install id) in the folder you give it.
- Before you create a folder or package, check for one whose name differs only in case (macOS and Windows treat them as the same) and use that one.
- Use the project's own shell. Windows: use PowerShell. If your sandbox blocks network access, ask for it once.
- Each step says what success looks like. If a step fails, read the error, fix the cause and retry; after two failed tries use the next option.
- Don't commit or push. Apart from the SunLicense CLI, install nothing outside the project: no system packages, language toolchains or package managers. If the SDK needs a package manager that isn't there, use the HTTP request from step 3 instead.
1. Work out what this project is before you change anything: its language, what kind of product it is (a plugin or mod for a game or server, a bot, a script or resource, a desktop app, a web app, a CLI tool, a library), how it starts, where it keeps its settings and how its releases are built. The steps below say what to do for each kind; where a kind isn't named, do what that kind of project usually does.
2. Get the SunLicense CLI. Use the first option that works; success: `sunlicense --version` prints a version.
a. Already installed: `sunlicense --version`.
b. macOS, Linux, WSL, Git Bash: `curl -fsSL https://sunlicense.com/install.sh | sh`
Windows PowerShell: `irm https://sunlicense.com/install.ps1 | iex` (cmd: `powershell -c "irm https://sunlicense.com/install.ps1 | iex"`)
If `sunlicense` isn't found afterwards, call it by the full path the installer printed.
c. Node.js is installed: write `npx -y @sunlicense/cli@latest` wherever a step says `sunlicense`.
d. Nothing can be installed or run: follow https://docs.sunlicense.com/guide/agent-setup.md instead of the CLI (the same steps as plain HTTPS calls), then continue at step 4.
3. In the project's root folder run `sunlicense init --json --parts license,analytics,unlock,notice,tamper,mcp`.
Success: JSON with "ok": true. It found or created a free account (a guest account when none is signed in), a product, an API key and one test license, and wrote SUNLICENSE_API_KEY and SUNLICENSE_LICENSE_KEY to the gitignored file in "envFile". Keep this JSON: the next steps use it.
"setup" in the JSON lists the parts below: skip a part whose "available" is false (my plan doesn't include it) and name it at the end; a part whose "done" is true is already set up, so check it still works instead of adding it again. If the CLI answers unknown flag: --parts, run the same command without --parts.
If "ok" is false with error.code "guest_limit" or "guest_unavailable": stop and tell me to sign up at https://app.sunlicense.com/signup and run `sunlicense login`, then paste this prompt again.
If "ok" is false with error.code "plan_limit": my plan has no room for another product. Stop and pass on error.message (it names my products and the upgrade); don't pick a product for me.
4. Add the license check to the app, as "integration" in the JSON says:
- "kind" "sdk": install the official SDK (integration.sdk.install) and adapt integration.sdk.code. "kind" "http", or an SDK that can't be installed or has no code to adapt: send the request in integration.http with the language's usual HTTP client.
- The installed SDK lacks a class a step below names (an older release): copy its single-file source from https://docs.sunlicense.com/guide/sdks.md#single-file-sources, changing only the package line. Never write SDK code yourself from the docs.
- If the JSON has project.template, that starter project has the check built in: follow its pattern where it fits.
- Base URL: account.server. API key: SUNLICENSE_API_KEY, from the environment or else the .env in the project's root (look there too when the app runs from a subfolder such as run/ or test-server/).
- A product shipped as a built file (a plugin's or mod's jar, a bundled bot or app, a desktop app) carries the API key inside: the build reads SUNLICENSE_API_KEY and writes it into a generated resource that isn't committed (Maven or Gradle resource filtering, a bundler define, a generated settings file). A server app or bot run from source reads it from its environment.
- Machine id: the SDK's own if it has one, else a stable value the system already has (its host name or machine id).
- License key: the customer's own, from where this kind of project keeps its settings: a plugin's or mod's config file, a bot's or server app's environment variable, a script resource's convar, a desktop app's settings (asked for on first run), a CLI tool's flag or environment variable. During development it falls back to SUNLICENSE_LICENSE_KEY.
- Check once at start-up. Rejected: show the reason and stop the paid features (a plugin or mod disables itself, a bot doesn't start, an app shows the reason and locks what's paid). SunLicense unreachable (network error or HTTP 5xx): keep working (fail open).
- Follow integration.rules. Keep the change small and in the project's style. Success: the project builds.
5. Add product analytics: which versions, operating systems, runtimes, platforms and countries run the product. Every install sends a small anonymous report every 30 minutes: no user, host or player names, IP addresses or file paths. Docs: https://docs.sunlicense.com/guide/sdks.md#built-in-analytics and https://docs.sunlicense.com/guide/product-analytics.md
- Start it from the same SunLicense client as the license check, with the license key and machine id it validates with (client.analytics(...) in the docs), so installs show up per license.
- No official SDK for the language, or it can't be installed: POST the report from the docs to account.server + /api/v2/analytics/report every 30 minutes on a background timer, with a random install id kept in the app's data folder.
- Start it once at start-up with the product's real version (from the build, manifest or package file, never a hard-coded string), and close it on shutdown.
- End users must be able to switch it off: add a setting named "analytics", on by default, next to the project's other settings (a config file, environment variable or convar), and pass it to the SDK's enabled option. The SDK also respects SUNLICENSE_ANALYTICS=off by itself.
- It must never slow start-up, block the main thread or crash the app. The SDK reports in the background and stays silent on errors.
- If the app has clear features or settings, count up to 3 important ones with analytics.feature("name"). Pick obvious ones.
- Success: the project builds.
6. Make a small part of the app run only with a valid license (core unlock), so deleting the license check doesn't give a working copy:
- Pick the core: something small the paid features can't work without and that isn't the license check itself (a class or module with core logic, default settings or rules, a lookup table, a script file), at most 512 KB.
- Seal it: `sunlicense seal <file> --product <product.code>` (product.code from the JSON) prints a sealed string (`SLS1.…`); `-o <file>` writes it to a file. It's safe to ship: save it as a resource or constant. Add the seal command to the release build so the sealed copy is made again whenever the core changes. Keep the plain core in the repository but out of the shipped build.
- At start-up, after a valid check, the SDK's `unseal(SEALED)` returns the bytes (the calls per language: https://docs.sunlicense.com/guide/sdks.md#protection-core-unlock-tamper-reports-notice-protected-files); load them the language's way. It throws when there's no valid unlock (a rejected license, or offline for more than 7 days): then keep the paid features off and show the license message. Outages shorter than that keep working: the SDK caches the unlock per machine.
- A plugin or mod (Java): seal a jar of the compiled core classes (or a data file) and load it with `SunLicenseProtection.classLoader(core, getClass().getClassLoader())`, or parse the data. Leave the core classes out of the shipped jar. The SunLicense templates (project.template) already seal their core in release builds: follow them.
- A bot, script, game-server resource or web app (JavaScript, Python, Lua, PHP): seal a module or data file; load the module from the string (Lua `load`, Python `exec` of compiled code, a JavaScript module from text) or parse the data.
- A desktop app: seal a data file or a module the main program loads at start-up.
- No SDK for the language: a valid check answers with `unlock`; unseal as https://docs.sunlicense.com/guide/protection.md#unseal-without-an-sdk says.
- Success: the project builds and the plain core isn't in the build output.
7. Add an ownership notice, so every copy says whose product it is:
- A short header comment in the main source file and in the entry file of anything you sealed or protected: `<product name> by <organization>. Licensed software: <terms link>. Copying or redistributing it without a license is not allowed.` Use account.organization and the product's name from the JSON, and the project's own license or terms link if it has one (else the store page, else no link).
- At start-up, after the license check, log the line the SDK's `notice()` returns, once: the product, the owner, the masked license key and the terms link. Without an SDK, log such a line yourself (key masked: first 4 characters).
- Where the line goes: a plugin's or mod's enable log, a bot's ready log, a script resource's server console, a desktop app's log (and its About box, if any), a web app's server log on boot (never the browser).
- Never print the customer's name, email or full key.
- Success: the project builds.
8. Report modified copies (patched, cracked or repacked) to Sentinel with the next license check. The app never stops itself because of it:
- In the release build, add `--digest <glob>` to the seal command from step 6 for the code you ship, so its expected hashes travel inside the sealed string. Each file is named by its path below the glob's folders. Never digest the file that holds the sealed string, config files or user data.
- Right after `unseal`, call the SDK's integrity check on the running copy; it compares with the digests from the sealed string. The result (OK or MODIFIED) goes with the next license check, but the start-up check ran before `unseal`: send it with the app's periodic check or, without one, with one more check in the background right after.
- A plugin or mod (Java): `--digest 'build/classes/java/main/**/*.class'` (Maven: `target/classes/**/*.class`; the names match the jar's entries) and `integrity(getClass().getClassLoader())`.
- A bot, script, game-server resource or web app: digest the shipped code (e.g. `--digest "dist/**/*.js"`, `--digest "server/**/*.lua"`) and pass the shipped folder to the integrity check.
- A desktop app: digest the main bundle (`app.asar` for Electron) and pass its folder.
- No SDK: compute the SHA-256 yourself and send `"integrity": "OK"` or `"MODIFIED"` in the validate request.
- In development (nothing sealed with digests yet), skip the check rather than report MODIFIED.
- Success: the project builds.
9. Run `sunlicense mcp install` so I can manage licenses by asking you (issue, suspend, look up customers, read analytics). Success: it names the file it wrote. If it prints a snippet instead, add it to your editor's MCP settings if you can, or put it in your last message. Web apps and editors without a shell use the remote server https://api.sunlicense.com/mcp.
10. Prove each part works: run the app, or a short script or test that calls your code.
License check, with the test license. License changes reach license checks within seconds: on an unexpected answer (such as NOT_FOUND right after step 3), retry every 5 seconds for up to 30 seconds before you change code.
a. It reports the license as valid; a product shipped as a built file does so too when the built file runs outside the project folder. `sunlicense validate --release` also prints VALID (--release keeps the CLI from using one of the test license's 2 machines).
b. `sunlicense licenses suspend [email protected] --yes`, then run your check again. Success: rejected with SUSPENDED.
c. `sunlicense licenses reinstate [email protected]`, then your check reports valid again.
Analytics: the SDK logs an accepted report, or the POST answers 2xx.
Core unlock: with the valid test license the core loads and the app works; while it's suspended (license check b.), `unseal` throws and the paid features stay off with the license message.
Ownership notice: running with the test license logs the notice line once, with the key masked.
Tamper reports: the release build with the test license checks valid, unseals, runs the integrity check and then checks the license again, so integrity OK reaches SunLicense (without that second check the part never ticks). A unit test shows that a changed copy of the file gives MODIFIED, without sending it: never send MODIFIED with the test license, it opens a Sentinel finding.
If a check gives the wrong answer, fix the code and repeat step 10. Delete scripts you only made for this step; keep real tests.
11. Record the parts SunLicense can't see from outside: `sunlicense setup report --product <product.code> --done notice`. Success: it prints the product's setup progress.
12. End with a short message to me (at most 30 lines):
- What you changed (files) and the defaults you picked.
- How to run the app with a license: where the customer's key goes, and how a release build gets the API key.
- How to issue, suspend and reinstate licenses: `sunlicense licenses issue`, `sunlicense licenses suspend <key>`, `sunlicense licenses reinstate <key>`, by asking you (MCP), or in the dashboard (`sunlicense open`).
- "Run `sunlicense guide` for a short interactive tour on your test license."
- Where the "analytics" setting lives and which features you count.
- "Charts appear on the product's Analytics tab in SunLicense a few minutes after the first report."
- What you sealed, where the sealed string lives and the build step that seals it again.
- The files with the header and where the notice line appears.
- Which files are checked: modified copies show up in Sentinel, which suggests suspending the license.
- If account.guest is true: "This is a guest account. It's deleted 30 days after it was last used: run `sunlicense claim` to keep it. Already have a SunLicense account? Run `sunlicense login`: everything moves into it, keys unchanged."
- Pass on any "warnings" from step 3, and name the parts you skipped.
- Set up over HTTP without the CLI (step 2d)? Then give the claim link (claimUrl) instead of `sunlicense claim`, the dashboard (it opens once the account is claimed) instead of the CLI commands, and the guest token once, to keep in a password manager.It holds no keys: the CLI writes them to a gitignored .env. There's no language or product-type choice: the agent works out what your project is (a plugin, mod, bot, script, desktop or web app) and acts on it. An agent without a shell or the CLI follows the HTTP recipe instead.
For a product you already have, open Products → the product → Setup and choose Copy prompt: the same prompt for your account and that product, with the parts your plan includes switched on: the license check, analytics with custom charts, protection (core unlock, ownership notice, tamper reports) and the extras (download watermark, a "Manage your license" link, MCP). Protected files, the offline fallback and obfuscated release builds start off: switch them on there to add them, or switch any part off to leave it out. The tab ticks each part off as your app shows it working, and re-running the prompt skips what's done. On sunlicense.com/prompt, Customize what it sets up picks the parts for the guest prompt.
Let it manage your account (MCP)
With the SunLicense CLI installed, sunlicense mcp gives the assistant tools to create a product and policy, issue a test license, create an API key for your app, block a machine and check a key the way your app does, so it can test what it built. It's included in every plan: Free (50 tool calls a day), Lite (300) and Standard (3,000).
- Create a personal access token with only the scopes the assistant needs: the dashboard's MCP page (Create a token for an assistant) ticks the usual ones and gives you the commands below with the token filled in (or use Settings → Personal access tokens, or sign in with
sunlicense login; that session lasts 12 hours). - Add the server:
claude mcp add sunlicense --env SUNLICENSE_TOKEN=slp_... -- sunlicense mcpcodex mcp add sunlicense --env SUNLICENSE_TOKEN=slp_... -- sunlicense mcp{
"mcpServers": {
"sunlicense": {
"command": "sunlicense",
"args": ["mcp"],
"env": { "SUNLICENSE_TOKEN": "slp_..." }
}
}
}AI assistants (MCP) lists every tool, the daily limits and what stays private.
claude.ai and ChatGPT
Web apps don't run the CLI: add https://api.sunlicense.com/mcp as a custom connector and sign in instead. See Connect claude.ai, ChatGPT and other web AI apps. Both share the same daily limit.
Claude Code plugin
The SunLicense plugin bundles a skill that knows how to add a license check the right way (official SDK, API key outside source control, stable machine id, fail open, masked keys, no bypasses) with SunLicense's remote MCP server:
/plugin marketplace add sunlicense-com/claude-plugin
/plugin install sunlicense@sunlicenseThe first time a tool runs, Claude Code opens SunLicense in your browser to connect (or run /mcp and choose Authenticate); no CLI or token needed. The skill and the MCP server work on every plan (Free: 50 MCP tool calls a day). Prefer the CLI with a personal access token (scripts, CI)? Use claude mcp add as above instead of the plugin's server. Source: github.com/sunlicense-com/claude-plugin.
Good to know
- Never give your app a personal access token. Apps use an API key (
slk_…); tokens (slp_…) are for the CLI and assistants, and can do everything their scopes allow. - Review the check. Ask the assistant to show you where it reads the API key and what happens when SunLicense says no or can't be reached. The SDKs page has the recommended behaviour.
- Your code stays yours. SunLicense receives the API calls the CLI makes, never your prompts or code.
