@wolpertingerlabs/drawlatch 1.0.0-alpha.7.0 → 1.0.0-alpha.9.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 +316 -484
- package/bin/drawlatch.js +687 -9
- package/dist/cli/generate-keys.d.ts +4 -4
- package/dist/cli/generate-keys.js +30 -25
- package/dist/mcp/server.js +225 -36
- package/dist/remote/ingestors/base-ingestor.d.ts +2 -0
- package/dist/remote/ingestors/base-ingestor.js +3 -0
- package/dist/remote/ingestors/manager.js +48 -12
- package/dist/remote/ingestors/types.d.ts +2 -0
- package/dist/remote/ingestors/webhook/webhook-lifecycle-manager.js +3 -3
- package/dist/remote/server.d.ts +3 -0
- package/dist/remote/server.js +340 -11
- package/dist/shared/config.d.ts +28 -27
- package/dist/shared/config.js +38 -32
- package/dist/shared/crypto/index.d.ts +1 -0
- package/dist/shared/crypto/index.js +1 -0
- package/dist/shared/crypto/key-manager.d.ts +67 -0
- package/dist/shared/crypto/key-manager.js +152 -0
- package/dist/shared/env-utils.d.ts +36 -0
- package/dist/shared/env-utils.js +140 -0
- package/dist/shared/protocol/handshake.js +14 -1
- package/dist/shared/protocol/index.d.ts +2 -0
- package/dist/shared/protocol/index.js +2 -0
- package/dist/shared/protocol/sync-client.d.ts +52 -0
- package/dist/shared/protocol/sync-client.js +99 -0
- package/dist/shared/protocol/sync.d.ts +67 -0
- package/dist/shared/protocol/sync.js +174 -0
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -1,687 +1,519 @@
|
|
|
1
1
|
# Drawlatch
|
|
2
2
|
|
|
3
|
-
> **Alpha Software:**
|
|
3
|
+
> **Alpha Software:** Expect breaking changes between updates.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Drawlatch is a config-driven proxy that gives AI agents authenticated access to external APIs. Define your connections and secrets in a single config file — agents get structured, allowlisted access to 22 pre-built APIs without ever seeing your credentials.
|
|
6
6
|
|
|
7
|
-
Drawlatch
|
|
7
|
+
**Using [Callboard](https://github.com/WolpertingerLabs/callboard)?** Drawlatch is built in — Callboard manages connections, secrets, and agent identities through its UI. You don't need to set up drawlatch separately.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
## Key Features
|
|
10
|
+
|
|
11
|
+
- **22 pre-built connections** — GitHub, Slack, Discord, Stripe, Notion, Linear, OpenAI, and [more](CONNECTIONS.md)
|
|
12
|
+
- **Endpoint allowlisting** — agents can only reach explicitly configured URL patterns
|
|
13
|
+
- **Per-caller access control** — each agent identity sees only its assigned connections
|
|
14
|
+
- **Real-time event ingestion** — WebSocket, webhook, and polling listeners for incoming events ([details](INGESTORS.md))
|
|
15
|
+
- **Two operating modes** — remote (secrets on a separate server with E2EE) or local (in-process library)
|
|
11
16
|
|
|
12
17
|
## How It Works
|
|
13
18
|
|
|
14
|
-
|
|
19
|
+
Drawlatch runs in two modes depending on your trust model:
|
|
15
20
|
|
|
16
|
-
|
|
21
|
+
### Remote Mode — Secrets Never Leave the Server
|
|
17
22
|
|
|
18
|
-
|
|
19
|
-
2. **Remote Secure Server** — holds all secrets (API keys, tokens, etc.) and only communicates through encrypted channels after mutual authentication. It injects secrets into outgoing HTTP requests on the proxy's behalf.
|
|
23
|
+
The local MCP proxy holds no secrets. It encrypts requests and forwards them to a remote server that injects credentials and makes the actual API calls.
|
|
20
24
|
|
|
21
25
|
```
|
|
22
|
-
┌──────────────┐
|
|
23
|
-
│ Claude Code
|
|
24
|
-
│ │
|
|
25
|
-
└──────────────┘
|
|
26
|
-
No secrets here Injects API keys,
|
|
27
|
-
tokens, headers
|
|
26
|
+
┌──────────────┐ ┌──────────────────┐ ┌──────────────┐
|
|
27
|
+
│ Claude Code │◄── stdio ──► MCP Proxy │◄── HTTP + E2EE ──► Remote Server │── HTTPS ────►│ External API │
|
|
28
|
+
│ │ (no secrets) │ │ (holds secrets) │ │ │
|
|
29
|
+
└──────────────┘ └──────────────────┘ └──────────────┘
|
|
28
30
|
```
|
|
29
31
|
|
|
30
|
-
The crypto layer uses
|
|
32
|
+
The crypto layer uses Ed25519 signatures for mutual authentication and X25519 ECDH to derive AES-256-GCM session keys — all built on Node.js native `crypto` with zero external dependencies.
|
|
31
33
|
|
|
32
|
-
### Local Mode
|
|
34
|
+
### Local Mode — In-Process Library
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
No server, no encryption. Your application imports drawlatch directly and calls the same `executeProxyRequest()` function the remote server uses. Secrets come from `process.env` on the same machine.
|
|
35
37
|
|
|
36
38
|
```
|
|
37
|
-
┌──────────────────────────────────────────┐
|
|
38
|
-
│ Your Application
|
|
39
|
-
│ ┌──────────┐ in-process ┌────────┐ │
|
|
40
|
-
│ │ Agent │◄──
|
|
41
|
-
│ │ │ │ routes │ │ local env / config
|
|
39
|
+
┌──────────────────────────────────────────┐ ┌──────────────┐
|
|
40
|
+
│ Your Application │── HTTPS ──────────►│ External API │
|
|
41
|
+
│ ┌──────────┐ in-process ┌────────┐ │ │ │
|
|
42
|
+
│ │ Agent │◄── call ──────►│ drawl. │ │ └──────────────┘
|
|
42
43
|
│ └──────────┘ └────────┘ │
|
|
43
44
|
└──────────────────────────────────────────┘
|
|
44
|
-
Secrets are on the same machine
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
**What you don't get:** Secret isolation from the agent. When running locally, secrets live in `process.env` on the same machine. The value proposition shifts from cryptographic secret hiding to **convenience and structured access** — a single config file managing many API connections with consistent patterns.
|
|
47
|
+
You still get config-driven route resolution, endpoint allowlisting, per-caller access control, and ingestor support — just without cryptographic secret isolation.
|
|
50
48
|
|
|
51
|
-
> **When to use which
|
|
49
|
+
> **When to use which:** Remote mode when secrets must be hidden from the agent's machine (shared servers, CI, untrusted environments). Local mode when running on your own machine and you want convenience without a separate server.
|
|
52
50
|
|
|
53
51
|
## Quick Start
|
|
54
52
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
This repo is structured as a **Claude Code plugin** with a marketplace. Install it directly:
|
|
58
|
-
|
|
59
|
-
```shell
|
|
60
|
-
# Add the marketplace (from a local clone)
|
|
61
|
-
/plugin marketplace add ./path/to/drawlatch
|
|
62
|
-
|
|
63
|
-
# Install the plugin
|
|
64
|
-
/plugin install drawlatch@drawlatch
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
Or load it directly during development:
|
|
68
|
-
|
|
69
|
-
```shell
|
|
70
|
-
claude --plugin-dir ./path/to/drawlatch
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Before using, set the `MCP_CONFIG_DIR` environment variable so the proxy can find its config and keys:
|
|
53
|
+
Get from zero to working in three commands:
|
|
74
54
|
|
|
75
55
|
```bash
|
|
76
|
-
|
|
77
|
-
|
|
56
|
+
# Install globally
|
|
57
|
+
npm install -g @wolpertingerlabs/drawlatch
|
|
78
58
|
|
|
79
|
-
|
|
59
|
+
# Set up keys, config, and .env in one step
|
|
60
|
+
drawlatch init --connections github
|
|
80
61
|
|
|
81
|
-
|
|
62
|
+
# Set your API token (edit the file or run this)
|
|
63
|
+
echo "GITHUB_TOKEN=ghp_your_token_here" >> ~/.drawlatch/.env
|
|
82
64
|
|
|
83
|
-
|
|
65
|
+
# Start the remote server
|
|
66
|
+
drawlatch start
|
|
67
|
+
```
|
|
84
68
|
|
|
85
|
-
|
|
69
|
+
Verify your setup:
|
|
86
70
|
|
|
87
71
|
```bash
|
|
88
|
-
|
|
72
|
+
drawlatch doctor # Validate full setup
|
|
73
|
+
drawlatch status # Check server is running
|
|
74
|
+
drawlatch config # View configuration and secret status
|
|
89
75
|
```
|
|
90
76
|
|
|
91
|
-
The
|
|
92
|
-
|
|
93
|
-
> **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`.
|
|
77
|
+
The `init` command generates keys, creates configs, exchanges public keys, and scaffolds the `.env` file. All steps are idempotent — safe to re-run.
|
|
94
78
|
|
|
95
|
-
|
|
79
|
+
### Connect to Claude Code
|
|
96
80
|
|
|
97
|
-
|
|
81
|
+
**Option 1: Claude Code Plugin (Recommended)**
|
|
98
82
|
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
npm install
|
|
103
|
-
npm run build
|
|
83
|
+
```shell
|
|
84
|
+
# Install the plugin
|
|
85
|
+
/plugin install drawlatch@drawlatch
|
|
104
86
|
```
|
|
105
87
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
All config and key files live inside `~/.drawlatch/` in the user's home directory by default. You can override this by setting the `MCP_CONFIG_DIR` environment variable.
|
|
88
|
+
The plugin's MCP server starts automatically. The proxy uses `~/.drawlatch/` by default — see [Advanced Configuration](#advanced-configuration) to use a custom path.
|
|
109
89
|
|
|
110
|
-
|
|
111
|
-
~/.drawlatch/
|
|
112
|
-
├── proxy.config.json # Local proxy config
|
|
113
|
-
├── remote.config.json # Remote server config
|
|
114
|
-
└── keys/
|
|
115
|
-
├── local/ # MCP proxy keypairs (one per alias)
|
|
116
|
-
│ └── my-laptop/ # Alias-named subdirectory
|
|
117
|
-
│ ├── signing.pub.pem # Ed25519 public key (share this)
|
|
118
|
-
│ ├── signing.key.pem # Ed25519 private key (keep secret)
|
|
119
|
-
│ ├── exchange.pub.pem # X25519 public key (share this)
|
|
120
|
-
│ └── exchange.key.pem # X25519 private key (keep secret)
|
|
121
|
-
├── remote/ # Remote server keypair
|
|
122
|
-
│ ├── signing.pub.pem
|
|
123
|
-
│ ├── signing.key.pem
|
|
124
|
-
│ ├── exchange.pub.pem
|
|
125
|
-
│ └── exchange.key.pem
|
|
126
|
-
└── peers/
|
|
127
|
-
├── alice/ # One subdirectory per caller
|
|
128
|
-
│ ├── signing.pub.pem # Caller's public signing key
|
|
129
|
-
│ └── exchange.pub.pem # Caller's public exchange key
|
|
130
|
-
├── bob/ # Another caller
|
|
131
|
-
│ ├── signing.pub.pem
|
|
132
|
-
│ └── exchange.pub.pem
|
|
133
|
-
└── remote-server/ # Remote server's public keys (for proxy)
|
|
134
|
-
├── signing.pub.pem
|
|
135
|
-
└── exchange.pub.pem
|
|
136
|
-
```
|
|
90
|
+
**Option 2: Auto-Discovery**
|
|
137
91
|
|
|
138
|
-
|
|
92
|
+
This repo includes a `.mcp.json` file, so Claude Code automatically discovers the MCP proxy when you open the project. Approve the server when prompted.
|
|
139
93
|
|
|
140
|
-
|
|
94
|
+
**Option 3: Manual Registration**
|
|
141
95
|
|
|
142
96
|
```bash
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
# Or use the default alias
|
|
147
|
-
npm run generate-keys -- local
|
|
148
|
-
|
|
149
|
-
# Generate remote server keypair
|
|
150
|
-
npm run generate-keys -- remote
|
|
97
|
+
claude mcp add drawlatch \
|
|
98
|
+
-e MCP_CONFIG_DIR=~/.drawlatch \
|
|
99
|
+
-- node /path/to/drawlatch/dist/mcp/server.js
|
|
151
100
|
```
|
|
152
101
|
|
|
153
|
-
|
|
102
|
+
> **Note:** Auto-discovery and manual registration use `dist/mcp/server.js`. The `dist/` directory is built automatically via `npm install` (prepare script). Rebuild manually with `npm run build` if needed.
|
|
154
103
|
|
|
155
|
-
|
|
104
|
+
### Manual Setup
|
|
156
105
|
|
|
157
|
-
|
|
106
|
+
For custom setups (different aliases, multiple callers, different machines), you can configure everything manually instead of using `drawlatch init`.
|
|
158
107
|
|
|
159
|
-
|
|
160
|
-
npm run generate-keys -- --dir /path/to/custom/keys
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
Or inspect the fingerprint of an existing keypair:
|
|
108
|
+
**1. Generate keys:**
|
|
164
109
|
|
|
165
110
|
```bash
|
|
166
|
-
|
|
111
|
+
drawlatch generate-keys local my-laptop
|
|
112
|
+
drawlatch generate-keys remote
|
|
167
113
|
```
|
|
168
114
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
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):
|
|
115
|
+
**2. Exchange public keys** — copy `*.pub.pem` files into the appropriate `keys/peers/` subdirectories. See [Key Exchange](#key-exchange) for details.
|
|
172
116
|
|
|
173
|
-
**
|
|
117
|
+
**3. Create configs** — copy the example files and edit:
|
|
174
118
|
|
|
175
119
|
```bash
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
cp ~/.drawlatch/keys/local/my-laptop/signing.pub.pem \
|
|
179
|
-
~/.drawlatch/keys/peers/my-laptop/signing.pub.pem
|
|
180
|
-
|
|
181
|
-
cp ~/.drawlatch/keys/local/my-laptop/exchange.pub.pem \
|
|
182
|
-
~/.drawlatch/keys/peers/my-laptop/exchange.pub.pem
|
|
120
|
+
cp remote.config.example.json ~/.drawlatch/remote.config.json
|
|
121
|
+
cp proxy.config.example.json ~/.drawlatch/proxy.config.json
|
|
183
122
|
```
|
|
184
123
|
|
|
185
|
-
**
|
|
124
|
+
**4. Create a `.env` file** with your API secrets:
|
|
186
125
|
|
|
187
126
|
```bash
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
cp ~/.drawlatch/keys/remote/exchange.pub.pem \
|
|
194
|
-
~/.drawlatch/keys/peers/remote-server/exchange.pub.pem
|
|
127
|
+
cat > ~/.drawlatch/.env << 'EOF'
|
|
128
|
+
# GITHUB_TOKEN=ghp_your_token_here
|
|
129
|
+
# DISCORD_BOT_TOKEN=your_bot_token_here
|
|
130
|
+
EOF
|
|
195
131
|
```
|
|
196
132
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
### Step 3: Create the Local Proxy Config
|
|
200
|
-
|
|
201
|
-
Copy the example and edit the paths to match your setup:
|
|
133
|
+
**5. Start the server:**
|
|
202
134
|
|
|
203
135
|
```bash
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
Edit `~/.drawlatch/proxy.config.json`:
|
|
208
|
-
|
|
209
|
-
```json
|
|
210
|
-
{
|
|
211
|
-
"remoteUrl": "http://127.0.0.1:9999",
|
|
212
|
-
"localKeyAlias": "my-laptop",
|
|
213
|
-
"remotePublicKeysDir": "~/.drawlatch/keys/peers/remote-server",
|
|
214
|
-
"connectTimeout": 10000,
|
|
215
|
-
"requestTimeout": 30000
|
|
216
|
-
}
|
|
136
|
+
drawlatch start
|
|
137
|
+
drawlatch doctor # Validate full setup
|
|
217
138
|
```
|
|
218
139
|
|
|
219
|
-
|
|
220
|
-
| --------------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------- |
|
|
221
|
-
| `remoteUrl` | URL of the remote secure server | `http://localhost:9999` |
|
|
222
|
-
| `localKeyAlias` | Key alias — resolved to `keys/local/<alias>/`. Overridden by `MCP_KEY_ALIAS` env var at runtime | _(none)_ |
|
|
223
|
-
| `localKeysDir` | Absolute path to the proxy's own keypair directory. Ignored when `localKeyAlias` is set | `~/.drawlatch/keys/local/default` |
|
|
224
|
-
| `remotePublicKeysDir` | Absolute path to the remote server's public keys | `~/.drawlatch/keys/peers/remote-server` |
|
|
225
|
-
| `connectTimeout` | Handshake timeout in milliseconds | `10000` (10s) |
|
|
226
|
-
| `requestTimeout` | Request timeout in milliseconds | `30000` (30s) |
|
|
227
|
-
|
|
228
|
-
**Alias resolution priority:**
|
|
229
|
-
|
|
230
|
-
1. `MCP_KEY_ALIAS` env var (highest — set per agent at spawn time)
|
|
231
|
-
2. `localKeyAlias` in `proxy.config.json`
|
|
232
|
-
3. `localKeysDir` in `proxy.config.json` (explicit full path for custom deployments)
|
|
233
|
-
4. Default: `keys/local/default`
|
|
234
|
-
|
|
235
|
-
### Step 4: Create the Remote Server Config
|
|
236
|
-
|
|
237
|
-
Copy the example and edit it to match your setup:
|
|
140
|
+
## MCP Tools
|
|
238
141
|
|
|
239
|
-
|
|
240
|
-
cp remote.config.example.json ~/.drawlatch/remote.config.json
|
|
241
|
-
```
|
|
142
|
+
Once connected, agents get these tools:
|
|
242
143
|
|
|
243
|
-
|
|
144
|
+
| Tool | Description |
|
|
145
|
+
|------|-------------|
|
|
146
|
+
| `secure_request` | Make authenticated HTTP requests. Route-level headers (auth tokens, API keys) are injected automatically — the agent never sees secret values. Supports JSON and multipart/form-data file uploads. |
|
|
147
|
+
| `list_routes` | Discover available APIs with metadata, docs links, allowed endpoints, and available secret placeholders. |
|
|
148
|
+
| `poll_events` | Retrieve buffered events from ingestors (Discord messages, GitHub webhooks, etc.) with cursor-based pagination. |
|
|
149
|
+
| `ingestor_status` | Get connection state, buffer sizes, event counts, and errors for all active ingestors. |
|
|
150
|
+
| `test_connection` | Verify API credentials with a pre-configured read-only request. |
|
|
151
|
+
| `control_listener` | Start, stop, or restart an event listener. |
|
|
152
|
+
| `list_listener_configs` | Get configurable fields for event listeners. |
|
|
153
|
+
| `set_listener_params` | Configure listener parameters (filters, buffer sizes, etc.). |
|
|
154
|
+
| `get_listener_params` | Read current listener parameter overrides. |
|
|
155
|
+
| `resolve_listener_options` | Fetch dynamic options for listener config fields (e.g., list of Trello boards). |
|
|
156
|
+
| `list_listener_instances` | List instances of a multi-instance listener. |
|
|
157
|
+
| `delete_listener_instance` | Remove a multi-instance listener instance. |
|
|
158
|
+
| `test_ingestor` | Test event listener configuration and credentials. |
|
|
244
159
|
|
|
245
|
-
|
|
160
|
+
## Configuration Reference
|
|
246
161
|
|
|
247
|
-
|
|
162
|
+
### Remote Server Config (`remote.config.json`)
|
|
248
163
|
|
|
249
164
|
```json
|
|
250
165
|
{
|
|
251
166
|
"host": "0.0.0.0",
|
|
252
167
|
"port": 9999,
|
|
253
168
|
"localKeysDir": "~/.drawlatch/keys/remote",
|
|
254
|
-
"
|
|
255
|
-
|
|
256
|
-
"name": "Personal Laptop",
|
|
257
|
-
"peerKeyDir": "~/.drawlatch/keys/peers/my-laptop",
|
|
258
|
-
"connections": ["github"]
|
|
259
|
-
}
|
|
260
|
-
},
|
|
169
|
+
"connectors": [],
|
|
170
|
+
"callers": {},
|
|
261
171
|
"rateLimitPerMinute": 60
|
|
262
172
|
}
|
|
263
173
|
```
|
|
264
174
|
|
|
265
|
-
|
|
175
|
+
| Field | Description | Default |
|
|
176
|
+
|-------|-------------|---------|
|
|
177
|
+
| `host` | Network interface to bind | `127.0.0.1` |
|
|
178
|
+
| `port` | Listen port | `9999` |
|
|
179
|
+
| `localKeysDir` | Path to server's own keypair | `~/.drawlatch/keys/remote` |
|
|
180
|
+
| `connectors` | Custom connector definitions (see below) | `[]` |
|
|
181
|
+
| `callers` | Per-caller access control (see below) | `{}` |
|
|
182
|
+
| `rateLimitPerMinute` | Max requests per minute per session | `60` |
|
|
183
|
+
|
|
184
|
+
### Callers
|
|
266
185
|
|
|
267
|
-
|
|
186
|
+
Each caller is identified by their public key and declares which connections they can access:
|
|
268
187
|
|
|
269
188
|
```json
|
|
270
189
|
{
|
|
271
|
-
"host": "0.0.0.0",
|
|
272
|
-
"port": 9999,
|
|
273
|
-
"localKeysDir": "~/.drawlatch/keys/remote",
|
|
274
|
-
"connectors": [
|
|
275
|
-
{
|
|
276
|
-
"alias": "internal-api",
|
|
277
|
-
"name": "Internal Admin API",
|
|
278
|
-
"headers": { "Authorization": "Bearer ${ADMIN_KEY}" },
|
|
279
|
-
"secrets": { "ADMIN_KEY": "${INTERNAL_ADMIN_KEY}" },
|
|
280
|
-
"allowedEndpoints": ["https://admin.internal.com/**"]
|
|
281
|
-
}
|
|
282
|
-
],
|
|
283
190
|
"callers": {
|
|
284
191
|
"alice": {
|
|
285
192
|
"name": "Alice (senior engineer)",
|
|
286
|
-
"peerKeyDir": "/keys/peers/alice",
|
|
287
|
-
"connections": ["github", "stripe", "internal-api"]
|
|
193
|
+
"peerKeyDir": "~/.drawlatch/keys/peers/alice",
|
|
194
|
+
"connections": ["github", "stripe", "internal-api"],
|
|
195
|
+
"env": {
|
|
196
|
+
"GITHUB_TOKEN": "${ALICE_GITHUB_TOKEN}"
|
|
197
|
+
}
|
|
288
198
|
},
|
|
289
199
|
"ci-server": {
|
|
290
200
|
"name": "GitHub Actions CI",
|
|
291
|
-
"peerKeyDir": "/keys/peers/ci-server",
|
|
201
|
+
"peerKeyDir": "~/.drawlatch/keys/peers/ci-server",
|
|
292
202
|
"connections": ["github"]
|
|
293
203
|
}
|
|
294
|
-
}
|
|
295
|
-
"rateLimitPerMinute": 60
|
|
204
|
+
}
|
|
296
205
|
}
|
|
297
206
|
```
|
|
298
207
|
|
|
299
|
-
|
|
208
|
+
| Field | Required | Description |
|
|
209
|
+
|-------|----------|-------------|
|
|
210
|
+
| `peerKeyDir` | Yes | Path to this caller's public key files |
|
|
211
|
+
| `connections` | Yes | Array of connection names (built-in or custom connector aliases) |
|
|
212
|
+
| `name` | No | Human-readable name for audit logs |
|
|
213
|
+
| `env` | No | Per-caller env var overrides — redirect secret resolution per caller |
|
|
214
|
+
| `ingestorOverrides` | No | Per-caller ingestor config overrides ([details](INGESTORS.md#caller-level-ingestor-overrides)) |
|
|
300
215
|
|
|
301
|
-
|
|
216
|
+
The `env` map lets multiple callers share the same connection with different credentials:
|
|
217
|
+
- Keys are the env var names connectors reference (e.g., `GITHUB_TOKEN`)
|
|
218
|
+
- Values are `"${REAL_ENV_VAR}"` (redirect) or literal strings (direct injection)
|
|
219
|
+
- Checked before `process.env` during secret resolution
|
|
302
220
|
|
|
303
|
-
|
|
221
|
+
### Custom Connectors
|
|
222
|
+
|
|
223
|
+
Define reusable route templates for APIs not covered by built-in connections:
|
|
304
224
|
|
|
305
225
|
```json
|
|
306
226
|
{
|
|
307
|
-
"
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
"
|
|
313
|
-
"
|
|
314
|
-
"connections": ["github"],
|
|
315
|
-
"env": {
|
|
316
|
-
"GITHUB_TOKEN": "${ALICE_GITHUB_TOKEN}"
|
|
317
|
-
}
|
|
318
|
-
},
|
|
319
|
-
"bob": {
|
|
320
|
-
"name": "Bob",
|
|
321
|
-
"peerKeyDir": "/keys/peers/bob",
|
|
322
|
-
"connections": ["github", "stripe"],
|
|
323
|
-
"env": {
|
|
324
|
-
"GITHUB_TOKEN": "${BOB_GITHUB_TOKEN}",
|
|
325
|
-
"STRIPE_SECRET_KEY": "sk_test_bob_dev_key"
|
|
326
|
-
}
|
|
227
|
+
"connectors": [
|
|
228
|
+
{
|
|
229
|
+
"alias": "internal-api",
|
|
230
|
+
"name": "Internal Admin API",
|
|
231
|
+
"allowedEndpoints": ["https://admin.internal.com/**"],
|
|
232
|
+
"headers": { "Authorization": "Bearer ${ADMIN_KEY}" },
|
|
233
|
+
"secrets": { "ADMIN_KEY": "${INTERNAL_ADMIN_KEY}" }
|
|
327
234
|
}
|
|
328
|
-
|
|
329
|
-
"rateLimitPerMinute": 60
|
|
235
|
+
]
|
|
330
236
|
}
|
|
331
237
|
```
|
|
332
238
|
|
|
333
|
-
|
|
239
|
+
| Field | Required | Description |
|
|
240
|
+
|-------|----------|-------------|
|
|
241
|
+
| `alias` | Yes | Unique name for referencing from caller `connections` lists |
|
|
242
|
+
| `allowedEndpoints` | Yes | Glob patterns for allowed URLs |
|
|
243
|
+
| `name` | No | Human-readable name |
|
|
244
|
+
| `description` | No | Short description |
|
|
245
|
+
| `docsUrl` | No | URL to API documentation |
|
|
246
|
+
| `headers` | No | Headers to auto-inject (`${VAR}` placeholders resolved from `secrets`) |
|
|
247
|
+
| `secrets` | No | Key-value pairs — literal strings or `${ENV_VAR}` references |
|
|
248
|
+
| `resolveSecretsInBody` | No | Resolve `${VAR}` in request bodies (default: `false`) |
|
|
334
249
|
|
|
335
|
-
|
|
336
|
-
- **Values** are either `"${REAL_ENV_VAR}"` (redirect to a different env var) or a literal string (direct injection)
|
|
337
|
-
- When resolving secrets, the caller's `env` is checked **before** `process.env`
|
|
250
|
+
Custom connectors with an `alias` matching a built-in connection name take precedence.
|
|
338
251
|
|
|
339
|
-
|
|
252
|
+
### Proxy Config (`proxy.config.json`)
|
|
340
253
|
|
|
341
|
-
|
|
254
|
+
Used by the local MCP proxy to connect to the remote server:
|
|
342
255
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
#### Connector Definition
|
|
353
|
-
|
|
354
|
-
Custom connectors define reusable route templates referenced by `alias` from caller connection lists. They follow the same structure as routes:
|
|
355
|
-
|
|
356
|
-
| Field | Required | Description |
|
|
357
|
-
| ---------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
358
|
-
| `alias` | Yes | Unique name for referencing this connector from caller `connections` lists |
|
|
359
|
-
| `allowedEndpoints` | Yes | Array of glob patterns for allowed URLs (e.g., `https://api.example.com/**`) |
|
|
360
|
-
| `name` | No | Human-readable name (e.g., `"Internal Admin API"`) |
|
|
361
|
-
| `description` | No | Short description of what the connector provides |
|
|
362
|
-
| `docsUrl` | No | URL to API documentation |
|
|
363
|
-
| `openApiUrl` | No | URL to OpenAPI/Swagger spec |
|
|
364
|
-
| `headers` | No | Headers to auto-inject. Values may contain `${VAR}` placeholders resolved from `secrets` |
|
|
365
|
-
| `secrets` | No | Key-value pairs. Values can be literal strings or `${ENV_VAR}` references resolved from environment variables at startup |
|
|
366
|
-
| `resolveSecretsInBody` | No | Whether to resolve `${VAR}` placeholders in request bodies. Default: `false` |
|
|
367
|
-
|
|
368
|
-
#### Caller Definition
|
|
256
|
+
```json
|
|
257
|
+
{
|
|
258
|
+
"remoteUrl": "http://127.0.0.1:9999",
|
|
259
|
+
"localKeyAlias": "my-laptop",
|
|
260
|
+
"remotePublicKeysDir": "~/.drawlatch/keys/peers/remote-server",
|
|
261
|
+
"connectTimeout": 10000,
|
|
262
|
+
"requestTimeout": 30000
|
|
263
|
+
}
|
|
264
|
+
```
|
|
369
265
|
|
|
370
|
-
| Field
|
|
371
|
-
|
|
372
|
-
| `
|
|
373
|
-
| `
|
|
374
|
-
| `
|
|
375
|
-
| `
|
|
376
|
-
| `
|
|
266
|
+
| Field | Description | Default |
|
|
267
|
+
|-------|-------------|---------|
|
|
268
|
+
| `remoteUrl` | URL of the remote server | `http://localhost:9999` |
|
|
269
|
+
| `localKeyAlias` | Key alias — resolved to `keys/local/<alias>/` | _(none)_ |
|
|
270
|
+
| `localKeysDir` | Explicit path to proxy's keypair (ignored when `localKeyAlias` is set) | `~/.drawlatch/keys/local/default` |
|
|
271
|
+
| `remotePublicKeysDir` | Path to remote server's public keys | `~/.drawlatch/keys/peers/remote-server` |
|
|
272
|
+
| `connectTimeout` | Handshake timeout (ms) | `10000` |
|
|
273
|
+
| `requestTimeout` | Request timeout (ms) | `30000` |
|
|
377
274
|
|
|
378
|
-
|
|
275
|
+
Key alias resolution order: `MCP_KEY_ALIAS` env var > `localKeyAlias` > `localKeysDir` > `keys/local/default`.
|
|
379
276
|
|
|
380
|
-
|
|
277
|
+
### Advanced Configuration
|
|
381
278
|
|
|
382
|
-
|
|
383
|
-
- **Environment variable references** — resolved from the server's environment: `"API_TOKEN": "${API_TOKEN}"`
|
|
384
|
-
- **Per-caller overrides** — when a caller has an `env` entry for a variable name, that value is used instead of `process.env`
|
|
279
|
+
#### `MCP_CONFIG_DIR`
|
|
385
280
|
|
|
386
|
-
|
|
281
|
+
By default, all config and key files live in `~/.drawlatch/`. Override with:
|
|
387
282
|
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
"Authorization": "Bearer ${API_TOKEN}"
|
|
391
|
-
}
|
|
283
|
+
```bash
|
|
284
|
+
export MCP_CONFIG_DIR=/custom/path/to/config
|
|
392
285
|
```
|
|
393
286
|
|
|
394
|
-
|
|
287
|
+
Useful for CI environments or running multiple independent setups on the same machine.
|
|
395
288
|
|
|
396
|
-
|
|
289
|
+
## Connections
|
|
397
290
|
|
|
398
|
-
|
|
291
|
+
22 pre-built connection templates ship with drawlatch. Reference them by name in a caller's `connections` list:
|
|
399
292
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
293
|
+
| Connection | API | Required Env Var(s) |
|
|
294
|
+
|------------|-----|---------------------|
|
|
295
|
+
| `anthropic` | Anthropic Claude API | `ANTHROPIC_API_KEY` |
|
|
296
|
+
| `bluesky` | Bluesky (AT Protocol) | `BLUESKY_ACCESS_TOKEN` |
|
|
297
|
+
| `devin` | Devin AI API | `DEVIN_API_KEY` |
|
|
298
|
+
| `discord-bot` | Discord Bot API | `DISCORD_BOT_TOKEN` |
|
|
299
|
+
| `discord-oauth` | Discord OAuth2 API | `DISCORD_OAUTH_TOKEN` |
|
|
300
|
+
| `github` | GitHub REST API | `GITHUB_TOKEN` |
|
|
301
|
+
| `google` | Google Workspace APIs | `GOOGLE_API_TOKEN` |
|
|
302
|
+
| `google-ai` | Google AI (Gemini) | `GOOGLE_AI_API_KEY` |
|
|
303
|
+
| `hex` | Hex API | `HEX_TOKEN` |
|
|
304
|
+
| `lichess` | Lichess API | `LICHESS_API_TOKEN` |
|
|
305
|
+
| `linear` | Linear GraphQL API | `LINEAR_API_KEY` |
|
|
306
|
+
| `mastodon` | Mastodon API | `MASTODON_ACCESS_TOKEN` |
|
|
307
|
+
| `notion` | Notion API | `NOTION_API_KEY` |
|
|
308
|
+
| `openai` | OpenAI API | `OPENAI_API_KEY` |
|
|
309
|
+
| `openrouter` | OpenRouter API | `OPENROUTER_API_KEY` |
|
|
310
|
+
| `reddit` | Reddit API | `REDDIT_ACCESS_TOKEN` |
|
|
311
|
+
| `slack` | Slack Web API | `SLACK_BOT_TOKEN` |
|
|
312
|
+
| `stripe` | Stripe Payments API | `STRIPE_SECRET_KEY` |
|
|
313
|
+
| `telegram` | Telegram Bot API | `TELEGRAM_BOT_TOKEN` |
|
|
314
|
+
| `trello` | Trello API | `TRELLO_API_KEY`, `TRELLO_TOKEN` |
|
|
315
|
+
| `twitch` | Twitch Helix API | `TWITCH_ACCESS_TOKEN`, `TWITCH_CLIENT_ID` |
|
|
316
|
+
| `x` | X (Twitter) API v2 | `X_BEARER_TOKEN` |
|
|
410
317
|
|
|
411
|
-
|
|
318
|
+
See **[CONNECTIONS.md](CONNECTIONS.md)** for auth details, optional env vars, and usage notes per connection.
|
|
412
319
|
|
|
413
|
-
|
|
320
|
+
## Event Ingestion
|
|
414
321
|
|
|
415
|
-
|
|
322
|
+
Drawlatch can collect real-time events from external services and buffer them for agents to poll. Three ingestor types are supported:
|
|
416
323
|
|
|
417
|
-
|
|
324
|
+
| Type | How It Works | Connections |
|
|
325
|
+
|------|-------------|-------------|
|
|
326
|
+
| **WebSocket** | Persistent connections to event gateways | Discord Gateway, Slack Socket Mode |
|
|
327
|
+
| **Webhook** | HTTP receivers with signature verification | GitHub, Stripe, Trello |
|
|
328
|
+
| **Poll** | Interval-based HTTP requests | Notion, Linear, Reddit, X, Bluesky, Mastodon, Telegram, Twitch |
|
|
418
329
|
|
|
419
|
-
|
|
420
|
-
# Development (with hot reload via tsx)
|
|
421
|
-
npm run dev:remote
|
|
330
|
+
Events are stored in per-caller ring buffers (default 200, max 1000) with monotonic IDs for cursor-based pagination. Agents retrieve events via `poll_events` and check status via `ingestor_status`.
|
|
422
331
|
|
|
423
|
-
|
|
424
|
-
npm run start:remote
|
|
425
|
-
```
|
|
332
|
+
For webhook ingestors, the remote server must be publicly accessible (or behind a tunnel). Use `drawlatch start --tunnel` to automatically start a Cloudflare tunnel.
|
|
426
333
|
|
|
427
|
-
**
|
|
334
|
+
See **[INGESTORS.md](INGESTORS.md)** for full configuration reference.
|
|
428
335
|
|
|
429
|
-
|
|
336
|
+
## Key Exchange
|
|
430
337
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
```bash
|
|
434
|
-
export MCP_CONFIG_DIR=~/.drawlatch
|
|
435
|
-
```
|
|
338
|
+
Remote mode requires mutual authentication via Ed25519/X25519 keypairs. Each identity gets four PEM files (signing + exchange, public + private). The `drawlatch init` command handles this automatically for single-machine setups.
|
|
436
339
|
|
|
437
|
-
|
|
340
|
+
For multi-machine setups, exchange public keys manually:
|
|
438
341
|
|
|
439
|
-
|
|
342
|
+
**Directory structure:**
|
|
440
343
|
|
|
441
|
-
```
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
344
|
+
```
|
|
345
|
+
~/.drawlatch/keys/
|
|
346
|
+
├── local/my-laptop/ # MCP proxy keypair
|
|
347
|
+
├── remote/ # Remote server keypair
|
|
348
|
+
└── peers/
|
|
349
|
+
├── my-laptop/ # Proxy's public keys (on the server)
|
|
350
|
+
└── remote-server/ # Server's public keys (on the proxy)
|
|
446
351
|
```
|
|
447
352
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
### Step 6: Webhook Endpoints (Optional)
|
|
451
|
-
|
|
452
|
-
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`.
|
|
353
|
+
**Exchange public keys** (`.pub.pem` only — never share private keys):
|
|
453
354
|
|
|
454
|
-
|
|
355
|
+
```bash
|
|
356
|
+
# Proxy's public keys → server's peers directory
|
|
357
|
+
cp keys/local/my-laptop/signing.pub.pem keys/peers/my-laptop/signing.pub.pem
|
|
358
|
+
cp keys/local/my-laptop/exchange.pub.pem keys/peers/my-laptop/exchange.pub.pem
|
|
455
359
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
360
|
+
# Server's public keys → proxy's peers directory
|
|
361
|
+
cp keys/remote/signing.pub.pem keys/peers/remote-server/signing.pub.pem
|
|
362
|
+
cp keys/remote/exchange.pub.pem keys/peers/remote-server/exchange.pub.pem
|
|
363
|
+
```
|
|
459
364
|
|
|
460
|
-
|
|
365
|
+
If the proxy and server are on different machines, transfer only `*.pub.pem` files via `scp` or similar.
|
|
461
366
|
|
|
462
|
-
### Multiple
|
|
367
|
+
### Multiple Agent Identities
|
|
463
368
|
|
|
464
|
-
|
|
369
|
+
Generate a keypair per agent and set `MCP_KEY_ALIAS` at spawn time:
|
|
465
370
|
|
|
466
371
|
```bash
|
|
467
|
-
|
|
468
|
-
|
|
372
|
+
drawlatch generate-keys local alice
|
|
373
|
+
drawlatch generate-keys local bob
|
|
469
374
|
```
|
|
470
375
|
|
|
471
|
-
Each agent's MCP server config specifies its alias via the `MCP_KEY_ALIAS` env var:
|
|
472
|
-
|
|
473
376
|
```json
|
|
474
377
|
{
|
|
475
378
|
"mcpServers": {
|
|
476
|
-
"
|
|
379
|
+
"drawlatch": {
|
|
477
380
|
"command": "node",
|
|
478
381
|
"args": ["dist/mcp/server.js"],
|
|
479
|
-
"env": {
|
|
480
|
-
"MCP_CONFIG_DIR": "~/.drawlatch",
|
|
481
|
-
"MCP_KEY_ALIAS": "alice"
|
|
482
|
-
}
|
|
382
|
+
"env": { "MCP_CONFIG_DIR": "~/.drawlatch", "MCP_KEY_ALIAS": "alice" }
|
|
483
383
|
}
|
|
484
384
|
}
|
|
485
385
|
}
|
|
486
386
|
```
|
|
487
387
|
|
|
488
|
-
|
|
388
|
+
Register each agent as a separate caller on the remote server with matching peer key directories.
|
|
489
389
|
|
|
490
|
-
##
|
|
491
|
-
|
|
492
|
-
Once connected, Claude Code gets access to four tools:
|
|
493
|
-
|
|
494
|
-
### `secure_request`
|
|
495
|
-
|
|
496
|
-
Make an authenticated HTTP request through the proxy. Route-level headers (e.g., `Authorization`) are injected automatically — the agent never sees the secret values.
|
|
497
|
-
|
|
498
|
-
```
|
|
499
|
-
method: GET | POST | PUT | PATCH | DELETE
|
|
500
|
-
url: Full URL (may contain ${VAR} placeholders)
|
|
501
|
-
headers: Optional additional headers
|
|
502
|
-
body: Optional request body
|
|
503
|
-
```
|
|
504
|
-
|
|
505
|
-
### `list_routes`
|
|
506
|
-
|
|
507
|
-
List all available routes for the current caller. Returns metadata (name, description, docs link), allowed endpoint patterns, available secret placeholder names (not values), and auto-injected header names. Different callers may see different routes based on their `connections` configuration.
|
|
508
|
-
|
|
509
|
-
### `poll_events`
|
|
510
|
-
|
|
511
|
-
Poll for new events from ingestors (Discord messages, GitHub webhooks, Notion updates, etc.). Returns events received since the given cursor.
|
|
390
|
+
## CLI Reference
|
|
512
391
|
|
|
513
392
|
```
|
|
514
|
-
|
|
515
|
-
after_id: Optional — cursor; returns events with id > after_id
|
|
516
|
-
```
|
|
517
|
-
|
|
518
|
-
Pass `after_id` from the last event you received to get only new events. Omit to get all buffered events. See **[INGESTORS.md](INGESTORS.md)** for details on configuring event sources.
|
|
519
|
-
|
|
520
|
-
### `ingestor_status`
|
|
393
|
+
drawlatch [command] [options]
|
|
521
394
|
|
|
522
|
-
|
|
395
|
+
Commands:
|
|
396
|
+
init Set up drawlatch (keys, config, .env) in one step
|
|
397
|
+
start Start the remote server (background daemon)
|
|
398
|
+
stop Stop the remote server
|
|
399
|
+
restart Restart the remote server
|
|
400
|
+
status Show server status (PID, port, uptime, health, sessions)
|
|
401
|
+
logs View server logs
|
|
402
|
+
config Show effective configuration and secret status
|
|
403
|
+
doctor Validate setup and diagnose issues
|
|
404
|
+
generate-keys Generate Ed25519 + X25519 keypairs
|
|
523
405
|
|
|
524
|
-
|
|
406
|
+
Options:
|
|
407
|
+
-h, --help Show help
|
|
408
|
+
-v, --version Show version
|
|
525
409
|
|
|
526
|
-
|
|
410
|
+
Init options:
|
|
411
|
+
--connections <list> Comma-separated connections to enable (e.g., github,slack)
|
|
412
|
+
--alias <name> Caller alias (default: "default")
|
|
527
413
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
414
|
+
Start options:
|
|
415
|
+
-f, --foreground Run in foreground
|
|
416
|
+
-t, --tunnel Start a Cloudflare tunnel for webhooks
|
|
417
|
+
--port <number> Override configured port
|
|
418
|
+
--host <address> Override configured host
|
|
531
419
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
resolveCallerRoutes,
|
|
536
|
-
resolveRoutes,
|
|
537
|
-
resolveSecrets,
|
|
538
|
-
} from "drawlatch/shared/config";
|
|
420
|
+
Logs options:
|
|
421
|
+
-n, --lines <num> Number of lines (default: 50)
|
|
422
|
+
--follow Tail the log output
|
|
539
423
|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
424
|
+
Generate-keys subcommands:
|
|
425
|
+
local [alias] Generate local proxy keypair (default alias: "default")
|
|
426
|
+
remote Generate remote server keypair
|
|
427
|
+
show <path> Show fingerprint of existing keypair
|
|
428
|
+
--dir <path> Generate to custom directory
|
|
545
429
|
```
|
|
546
430
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
| Export Path | Description |
|
|
550
|
-
| ---------------------------- | ------------------------------------------------------------------ |
|
|
551
|
-
| `drawlatch` | MCP proxy server (stdio transport) — the default entry point |
|
|
552
|
-
| `drawlatch/remote/server` | Remote server functions including `executeProxyRequest()` |
|
|
553
|
-
| `drawlatch/remote/ingestors` | `IngestorManager` and all ingestor types |
|
|
554
|
-
| `drawlatch/shared/config` | Config loading, caller/route resolution, secret resolution |
|
|
555
|
-
| `drawlatch/shared/connections`| Connection template loading |
|
|
556
|
-
| `drawlatch/shared/crypto` | Key generation, encrypted channel, key serialization |
|
|
557
|
-
| `drawlatch/shared/protocol` | Handshake protocol, message types |
|
|
431
|
+
## Library Usage (Local Mode)
|
|
558
432
|
|
|
559
|
-
|
|
433
|
+
Import drawlatch directly for in-process use — no server, no encryption:
|
|
560
434
|
|
|
561
435
|
```typescript
|
|
562
436
|
import { loadRemoteConfig, resolveCallerRoutes, resolveRoutes, resolveSecrets } from "drawlatch/shared/config";
|
|
563
437
|
import { executeProxyRequest } from "drawlatch/remote/server";
|
|
564
438
|
|
|
565
|
-
// Load config and resolve routes for a specific caller
|
|
566
439
|
const config = loadRemoteConfig();
|
|
567
440
|
const callerRoutes = resolveCallerRoutes(config, "my-laptop");
|
|
568
441
|
const callerEnv = resolveSecrets(config.callers["my-laptop"]?.env ?? {});
|
|
569
442
|
const routes = resolveRoutes(callerRoutes, callerEnv);
|
|
570
443
|
|
|
571
|
-
// Make a request — same function the remote server uses
|
|
572
444
|
const result = await executeProxyRequest(
|
|
573
445
|
{ method: "GET", url: "https://api.github.com/user" },
|
|
574
446
|
routes,
|
|
575
447
|
);
|
|
576
448
|
```
|
|
577
449
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
## Development
|
|
450
|
+
### Available Exports
|
|
581
451
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
452
|
+
| Export Path | Description |
|
|
453
|
+
|-------------|-------------|
|
|
454
|
+
| `drawlatch` | MCP proxy server (stdio transport) |
|
|
455
|
+
| `drawlatch/remote/server` | `executeProxyRequest()` and server functions |
|
|
456
|
+
| `drawlatch/remote/ingestors` | `IngestorManager` and ingestor types |
|
|
457
|
+
| `drawlatch/shared/config` | Config loading, route/secret resolution |
|
|
458
|
+
| `drawlatch/shared/connections` | Connection template loading |
|
|
459
|
+
| `drawlatch/shared/env-utils` | Environment variable and secret utilities |
|
|
460
|
+
| `drawlatch/shared/crypto` | Key generation, encrypted channel |
|
|
461
|
+
| `drawlatch/shared/protocol` | Handshake protocol, message types |
|
|
585
462
|
|
|
586
|
-
|
|
587
|
-
npm run test:watch
|
|
463
|
+
## Security Model
|
|
588
464
|
|
|
589
|
-
|
|
590
|
-
npm run test:coverage
|
|
465
|
+
### Both Modes
|
|
591
466
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
467
|
+
- **Endpoint allowlisting** — requests only proxied to explicitly configured URL patterns
|
|
468
|
+
- **Per-caller access control** — each caller only sees their assigned connections
|
|
469
|
+
- **Per-caller credential isolation** — same connector, different credentials via `env` overrides
|
|
470
|
+
- **Rate limiting** — configurable per-session (default: 60/min)
|
|
471
|
+
- **Audit logging** — all operations logged with caller identity, session ID, timestamps
|
|
595
472
|
|
|
596
|
-
|
|
597
|
-
npm run format
|
|
598
|
-
npm run format:check
|
|
599
|
-
```
|
|
473
|
+
### Remote Mode Only
|
|
600
474
|
|
|
601
|
-
|
|
475
|
+
- **Zero secrets on the client** — the MCP proxy never sees API keys or tokens
|
|
476
|
+
- **Mutual authentication** — Ed25519 signatures before any data exchange
|
|
477
|
+
- **End-to-end encryption** — AES-256-GCM with X25519 ECDH session keys
|
|
478
|
+
- **Replay protection** — monotonic counters on all encrypted messages
|
|
479
|
+
- **Session isolation** — unique session keys per handshake, 30-minute TTL
|
|
480
|
+
- **File permissions** — private keys `0600`, key directories `0700`
|
|
602
481
|
|
|
603
|
-
|
|
482
|
+
## Development
|
|
604
483
|
|
|
605
|
-
|
|
484
|
+
```bash
|
|
485
|
+
npm test # Run tests
|
|
486
|
+
npm run test:watch # Watch mode
|
|
487
|
+
npm run test:coverage # Coverage report
|
|
488
|
+
npm run lint # Lint
|
|
489
|
+
npm run format # Format
|
|
606
490
|
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
├── .claude-plugin/ # Plugin metadata
|
|
610
|
-
│ ├── plugin.json # Plugin manifest (name, version, description)
|
|
611
|
-
│ └── marketplace.json # Marketplace catalog for distribution
|
|
612
|
-
├── .mcp.json # MCP server config (used by plugin system + auto-discovery)
|
|
613
|
-
├── dist/ # Compiled JavaScript (built via `npm run build` or `prepare`)
|
|
614
|
-
│ └── mcp/server.js # MCP proxy entrypoint
|
|
615
|
-
└── src/ # TypeScript source
|
|
491
|
+
npm run dev:remote # Remote server with hot reload
|
|
492
|
+
npm run dev:mcp # MCP proxy with hot reload
|
|
616
493
|
```
|
|
617
494
|
|
|
618
|
-
### Source
|
|
495
|
+
### Source Structure
|
|
619
496
|
|
|
620
497
|
```
|
|
621
498
|
src/
|
|
622
|
-
├── cli/
|
|
623
|
-
|
|
624
|
-
├──
|
|
625
|
-
│ ├── github.json # GitHub REST API
|
|
626
|
-
│ ├── stripe.json # Stripe Payments API
|
|
627
|
-
│ └── ... # 22 templates total
|
|
628
|
-
├── mcp/
|
|
629
|
-
│ └── server.ts # Local MCP proxy server (stdio transport)
|
|
499
|
+
├── cli/ # Key generation CLI
|
|
500
|
+
├── connections/ # 22 pre-built route templates (JSON)
|
|
501
|
+
├── mcp/server.ts # Local MCP proxy (stdio transport)
|
|
630
502
|
├── remote/
|
|
631
|
-
│ ├── server.ts
|
|
632
|
-
│
|
|
633
|
-
│
|
|
634
|
-
│
|
|
635
|
-
│ ├──
|
|
636
|
-
│
|
|
637
|
-
│ ├── manager.ts # Lifecycle management, per-caller routing
|
|
638
|
-
│ ├── registry.ts # Factory registry for ingestor types
|
|
639
|
-
│ ├── types.ts # Shared types and config interfaces
|
|
640
|
-
│ ├── discord/ # Discord Gateway WebSocket (v10)
|
|
641
|
-
│ ├── slack/ # Slack Socket Mode WebSocket
|
|
642
|
-
│ ├── webhook/ # Webhook receivers (GitHub, Stripe, Trello)
|
|
643
|
-
│ └── poll/ # Interval-based HTTP polling (Notion, Linear, etc.)
|
|
503
|
+
│ ├── server.ts # Remote secure server (Express)
|
|
504
|
+
│ └── ingestors/ # Event ingestion system
|
|
505
|
+
│ ├── discord/ # Discord Gateway WebSocket
|
|
506
|
+
│ ├── slack/ # Slack Socket Mode WebSocket
|
|
507
|
+
│ ├── webhook/ # GitHub, Stripe, Trello webhooks
|
|
508
|
+
│ └── poll/ # Interval-based HTTP polling
|
|
644
509
|
└── shared/
|
|
645
|
-
├── config.ts
|
|
646
|
-
├── connections.ts
|
|
647
|
-
├──
|
|
648
|
-
├── crypto/
|
|
649
|
-
|
|
650
|
-
│ ├── channel.ts # AES-256-GCM encrypted channel
|
|
651
|
-
│ └── index.ts # Re-exports
|
|
652
|
-
└── protocol/
|
|
653
|
-
├── handshake.ts # Mutual auth (Noise NK-inspired)
|
|
654
|
-
├── messages.ts # Application-layer message types
|
|
655
|
-
└── index.ts # Re-exports
|
|
510
|
+
├── config.ts # Config loading, route resolution
|
|
511
|
+
├── connections.ts # Connection template loading
|
|
512
|
+
├── env-utils.ts # Environment variable utilities
|
|
513
|
+
├── crypto/ # Ed25519/X25519 keys, AES-256-GCM channel
|
|
514
|
+
└── protocol/ # Handshake, message types
|
|
656
515
|
```
|
|
657
516
|
|
|
658
|
-
## Security Model
|
|
659
|
-
|
|
660
|
-
### Both Modes
|
|
661
|
-
|
|
662
|
-
These protections apply regardless of whether you use remote or local mode:
|
|
663
|
-
|
|
664
|
-
- **Per-caller access control** — each caller only sees and can use the connections explicitly assigned to them
|
|
665
|
-
- **Per-caller credential isolation** — callers sharing the same connector can have different credentials via `env` overrides
|
|
666
|
-
- **Endpoint allowlisting** — requests are only proxied to explicitly configured URL patterns
|
|
667
|
-
- **Rate limiting** — configurable per-session request rate limiting (default: 60/min)
|
|
668
|
-
- **Audit logging** — all operations are logged with caller identity, session ID, and timestamps
|
|
669
|
-
|
|
670
|
-
### Remote Mode Only
|
|
671
|
-
|
|
672
|
-
These additional protections apply when running the two-component remote architecture:
|
|
673
|
-
|
|
674
|
-
- **Zero secrets on the client** — the local MCP proxy never sees API keys or tokens
|
|
675
|
-
- **Mutual authentication** — both sides prove their identity using Ed25519 signatures before any data is exchanged
|
|
676
|
-
- **End-to-end encryption** — all requests/responses are encrypted with AES-256-GCM session keys derived via X25519 ECDH
|
|
677
|
-
- **Replay protection** — monotonic counters prevent replay attacks
|
|
678
|
-
- **Session isolation** — each handshake produces unique session keys with a 30-minute TTL
|
|
679
|
-
- **File permissions** — private keys are saved with `0600`, directories with `0700`
|
|
680
|
-
|
|
681
|
-
### Local Mode Caveat
|
|
682
|
-
|
|
683
|
-
When using Drawlatch as an in-process library (local mode), secrets are resolved from `process.env` on the same machine as the agent. The encryption and mutual authentication layers are not used. The security value in local mode comes from **structured access control** (endpoint allowlisting, per-caller route isolation) rather than cryptographic secret isolation.
|
|
684
|
-
|
|
685
517
|
## License
|
|
686
518
|
|
|
687
519
|
MIT
|