@wolpertingerlabs/drawlatch 1.0.0-alpha.6.0 → 1.0.0-alpha.8.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 +81 -31
- package/bin/drawlatch.js +454 -5
- package/dist/mcp/server.js +265 -26
- package/dist/remote/ingestors/manager.js +43 -10
- package/dist/remote/ingestors/webhook/webhook-lifecycle-manager.js +3 -3
- package/dist/remote/server.d.ts +15 -0
- package/dist/remote/server.js +211 -15
- package/dist/shared/config.d.ts +2 -2
- package/dist/shared/env-utils.d.ts +35 -0
- package/dist/shared/env-utils.js +143 -0
- package/dist/shared/protocol/handshake.js +14 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -70,31 +70,51 @@ Or load it directly during development:
|
|
|
70
70
|
claude --plugin-dir ./path/to/drawlatch
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
The plugin's MCP server starts automatically when enabled. The `secure_request` and `list_routes` tools become available immediately. The proxy uses `~/.drawlatch/` by default — see [Advanced Configuration](#advanced-configuration) to use a custom path.
|
|
74
|
+
|
|
75
|
+
### Option 2: Auto-Discovery (opening this repo directly)
|
|
76
|
+
|
|
77
|
+
This repo includes a `.mcp.json` file at the root, so Claude Code **automatically discovers** the MCP proxy server when you open the project. On first launch, Claude Code will prompt you to approve the server — accept, and the `secure_request` and `list_routes` tools become available immediately.
|
|
78
|
+
|
|
79
|
+
You need a working setup first (run `drawlatch init` + `drawlatch start`). See [Setup](#setup) below. The proxy uses `~/.drawlatch/` by default — see [Advanced Configuration](#advanced-configuration) to use a custom path.
|
|
80
|
+
|
|
81
|
+
> **Note:** Auto-discovery uses the `dist/mcp/server.js` entrypoint. The `dist/` directory is built automatically when you run `npm install` (via the `prepare` script). If you need to rebuild manually, run `npm run build`.
|
|
82
|
+
|
|
83
|
+
## Setup
|
|
84
|
+
|
|
85
|
+
### Quick Start (Recommended)
|
|
86
|
+
|
|
87
|
+
Get from zero to working in three commands:
|
|
74
88
|
|
|
75
89
|
```bash
|
|
76
|
-
|
|
77
|
-
|
|
90
|
+
# Install globally
|
|
91
|
+
npm install -g @wolpertingerlabs/drawlatch
|
|
78
92
|
|
|
79
|
-
|
|
93
|
+
# Set up keys, config, and .env in one step
|
|
94
|
+
drawlatch init --connections github
|
|
80
95
|
|
|
81
|
-
|
|
96
|
+
# Set your API token (edit the file or run this)
|
|
97
|
+
echo "GITHUB_TOKEN=ghp_your_token_here" >> ~/.drawlatch/.env
|
|
82
98
|
|
|
83
|
-
|
|
99
|
+
# Start the remote server
|
|
100
|
+
drawlatch start
|
|
101
|
+
```
|
|
84
102
|
|
|
85
|
-
|
|
103
|
+
Verify your setup:
|
|
86
104
|
|
|
87
105
|
```bash
|
|
88
|
-
|
|
106
|
+
drawlatch doctor # Validate full setup
|
|
107
|
+
drawlatch status # Check server is running
|
|
108
|
+
drawlatch config # View configuration and secret status
|
|
89
109
|
```
|
|
90
110
|
|
|
91
|
-
|
|
111
|
+
That's it. The `init` command generates keys, creates configs, exchanges public keys, and scaffolds the `.env` file. All steps are idempotent — safe to re-run.
|
|
92
112
|
|
|
93
|
-
|
|
113
|
+
For custom setups (different aliases, multiple callers, different machines), see the [Manual Setup](#manual-setup) section below.
|
|
94
114
|
|
|
95
|
-
|
|
115
|
+
### Manual Setup
|
|
96
116
|
|
|
97
|
-
|
|
117
|
+
#### Prerequisites
|
|
98
118
|
|
|
99
119
|
```bash
|
|
100
120
|
git clone <repo-url>
|
|
@@ -103,9 +123,9 @@ npm install
|
|
|
103
123
|
npm run build
|
|
104
124
|
```
|
|
105
125
|
|
|
106
|
-
|
|
126
|
+
#### Directory Structure
|
|
107
127
|
|
|
108
|
-
All config and key files live inside `~/.drawlatch/` in the user's home directory by default.
|
|
128
|
+
All config and key files live inside `~/.drawlatch/` in the user's home directory by default. Override with `MCP_CONFIG_DIR` for custom deployments (see [Advanced Configuration](#advanced-configuration)).
|
|
109
129
|
|
|
110
130
|
```
|
|
111
131
|
~/.drawlatch/
|
|
@@ -135,7 +155,7 @@ All config and key files live inside `~/.drawlatch/` in the user's home director
|
|
|
135
155
|
└── exchange.pub.pem
|
|
136
156
|
```
|
|
137
157
|
|
|
138
|
-
|
|
158
|
+
#### Step 1: Generate Keys
|
|
139
159
|
|
|
140
160
|
Generate keypairs for both the local proxy and the remote server:
|
|
141
161
|
|
|
@@ -166,7 +186,7 @@ Or inspect the fingerprint of an existing keypair:
|
|
|
166
186
|
npm run generate-keys -- show ~/.drawlatch/keys/local/my-laptop
|
|
167
187
|
```
|
|
168
188
|
|
|
169
|
-
|
|
189
|
+
#### Step 2: Exchange Public Keys
|
|
170
190
|
|
|
171
191
|
The local proxy and remote server need each other's public keys for mutual authentication. Copy the **public** key files (`.pub.pem` only — never share private keys):
|
|
172
192
|
|
|
@@ -196,7 +216,7 @@ cp ~/.drawlatch/keys/remote/exchange.pub.pem \
|
|
|
196
216
|
|
|
197
217
|
> **Tip:** If the proxy and remote server are on different machines, securely transfer only the `*.pub.pem` files (e.g., via `scp`). Each caller gets its own subdirectory under the peers directory — the directory name becomes the caller's alias used in the remote config and audit logs.
|
|
198
218
|
|
|
199
|
-
|
|
219
|
+
#### Step 3: Create the Local Proxy Config
|
|
200
220
|
|
|
201
221
|
Copy the example and edit the paths to match your setup:
|
|
202
222
|
|
|
@@ -232,7 +252,7 @@ Edit `~/.drawlatch/proxy.config.json`:
|
|
|
232
252
|
3. `localKeysDir` in `proxy.config.json` (explicit full path for custom deployments)
|
|
233
253
|
4. Default: `keys/local/default`
|
|
234
254
|
|
|
235
|
-
|
|
255
|
+
#### Step 4: Create the Remote Server Config
|
|
236
256
|
|
|
237
257
|
Copy the example and edit it to match your setup:
|
|
238
258
|
|
|
@@ -393,7 +413,7 @@ Header values can reference secrets using `${VAR}` placeholders:
|
|
|
393
413
|
|
|
394
414
|
The placeholder `${API_TOKEN}` is resolved against the route's resolved `secrets` map. This means the actual secret value is never exposed to the local proxy or Claude Code — it only exists on the remote server.
|
|
395
415
|
|
|
396
|
-
|
|
416
|
+
#### Connections (Pre-built Route Templates)
|
|
397
417
|
|
|
398
418
|
Instead of manually configuring connectors for popular APIs, you can use **connections** — pre-built route templates that ship with the package (`github`, `stripe`, `openai`, etc.). Reference them by name in a caller's `connections` list:
|
|
399
419
|
|
|
@@ -412,28 +432,47 @@ Set the required environment variables (e.g., `GITHUB_TOKEN`, `STRIPE_SECRET_KEY
|
|
|
412
432
|
|
|
413
433
|
See **[CONNECTIONS.md](CONNECTIONS.md)** for the full list of available connections, required environment variables, and usage examples.
|
|
414
434
|
|
|
415
|
-
|
|
435
|
+
#### Step 5: Create an Environment File
|
|
436
|
+
|
|
437
|
+
Create a `.env` file in your config directory with your API secrets:
|
|
438
|
+
|
|
439
|
+
```bash
|
|
440
|
+
cat > ~/.drawlatch/.env << 'EOF'
|
|
441
|
+
# Uncomment and set tokens for your enabled connections
|
|
442
|
+
# GITHUB_TOKEN=ghp_your_token_here
|
|
443
|
+
# DISCORD_BOT_TOKEN=your_bot_token_here
|
|
444
|
+
# STRIPE_SECRET_KEY=sk_your_key_here
|
|
445
|
+
EOF
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
The remote server reads this file at startup. Use `drawlatch config` to check which secrets are set.
|
|
449
|
+
|
|
450
|
+
#### Step 6: Start the Servers
|
|
416
451
|
|
|
417
452
|
**Start the remote server:**
|
|
418
453
|
|
|
419
454
|
```bash
|
|
420
|
-
#
|
|
455
|
+
# Using the drawlatch CLI (recommended — runs as a background daemon)
|
|
456
|
+
drawlatch start
|
|
457
|
+
|
|
458
|
+
# Or for development (with hot reload via tsx)
|
|
421
459
|
npm run dev:remote
|
|
422
460
|
|
|
423
|
-
#
|
|
461
|
+
# Or production without the daemon (requires `npm run build` first)
|
|
424
462
|
npm run start:remote
|
|
425
463
|
```
|
|
426
464
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
The repo includes a `.mcp.json` at the root, so Claude Code auto-discovers the proxy when you open the project directory. Just approve the server when prompted — no manual registration needed.
|
|
430
|
-
|
|
431
|
-
The `.mcp.json` requires the `MCP_CONFIG_DIR` environment variable to be set so the proxy can locate its config and keys. Set it to the absolute path of your `~/.drawlatch/` directory:
|
|
465
|
+
Verify it's running:
|
|
432
466
|
|
|
433
467
|
```bash
|
|
434
|
-
|
|
468
|
+
drawlatch status # Check PID, uptime, health
|
|
469
|
+
drawlatch doctor # Validate full setup
|
|
435
470
|
```
|
|
436
471
|
|
|
472
|
+
**Connect the local MCP proxy to Claude Code:**
|
|
473
|
+
|
|
474
|
+
The repo includes a `.mcp.json` at the root, so Claude Code auto-discovers the proxy when you open the project directory. Just approve the server when prompted — no manual registration needed. The proxy uses `~/.drawlatch/` by default.
|
|
475
|
+
|
|
437
476
|
**Alternative: manual registration**
|
|
438
477
|
|
|
439
478
|
If you prefer not to use auto-discovery, register the MCP server directly:
|
|
@@ -441,13 +480,12 @@ If you prefer not to use auto-discovery, register the MCP server directly:
|
|
|
441
480
|
```bash
|
|
442
481
|
claude mcp add secure-proxy \
|
|
443
482
|
--transport stdio --scope local \
|
|
444
|
-
-e MCP_CONFIG_DIR=~/.drawlatch \
|
|
445
483
|
-- node /absolute/path/to/drawlatch/dist/mcp/server.js
|
|
446
484
|
```
|
|
447
485
|
|
|
448
486
|
After connecting (either via auto-discovery or manual registration), the proxy will automatically perform the encrypted handshake with the remote server on first use.
|
|
449
487
|
|
|
450
|
-
|
|
488
|
+
#### Step 7: Webhook Endpoints (Optional)
|
|
451
489
|
|
|
452
490
|
If any of your connections use webhook ingestors (e.g., GitHub, Stripe, Trello), the remote server automatically exposes `POST /webhooks/:path` routes on the same port. External services send webhook POSTs to these endpoints, and the server verifies signatures, buffers events in per-caller ring buffers, and makes them available via `poll_events`.
|
|
453
491
|
|
|
@@ -459,7 +497,19 @@ If any of your connections use webhook ingestors (e.g., GitHub, Stripe, Trello),
|
|
|
459
497
|
|
|
460
498
|
The webhook path is configured in each connection template's `ingestor.webhook.path` field. See **[INGESTORS.md](INGESTORS.md)** for full details on webhook, WebSocket, and poll ingestors.
|
|
461
499
|
|
|
462
|
-
###
|
|
500
|
+
### Advanced Configuration
|
|
501
|
+
|
|
502
|
+
#### `MCP_CONFIG_DIR`
|
|
503
|
+
|
|
504
|
+
By default, all config and key files live in `~/.drawlatch/`. You can override this by setting the `MCP_CONFIG_DIR` environment variable before launching the proxy or server:
|
|
505
|
+
|
|
506
|
+
```bash
|
|
507
|
+
export MCP_CONFIG_DIR=/custom/path/to/config
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
This is useful for non-standard deployments, CI environments, or running multiple independent setups on the same machine.
|
|
511
|
+
|
|
512
|
+
#### Multiple Agents (Multi-Identity)
|
|
463
513
|
|
|
464
514
|
When multiple agents share the same machine, each needs its own key identity. Generate a keypair per agent:
|
|
465
515
|
|