dynamsoft-license-mcp

v0.2.0
dynamsoft-license-mcp Checked 4 days ago Published 5 days ago

MCP server that provisions Dynamsoft trial license keys through the customer portal Google sign-in and explains how to wire the key into each SDK.

This MCP server prepares Dynamsoft trial licenses and provides SDK initialization examples. In a conversation, prepare_trial_license reports the status, product and edition. The server stores a successfully acquired key in its local cache. A program that needs the full value can call get_trial_license directly outside a model conversation. Add it to any stdio MCP client (Claude Code, Cursor, Codex, Copilot CLI…): To generate initialization code, use get_license_guide and have the application read its normal configuration.

Summary extracted from the README.

dynamsoft-license-mcp

This MCP server prepares Dynamsoft trial licenses and provides SDK initialization examples. In a conversation, prepare_trial_license reports the status, product and edition. The server stores a successfully acquired key in its local cache. A program that needs the full value can call get_trial_license directly outside a model conversation.

Requirements

Requirement Notes
Node.js 22+ Uses the built-in WebSocket to talk to the browser. Node 18/20 exit with a message.
Chrome or Edge Auto-detected; override with CHROME_PATH.
A Google account One that may sign in to the Dynamsoft customer portal. Signing in creates or reuses the customer account for that identity.

Install

Add it to any stdio MCP client (Claude Code, Cursor, Codex, Copilot CLI…):

{
  "mcpServers": {
    "dynamsoft-license": {
      "command": "npx",
      "args": ["-y", "dynamsoft-license-mcp"]
    }
  }
}

Tools

Tool Input Output
prepare_trial_license product, package, wait_ms Preparation status and requested product and edition. Errors return only {"status":"error"}.
get_trial_license product, package, wait_ms, force_refresh Programmatic clients receive the full key, expiry, masked form and source.
get_license_guide product, platform, framework The exact initialization call for that platform, the environment variable to use, and the suggested edition. Code only, no key.
describe_license license_key (optional) Masked preview, key format, organization id, license server, expiry. Never the full key.
get_trial_page_url product, package The official trial page, for users who would rather apply by hand.

First run

To generate initialization code, use get_license_guide and have the application read its normal configuration. For manual setup, get_trial_page_url supplies the official portal link.

When you ask a chat assistant to prepare a trial, it can call prepare_trial_license. The server checks its cache, then your portal account, and can issue a new trial if needed. If sign-in is required, complete it in the browser opened by the server.

{
  "status": "ok",
  "product": "dcv",
  "package": "cross-platform"
}

ok means the key is cached. A runtime integration can call get_trial_license directly using the same local server cache and pass the returned value to the SDK in its own process. Keep the raw tool response out of model messages and logs. If you manage application configuration yourself, you can obtain the value in the customer portal.

For login_required, finish signing in and retry preparation. For email_sent, check your portal account's inbox. unavailable means the portal supplied no key. A tool error returns the fixed error status.

Quota behaviour

The portal allows only a small number of trial requests per account and product, and asks survey questions after the second. The server is therefore strictly lazy:

Order Step Cost
1 Local cache (licenses.json) free, offline
2 Portal license list (GetCompanyRecordList) free, read-only
3 Portal trial request (RequestFromWeb) one request
4 Google sign-in only when there is no usable session

Only step 3 consumes quota. force_refresh is the only way to reach it while a valid key already exists, so leave it alone unless the key is genuinely wrong.

How the sign-in works

The portal's OAuth entry point is GET /api-common/Api/User/Login/Google?callback=<url>, and it refuses any callback that is not on www.dynamsoft.com — a local redirect cannot receive the token. The session it creates lives in HttpOnly cookies on the portal domain, which no separate process can read either. So the only workable path is to drive a real browser and read the cookies over the DevTools protocol.

That is deliberately done with zero dependencies:

  • The installed Chrome/Edge is launched with a dedicated profile and --remote-debugging-port=0.
  • The server connects with Node's built-in WebSocket and reads cookies via Storage.getCookies.
  • No Playwright/Puppeteer, so there is no browser download and — importantly — no --enable-automation flag, which is the usual reason Google rejects a sign-in as an insecure browser.

