@wuyax/mcps 0.1.0-beta.1 → 0.1.0-beta.3

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/dist/index.d.cts CHANGED
@@ -1,3 +1,7 @@
1
+ import { Separator, Theme } from '@inquirer/core';
2
+ import { Context } from '@inquirer/type';
3
+ import { Command } from 'commander';
4
+
1
5
  type McpAgentType = "amp" | "antigravity" | "antigravity-cli" | "augment" | "cline" | "cline-cli" | "claude-code" | "claude-desktop" | "codex" | "cursor" | "gemini-cli" | "grok" | "goose" | "github-copilot-cli" | "kimi-code-cli" | "kiro" | "opencode" | "pi" | "qoder" | "qwen-code" | "trae" | "vscode" | "zed";
2
6
  type McpConfigFormat = "json" | "jsonc" | "yaml" | "toml";
3
7
  type McpTransportType = "http" | "sse" | "stdio";
@@ -70,6 +74,7 @@ interface McpInstallResultForAgent {
70
74
  agent: McpAgentType;
71
75
  success: boolean;
72
76
  path: string;
77
+ coConfiguredAgents?: McpAgentType[];
73
78
  error?: string;
74
79
  }
75
80
  interface InstallMcpServerResult {
@@ -92,8 +97,30 @@ interface RemoveMcpServerResult {
92
97
  agent: McpAgentType;
93
98
  path: string;
94
99
  removed: boolean;
100
+ coAffectedAgents?: McpAgentType[];
95
101
  error?: string;
96
102
  }
103
+ interface ConfigCluster {
104
+ configPath: string;
105
+ configKey: string;
106
+ targetAgents: McpAgentType[];
107
+ coHostedAgents: McpAgentType[];
108
+ }
109
+ interface UpdateMcpServerOptions extends McpScopeOptions {
110
+ serverName: string;
111
+ config: McpServerConfig;
112
+ previousConfig?: McpServerConfig;
113
+ agents?: McpAgentType[];
114
+ }
115
+ interface UpdateMcpServerResult {
116
+ serverName: string;
117
+ config: McpServerConfig;
118
+ results: McpInstallResultForAgent[];
119
+ incompatible: {
120
+ agent: McpAgentType;
121
+ reason: string;
122
+ }[];
123
+ }
97
124
 
98
125
  declare const mcpAgents: Record<McpAgentType, McpAgentConfig>;
99
126
  declare const mcpAgentAliases: Record<string, McpAgentType>;
@@ -243,6 +270,35 @@ declare const resolveTargetAgents: (query?: TargetResolutionQuery) => TargetReso
243
270
  type InstallMcpServerForAgentOptions = McpScopeOptions;
244
271
  declare const installMcpServerForAgent: (serverName: string, serverConfig: McpServerConfig, agentType: McpAgentType, options?: InstallMcpServerForAgentOptions) => McpInstallResultForAgent;
245
272
  declare const installMcpServerForAgents: (serverName: string, serverConfig: McpServerConfig, agentTypes: McpAgentType[], options?: InstallMcpServerForAgentOptions) => McpInstallResultForAgent[];
273
+ interface InstallToCompatibleAgentsOptions extends McpScopeOptions {
274
+ allAgents: McpAgentType[];
275
+ incompatible?: Array<{
276
+ agent: McpAgentType;
277
+ reason: string;
278
+ }>;
279
+ }
280
+ declare const installToCompatibleAgents: (serverName: string, serverConfig: McpServerConfig, options: InstallToCompatibleAgentsOptions) => McpInstallResultForAgent[];
281
+
282
+ /**
283
+ * Returns candidate agent types relevant for the given scope.
284
+ */
285
+ declare const getCandidateAgentsForScope: (options?: McpScopeOptions) => McpAgentType[];
286
+ /**
287
+ * Returns all other agents sharing the exact same physical configuration target
288
+ * (same configPath and configKey) for the given scope.
289
+ */
290
+ declare const getCoHostedAgents: (agentType: McpAgentType, options?: McpScopeOptions) => McpAgentType[];
291
+ /**
292
+ * Resolves configuration clusters for a given list of requested agents.
293
+ * Groups requested agents sharing the same physical config path, and tracks
294
+ * any remaining co-hosted agents sharing the same target that were not in the request.
295
+ */
296
+ declare const resolveConfigClusters: (agentTypes: McpAgentType[], options?: McpScopeOptions) => ConfigCluster[];
297
+ /**
298
+ * Sorts agent types so that agents sharing the same physical config target
299
+ * appear adjacent to each other in the returned array.
300
+ */
301
+ declare const sortAgentsWithClusters: (agentTypes: McpAgentType[], options?: McpScopeOptions) => McpAgentType[];
246
302
 
247
303
  interface ListInstalledMcpServersOptions extends McpScopeOptions {
248
304
  agents?: McpAgentType[];
@@ -259,6 +315,33 @@ declare const removeMcpServerFromAgent: (serverName: string, agentType: McpAgent
259
315
  }) => RemoveMcpServerResult;
260
316
  declare const removeMcpServer: (options: RemoveMcpServerOptions) => RemoveMcpServerResult[];
261
317
 
318
+ /**
319
+ * Transforms a server configuration into a clean remote configuration,
320
+ * stripping stdio-exclusive fields (command, args, env).
321
+ */
322
+ declare const toRemoteServerConfig: (config: McpServerConfig, defaultTransport?: McpRemoteTransport) => McpServerConfig;
323
+ /**
324
+ * Transforms a server configuration into a clean stdio configuration,
325
+ * stripping remote-exclusive fields (url, type, headers).
326
+ */
327
+ declare const toStdioServerConfig: (config: McpServerConfig) => McpServerConfig;
328
+ type UpdateTransitionType = "switch-to-remote" | "switch-to-stdio" | "merge-remote" | "merge-stdio";
329
+ /**
330
+ * Determines the transition category when updating an MCP server configuration.
331
+ */
332
+ declare const detectUpdateTransition: (incoming: McpServerConfig, previous?: McpServerConfig) => UpdateTransitionType;
333
+ /**
334
+ * Strips obsolete fields when switching between stdio and remote protocols.
335
+ * When switching to remote (url is provided), stdio fields (command, args, env) are removed.
336
+ * When switching to stdio (command is provided), remote fields (url, type, headers) are removed.
337
+ */
338
+ declare const sanitizeUpdatedServerConfig: (incoming: McpServerConfig, previous?: McpServerConfig) => McpServerConfig;
339
+ /**
340
+ * Core Orchestration: Updates an existing MCP server across specified or installed coding agents,
341
+ * sanitizing protocol dirty fields and validating transport capabilities.
342
+ */
343
+ declare const updateMcpServer: (options: UpdateMcpServerOptions) => UpdateMcpServerResult;
344
+
262
345
  declare const mainMenu: () => Promise<void>;
263
346
 
264
347
  interface WizardAddOptions extends McpScopeOptions {
@@ -272,7 +355,57 @@ interface WizardAddOptions extends McpScopeOptions {
272
355
  }
273
356
  declare const wizardAdd: (initial?: WizardAddOptions) => Promise<boolean>;
274
357
 
275
- type WizardManageOptions = McpScopeOptions;
358
+ interface DisplayServerDetailsOptions extends McpScopeOptions {
359
+ serverName: string;
360
+ config: McpServerConfig;
361
+ agents?: McpAgentType[];
362
+ hasDivergence?: boolean;
363
+ titlePrefix?: string;
364
+ }
365
+ /**
366
+ * Reusable display function for server details with secret masking.
367
+ */
368
+ declare const displayServerDetails: ({ serverName, config, agents, hasDivergence, global: isGlobal, titlePrefix, }: DisplayServerDetailsOptions) => void;
369
+
370
+ /**
371
+ * Validates and resolves remote transport string into McpRemoteTransport.
372
+ */
373
+ declare const resolveTransport: (input: string | undefined) => McpRemoteTransport | undefined;
374
+
375
+ declare const SECRET_KEY_PATTERN: RegExp;
376
+ /**
377
+ * Masks sensitive values for secure CLI display.
378
+ */
379
+ declare const maskSecretValue: (key: string, value: string) => string;
380
+ declare const SECRET_HEADER_PATTERN: RegExp;
381
+ /**
382
+ * Masks sensitive HTTP header values for secure CLI display.
383
+ */
384
+ declare const maskSecretHeader: (key: string, value: string) => string;
385
+
386
+ interface GroupedInstalledServer {
387
+ serverName: string;
388
+ agents: McpAgentType[];
389
+ paths: string[];
390
+ config: McpServerConfig;
391
+ hasDivergence?: boolean;
392
+ }
393
+ declare const normalizeServerConfig: (raw: unknown) => McpServerConfig;
394
+ /**
395
+ * Groups a flat array of ListedMcpServer entries by serverName.
396
+ */
397
+ declare const groupInstalledServersByName: (installed: ListedMcpServer[]) => Map<string, GroupedInstalledServer>;
398
+
399
+ interface WizardManageOptions extends McpScopeOptions {
400
+ serverName?: string;
401
+ }
402
+ interface EditServerConfigOptions extends McpScopeOptions {
403
+ targetGroup: GroupedInstalledServer;
404
+ }
405
+ /**
406
+ * Interactive prompt flow to switch an MCP server between stdio and remote protocols.
407
+ */
408
+ declare const promptSwitchServerType: (currentConfig: McpServerConfig, serverName: string) => Promise<McpServerConfig>;
276
409
  declare const wizardManage: (options?: WizardManageOptions) => Promise<void>;
277
410
 
278
411
  interface WizardRemoveOptions extends McpScopeOptions {
@@ -281,6 +414,35 @@ interface WizardRemoveOptions extends McpScopeOptions {
281
414
  }
282
415
  declare const wizardRemove: (options?: WizardRemoveOptions) => Promise<boolean>;
283
416
 
417
+ interface PromptEditKeyValueOptions {
418
+ title: string;
419
+ itemNoun: string;
420
+ itemsNoun: string;
421
+ maskValue: (key: string, value: string) => string;
422
+ isSecretKey: (key: string) => boolean;
423
+ formatText: (items: Record<string, string>) => string;
424
+ parseText: (text: string) => Record<string, string>;
425
+ editorPostfix?: string;
426
+ editorMessage: string;
427
+ pasteMessage: string;
428
+ keyPromptMessage: string;
429
+ valuePromptMessage: string;
430
+ separator: "=" | ":";
431
+ }
432
+ /**
433
+ * Generic reusable interactive key-value editing loop supporting:
434
+ * - Editor launch with pre-filled content ($EDITOR)
435
+ * - Single item upsert (with secret detection & password masking)
436
+ * - Single item deletion
437
+ * - Multiline paste (with merge or replace choices)
438
+ * - Clear all items
439
+ */
440
+ declare const promptEditKeyValueConfig: (currentItems: Record<string, string> | undefined, options: PromptEditKeyValueOptions) => Promise<Record<string, string>>;
441
+
442
+ /**
443
+ * Formats a key-value env record into .env formatted multiline string.
444
+ */
445
+ declare const formatEnvText: (env: Record<string, string>) => string;
284
446
  /**
285
447
  * Parses multiline .env formatted text into a key-value record.
286
448
  * Supports:
@@ -298,7 +460,16 @@ declare const parseEnvText: (rawText: string) => Record<string, string>;
298
460
  * 3. Add key-value one by one (with secret mask detection)
299
461
  */
300
462
  declare const promptEnvConfig: (initialEnv?: Record<string, string>) => Promise<Record<string, string>>;
463
+ /**
464
+ * Dedicated prompt loop for inspecting, modifying, adding, and removing
465
+ * environment variables of an existing MCP server configuration.
466
+ */
467
+ declare const promptEditEnvConfig: (currentEnv?: Record<string, string>) => Promise<Record<string, string>>;
301
468
 
469
+ /**
470
+ * Formats a key-value headers record into multiline Key: Value text.
471
+ */
472
+ declare const formatHeadersText: (headers: Record<string, string>) => string;
302
473
  /**
303
474
  * Parses multiline HTTP headers text (Key: Value or Key=Value) into a Record<string, string>.
304
475
  */
@@ -307,6 +478,11 @@ declare const parseHeadersText: (rawText: string) => Record<string, string>;
307
478
  * Interactively prompts user for HTTP headers.
308
479
  */
309
480
  declare const promptHeadersConfig: (initialHeaders?: Record<string, string>) => Promise<Record<string, string>>;
481
+ /**
482
+ * Dedicated prompt loop for inspecting, modifying, adding, and removing
483
+ * HTTP headers of an existing MCP server configuration.
484
+ */
485
+ declare const promptEditHeadersConfig: (currentHeaders?: Record<string, string>) => Promise<Record<string, string>>;
310
486
 
311
487
  /**
312
488
  * Parses a command-line argument string into an array of arguments,
@@ -317,6 +493,15 @@ declare const parseArgsString: (rawText: string) => string[];
317
493
  * Prompts the user for additional command-line arguments.
318
494
  */
319
495
  declare const promptArgsConfig: (initialArgs?: string[]) => Promise<string[]>;
496
+ /**
497
+ * Formats an array of argument strings into a space-separated CLI string,
498
+ * quoting arguments containing spaces or quotes.
499
+ */
500
+ declare const formatArgsString: (args: string[]) => string;
501
+ /**
502
+ * Dedicated prompt for editing command arguments with current arguments pre-filled.
503
+ */
504
+ declare const promptEditArgs: (currentArgs?: string[]) => Promise<string[]>;
320
505
 
321
506
  interface PromptScopeAndAgentsOptions extends McpScopeOptions {
322
507
  defaultGlobal?: boolean;
@@ -342,17 +527,71 @@ interface PromptScopeOptions extends McpScopeOptions {
342
527
  */
343
528
  declare const promptScope: (options?: PromptScopeOptions) => Promise<boolean>;
344
529
 
345
- interface GroupedInstalledServer {
346
- serverName: string;
530
+ interface LinkedChoice<Value> {
531
+ value: Value;
532
+ name?: string;
533
+ checkedName?: string;
534
+ description?: string;
535
+ short?: string;
536
+ disabled?: boolean | string;
537
+ checked?: boolean;
538
+ linkedValues?: Value[];
539
+ }
540
+ interface NormalizedLinkedChoice<Value> {
541
+ value: Value;
542
+ name: string;
543
+ checkedName: string;
544
+ description?: string;
545
+ short: string;
546
+ disabled: boolean | string;
547
+ checked: boolean;
548
+ linkedValues: Value[];
549
+ }
550
+ interface LinkedCheckboxTheme {
551
+ icon: {
552
+ checked: string;
553
+ unchecked: string;
554
+ cursor: string;
555
+ disabledChecked: string;
556
+ disabledUnchecked: string;
557
+ };
558
+ style: {
559
+ disabled: (text: string) => string;
560
+ renderSelectedChoices: <T>(selectedChoices: ReadonlyArray<NormalizedLinkedChoice<T>>, allChoices: ReadonlyArray<NormalizedLinkedChoice<T> | Separator>) => string;
561
+ description: (text: string) => string;
562
+ keysHelpTip: (keys: [key: string, action: string][]) => string;
563
+ highlight: (text: string) => string;
564
+ };
565
+ i18n: {
566
+ disabledError: string;
567
+ };
568
+ }
569
+ interface LinkedCheckboxConfig<Value = string> {
570
+ message: string;
571
+ prefix?: string;
572
+ pageSize?: number;
573
+ choices: ReadonlyArray<Separator | Value | LinkedChoice<Value>>;
574
+ loop?: boolean;
575
+ required?: boolean;
576
+ validate?: (choices: readonly NormalizedLinkedChoice<Value>[]) => boolean | string | Promise<string | boolean>;
577
+ theme?: Partial<Theme<LinkedCheckboxTheme>>;
578
+ }
579
+ type LinkedCheckboxPrompt = <Value>(config: LinkedCheckboxConfig<Value>, context?: Context) => Promise<Value[]>;
580
+ declare const linkedCheckbox: LinkedCheckboxPrompt;
581
+
582
+ declare const mcpManageCommand: Command;
583
+
584
+ interface BuildLinkedAgentChoicesOptions {
347
585
  agents: McpAgentType[];
348
- paths: string[];
349
- config: McpServerConfig;
586
+ checkedAgents: McpAgentType[];
587
+ detectedAgents?: McpAgentType[];
588
+ scopeOptions?: McpScopeOptions;
350
589
  }
351
- declare const normalizeServerConfig: (raw: unknown) => McpServerConfig;
352
590
  /**
353
- * Groups a flat array of ListedMcpServer entries by serverName.
591
+ * Builds normalized LinkedChoice items for an interactive agent list,
592
+ * calculating co-hosted agents and attaching link indicators.
354
593
  */
355
- declare const groupInstalledServersByName: (installed: ListedMcpServer[]) => Map<string, GroupedInstalledServer>;
594
+ declare const buildLinkedAgentChoices: (options: BuildLinkedAgentChoicesOptions) => LinkedChoice<McpAgentType>[];
356
595
 
357
596
  /**
358
597
  * Deep module: Transforms standard McpServerConfig into an Agent-specific configuration shape
@@ -375,4 +614,4 @@ declare const transformServerConfigForAgent: (agent: McpAgentConfig, serverName:
375
614
  global: boolean;
376
615
  }) => unknown;
377
616
 
378
- export { AgentConfigStore, type AgentConfigStoreListResult, type AgentConfigStoreRemoveResult, type AgentConfigStoreWriteResult, type ConfigStoreAdapter, type ConfigTargetDescriptor, DEFAULT_REMOTE_TRANSPORT, type GroupedInstalledServer, type IncompatibleAgent, type InstallMcpServerOptions, type InstallMcpServerResult, type ListedMcpServer, type McpAgentConfig, type McpAgentType, type McpConfigFormat, type McpInstallResultForAgent, type McpRemoteServerConfig, type McpRemoteTransport, type McpScopeOptions, type McpServerConfig, type McpSourceType, type McpStdioServerConfig, type McpTransportType, NPX_COMMAND, NPX_DASH_Y, type ParsedMcpSource, type RemoveMcpServerOptions, type RemoveMcpServerResult, type ServerConfigDialect, type ServerConfigDialectName, type ServerConfigDialectOptions, type TargetResolutionQuery, type TargetResolutionResult, installMcpServer as add, agentConfigStore, buildMcpServerConfig, createAgentTransform, detectGloballyInstalledMcpAgents, detectProjectInstalledMcpAgents, extractPackageName, getMcpAgentConfig, getMcpAgentTypes, getMcpAgentsSupportingProjectScope, groupInstalledServersByName, installMcpServer as install, installMcpServer, installMcpServerForAgent, installMcpServerForAgents, isMcpAgentType, isMcpTransportSupported, isRemoteMcpSource, isRemoteServerConfig, isStdioServerConfig, listInstalledMcpServers as list, listInstalledMcpServers, listServersInConfigFile, mainMenu, mcpAgentAliases, mcpAgents, normalizeServerConfig, parseArgsString, parseEnvText, parseHeadersText, parseMcpSource, parseServerConfig, parseMcpSource as parseSource, promptArgsConfig, promptEnvConfig, promptHeadersConfig, promptScope, promptScopeAndAgents, readConfigFile, removeMcpServer as remove, removeMcpServer, removeMcpServerFromAgent, removeServerFromConfigFile, resolveMcpAgentAlias, resolveMcpConfigTarget, resolveTargetAgents, transformServerConfig, transformServerConfigForAgent, wizardAdd, wizardManage, wizardRemove, writeServerToConfigFile };
617
+ export { AgentConfigStore, type AgentConfigStoreListResult, type AgentConfigStoreRemoveResult, type AgentConfigStoreWriteResult, type BuildLinkedAgentChoicesOptions, type ConfigCluster, type ConfigStoreAdapter, type ConfigTargetDescriptor, DEFAULT_REMOTE_TRANSPORT, type DisplayServerDetailsOptions, type EditServerConfigOptions, type GroupedInstalledServer, type IncompatibleAgent, type InstallMcpServerOptions, type InstallMcpServerResult, type InstallToCompatibleAgentsOptions, type LinkedCheckboxPrompt, type LinkedChoice, type ListedMcpServer, type McpAgentConfig, type McpAgentType, type McpConfigFormat, type McpInstallResultForAgent, type McpRemoteServerConfig, type McpRemoteTransport, type McpScopeOptions, type McpServerConfig, type McpSourceType, type McpStdioServerConfig, type McpTransportType, NPX_COMMAND, NPX_DASH_Y, type ParsedMcpSource, type PromptEditKeyValueOptions, type RemoveMcpServerOptions, type RemoveMcpServerResult, SECRET_HEADER_PATTERN, SECRET_KEY_PATTERN, type ServerConfigDialect, type ServerConfigDialectName, type ServerConfigDialectOptions, type TargetResolutionQuery, type TargetResolutionResult, type UpdateMcpServerOptions, type UpdateMcpServerResult, type UpdateTransitionType, type WizardManageOptions, installMcpServer as add, agentConfigStore, buildLinkedAgentChoices, buildMcpServerConfig, createAgentTransform, detectGloballyInstalledMcpAgents, detectProjectInstalledMcpAgents, detectUpdateTransition, displayServerDetails, extractPackageName, formatArgsString, formatEnvText, formatHeadersText, getCandidateAgentsForScope, getCoHostedAgents, getMcpAgentConfig, getMcpAgentTypes, getMcpAgentsSupportingProjectScope, groupInstalledServersByName, installMcpServer as install, installMcpServer, installMcpServerForAgent, installMcpServerForAgents, installToCompatibleAgents, isMcpAgentType, isMcpTransportSupported, isRemoteMcpSource, isRemoteServerConfig, isStdioServerConfig, linkedCheckbox, listInstalledMcpServers as list, listInstalledMcpServers, listServersInConfigFile, mainMenu, maskSecretHeader, maskSecretValue, mcpAgentAliases, mcpAgents, mcpManageCommand, normalizeServerConfig, parseArgsString, parseEnvText, parseHeadersText, parseMcpSource, parseServerConfig, parseMcpSource as parseSource, promptArgsConfig, promptEditArgs, promptEditEnvConfig, promptEditHeadersConfig, promptEditKeyValueConfig, promptEnvConfig, promptHeadersConfig, promptScope, promptScopeAndAgents, promptSwitchServerType, readConfigFile, removeMcpServer as remove, removeMcpServer, removeMcpServerFromAgent, removeServerFromConfigFile, resolveConfigClusters, resolveMcpAgentAlias, resolveMcpConfigTarget, resolveTargetAgents, resolveTransport, sanitizeUpdatedServerConfig, sortAgentsWithClusters, toRemoteServerConfig, toStdioServerConfig, transformServerConfig, transformServerConfigForAgent, updateMcpServer as update, updateMcpServer, wizardAdd, wizardManage, wizardRemove, writeServerToConfigFile };