@drawpro/mcp 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,13 +3,24 @@
3
3
  Local MCP server for DrawPro. Lets Claude read and create diagrams in your
4
4
  account from Claude Code, Claude Desktop, or any MCP client.
5
5
 
6
+ Full documentation:
7
+ [setup](https://github.com/deBilla/drawpro/blob/main/docs/connect-claude-code.md) ·
8
+ [tools](https://github.com/deBilla/drawpro/blob/main/docs/mcp-tools.md) ·
9
+ [diagram specs](https://github.com/deBilla/drawpro/blob/main/docs/diagram-specs.md) ·
10
+ [privacy](https://github.com/deBilla/drawpro/blob/main/docs/privacy.md)
11
+
6
12
  ## Setup
7
13
 
8
14
  ```bash
9
- claude mcp add drawpro --scope user -e DRAWPRO_TOKEN="dp_live_..." -- npx -y @drawpro/mcp
15
+ claude mcp add drawpro --scope user -- npx -y @drawpro/mcp
16
+ npx -y @drawpro/mcp auth dp_live_...
10
17
  ```
11
18
 
12
- Mint the token in DrawPro under **Connect to Claude Code**.
19
+ Mint the token in DrawPro under **Connect to Claude Code**. `auth` verifies it
20
+ against the API before saving, and `auth dp_live_<new>` rotates it later —
21
+ Claude Code can add and remove a server but not edit one, so a token passed with
22
+ `-e DRAWPRO_TOKEN` can only be changed by removing and re-adding the server.
23
+ `DRAWPRO_TOKEN` still works and takes precedence.
13
24
 
14
25
  `--scope user` registers it for every project on your machine. The scope
15
26
  otherwise defaults to `local`, which loads the server only in the directory the
package/dist/server.js CHANGED
@@ -430,6 +430,9 @@ function installId() {
430
430
  function telemetryEnabled() {
431
431
  return readConfig().telemetry === "on";
432
432
  }
433
+ function resolveToken() {
434
+ return process.env.DRAWPRO_TOKEN || readConfig().token;
435
+ }
433
436
 
434
437
  // ../diagram/src/ids.ts
435
438
  var import_fractional_indexing = require("fractional-indexing");
@@ -1396,10 +1399,10 @@ var ConfigError = class extends Error {
1396
1399
  var clientInstance = null;
1397
1400
  function api() {
1398
1401
  if (!clientInstance) {
1399
- const token = process.env.DRAWPRO_TOKEN;
1402
+ const token = resolveToken();
1400
1403
  if (!token) {
1401
1404
  throw new ConfigError(
1402
- 'DRAWPRO_TOKEN is not set. Create a token in DrawPro under "Connect to Claude Code", then:\n claude mcp add drawpro --scope user -e DRAWPRO_TOKEN="dp_live_..." -- npx -y @drawpro/mcp'
1405
+ 'No API token. Create one in DrawPro under "Connect to Claude Code", then:\n npx -y @drawpro/mcp auth dp_live_...\n\nOr supply it through the environment when registering the server:\n claude mcp add drawpro --scope user -e DRAWPRO_TOKEN="dp_live_..." -- npx -y @drawpro/mcp'
1403
1406
  );
1404
1407
  }
1405
1408
  clientInstance = new DrawProClient(BASE_URL, token, (t) => inFlight.push(t));
@@ -1407,7 +1410,7 @@ function api() {
1407
1410
  return clientInstance;
1408
1411
  }
1409
1412
  var SESSION_ID = Math.random().toString(36).slice(2, 10);
1410
- var VERSION = "0.4.1";
1413
+ var VERSION = "0.5.0";
1411
1414
  var inFlight = [];
1412
1415
  var cachedUser = null;
1413
1416
  async function currentUser() {
@@ -1960,12 +1963,56 @@ function maybeSendInBackground() {
1960
1963
  if (ok) writeConfig({ lastReportAt: (/* @__PURE__ */ new Date()).toISOString() });
1961
1964
  });
1962
1965
  }
1966
+ async function auth(arg) {
1967
+ if (arg === "--forget") {
1968
+ writeConfig({ token: void 0 });
1969
+ console.log("Token cleared.");
1970
+ return;
1971
+ }
1972
+ if (!arg) {
1973
+ const current = readConfig().token;
1974
+ const fromEnv = Boolean(process.env.DRAWPRO_TOKEN);
1975
+ if (fromEnv) {
1976
+ console.log("Using DRAWPRO_TOKEN from the environment, which takes precedence.");
1977
+ } else if (current) {
1978
+ console.log(`Stored token: ${current.slice(0, 16)}\u2026`);
1979
+ } else {
1980
+ console.log("No token stored.");
1981
+ }
1982
+ console.log("\n drawpro-mcp auth dp_live_... store or replace it");
1983
+ console.log(" drawpro-mcp auth --forget clear it");
1984
+ return;
1985
+ }
1986
+ if (!arg.startsWith("dp_live_")) {
1987
+ throw new ConfigError("That does not look like a DrawPro token \u2014 they begin with dp_live_.");
1988
+ }
1989
+ const probe = new DrawProClient(BASE_URL, arg);
1990
+ let email;
1991
+ try {
1992
+ email = (await probe.me()).email;
1993
+ } catch (err) {
1994
+ throw new ConfigError(
1995
+ `That token was rejected, so it has not been saved: ${err.message}`
1996
+ );
1997
+ }
1998
+ writeConfig({ token: arg });
1999
+ console.log(`Token saved for ${email}.`);
2000
+ if (process.env.DRAWPRO_TOKEN) {
2001
+ console.log(
2002
+ "\nNote: DRAWPRO_TOKEN is also set in this environment and takes precedence.\nRemove it from the MCP registration for the stored token to be used."
2003
+ );
2004
+ }
2005
+ }
1963
2006
  async function main() {
1964
2007
  const command = process.argv[2];
1965
2008
  if (command === "login") {
1966
2009
  await login(process.argv.includes("--forget"));
1967
2010
  return;
1968
2011
  }
2012
+ if (command === "auth") {
2013
+ await auth(process.argv[3]);
2014
+ return;
2015
+ }
1969
2016
  if (command === "telemetry") {
1970
2017
  await telemetry(process.argv[3]);
1971
2018
  return;
@@ -1981,7 +2028,7 @@ async function main() {
1981
2028
  }
1982
2029
  if (command && command !== "serve") {
1983
2030
  console.error(
1984
- `Unknown command "${command}". Use: drawpro-mcp [serve|login|stats|telemetry|report]`
2031
+ `Unknown command "${command}". Use: drawpro-mcp [serve|auth|login|stats|telemetry|report]`
1985
2032
  );
1986
2033
  process.exit(2);
1987
2034
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawpro/mcp",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "MCP server for DrawPro \u2014 read and create end-to-end encrypted Excalidraw diagrams from Claude",
5
5
  "license": "MIT",
6
6
  "repository": {