@wuyax/mcps 0.1.0-beta.2 → 0.1.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/LICENSE +21 -0
- package/README.md +244 -20
- package/dist/chunk-AWD3VQ3S.js +1624 -0
- package/dist/chunk-O3BRJFEC.js +1898 -0
- package/dist/cli.cjs +1553 -852
- package/dist/cli.js +186 -16
- package/dist/index.cjs +678 -1755
- package/dist/index.d.cts +162 -299
- package/dist/index.d.ts +162 -299
- package/dist/index.js +29 -74
- package/dist/{chunk-7V5XL4RI.js → interactive.cjs} +1649 -1172
- package/dist/interactive.d.cts +228 -0
- package/dist/interactive.d.ts +228 -0
- package/dist/interactive.js +53 -0
- package/dist/types-lEP3zGvf.d.cts +128 -0
- package/dist/types-lEP3zGvf.d.ts +128 -0
- package/package.json +33 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 wuyax
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -12,8 +12,9 @@ Cross-platform Model Context Protocol (MCP) server manager, synchronizer, and co
|
|
|
12
12
|
- **Multi-Format Storage**: Native read and write engines for JSON, JSONC (preserving existing comments and AST structure via `jsonc-parser`), YAML, and TOML.
|
|
13
13
|
- **Declarative Dialect Transforms**: Intelligent transformation layer adapting standard `McpServerConfig` models into agent-specific field shapes (`command` array vs binary string, `cmd` vs `command`, `envs` vs `env` vs `environment`, `uri` vs `url`, transport indicators, timeouts, and metadata flags).
|
|
14
14
|
- **Intelligent Source Resolution**: Accepts npm package specs, remote HTTP/SSE endpoints, local CLI commands, and Docker containers. Automatically strips npm scopes, package affixes, script extensions, and URL host clutter to infer clean server names.
|
|
15
|
-
- **
|
|
16
|
-
- **
|
|
15
|
+
- **Config Clustering & Co-Hosted Deduplication**: Automatically detects agents sharing the same physical configuration target (such as Claude Code, GitHub Copilot CLI, and Qoder sharing `.mcp.json`). Deduplicates filesystem writes, keeps interactive selection synchronized via linked checkboxes, and reports co-configured and co-affected agents.
|
|
16
|
+
- **Cross-Agent Synchronization & In-Place Editing**: Inspect installed MCP servers across project and global scopes, view parsed details with secret masking, edit configurations in-place with protocol switching (stdio <-> remote), and sync/clone configurations to other agents with automatic dialect and format translation.
|
|
17
|
+
- **Dual Mode (Interactive TTY + Headless CLI)**: Rich interactive terminal wizards with multiline `.env`/header pasting, `$EDITOR` launching, and password masking for secrets, combined with robust CLI commands (`add`, `manage`, `list`, `remove`) and standard exit codes for CI/CD and autonomous agents.
|
|
17
18
|
- **Pluggable Architecture**: Decoupled deep modules including `AgentConfigStore` (supporting filesystem and in-memory test adapters), `resolveTargetAgents` (capability and transport filtering), and declarative transform dialects.
|
|
18
19
|
|
|
19
20
|
---
|
|
@@ -73,6 +74,18 @@ List installed MCP servers in the current project:
|
|
|
73
74
|
mcps list
|
|
74
75
|
```
|
|
75
76
|
|
|
77
|
+
Inspect an installed MCP server's configuration details:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
mcps manage server-filesystem
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Update command arguments or environment variables non-interactively:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
mcps manage server-filesystem --args "/workspace" "/data" -y
|
|
87
|
+
```
|
|
88
|
+
|
|
76
89
|
Remove an MCP server from all agents globally without prompting:
|
|
77
90
|
|
|
78
91
|
```bash
|
|
@@ -104,7 +117,7 @@ When launched with no arguments, the main menu offers:
|
|
|
104
117
|
4. **Scope & Agent Selection**:
|
|
105
118
|
- Choose between **Project** (`.`) and **Global** (user home directory).
|
|
106
119
|
- Scans filesystem to auto-detect installed agents in the chosen scope.
|
|
107
|
-
- Presents a checkbox list
|
|
120
|
+
- Presents a synchronized linked checkbox list (`linkedCheckbox`): detected agents carry `[detected]` tags and are pre-selected by default. Agents sharing the same physical configuration file (e.g. `claude-code`, `github-copilot-cli`, and `qoder` in project scope) are grouped and labeled with `[shared: <agents>]`. Selecting or deselecting any agent automatically updates its linked co-hosted peers.
|
|
108
121
|
5. **Arguments**: Configure optional CLI arguments (quote-aware parsing for paths with spaces).
|
|
109
122
|
6. **Environment Variables & Secrets**:
|
|
110
123
|
- `Skip / None`: Proceed without environment variables.
|
|
@@ -113,30 +126,32 @@ When launched with no arguments, the main menu offers:
|
|
|
113
126
|
- `Enter key-value pairs one by one`: Prompts for individual variables. Automatically detects sensitive keys (`token`, `key`, `secret`, `password`, `auth`, `credential`) and masks input using password prompts.
|
|
114
127
|
7. **HTTP Headers** (for remote servers):
|
|
115
128
|
- Supports multiline terminal pasting (`Key: Value` or `Key=Value`), `$EDITOR` entry, or step-by-step entry with secret masking for authorization tokens.
|
|
116
|
-
8. **Configuration Preview & Confirmation**: Displays normalized parameters before writing to disk.
|
|
129
|
+
8. **Configuration Preview & Confirmation**: Displays normalized parameters before writing to disk, deduplicating writes across co-hosted config files and highlighting `(co-configured: <agents>)` on completion.
|
|
117
130
|
|
|
118
|
-
### Manage & Sync Wizard (`mcps` -> Manage)
|
|
131
|
+
### Manage & Sync Wizard (`mcps` -> Manage, or `mcps manage [server-name]`)
|
|
119
132
|
|
|
120
|
-
1. Prompts for scope (**Project** or **Global**).
|
|
121
|
-
2. Lists all configured MCP servers grouped by server name along with
|
|
122
|
-
3. Inspects
|
|
133
|
+
1. Prompts for scope (**Project** or **Global**), or accepts scope flag (`-g, --global`).
|
|
134
|
+
2. Lists all configured MCP servers grouped by server name along with configuring agents. Directly passing `[server-name]` skips the server selection step.
|
|
135
|
+
3. Inspects server details: transport type, URL or command, arguments, environment variables, and headers (with password and token masking). If configurations diverge across agents, displays a divergence warning.
|
|
123
136
|
4. Allows triggering **Edit server configuration**:
|
|
137
|
+
- **Switch Server Type**: Convert a local command (stdio) to a remote endpoint (HTTP/SSE) or vice versa in-place with interactive input prompts.
|
|
124
138
|
- **Environment Variables (`env`)**: Inspect masked secrets, modify or add variables one-by-one, open in `$EDITOR` with pre-filled `.env` format, paste multiline `.env` definitions (merge or replace), or delete variables.
|
|
125
139
|
- **Command Arguments (`args`)**: Edit arguments in-place with existing arguments pre-filled.
|
|
126
140
|
- **Command (`command`)**: Update executable name or binary path.
|
|
127
|
-
- **Remote Endpoints (`url`, `type`, `headers`)**: Modify remote URLs, toggle HTTP
|
|
128
|
-
-
|
|
141
|
+
- **Remote Endpoints (`url`, `type`, `headers`)**: Modify remote URLs, toggle between HTTP and SSE transport, and manage HTTP headers.
|
|
142
|
+
- **Reset & Discard**: Reset working changes back to the original values or cancel to discard edits without saving.
|
|
143
|
+
- Saves and persists updated configurations to target agent files using native formats and schema dialects, displaying `(co-configured: <agents>)` feedback for shared configuration targets.
|
|
129
144
|
5. Allows triggering **Sync / clone to other agents**:
|
|
130
145
|
- Identifies candidate agents that do not currently have the server configured.
|
|
131
146
|
- Filters candidate agents by scope and transport capability.
|
|
132
|
-
-
|
|
147
|
+
- Uses linked checkbox selection for candidate agents, keeping co-hosted targets in sync.
|
|
148
|
+
- Writes the server configuration to selected targets using their respective native config formats and schema dialects, displaying `(co-configured: <agents>)` feedback.
|
|
133
149
|
|
|
134
150
|
### Remove Wizard (`mcps remove` without name)
|
|
135
151
|
|
|
136
|
-
|
|
137
152
|
1. Prompts for scope (**Project** or **Global**).
|
|
138
153
|
2. Lists configured servers for selection.
|
|
139
|
-
3. Removes the selected server from target agent configuration files with safety confirmation.
|
|
154
|
+
3. Removes the selected server from target agent configuration files with safety confirmation, displaying `(co-affected: <agents>)` feedback when removing from shared configuration targets.
|
|
140
155
|
|
|
141
156
|
---
|
|
142
157
|
|
|
@@ -180,6 +195,15 @@ When neither `-a` nor `--all` is specified:
|
|
|
180
195
|
2. If agents are detected, filters them by transport capability (e.g. stdio-only agents like Claude Desktop are excluded when adding remote HTTP/SSE servers).
|
|
181
196
|
3. If no agents are detected, logs a diagnostic warning and exits with code `1`.
|
|
182
197
|
|
|
198
|
+
#### Co-Hosted Agent Deduplication
|
|
199
|
+
|
|
200
|
+
When target agents share the same physical configuration file (e.g. Claude Code, GitHub Copilot CLI, and Qoder sharing project `.mcp.json`), `mcps` automatically clusters the targets, executes a single file write, and logs co-hosted feedback:
|
|
201
|
+
|
|
202
|
+
```text
|
|
203
|
+
claude-code .mcp.json
|
|
204
|
+
Note: Also configured for co-hosted agent(s): github-copilot-cli, qoder
|
|
205
|
+
```
|
|
206
|
+
|
|
183
207
|
#### Examples
|
|
184
208
|
|
|
185
209
|
```bash
|
|
@@ -239,6 +263,86 @@ mcps list --json
|
|
|
239
263
|
|
|
240
264
|
---
|
|
241
265
|
|
|
266
|
+
### `mcps manage [server-name]`
|
|
267
|
+
|
|
268
|
+
Inspects, modifies in-place, or synchronizes installed MCP server configurations across coding agents.
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
mcps manage [server-name] [options]
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
#### Arguments
|
|
275
|
+
|
|
276
|
+
- `[server-name]`: Name of the MCP server to inspect or manage.
|
|
277
|
+
- In an interactive terminal (TTY): If omitted, launches the interactive Manage & Sync Wizard. If provided without modification flags, displays server details and opens the interactive edit/sync menu.
|
|
278
|
+
- In non-interactive mode (`--yes` or non-TTY): Required when passing modification flags. When passed without modification flags, prints server configuration details (with masked secrets) and exits.
|
|
279
|
+
|
|
280
|
+
#### Options
|
|
281
|
+
|
|
282
|
+
- `-a, --agent <agents...>`: Target specific agents for inspection or update. When omitted during updates, defaults to all agents currently configuring the server.
|
|
283
|
+
- `-g, --global`: Target global user-level configurations instead of current project directory.
|
|
284
|
+
- `-t, --transport <type>`: Transport type for remote servers (`http` or `sse`).
|
|
285
|
+
- `--header <header...>`: HTTP header formatted as `Key: Value`. Repeatable.
|
|
286
|
+
- `--clear-headers`: Clear all HTTP headers for remote servers.
|
|
287
|
+
- `--env <env...>`: Environment variable formatted as `KEY=VALUE`. Repeatable.
|
|
288
|
+
- `--clear-env`: Clear all environment variables for stdio servers.
|
|
289
|
+
- `--args <args...>`: CLI arguments for stdio/package servers.
|
|
290
|
+
- `--clear-args`: Clear all arguments for stdio/package servers.
|
|
291
|
+
- `--command <command>`: Executable command for stdio servers.
|
|
292
|
+
- `--url <url>`: Remote endpoint URL.
|
|
293
|
+
- `-y, --yes`: Non-interactive mode; skips confirmation and interactive prompts.
|
|
294
|
+
|
|
295
|
+
#### Protocol Switching & Sanitization
|
|
296
|
+
|
|
297
|
+
`mcps manage` automatically handles protocol transitions and prevents configuration pollution:
|
|
298
|
+
- **Mutual Exclusion**: `--url` (remote) and `--command` (stdio) cannot be specified simultaneously.
|
|
299
|
+
- **Switching to Remote**: Supplying `--url` strips existing stdio fields (`command`, `args`, `env`) and applies remote parameters (`url`, `type`, `headers`). Target agents that only support stdio (e.g. Claude Desktop) are skipped with diagnostic warnings.
|
|
300
|
+
- **Switching to Stdio**: Supplying `--command` strips existing remote fields (`url`, `type`, `headers`) and applies stdio parameters (`command`, `args`, `env`).
|
|
301
|
+
- **Clear Flags**: `--clear-env`, `--clear-args`, and `--clear-headers` strip their respective configuration fields. They can also be paired with replacement values (for instance, `--clear-env --env "NEW_VAR=1"` replaces all previous environment variables).
|
|
302
|
+
- **Mismatched Flag Warnings**: Providing stdio flags (`--env`, `--args`) when configuring a remote server or remote flags (`--header`, `--transport`) when configuring a stdio server outputs warnings and safely ignores incompatible flags.
|
|
303
|
+
|
|
304
|
+
#### Co-Hosted Agent Synchronization
|
|
305
|
+
|
|
306
|
+
When updating a server on an agent that shares a physical configuration file with other agents, `mcps` deduplicates the operation to a single write and reports co-configured agents:
|
|
307
|
+
|
|
308
|
+
```text
|
|
309
|
+
claude-code: Successfully updated in .mcp.json
|
|
310
|
+
Note: Also configured for co-hosted agent(s): github-copilot-cli, qoder
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
#### Examples
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
# Inspect server configuration and configured agents in current project
|
|
317
|
+
mcps manage postgres
|
|
318
|
+
|
|
319
|
+
# Inspect a globally configured server
|
|
320
|
+
mcps manage memory -g
|
|
321
|
+
|
|
322
|
+
# Update command arguments for an existing stdio server
|
|
323
|
+
mcps manage postgres --args --read-only --port 5432 -y
|
|
324
|
+
|
|
325
|
+
# Merge additional environment variables into an existing stdio server
|
|
326
|
+
mcps manage postgres --env "DB_POOL=10" -y
|
|
327
|
+
|
|
328
|
+
# Replace all environment variables with a new set using --clear-env
|
|
329
|
+
mcps manage postgres --clear-env --env "POSTGRES_URL=postgresql://localhost:5432/db" -y
|
|
330
|
+
|
|
331
|
+
# Clear all CLI arguments from a stdio server
|
|
332
|
+
mcps manage postgres --clear-args -y
|
|
333
|
+
|
|
334
|
+
# Switch an existing stdio server to a remote SSE server
|
|
335
|
+
mcps manage github --url https://api.github.com/mcp/sse -t sse --header "Authorization: Bearer ghp_token" -y
|
|
336
|
+
|
|
337
|
+
# Switch an existing remote server to a local command
|
|
338
|
+
mcps manage github --command "npx -y @modelcontextprotocol/server-github" -y
|
|
339
|
+
|
|
340
|
+
# Update server configuration on specific target agents only
|
|
341
|
+
mcps manage postgres --args --timeout 60 -a cursor vscode -y
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
242
346
|
### `mcps remove [name]` (alias: `mcps rm`)
|
|
243
347
|
|
|
244
348
|
Removes an MCP server from agent configuration files.
|
|
@@ -258,6 +362,15 @@ mcps rm [name] [options]
|
|
|
258
362
|
- `-a, --agent <agents...>`: Filter removal to specific agents. Pass `'*'` to target all agents.
|
|
259
363
|
- `-y, --yes`: Skip confirmation prompts.
|
|
260
364
|
|
|
365
|
+
#### Co-Affected Agent Reporting
|
|
366
|
+
|
|
367
|
+
When removing a server from a configuration file shared by multiple agents, `mcps` performs a single file mutation and reports all co-affected agents:
|
|
368
|
+
|
|
369
|
+
```text
|
|
370
|
+
claude-code removed postgres .mcp.json
|
|
371
|
+
Note: Also affects co-hosted agent(s): github-copilot-cli, qoder
|
|
372
|
+
```
|
|
373
|
+
|
|
261
374
|
#### Examples
|
|
262
375
|
|
|
263
376
|
```bash
|
|
@@ -335,6 +448,17 @@ When a source string is provided to `mcps add`, `mcps` parses and normalizes it
|
|
|
335
448
|
| **VS Code** | `vscode` | `github-copilot` | Project, Global | stdio, http, sse | `jsonc` | `.vscode/mcp.json` / User `mcp.json` |
|
|
336
449
|
| **Zed** | `zed` | - | Project, Global | stdio, http, sse | `jsonc` | `.zed/settings.json` / `~/.config/zed/settings.json` |
|
|
337
450
|
|
|
451
|
+
### Co-Hosted Agent Configurations
|
|
452
|
+
|
|
453
|
+
Several agents share identical configuration files and root keys. `mcps` automatically groups these agents into configuration clusters to deduplicate disk mutations and keep states synchronized:
|
|
454
|
+
|
|
455
|
+
| Configuration Path | Key | Co-Hosted Agents | Scope |
|
|
456
|
+
| :--- | :--- | :--- | :--- |
|
|
457
|
+
| `.mcp.json` | `mcpServers` | `claude-code`, `github-copilot-cli`, `qoder` | Project |
|
|
458
|
+
| `.cline/mcp.json` | `mcpServers` | `cline`, `cline-cli` | Project |
|
|
459
|
+
| `.agents/mcp_config.json` | `mcpServers` | `antigravity`, `antigravity-cli` | Project |
|
|
460
|
+
| `~/.gemini/config/mcp_config.json` | `mcpServers` | `antigravity`, `antigravity-cli` | Global |
|
|
461
|
+
|
|
338
462
|
### Environment Variable Overrides
|
|
339
463
|
|
|
340
464
|
For headless environments, Docker containers, and non-standard filesystem layouts, `mcps` respects environment variables for agent directories:
|
|
@@ -393,11 +517,12 @@ Agent configurations diverge significantly in syntax and structure. `mcps` maps
|
|
|
393
517
|
|
|
394
518
|
`mcps` exports a strongly-typed API for ESM and CommonJS.
|
|
395
519
|
|
|
396
|
-
###
|
|
520
|
+
### Server Lifecycle: Install, Update, List & Remove
|
|
397
521
|
|
|
398
522
|
```typescript
|
|
399
523
|
import {
|
|
400
524
|
installMcpServer,
|
|
525
|
+
updateMcpServer,
|
|
401
526
|
listInstalledMcpServers,
|
|
402
527
|
removeMcpServer,
|
|
403
528
|
parseMcpSource,
|
|
@@ -417,6 +542,32 @@ const installResult = installMcpServer({
|
|
|
417
542
|
|
|
418
543
|
console.log(`Configured ${installResult.serverName}:`);
|
|
419
544
|
for (const record of installResult.results) {
|
|
545
|
+
if (record.success) {
|
|
546
|
+
const coHosted = record.coConfiguredAgents
|
|
547
|
+
? ` (co-configured: ${record.coConfiguredAgents.join(", ")})`
|
|
548
|
+
: "";
|
|
549
|
+
console.log(` ${record.agent}: OK -> ${record.path}${coHosted}`);
|
|
550
|
+
} else {
|
|
551
|
+
console.error(` ${record.agent}: Error -> ${record.error}`);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// 2. Update an MCP server (with automatic protocol sanitization and capability filtering)
|
|
556
|
+
const updateResult = updateMcpServer({
|
|
557
|
+
serverName: "postgres",
|
|
558
|
+
config: {
|
|
559
|
+
command: "npx",
|
|
560
|
+
args: ["-y", "@modelcontextprotocol/server-postgres", "--max-connections", "20"],
|
|
561
|
+
env: {
|
|
562
|
+
POSTGRES_CONNECTION_STRING: "postgresql://localhost:5432/production",
|
|
563
|
+
},
|
|
564
|
+
},
|
|
565
|
+
agents: ["cursor", "vscode"],
|
|
566
|
+
global: false,
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
console.log(`Updated ${updateResult.serverName}:`);
|
|
570
|
+
for (const record of updateResult.results) {
|
|
420
571
|
if (record.success) {
|
|
421
572
|
console.log(` ${record.agent}: OK -> ${record.path}`);
|
|
422
573
|
} else {
|
|
@@ -424,7 +575,7 @@ for (const record of installResult.results) {
|
|
|
424
575
|
}
|
|
425
576
|
}
|
|
426
577
|
|
|
427
|
-
//
|
|
578
|
+
// 3. List installed MCP servers
|
|
428
579
|
const servers = listInstalledMcpServers({
|
|
429
580
|
global: false,
|
|
430
581
|
agents: ["cursor", "vscode"],
|
|
@@ -434,12 +585,19 @@ for (const s of servers) {
|
|
|
434
585
|
console.log(`${s.serverName} on ${s.agent} (${s.path})`);
|
|
435
586
|
}
|
|
436
587
|
|
|
437
|
-
//
|
|
588
|
+
// 4. Remove an MCP server
|
|
438
589
|
const removeResults = removeMcpServer({
|
|
439
590
|
name: "postgres",
|
|
440
591
|
agents: ["cursor", "vscode"],
|
|
441
592
|
global: false,
|
|
442
593
|
});
|
|
594
|
+
|
|
595
|
+
for (const record of removeResults) {
|
|
596
|
+
const coAffected = record.coAffectedAgents
|
|
597
|
+
? ` (also affects: ${record.coAffectedAgents.join(", ")})`
|
|
598
|
+
: "";
|
|
599
|
+
console.log(`Removed from ${record.agent} at ${record.path}${coAffected}`);
|
|
600
|
+
}
|
|
443
601
|
```
|
|
444
602
|
|
|
445
603
|
### Parsing Sources & Resolving Agents
|
|
@@ -486,9 +644,69 @@ const server = memoryStore.readServer("cursor", "test-server");
|
|
|
486
644
|
console.log(server);
|
|
487
645
|
```
|
|
488
646
|
|
|
489
|
-
###
|
|
647
|
+
### Config Clusters & Co-Hosted Agent Resolution
|
|
648
|
+
|
|
649
|
+
Query and resolve agents sharing underlying physical configuration files:
|
|
650
|
+
|
|
651
|
+
```typescript
|
|
652
|
+
import {
|
|
653
|
+
resolveConfigClusters,
|
|
654
|
+
getCoHostedAgents,
|
|
655
|
+
getCandidateAgentsForScope,
|
|
656
|
+
sortAgentsByClusters,
|
|
657
|
+
installToCompatibleAgents,
|
|
658
|
+
} from "@wuyax/mcps";
|
|
659
|
+
|
|
660
|
+
// 1. Find agents sharing configuration with Claude Code in project scope
|
|
661
|
+
const coHosted = getCoHostedAgents("claude-code", { global: false });
|
|
662
|
+
// ['github-copilot-cli', 'qoder']
|
|
663
|
+
|
|
664
|
+
// 2. Resolve deduplicated clusters for a batch of agents
|
|
665
|
+
const clusters = resolveConfigClusters(
|
|
666
|
+
["claude-code", "github-copilot-cli", "cursor", "cline"],
|
|
667
|
+
{ global: false },
|
|
668
|
+
);
|
|
669
|
+
for (const cluster of clusters) {
|
|
670
|
+
console.log(`Target: ${cluster.configPath} [${cluster.configKey}]`);
|
|
671
|
+
console.log(` Target agents: ${cluster.targetAgents.join(", ")}`);
|
|
672
|
+
console.log(` Unselected co-hosted: ${cluster.coHostedAgents.join(", ")}`);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// 3. Sort agents so cluster peers appear adjacent in lists
|
|
676
|
+
const sorted = sortAgentsByClusters(["github-copilot-cli", "cursor", "claude-code"]);
|
|
677
|
+
// ['github-copilot-cli', 'claude-code', 'cursor']
|
|
678
|
+
|
|
679
|
+
// 4. Batch-install to compatible agents with cluster deduplication
|
|
680
|
+
const results = installToCompatibleAgents("my-server", serverConfig, {
|
|
681
|
+
allAgents: ["claude-code", "cursor", "claude-desktop"],
|
|
682
|
+
incompatible: [
|
|
683
|
+
{ agent: "claude-desktop", reason: "Claude Desktop currently supports only stdio MCP servers." },
|
|
684
|
+
],
|
|
685
|
+
global: false,
|
|
686
|
+
});
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
### Exported Utilities & Interactive Prompts
|
|
490
690
|
|
|
491
|
-
|
|
691
|
+
`mcps` provides two dedicated export surfaces:
|
|
692
|
+
1. **Headless Programmatic SDK (`@wuyax/mcps`)**: Clean, dependency-light API for servers, clusters, protocols, and security masking.
|
|
693
|
+
2. **Interactive UI Wizards & Prompts (`@wuyax/mcps/interactive`)**: Terminal UI wizards and Inquirer prompts for custom CLI integrations.
|
|
694
|
+
|
|
695
|
+
#### Headless Utilities (`@wuyax/mcps`)
|
|
696
|
+
|
|
697
|
+
```typescript
|
|
698
|
+
import {
|
|
699
|
+
parseServerConfig,
|
|
700
|
+
buildMcpServerConfig,
|
|
701
|
+
applyServerConfigDelta,
|
|
702
|
+
detectUpdateTransition,
|
|
703
|
+
sanitizeUpdatedServerConfig,
|
|
704
|
+
maskSecretValue,
|
|
705
|
+
maskSecretHeader,
|
|
706
|
+
} from "@wuyax/mcps";
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
#### Interactive Terminal UI & Wizards (`@wuyax/mcps/interactive`)
|
|
492
710
|
|
|
493
711
|
```typescript
|
|
494
712
|
import {
|
|
@@ -496,13 +714,16 @@ import {
|
|
|
496
714
|
wizardAdd,
|
|
497
715
|
wizardManage,
|
|
498
716
|
wizardRemove,
|
|
717
|
+
linkedCheckbox,
|
|
718
|
+
buildLinkedAgentChoices,
|
|
719
|
+
promptSwitchServerType,
|
|
499
720
|
promptScopeAndAgents,
|
|
500
721
|
promptEnvConfig,
|
|
501
722
|
promptHeadersConfig,
|
|
502
723
|
promptArgsConfig,
|
|
503
724
|
parseEnvText,
|
|
504
725
|
parseHeadersText,
|
|
505
|
-
} from "@wuyax/mcps";
|
|
726
|
+
} from "@wuyax/mcps/interactive";
|
|
506
727
|
```
|
|
507
728
|
|
|
508
729
|
---
|
|
@@ -512,7 +733,10 @@ import {
|
|
|
512
733
|
`mcps` is organized around decoupled deep modules:
|
|
513
734
|
|
|
514
735
|
- **CLI Commands (`src/cli/`)**: Built with `commander`. Provides non-interactive execution with full flags and TTY wizard fallbacks.
|
|
515
|
-
- **Interactive Wizards (`src/interactive/`)**: Terminal UI built with `@inquirer/prompts`. Handles scope selection, credential masking, multiline terminal and `$EDITOR` input, and cross-agent synchronization.
|
|
736
|
+
- **Interactive Wizards (`src/interactive/`)**: Terminal UI built with `@inquirer/prompts`. Handles scope selection, credential masking, multiline terminal and `$EDITOR` input, in-place configuration editing, and cross-agent synchronization.
|
|
737
|
+
- **Linked Checkbox Prompt (`src/interactive/prompts/linked-checkbox.ts`)**: Extensible interactive checkbox prompt supporting linked peer selection and custom descriptive metadata.
|
|
738
|
+
- **Core Orchestration (`src/install-mcp-server.ts`, `src/update-mcp-server.ts`, `src/installer.ts`, `src/remove.ts`, `src/list.ts`)**: Pure functions orchestrating agent detection, protocol sanitization, config transformation, and persistence.
|
|
739
|
+
- **Config Clusters & Co-Hosted Deduplication (`src/resolve-config-clusters.ts`)**: Identifies agents sharing identical configuration files and keys, deduplicating physical disk operations and synchronizing interactive selection states.
|
|
516
740
|
- **Target Agent Resolver (`src/resolve-target-agents.ts`)**: Resolves target agents from CLI arguments, wildcards, auto-detection, and transport capability constraints.
|
|
517
741
|
- **Agent Config Store (`src/config-store.ts`)**: Unified persistence engine behind a pluggable storage seam (`ConfigStoreAdapter`), handling path resolution, existence checks, and file serialization.
|
|
518
742
|
- **Format Adapters (`src/formats/`)**: Isolated adapters for `json`, comment-preserving `jsonc` (via `jsonc-parser`), `yaml`, and `toml`.
|