lazy-mcp 1.1.4 → 1.3.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
@@ -1,53 +1,226 @@
1
- # Lazy MCP Proxy (experiment)
2
-
3
- A proxy tool that converts normal MCP servers to use a lazy-loading pattern with three core tools, dramatically reducing initial context usage and enabling support for hundreds of commands.
4
-
5
- ## Overview
6
-
7
- Instead of exposing all tools directly (which can consume many context tokens), this proxy exposes only three meta-tools:
1
+ # Lazy MCP Proxy
2
+
3
+ ![Pipeline Status](https://gitlab.com/gitlab-org/search-team/experiments/lazy-mcp/badges/main/pipeline.svg)
4
+
5
+ A proxy tool that converts normal MCP servers to use a lazy-loading pattern, dramatically reducing initial context usage by 90%+ and enabling support for hundreds of commands.
6
+
7
+ ## Table of Contents
8
+
9
+ <!-- TOC_START -->
10
+ - [Table of Contents](#table-of-contents)
11
+ - [Features](#features)
12
+ - [Modes](#modes)
13
+ - [Single-Server Mode (Legacy)](#single-server-mode-legacy)
14
+ - [Multi-Server Mode (NEW!)](#multi-server-mode-new)
15
+ - [Installation](#installation)
16
+ - [Usage](#usage)
17
+ - [Multi-Server Mode (Recommended)](#multi-server-mode-recommended)
18
+ - [Single-Server Mode (Legacy)](#single-server-mode-legacy)
19
+ - [Local MCP Servers](#local-mcp-servers)
20
+ - [Remote MCP Servers](#remote-mcp-servers)
21
+ - [Claude Desktop / OpenCode Integration](#claude-desktop--opencode-integration)
22
+ - [Multi-Server Mode (Recommended)](#multi-server-mode-recommended)
23
+ - [Single-Server Mode (Legacy)](#single-server-mode-legacy)
24
+ - [Example](#example)
25
+ - [Development](#development)
26
+ - [Publishing New Versions](#publishing-new-versions)
27
+ - [For Maintainers](#for-maintainers)
28
+ - [Configuration Reference](#configuration-reference)
29
+ - [Server Configuration Fields](#server-configuration-fields)
30
+ - [Command Format](#command-format)
31
+ - [Environment Variables](#environment-variables)
32
+ - [Health Monitoring](#health-monitoring)
33
+ - [Benefits](#benefits)
34
+ - [Documentation](#documentation)
35
+ <!-- TOC_END -->
36
+
37
+ ## Features
38
+
39
+ - **Single-Server Mode**: Wrap one MCP server with 3 meta-tools (legacy mode)
40
+ - **Multi-Server Mode**: Aggregate multiple MCP servers with on-demand discovery (NEW!)
41
+ - **Lazy Loading**: Only discover tools when needed, not upfront
42
+ - **Batch Discovery**: Discover multiple servers in one call
43
+ - **90%+ Context Reduction**: From ~16K to ~1.5K tokens initially
44
+ - **Background Health Monitoring**: Probes all servers on startup and periodically; `list_servers` shows accurate health from the first call
45
+
46
+ ## Modes
47
+
48
+ ### Single-Server Mode (Legacy)
49
+
50
+ Wraps one MCP server and exposes three meta-tools:
8
51
 
9
52
  - `list_commands` - Returns command names and brief descriptions
10
53
  - `describe_commands` - Accepts `command_names: Array[String]`, returns full schemas
11
54
  - `invoke_command` - Executes commands with `command_name: String, parameters: Object`
12
55
 
56
+ ### Multi-Server Mode (NEW!)
57
+
58
+ Aggregates multiple MCP servers and exposes four meta-tools:
59
+
60
+ - `list_servers` - Lists all configured MCP servers with health status
61
+ - `list_commands` - Discovers tools from specific server(s), supports batch discovery
62
+ - `describe_commands` - Gets detailed schemas from a server
63
+ - `invoke_command` - Executes commands from a specific server
64
+
13
65
  ## Installation
14
66
 
67
+ **Recommended:** Use with npx to always get the latest version:
68
+
15
69
  ```bash
16
- npm install -g lazy-mcp
70
+ npx lazy-mcp@latest <server-command-or-url>
17
71
  ```
18
72
 
19
- Or use with npx:
73
+ Or install globally (locks to specific version):
20
74
 
21
75
  ```bash
22
- npx lazy-mcp <server-command-or-url>
76
+ npm install -g lazy-mcp
23
77
  ```
24
78
 
25
79
  ## Usage
26
80
 
27
- ### Local MCP Servers (Easy Development)
81
+ ### Multi-Server Mode (Recommended)
82
+
83
+ Create a configuration file at `~/.config/lazy-mcp/servers.json`:
84
+
85
+ ```json
86
+ {
87
+ "mode": "multi-server",
88
+ "servers": [
89
+ {
90
+ "name": "chrome-devtools",
91
+ "description": "Chrome DevTools automation",
92
+ "type": "local",
93
+ "command": ["npx", "-y", "chrome-devtools-mcp@latest"]
94
+ },
95
+ {
96
+ "name": "gitlab",
97
+ "description": "GitLab API integration",
98
+ "type": "local",
99
+ "command": [
100
+ "npx",
101
+ "mcp-remote@latest",
102
+ "https://gitlab.com/api/v4/mcp",
103
+ "--static-oauth-client-metadata",
104
+ "{\"scope\": \"mcp\"}"
105
+ ]
106
+ },
107
+ {
108
+ "name": "my-remote-server",
109
+ "description": "Custom remote MCP server",
110
+ "type": "remote",
111
+ "url": "https://api.example.com/mcp",
112
+ "headers": {
113
+ "Authorization": "Bearer ${API_TOKEN}"
114
+ }
115
+ }
116
+ ],
117
+ "healthMonitor": {
118
+ "enabled": true,
119
+ "interval": 30000,
120
+ "timeout": 10000
121
+ }
122
+ }
123
+ ```
124
+
125
+ Then run:
126
+
127
+ ```bash
128
+ # Using npx (recommended - always latest version)
129
+ npx lazy-mcp@latest --config ~/.config/lazy-mcp/servers.json
130
+
131
+ # Or via environment variable
132
+ LAZY_MCP_CONFIG=~/.config/lazy-mcp/servers.json npx lazy-mcp@latest
133
+
134
+ # Or if installed globally
135
+ lazy-mcp --config ~/.config/lazy-mcp/servers.json
136
+ ```
137
+
138
+ ### Single-Server Mode (Legacy)
139
+
140
+ #### Local MCP Servers
28
141
 
29
142
  ```bash
30
143
  # Run a Python MCP server
31
- lazy-mcp python my_server.py
144
+ npx lazy-mcp@latest python my_server.py
32
145
 
33
146
  # Run a Node.js server with arguments
34
- lazy-mcp node server.js --port 8080
147
+ npx lazy-mcp@latest node server.js --port 8080
35
148
 
36
149
  # Run complex commands (use quotes)
37
- lazy-mcp "uvicorn server:app --host 0.0.0.0 --port 3000"
150
+ npx lazy-mcp@latest "uvicorn server:app --host 0.0.0.0 --port 3000"
38
151
  ```
39
152
 
40
- ### Remote MCP Servers (Production)
153
+ #### Remote MCP Servers
41
154
 
42
155
  ```bash
43
156
  # Connect to a remote HTTP MCP server
44
- lazy-mcp http://localhost:3000/mcp
157
+ npx lazy-mcp@latest http://localhost:3000/mcp
45
158
 
46
159
  # With authentication headers
47
- lazy-mcp https://api.example.com/mcp --header "Authorization=Bearer token123"
160
+ npx lazy-mcp@latest https://api.example.com/mcp --header "Authorization=Bearer token123"
48
161
 
49
162
  # Multiple headers
50
- lazy-mcp https://api.example.com/mcp --header "X-API-Key=abc123" --header "User-Agent=my-app/1.0"
163
+ npx lazy-mcp@latest https://api.example.com/mcp --header "X-API-Key=abc123" --header "User-Agent=my-app/1.0"
164
+ ```
165
+
166
+ ## Claude Desktop / OpenCode Integration
167
+
168
+ ### Multi-Server Mode (Recommended)
169
+
170
+ Replace multiple MCP server entries with one aggregated proxy:
171
+
172
+ **Before** (5 separate MCP servers):
173
+ ```json
174
+ {
175
+ "mcp": {
176
+ "chrome-devtools": { "command": ["npx", "lazy-mcp@latest", "npx", "-y", "chrome-devtools-mcp@latest"] },
177
+ "gitlab": { "command": ["npx", "lazy-mcp@latest", "npx", "mcp-remote@latest", "https://..."] },
178
+ "grepai": { "command": ["npx", "lazy-mcp@latest", "grepai", "mcp-serve"] },
179
+ "context7": { "command": ["npx", "-y", "@upstash/context7-mcp"] },
180
+ "perplexity": { "command": ["npx", "-y", "@perplexity-ai/mcp-server"] }
181
+ }
182
+ }
183
+ ```
184
+
185
+ **After** (Consolidated into 1 multi-server proxy):
186
+ ```json
187
+ {
188
+ "mcp": {
189
+ "lazy-mcp": {
190
+ "type": "local",
191
+ "command": ["npx", "lazy-mcp@latest", "--config", "~/.config/lazy-mcp/servers.json"],
192
+ "enabled": true
193
+ }
194
+ }
195
+ }
196
+ ```
197
+
198
+ Where `~/.config/lazy-mcp/servers.json` contains all 5 servers:
199
+ ```json
200
+ {
201
+ "mode": "multi-server",
202
+ "servers": [
203
+ { "name": "chrome-devtools", "description": "Chrome DevTools automation", "type": "local", "command": ["npx", "-y", "chrome-devtools-mcp@latest"] },
204
+ { "name": "gitlab", "description": "GitLab API integration", "type": "local", "command": ["npx", "mcp-remote@latest", "https://..."] },
205
+ { "name": "grepai", "description": "Search codebase", "type": "local", "command": ["grepai", "mcp-serve"] },
206
+ { "name": "context7", "description": "Library documentation", "type": "local", "command": ["npx", "-y", "@upstash/context7-mcp"] },
207
+ { "name": "perplexity", "description": "Web search", "type": "local", "command": ["npx", "-y", "@perplexity-ai/mcp-server"] }
208
+ ]
209
+ }
210
+ ```
211
+
212
+ **Result**: ~90% context reduction (from ~16K to ~1.5K tokens initially)
213
+
214
+ ### Single-Server Mode (Legacy)
215
+
216
+ ```json
217
+ {
218
+ "mcp": {
219
+ "gitlab": {
220
+ "command": ["npx", "lazy-mcp@latest", "npx", "mcp-remote", "https://gitlab.com/api/v4/mcp"]
221
+ }
222
+ }
223
+ }
51
224
  ```
52
225
 
53
226
  ## Example
@@ -58,7 +231,7 @@ python my_server.py
58
231
  # Exposes: tool1, tool2, tool3, ..., tool100 (uses 100x context tokens)
59
232
 
60
233
  # Through lazy proxy - local
61
- lazy-mcp python my_server.py
234
+ npx lazy-mcp@latest python my_server.py
62
235
  # Exposes: list_commands, describe_commands, invoke_command (uses 3x context tokens)
63
236
 
64
237
  # Original remote server
@@ -66,7 +239,7 @@ curl http://localhost:3000/mcp -d '{"method":"tools/list"}'
66
239
  # Returns: tool1, tool2, tool3, ..., tool100 (uses 100x context when loaded)
67
240
 
68
241
  # Through lazy proxy - remote
69
- lazy-mcp http://localhost:3000/mcp
242
+ npx lazy-mcp@latest http://localhost:3000/mcp
70
243
  # Exposes: list_commands, describe_commands, invoke_command (uses 3x context tokens)
71
244
  ```
72
245
 
@@ -118,10 +291,95 @@ npm run dev -- http://localhost:3000/mcp
118
291
  git push --tags
119
292
  ```
120
293
 
294
+ ## Configuration Reference
295
+
296
+ ### Server Configuration Fields
297
+
298
+ | Field | Type | Required | Description |
299
+ |-------|------|----------|-------------|
300
+ | `name` | string | ✅ | Unique server identifier |
301
+ | `description` | string | ✅ | Human-readable description |
302
+ | `type` | "local" \| "remote" | ✅ | Server connection type |
303
+ | `command` | string[] \| string | For local | Command to execute (array format recommended) |
304
+ | `args` | string[] | Optional | Arguments (only if command is string) |
305
+ | `url` | string | For remote | HTTP/HTTPS URL |
306
+ | `headers` | object | Optional | HTTP headers for remote servers |
307
+ | `env` | object | Optional | Environment variables (supports `${VAR}` expansion) |
308
+ | `enabled` | boolean | Optional | Enable/disable server (default: true) |
309
+ | `examples` | object[] | Optional | Usage examples shown in `list_servers` output |
310
+ | `tags` | string[] | Optional | Capability tags for filtering (e.g. `"api"`, `"browser"`) |
311
+
312
+ ### Command Format
313
+
314
+ **Recommended** (OpenCode-compatible):
315
+ ```json
316
+ {
317
+ "command": ["npx", "-y", "my-mcp-server", "--port", "3000"]
318
+ }
319
+ ```
320
+
321
+ **Legacy** (still supported):
322
+ ```json
323
+ {
324
+ "command": "npx",
325
+ "args": ["-y", "my-mcp-server", "--port", "3000"]
326
+ }
327
+ ```
328
+
329
+ ### Environment Variables
330
+
331
+ Use `${VAR_NAME}` to reference environment variables:
332
+
333
+ ```json
334
+ {
335
+ "env": {
336
+ "API_KEY": "${MY_API_KEY}",
337
+ "DEBUG": "true"
338
+ },
339
+ "headers": {
340
+ "Authorization": "Bearer ${AUTH_TOKEN}"
341
+ }
342
+ }
343
+ ```
344
+
345
+ ### Health Monitoring
346
+
347
+ lazy-mcp includes a background health monitor that probes all servers on startup and periodically. This means `list_servers` returns accurate `healthy` and `error` fields from the very first call, without needing to trigger discovery manually.
348
+
349
+ Successful probes also populate the discovery cache, so the first `list_commands` call for a healthy server returns instantly from cache.
350
+
351
+ **Top-level configuration** (in `servers.json`):
352
+
353
+ | Field | Type | Default | Description |
354
+ |-------|------|---------|-------------|
355
+ | `healthMonitor.enabled` | boolean | `true` | Enable/disable background health monitoring |
356
+ | `healthMonitor.interval` | number | `30000` | Interval between health checks (ms) |
357
+ | `healthMonitor.timeout` | number | `10000` | Timeout per server probe (ms) |
358
+
359
+ To disable:
360
+ ```json
361
+ {
362
+ "mode": "multi-server",
363
+ "servers": [...],
364
+ "healthMonitor": { "enabled": false }
365
+ }
366
+ ```
367
+
121
368
  ## Benefits
122
369
 
123
- - **Dramatic reduction** in initial context usage
124
- - **Progressive tool discovery** - only load schemas when needed
370
+ - **90%+ context reduction** - From ~16K to ~1.5K tokens initially
371
+ - **Progressive tool discovery** - Only load schemas when needed
372
+ - **Multi-server aggregation** - Manage multiple MCP servers in one config
373
+ - **Batch discovery** - Discover multiple servers efficiently
125
374
  - **Scales to hundreds** of commands without context bloat
126
- - **Clean separation** of concerns between discovery and execution
127
- - **Header forwarding** for authentication and custom headers
375
+ - **Flexible configuration** - Enable/disable servers on demand
376
+ - **Environment variable support** - Secure credential management
377
+ - **Both local and remote** - Support for subprocess and HTTP servers
378
+ - **Health monitoring** - Background probes detect broken servers before you hit them
379
+
380
+ ## Documentation
381
+
382
+ - **[AGENTS.md](./AGENTS.md)** - Development guide for AI coding agents (build commands, code style, testing patterns)
383
+ - **[doc/ARCHITECTURE.md](./doc/ARCHITECTURE.md)** - Architecture overview and design patterns
384
+ - **[doc/CONTRIBUTING.md](./doc/CONTRIBUTING.md)** - Contributing guide with common development tasks
385
+ - **[Configuration Reference](#configuration-reference)** - Server configuration options (above)
package/dist/cli.js CHANGED
@@ -3,6 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const child_process_1 = require("child_process");
5
5
  const server_1 = require("./server");
6
+ const config_1 = require("./config");
7
+ const server_manager_1 = require("./server-manager");
6
8
  class RemoteMCPServer {
7
9
  constructor(serverUrl, headers = {}) {
8
10
  this.connected = false;
@@ -132,18 +134,35 @@ class LocalMCPServer {
132
134
  }
133
135
  }
134
136
  }
137
+ function detectMode(args) {
138
+ // Check for --config flag
139
+ if (args.includes('--config')) {
140
+ return 'multi';
141
+ }
142
+ // Check for LAZY_MCP_CONFIG env var
143
+ if (process.env.LAZY_MCP_CONFIG) {
144
+ return 'multi';
145
+ }
146
+ // Default: single-server mode
147
+ return 'single';
148
+ }
135
149
  function parseArgs(args) {
136
150
  if (args.length === 0) {
137
151
  console.error('Usage: lazy-mcp <server-command-or-url> [args...] [--header key=value]...');
152
+ console.error(' lazy-mcp --config <config-file>');
138
153
  console.error('');
139
- console.error('Local MCP servers:');
154
+ console.error('Single-server mode (local MCP servers):');
140
155
  console.error(' lazy-mcp python my_server.py');
141
156
  console.error(' lazy-mcp node server.js --port 8080');
142
157
  console.error(' lazy-mcp "uvicorn server:app --port 3000"');
143
158
  console.error('');
144
- console.error('Remote MCP servers:');
159
+ console.error('Single-server mode (remote MCP servers):');
145
160
  console.error(' lazy-mcp http://localhost:3000/mcp');
146
161
  console.error(' lazy-mcp https://api.example.com/mcp --header "Authorization=Bearer token123"');
162
+ console.error('');
163
+ console.error('Multi-server mode:');
164
+ console.error(' lazy-mcp --config ~/.config/lazy-mcp/servers.json');
165
+ console.error(' LAZY_MCP_CONFIG=~/.config/lazy-mcp/servers.json lazy-mcp');
147
166
  process.exit(1);
148
167
  }
149
168
  const firstArg = args[0];
@@ -182,6 +201,54 @@ function parseArgs(args) {
182
201
  }
183
202
  async function main() {
184
203
  const args = process.argv.slice(2);
204
+ const mode = detectMode(args);
205
+ if (mode === 'multi') {
206
+ await runMultiServerMode(args);
207
+ }
208
+ else {
209
+ await runSingleServerMode(args);
210
+ }
211
+ }
212
+ async function runMultiServerMode(args) {
213
+ // Get config path from --config flag or environment variable
214
+ let configPath;
215
+ const configIndex = args.indexOf('--config');
216
+ if (configIndex !== -1 && configIndex + 1 < args.length) {
217
+ configPath = args[configIndex + 1];
218
+ }
219
+ else if (process.env.LAZY_MCP_CONFIG) {
220
+ configPath = process.env.LAZY_MCP_CONFIG;
221
+ }
222
+ if (!configPath) {
223
+ console.error('Error: Config file path is required for multi-server mode');
224
+ console.error('Use: lazy-mcp --config <config-file>');
225
+ console.error('Or set: LAZY_MCP_CONFIG=<config-file>');
226
+ process.exit(1);
227
+ }
228
+ try {
229
+ const config = config_1.ConfigLoader.load(configPath);
230
+ const serverManager = new server_manager_1.ServerManager(config.servers, config.cache, config.healthMonitor);
231
+ const lazyServer = new server_1.LazyMCPServer(undefined, serverManager);
232
+ const cleanup = async () => {
233
+ console.error('\nShutting down...');
234
+ await serverManager.closeAll();
235
+ process.exit(0);
236
+ };
237
+ process.on('SIGINT', cleanup);
238
+ process.on('SIGTERM', cleanup);
239
+ const enabledServers = config.servers.filter(s => s.enabled !== false);
240
+ console.error(`Starting lazy MCP multi-server proxy with ${enabledServers.length} servers`);
241
+ console.error(`Servers: ${enabledServers.map(s => s.name).join(', ')}`);
242
+ // Start background health monitor (probes all servers on startup + periodically)
243
+ serverManager.startHealthMonitor();
244
+ await lazyServer.run();
245
+ }
246
+ catch (error) {
247
+ console.error('Error starting multi-server mode:', error);
248
+ process.exit(1);
249
+ }
250
+ }
251
+ async function runSingleServerMode(args) {
185
252
  const parsed = parseArgs(args);
186
253
  let originalServer;
187
254
  let description;
@@ -202,7 +269,6 @@ async function main() {
202
269
  description = `local server: ${parsed.command} ${(parsed.commandArgs || []).join(' ')}`.trim();
203
270
  }
204
271
  const lazyServer = new server_1.LazyMCPServer(originalServer);
205
- // Handle cleanup on exit
206
272
  const cleanup = async () => {
207
273
  console.error('\nShutting down...');
208
274
  await originalServer.close();
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,iDAAoD;AACpD,qCAAyC;AAGzC,MAAM,eAAe;IAKnB,YAAY,SAAiB,EAAE,UAAkC,EAAE;QAF3D,cAAS,GAAY,KAAK,CAAC;QAGjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG;YACb,cAAc,EAAE,kBAAkB;YAClC,GAAG,OAAO;SACX,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,WAAW,CAAC,MAAc,EAAE,MAAY;QACpD,MAAM,OAAO,GAAG;YACd,OAAO,EAAE,KAAK;YACd,EAAE,EAAE,IAAI,CAAC,G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D,MAAM,cAAc,CAAC,KAAK,EAAE,CAAC;QAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { MultiServerConfig } from './types';
2
+ export declare class ConfigLoader {
3
+ static load(configPath: string): MultiServerConfig;
4
+ private static resolvePath;
5
+ private static validate;
6
+ private static validateServer;
7
+ static expandEnvVars(value: string): string;
8
+ static processEnv(env: Record<string, string>): Record<string, string>;
9
+ }
10
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAgB,MAAM,SAAS,CAAC;AAE1D,qBAAa,YAAY;IACvB,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB;IAmBlD,OAAO,CAAC,MAAM,CAAC,WAAW;IAO1B,OAAO,CAAC,MAAM,CAAC,QAAQ;IAoBvB,OAAO,CAAC,MAAM,CAAC,cAAc;IAyD7B,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAM3C,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAOvE"}
package/dist/config.js ADDED
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ConfigLoader = void 0;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const os = __importStar(require("os"));
40
+ class ConfigLoader {
41
+ static load(configPath) {
42
+ const resolvedPath = this.resolvePath(configPath);
43
+ if (!fs.existsSync(resolvedPath)) {
44
+ throw new Error(`Config file not found: ${resolvedPath}`);
45
+ }
46
+ const content = fs.readFileSync(resolvedPath, 'utf-8');
47
+ let config;
48
+ try {
49
+ config = JSON.parse(content);
50
+ }
51
+ catch (error) {
52
+ throw new Error(`Invalid JSON in config file: ${error}`);
53
+ }
54
+ return this.validate(config);
55
+ }
56
+ static resolvePath(configPath) {
57
+ if (configPath.startsWith('~/')) {
58
+ return path.join(os.homedir(), configPath.slice(2));
59
+ }
60
+ return path.resolve(configPath);
61
+ }
62
+ static validate(config) {
63
+ if (config.mode !== 'multi-server') {
64
+ throw new Error('Config must have mode: "multi-server"');
65
+ }
66
+ if (!Array.isArray(config.servers)) {
67
+ throw new Error('Config must have a "servers" array');
68
+ }
69
+ if (config.servers.length === 0) {
70
+ throw new Error('Config must have at least one server');
71
+ }
72
+ config.servers.forEach((server, index) => {
73
+ this.validateServer(server, index);
74
+ });
75
+ return config;
76
+ }
77
+ static validateServer(server, index) {
78
+ const prefix = `Server ${index}`;
79
+ if (!server.name || typeof server.name !== 'string') {
80
+ throw new Error(`${prefix}: "name" is required and must be a string`);
81
+ }
82
+ if (!server.description || typeof server.description !== 'string') {
83
+ throw new Error(`${prefix} (${server.name}): "description" is required and must be a string`);
84
+ }
85
+ if (!server.type || !['local', 'remote'].includes(server.type)) {
86
+ throw new Error(`${prefix} (${server.name}): "type" must be "local" or "remote"`);
87
+ }
88
+ if (server.type === 'local') {
89
+ if (!server.command) {
90
+ throw new Error(`${prefix} (${server.name}): local servers require "command"`);
91
+ }
92
+ // Support both formats:
93
+ // 1. OpenCode format: command: ["npx", "-y", "package"]
94
+ // 2. Legacy format: command: "npx", args: ["-y", "package"]
95
+ if (Array.isArray(server.command)) {
96
+ if (server.command.length === 0) {
97
+ throw new Error(`${prefix} (${server.name}): "command" array cannot be empty`);
98
+ }
99
+ if (!server.command.every((arg) => typeof arg === 'string')) {
100
+ throw new Error(`${prefix} (${server.name}): "command" array must contain only strings`);
101
+ }
102
+ }
103
+ else if (typeof server.command === 'string') {
104
+ if (server.args && !Array.isArray(server.args)) {
105
+ throw new Error(`${prefix} (${server.name}): "args" must be an array`);
106
+ }
107
+ }
108
+ else {
109
+ throw new Error(`${prefix} (${server.name}): "command" must be a string or array`);
110
+ }
111
+ }
112
+ if (server.type === 'remote') {
113
+ if (!server.url || typeof server.url !== 'string') {
114
+ throw new Error(`${prefix} (${server.name}): remote servers require "url" as a string`);
115
+ }
116
+ if (!server.url.startsWith('http://') && !server.url.startsWith('https://') &&
117
+ !server.url.startsWith('ws://') && !server.url.startsWith('wss://')) {
118
+ throw new Error(`${prefix} (${server.name}): "url" must start with http://, https://, ws://, or wss://`);
119
+ }
120
+ if (server.headers && typeof server.headers !== 'object') {
121
+ throw new Error(`${prefix} (${server.name}): "headers" must be an object`);
122
+ }
123
+ }
124
+ if (server.env && typeof server.env !== 'object') {
125
+ throw new Error(`${prefix} (${server.name}): "env" must be an object`);
126
+ }
127
+ }
128
+ static expandEnvVars(value) {
129
+ return value.replace(/\$\{([^}]+)\}/g, (match, varName) => {
130
+ return process.env[varName] || match;
131
+ });
132
+ }
133
+ static processEnv(env) {
134
+ const processed = {};
135
+ for (const [key, value] of Object.entries(env)) {
136
+ processed[key] = this.expandEnvVars(value);
137
+ }
138
+ return processed;
139
+ }
140
+ }
141
+ exports.ConfigLoader = ConfigLoader;
142
+ //# sourceMappingURL=config.js.map