@drawpro/mcp 0.5.0 → 0.6.1
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 +8 -7
- package/dist/server.js +82 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,15 +12,16 @@ Full documentation:
|
|
|
12
12
|
## Setup
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
|
|
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**.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|
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.
|
|
1414
|
+
var VERSION = "0.6.1";
|
|
1414
1415
|
var inFlight = [];
|
|
1415
1416
|
var cachedUser = null;
|
|
1416
1417
|
async function currentUser() {
|
|
@@ -1425,7 +1426,14 @@ async function unlockedKey() {
|
|
|
1425
1426
|
const key = loadKey(user.email);
|
|
1426
1427
|
if (!key) {
|
|
1427
1428
|
return {
|
|
1428
|
-
error:
|
|
1429
|
+
error: `This account (${user.email}) is locked, so names and contents cannot be read.
|
|
1430
|
+
|
|
1431
|
+
Ask the user to run this in a terminal:
|
|
1432
|
+
npx -y @drawpro/mcp login
|
|
1433
|
+
|
|
1434
|
+
It prompts for their passcode and stores the derived key in the OS keychain. They do NOT need to restart \u2014 once it completes, simply try the same tool again and it will work.
|
|
1435
|
+
|
|
1436
|
+
Never ask the user for their passcode here. It is the account's master secret and must not pass through this conversation.`
|
|
1429
1437
|
};
|
|
1430
1438
|
}
|
|
1431
1439
|
return { key };
|
|
@@ -2003,12 +2011,82 @@ async function auth(arg) {
|
|
|
2003
2011
|
);
|
|
2004
2012
|
}
|
|
2005
2013
|
}
|
|
2014
|
+
function claudeAvailable() {
|
|
2015
|
+
try {
|
|
2016
|
+
(0, import_node_child_process2.execFileSync)("claude", ["--version"], { stdio: "ignore" });
|
|
2017
|
+
return true;
|
|
2018
|
+
} catch {
|
|
2019
|
+
return false;
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
async function connect(token) {
|
|
2023
|
+
if (!token) {
|
|
2024
|
+
throw new ConfigError(
|
|
2025
|
+
'Usage: drawpro-mcp connect dp_live_...\nCreate a token in DrawPro under "Connect to Claude Code".'
|
|
2026
|
+
);
|
|
2027
|
+
}
|
|
2028
|
+
if (!token.startsWith("dp_live_")) {
|
|
2029
|
+
throw new ConfigError("That does not look like a DrawPro token \u2014 they begin with dp_live_.");
|
|
2030
|
+
}
|
|
2031
|
+
process.stdout.write("Checking the token... ");
|
|
2032
|
+
let user;
|
|
2033
|
+
try {
|
|
2034
|
+
user = await new DrawProClient(BASE_URL, token).me();
|
|
2035
|
+
} catch (err) {
|
|
2036
|
+
console.log("");
|
|
2037
|
+
throw new ConfigError(`rejected, nothing has been changed: ${err.message}`);
|
|
2038
|
+
}
|
|
2039
|
+
console.log(`ok \u2014 ${user.email}`);
|
|
2040
|
+
writeConfig({ token });
|
|
2041
|
+
if (!claudeAvailable()) {
|
|
2042
|
+
console.log("\nToken saved, but the `claude` command was not found, so the server could not");
|
|
2043
|
+
console.log("be registered. Register it yourself, without -e DRAWPRO_TOKEN:");
|
|
2044
|
+
console.log("\n claude mcp add drawpro --scope user -- npx -y @drawpro/mcp");
|
|
2045
|
+
return;
|
|
2046
|
+
}
|
|
2047
|
+
try {
|
|
2048
|
+
(0, import_node_child_process2.execFileSync)("claude", ["mcp", "remove", "drawpro", "-s", "user"], { stdio: "ignore" });
|
|
2049
|
+
} catch {
|
|
2050
|
+
}
|
|
2051
|
+
try {
|
|
2052
|
+
(0, import_node_child_process2.execFileSync)("claude", ["mcp", "add", "drawpro", "-s", "user", "--", "npx", "-y", "@drawpro/mcp"], {
|
|
2053
|
+
stdio: "ignore"
|
|
2054
|
+
});
|
|
2055
|
+
} catch (err) {
|
|
2056
|
+
throw new ConfigError(
|
|
2057
|
+
`Token saved, but registering with Claude Code failed: ${err.message}
|
|
2058
|
+
Register it yourself: claude mcp add drawpro --scope user -- npx -y @drawpro/mcp`
|
|
2059
|
+
);
|
|
2060
|
+
}
|
|
2061
|
+
console.log("Registered with Claude Code for all your projects.");
|
|
2062
|
+
if (user.encryptedPrivateKey && !loadKey(user.email)) {
|
|
2063
|
+
console.log("\nCreating diagrams will work now. Reading them needs your passcode, which");
|
|
2064
|
+
console.log("unwraps your private key on this machine \u2014 it is never sent anywhere.");
|
|
2065
|
+
console.log("Unlock now, or skip and run `npx -y @drawpro/mcp login` later.\n");
|
|
2066
|
+
const passcode = await askHidden("passcode (or press enter to skip): ");
|
|
2067
|
+
if (passcode) {
|
|
2068
|
+
process.stdout.write("unlocking... ");
|
|
2069
|
+
try {
|
|
2070
|
+
const key = await decryptPrivateKey(user.encryptedPrivateKey, passcode, user.salt);
|
|
2071
|
+
const { location } = storeKey(user.email, key);
|
|
2072
|
+
console.log(`done, stored in the ${location}.`);
|
|
2073
|
+
} catch {
|
|
2074
|
+
console.log("incorrect passcode. Run `npx -y @drawpro/mcp login` when ready.");
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
console.log("\nRestart Claude Code, then ask it to list your DrawPro workspaces.");
|
|
2079
|
+
}
|
|
2006
2080
|
async function main() {
|
|
2007
2081
|
const command = process.argv[2];
|
|
2008
2082
|
if (command === "login") {
|
|
2009
2083
|
await login(process.argv.includes("--forget"));
|
|
2010
2084
|
return;
|
|
2011
2085
|
}
|
|
2086
|
+
if (command === "connect") {
|
|
2087
|
+
await connect(process.argv[3]);
|
|
2088
|
+
return;
|
|
2089
|
+
}
|
|
2012
2090
|
if (command === "auth") {
|
|
2013
2091
|
await auth(process.argv[3]);
|
|
2014
2092
|
return;
|
|
@@ -2028,7 +2106,7 @@ async function main() {
|
|
|
2028
2106
|
}
|
|
2029
2107
|
if (command && command !== "serve") {
|
|
2030
2108
|
console.error(
|
|
2031
|
-
`Unknown command "${command}". Use: drawpro-mcp [serve|auth|login|stats|telemetry|report]`
|
|
2109
|
+
`Unknown command "${command}". Use: drawpro-mcp [serve|connect|auth|login|stats|telemetry|report]`
|
|
2032
2110
|
);
|
|
2033
2111
|
process.exit(2);
|
|
2034
2112
|
}
|