@drawpro/mcp 0.5.0 → 0.6.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
@@ -12,15 +12,16 @@ Full documentation:
12
12
  ## Setup
13
13
 
14
14
  ```bash
15
- claude mcp add drawpro --scope user -- npx -y @drawpro/mcp
16
- npx -y @drawpro/mcp auth dp_live_...
15
+ npx -y @drawpro/mcp connect dp_live_...
17
16
  ```
18
17
 
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.
18
+ Mint the token in DrawPro under **Connect to Claude Code**. One command: it
19
+ verifies the token, registers the server with Claude Code for all projects, and
20
+ offers to unlock reading. Re-run it with a new token to rotate. Nothing changes
21
+ if the token is rejected.
22
+
23
+ `auth`, `login`, and `claude mcp add` remain available separately if you would
24
+ rather do the steps yourself.
24
25
 
25
26
  `--scope user` registers it for every project on your machine. The scope
26
27
  otherwise defaults to `local`, which loads the server only in the directory the
package/dist/server.js CHANGED
@@ -24,6 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  ));
25
25
 
26
26
  // src/server.ts
27
+ var import_node_child_process2 = require("node:child_process");
27
28
  var import_node_fs3 = require("node:fs");
28
29
  var import_node_os3 = require("node:os");
29
30
  var import_node_path3 = require("node:path");
@@ -1402,7 +1403,7 @@ function api() {
1402
1403
  const token = resolveToken();
1403
1404
  if (!token) {
1404
1405
  throw new ConfigError(
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'
1406
+ 'No API token. Create one in DrawPro under "Connect to Claude Code", then:\n npx -y @drawpro/mcp connect 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'
1406
1407
  );
1407
1408
  }
1408
1409
  clientInstance = new DrawProClient(BASE_URL, token, (t) => inFlight.push(t));
@@ -1410,7 +1411,7 @@ function api() {
1410
1411
  return clientInstance;
1411
1412
  }
1412
1413
  var SESSION_ID = Math.random().toString(36).slice(2, 10);
1413
- var VERSION = "0.5.0";
1414
+ var VERSION = "0.6.0";
1414
1415
  var inFlight = [];
1415
1416
  var cachedUser = null;
1416
1417
  async function currentUser() {
@@ -2003,12 +2004,82 @@ async function auth(arg) {
2003
2004
  );
2004
2005
  }
2005
2006
  }
2007
+ function claudeAvailable() {
2008
+ try {
2009
+ (0, import_node_child_process2.execFileSync)("claude", ["--version"], { stdio: "ignore" });
2010
+ return true;
2011
+ } catch {
2012
+ return false;
2013
+ }
2014
+ }
2015
+ async function connect(token) {
2016
+ if (!token) {
2017
+ throw new ConfigError(
2018
+ 'Usage: drawpro-mcp connect dp_live_...\nCreate a token in DrawPro under "Connect to Claude Code".'
2019
+ );
2020
+ }
2021
+ if (!token.startsWith("dp_live_")) {
2022
+ throw new ConfigError("That does not look like a DrawPro token \u2014 they begin with dp_live_.");
2023
+ }
2024
+ process.stdout.write("Checking the token... ");
2025
+ let user;
2026
+ try {
2027
+ user = await new DrawProClient(BASE_URL, token).me();
2028
+ } catch (err) {
2029
+ console.log("");
2030
+ throw new ConfigError(`rejected, nothing has been changed: ${err.message}`);
2031
+ }
2032
+ console.log(`ok \u2014 ${user.email}`);
2033
+ writeConfig({ token });
2034
+ if (!claudeAvailable()) {
2035
+ console.log("\nToken saved, but the `claude` command was not found, so the server could not");
2036
+ console.log("be registered. Register it yourself, without -e DRAWPRO_TOKEN:");
2037
+ console.log("\n claude mcp add drawpro --scope user -- npx -y @drawpro/mcp");
2038
+ return;
2039
+ }
2040
+ try {
2041
+ (0, import_node_child_process2.execFileSync)("claude", ["mcp", "remove", "drawpro", "-s", "user"], { stdio: "ignore" });
2042
+ } catch {
2043
+ }
2044
+ try {
2045
+ (0, import_node_child_process2.execFileSync)("claude", ["mcp", "add", "drawpro", "-s", "user", "--", "npx", "-y", "@drawpro/mcp"], {
2046
+ stdio: "ignore"
2047
+ });
2048
+ } catch (err) {
2049
+ throw new ConfigError(
2050
+ `Token saved, but registering with Claude Code failed: ${err.message}
2051
+ Register it yourself: claude mcp add drawpro --scope user -- npx -y @drawpro/mcp`
2052
+ );
2053
+ }
2054
+ console.log("Registered with Claude Code for all your projects.");
2055
+ if (user.encryptedPrivateKey && !loadKey(user.email)) {
2056
+ console.log("\nCreating diagrams will work now. Reading them needs your passcode, which");
2057
+ console.log("unwraps your private key on this machine \u2014 it is never sent anywhere.");
2058
+ console.log("Unlock now, or skip and run `npx -y @drawpro/mcp login` later.\n");
2059
+ const passcode = await askHidden("passcode (or press enter to skip): ");
2060
+ if (passcode) {
2061
+ process.stdout.write("unlocking... ");
2062
+ try {
2063
+ const key = await decryptPrivateKey(user.encryptedPrivateKey, passcode, user.salt);
2064
+ const { location } = storeKey(user.email, key);
2065
+ console.log(`done, stored in the ${location}.`);
2066
+ } catch {
2067
+ console.log("incorrect passcode. Run `npx -y @drawpro/mcp login` when ready.");
2068
+ }
2069
+ }
2070
+ }
2071
+ console.log("\nRestart Claude Code, then ask it to list your DrawPro workspaces.");
2072
+ }
2006
2073
  async function main() {
2007
2074
  const command = process.argv[2];
2008
2075
  if (command === "login") {
2009
2076
  await login(process.argv.includes("--forget"));
2010
2077
  return;
2011
2078
  }
2079
+ if (command === "connect") {
2080
+ await connect(process.argv[3]);
2081
+ return;
2082
+ }
2012
2083
  if (command === "auth") {
2013
2084
  await auth(process.argv[3]);
2014
2085
  return;
@@ -2028,7 +2099,7 @@ async function main() {
2028
2099
  }
2029
2100
  if (command && command !== "serve") {
2030
2101
  console.error(
2031
- `Unknown command "${command}". Use: drawpro-mcp [serve|auth|login|stats|telemetry|report]`
2102
+ `Unknown command "${command}". Use: drawpro-mcp [serve|connect|auth|login|stats|telemetry|report]`
2032
2103
  );
2033
2104
  process.exit(2);
2034
2105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawpro/mcp",
3
- "version": "0.5.0",
3
+ "version": "0.6.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": {