With the cookies in hand the server calls the portal's own APIs, the same ones its website uses:

Endpoint Purpose
POST /api-common/Api/User/Info Account email and company id.
POST /api-portal/Api/Trial/GetCompanyRecordList Existing keys for a product/edition (read-only).
POST /api-portal/Api/Trial/RequestFromWeb Issue the trial key.

The session is stored locally, so the browser is only needed the first time.

These are the website's internal endpoints, not a documented public API. A portal change can break this server; get_trial_page_url is the permanent fallback.

Products and editions

product Product
dcv (default) Dynamsoft Capture Vision (barcode + document + MRZ capabilities)
dbr Dynamsoft Barcode Reader
dwt Dynamic Web TWAIN
ddv Dynamsoft Document Viewer
mrz MRZ Scanner
mds Mobile Document Scanner
mwc Mobile Web Capture
dwt-ddv Web TWAIN + Document Viewer bundle
package Edition
cross-platform (default) Any platform
web Web / JavaScript
mobile Android / iOS
desktop Server / desktop (Python, .NET, Java, C++, Node.js)

The edition is the part that matters: the runtime enforces it, and a desktop key in a browser fails with [License] License mismatch: Browser requested. Pick the edition that matches where the code runs — web for a browser app, mobile for a phone app, desktop for a script or service, and cross-platform when one key has to serve several.

The product argument mainly decides which portal record the request is filed under. One key covers the Dynamsoft products: a key already cached for one product is reused for another when the edition matches (reported as source: "cache-shared"), so asking for dwt after dcv returns the same key without spending a trial request.

Data stored locally

Under ~/.dynamsoft-license-mcp/ (override with DYNAMSOFT_LICENSE_HOME):

File Contents
session.json Portal cookies plus account email/company. Owner-only permissions.
licenses.json Keys per product/edition with expiry. Owner-only permissions.
browser-profile/ The Chrome profile used for sign-in (keeps the Google session).

Delete that directory to sign out completely.

Privacy and security

  • prepare_trial_license returns an allowlisted status and the requested product and edition. Portal messages, account details, license values and exception text stay out of its response.
  • get_trial_license returns a full key and describe_license returns license metadata. A model client that invokes either tool receives its response in context.
  • Files are created with owner-only permissions (0600).
  • No credentials are collected in chat: the sign-in happens in a real browser window that the server does not read beyond the cookies it needs.
  • Signing in provisions a real Dynamsoft account for that Google identity, on that account holder's behalf. Use it with their consent.

Troubleshooting

Symptom Fix
No Chrome or Edge found Install one, or set CHROME_PATH to the executable.
Sign-in page says the browser is not secure Retry; this server does not use automation flags. If it persists, sign in through the portal in your normal browser and use get_trial_page_url.
status: "login_required", reason: "timeout" Sign in, then call again; the session survives.
status: "login_required", reason: "browser_closed" The window was closed before sign-in finished. Call again to reopen it.
session_end / session expired Call again; the next call reopens the sign-in page.
Trial request rejected The account has hit the request limit for that product. Use an existing key, or the manual page.
Corporate TLS interception Set NODE_EXTRA_CA_CERTS to your root CA bundle.
Headless server / CI Not supported: there is no browser to sign in with. Pre-provision a key instead.

Development

npm install
npm test           # stdio smoke test, no network, no sign-in
npm run test:live  # real portal calls; needs a saved session, never prints a key
Path Role
src/index.js stdio entry point, browser cleanup on exit
src/server.js MCP tool definitions
src/acquire.js cache → portal list → portal request → sign-in policy
src/portal.js portal API calls
src/session.js session reuse and sign-in orchestration
src/browser.js Chrome discovery, CDP client, cookie reading
src/license.js masking, DLS2 decoding, expiry math
src/guides.js per-platform initialization snippets
src/catalog.js product/edition identifiers and portal URLs

License

MIT.