@kwonye/mcpx 0.1.94 → 0.1.95

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.
Files changed (66) hide show
  1. package/dist/adapters/claude-desktop.d.ts.map +1 -1
  2. package/dist/adapters/claude.d.ts +2 -1
  3. package/dist/adapters/claude.d.ts.map +1 -1
  4. package/dist/adapters/cline.d.ts +3 -1
  5. package/dist/adapters/cline.d.ts.map +1 -1
  6. package/dist/adapters/codex.d.ts +2 -1
  7. package/dist/adapters/codex.d.ts.map +1 -1
  8. package/dist/adapters/cursor.d.ts +2 -1
  9. package/dist/adapters/cursor.d.ts.map +1 -1
  10. package/dist/adapters/hermes.d.ts +11 -0
  11. package/dist/adapters/hermes.d.ts.map +1 -0
  12. package/dist/adapters/index.d.ts.map +1 -1
  13. package/dist/adapters/kiro.d.ts.map +1 -1
  14. package/dist/adapters/openclaw.d.ts +11 -0
  15. package/dist/adapters/openclaw.d.ts.map +1 -0
  16. package/dist/adapters/opencode.d.ts +2 -1
  17. package/dist/adapters/opencode.d.ts.map +1 -1
  18. package/dist/adapters/qwen.d.ts.map +1 -1
  19. package/dist/adapters/utils/index.d.ts +7 -1
  20. package/dist/adapters/utils/index.d.ts.map +1 -1
  21. package/dist/adapters/vscode.d.ts +2 -1
  22. package/dist/adapters/vscode.d.ts.map +1 -1
  23. package/dist/{cli-154shqmt.js → cli-28fsxhe3.js} +310 -94
  24. package/dist/{cli-9fmn9y72.js → cli-njtbb11m.js} +104 -28
  25. package/dist/{cli-csfsg1yf.js → cli-v27bt25d.js} +79 -7
  26. package/dist/{cli-n8vt375e.js → cli-wxw1t3rr.js} +714 -210
  27. package/dist/cli.d.ts.map +1 -1
  28. package/dist/cli.js +359 -72
  29. package/dist/compat/hermes.d.ts +7 -0
  30. package/dist/compat/hermes.d.ts.map +1 -0
  31. package/dist/compat/index.d.ts.map +1 -1
  32. package/dist/compat/openclaw.d.ts +7 -0
  33. package/dist/compat/openclaw.d.ts.map +1 -0
  34. package/dist/{config-dtc3c79c.js → config-5p08cb0c.js} +1 -1
  35. package/dist/core/add-command.d.ts.map +1 -1
  36. package/dist/core/config-store.d.ts +30 -0
  37. package/dist/core/config-store.d.ts.map +1 -1
  38. package/dist/core/config.d.ts.map +1 -1
  39. package/dist/core/daemon.d.ts +5 -1
  40. package/dist/core/daemon.d.ts.map +1 -1
  41. package/dist/core/index.d.ts +2 -2
  42. package/dist/core/index.d.ts.map +1 -1
  43. package/dist/core/index.js +15 -66
  44. package/dist/core/managed-index-lock.d.ts +2 -0
  45. package/dist/core/managed-index-lock.d.ts.map +1 -0
  46. package/dist/core/oauth.d.ts.map +1 -1
  47. package/dist/core/plugin-host.d.ts +2 -0
  48. package/dist/core/plugin-host.d.ts.map +1 -0
  49. package/dist/core/plugin-manager.d.ts +19 -6
  50. package/dist/core/plugin-manager.d.ts.map +1 -1
  51. package/dist/core/plugin-parse.d.ts.map +1 -1
  52. package/dist/core/plugin-projections.d.ts.map +1 -1
  53. package/dist/core/skill-projections.d.ts +3 -0
  54. package/dist/core/skill-projections.d.ts.map +1 -0
  55. package/dist/core/status.d.ts.map +1 -1
  56. package/dist/core/sync.d.ts.map +1 -1
  57. package/dist/core/update-manager.d.ts.map +1 -1
  58. package/dist/gateway/server.d.ts.map +1 -1
  59. package/dist/plugin-host-954a7tf7.js +129 -0
  60. package/dist/{plugin-manager-1sjwfnah.js → plugin-manager-m8ar2271.js} +11 -3
  61. package/dist/types.d.ts +3 -1
  62. package/dist/types.d.ts.map +1 -1
  63. package/dist/version.d.ts +1 -1
  64. package/dist/version.d.ts.map +1 -1
  65. package/package.json +3 -2
  66. package/dist/cli-mxmgxdm2.js +0 -2257
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  persistSyncState,
3
3
  syncAllClients
4
- } from "./cli-n8vt375e.js";
4
+ } from "./cli-wxw1t3rr.js";
5
5
  import {
6
6
  loadConfig,
7
7
  saveConfig
8
- } from "./cli-csfsg1yf.js";
8
+ } from "./cli-v27bt25d.js";
9
9
  import {
10
10
  SecretsManager
11
11
  } from "./cli-tk8bggg5.js";
@@ -468,6 +468,10 @@ var HOOKS_JSON_REL = path4.join("hooks", "hooks.json");
468
468
  var SKILLS_DIR = "skills";
469
469
  var COMMANDS_DIR = "commands";
470
470
  var AGENTS_DIR = "agents";
471
+ function sanitizeComponentId(id) {
472
+ const stripped = id.replace(/[\/\\]/g, "_").replace(/^\.+/, "");
473
+ return stripped.length > 0 ? stripped : "unnamed";
474
+ }
471
475
  function readManifest(pluginRoot) {
472
476
  const manifestPath = path4.join(pluginRoot, PLUGIN_JSON_REL);
473
477
  if (!fs4.existsSync(manifestPath)) {
@@ -528,7 +532,7 @@ function discoverSkills(pluginRoot) {
528
532
  const content = fs4.readFileSync(skillPath, "utf8");
529
533
  const { frontmatter } = parseFrontmatter(content);
530
534
  results.push({
531
- id: frontmatter.name ?? path4.basename(entry.name, ".md"),
535
+ id: sanitizeComponentId(frontmatter.name ?? path4.basename(entry.name, ".md")),
532
536
  type: "skills",
533
537
  path: skillPath,
534
538
  description: frontmatter.description
@@ -541,7 +545,7 @@ function discoverSkills(pluginRoot) {
541
545
  const content = fs4.readFileSync(skillMdPath, "utf8");
542
546
  const { frontmatter } = parseFrontmatter(content);
543
547
  results.push({
544
- id: frontmatter.name ?? entry.name,
548
+ id: sanitizeComponentId(frontmatter.name ?? entry.name),
545
549
  type: "skills",
546
550
  path: skillMdPath,
547
551
  description: frontmatter.description
@@ -564,7 +568,7 @@ function discoverCommands(pluginRoot) {
564
568
  const content = fs4.readFileSync(cmdPath, "utf8");
565
569
  const { frontmatter } = parseFrontmatter(content);
566
570
  results.push({
567
- id: frontmatter.name ?? path4.basename(entry.name, ".md"),
571
+ id: sanitizeComponentId(frontmatter.name ?? path4.basename(entry.name, ".md")),
568
572
  type: "commands",
569
573
  path: cmdPath,
570
574
  description: frontmatter.description
@@ -587,7 +591,7 @@ function discoverAgents(pluginRoot) {
587
591
  const content = fs4.readFileSync(agentPath, "utf8");
588
592
  const { frontmatter } = parseFrontmatter(content);
589
593
  results.push({
590
- id: frontmatter.name ?? path4.basename(entry.name, ".md"),
594
+ id: sanitizeComponentId(frontmatter.name ?? path4.basename(entry.name, ".md")),
591
595
  type: "agents",
592
596
  path: agentPath,
593
597
  description: frontmatter.description
@@ -644,6 +648,9 @@ function discoverComponents(pluginRoot) {
644
648
  function hasManifest(pluginRoot) {
645
649
  return fs4.existsSync(path4.join(pluginRoot, PLUGIN_JSON_REL));
646
650
  }
651
+ function resolvePluginVars(value, pluginRoot, dataDir) {
652
+ return value.replace(/\$\{CLAUDE_PLUGIN_ROOT\}/g, pluginRoot).replace(/\$\{DATA\}/g, dataDir).replace(/\$\{CLAUDE_PROJECT_DIR\}/g, pluginRoot);
653
+ }
647
654
 
648
655
  // src/core/plugin-manager.ts
649
656
  class PluginManager {
@@ -734,10 +741,8 @@ class PluginManager {
734
741
  const approved = plugin.approvals?.mcpServers !== false;
735
742
  config.servers[nsName] = {
736
743
  transport: "stdio",
737
- command: mcp.command,
738
- args: mcp.args,
739
- env: mcp.env,
740
- cwd: mcp.cwd || plugin.root,
744
+ command: "npx",
745
+ args: ["-y", "@kwonye/mcpx@latest", "plugin-host", pluginId, mcp.id],
741
746
  enabled: enabled && approved
742
747
  };
743
748
  }
@@ -771,10 +776,8 @@ class PluginManager {
771
776
  const nsName = `${pluginName}__${mcp.id}`;
772
777
  config.servers[nsName] = {
773
778
  transport: "stdio",
774
- command: mcp.command,
775
- args: mcp.args,
776
- env: mcp.env,
777
- cwd: mcp.cwd || current.root,
779
+ command: "npx",
780
+ args: ["-y", "@kwonye/mcpx@latest", "plugin-host", pluginId, mcp.id],
778
781
  enabled: current.enabled && approved
779
782
  };
780
783
  }
@@ -884,30 +887,62 @@ async function installPlugin(source, options) {
884
887
  const manager = new PluginManager;
885
888
  return manager.installPlugin(source, options);
886
889
  }
887
- async function updatePlugin(name) {
890
+ async function updatePlugin(nameOrId) {
888
891
  const manager = new PluginManager;
889
- return manager.updatePlugin(name);
892
+ const config = loadConfig(manager["configPath"]);
893
+ const id = resolvePluginId(config, nameOrId);
894
+ return manager.updatePlugin(id);
890
895
  }
891
- async function uninstallPlugin(name, keepData) {
896
+ async function uninstallPlugin(nameOrId, keepData) {
892
897
  const manager = new PluginManager;
893
- await manager.uninstallPlugin(name, keepData);
898
+ const config = loadConfig(manager["configPath"]);
899
+ const id = resolvePluginId(config, nameOrId);
900
+ await manager.uninstallPlugin(id, keepData);
894
901
  }
895
- async function enablePlugin(name) {
902
+ async function enablePlugin(nameOrId) {
896
903
  const manager = new PluginManager;
897
- await manager.enablePlugin(name);
904
+ const config = loadConfig(manager["configPath"]);
905
+ const id = resolvePluginId(config, nameOrId);
906
+ await manager.enablePlugin(id);
898
907
  }
899
- async function disablePlugin(name) {
908
+ async function disablePlugin(nameOrId) {
900
909
  const manager = new PluginManager;
901
- await manager.disablePlugin(name);
910
+ const config = loadConfig(manager["configPath"]);
911
+ const id = resolvePluginId(config, nameOrId);
912
+ await manager.disablePlugin(id);
902
913
  }
903
- async function approvePluginComponent(name, component) {
914
+ async function setPluginProjectOverride(nameOrId, projectPath, override) {
915
+ const config = loadConfig();
916
+ const id = resolvePluginId(config, nameOrId);
917
+ const plugin = config.plugins?.[id];
918
+ if (!plugin)
919
+ throw new Error(`Plugin ${id} not found`);
920
+ if (!config.projects?.[projectPath]) {
921
+ throw new Error(`Project "${projectPath}" is not registered. Run "mcpx project init" there first.`);
922
+ }
923
+ if (!plugin.projectOverrides)
924
+ plugin.projectOverrides = {};
925
+ plugin.projectOverrides[projectPath] = { ...plugin.projectOverrides[projectPath], ...override };
926
+ saveConfig(config);
927
+ const secrets = new SecretsManager;
928
+ const syncConfig = loadConfig();
929
+ const summary = syncAllClients(syncConfig, secrets);
930
+ persistSyncState(summary, syncConfig);
931
+ saveConfig(syncConfig);
932
+ }
933
+ async function approvePluginComponent(nameOrId, component) {
904
934
  const manager = new PluginManager;
905
- await manager.approveComponent(name, component);
935
+ const config = loadConfig(manager["configPath"]);
936
+ const id = resolvePluginId(config, nameOrId);
937
+ await manager.approveComponent(id, component);
906
938
  }
907
- async function getPluginStatus(name) {
939
+ async function getPluginStatus(nameOrId) {
908
940
  const manager = new PluginManager;
909
- if (name)
910
- return manager.getPluginStatus(name);
941
+ if (nameOrId) {
942
+ const config = loadConfig(manager["configPath"]);
943
+ const id = resolvePluginId(config, nameOrId);
944
+ return manager.getPluginStatus(id);
945
+ }
911
946
  const plugins = await manager.listPlugins();
912
947
  return plugins[0] || null;
913
948
  }
@@ -915,9 +950,50 @@ async function listPlugins() {
915
950
  const manager = new PluginManager;
916
951
  return manager.listPlugins();
917
952
  }
953
+ function resolvePluginId(config, nameOrId) {
954
+ const plugins = config.plugins ?? {};
955
+ if (plugins[nameOrId])
956
+ return nameOrId;
957
+ const matches = Object.keys(plugins).filter((id) => plugins[id].name === nameOrId);
958
+ if (matches.length === 1)
959
+ return matches[0];
960
+ if (matches.length === 0) {
961
+ throw new Error(`Plugin "${nameOrId}" not found. Available: ${Object.values(plugins).map((p) => `${p.name} (${p.id})`).join(", ") || "none"}`);
962
+ }
963
+ throw new Error(`Multiple plugins match "${nameOrId}": ${matches.join(", ")}. Use the full id (<name>@<sha8>).`);
964
+ }
965
+ async function pluginConfigSet(nameOrId, key, value, projectPath) {
966
+ const manager = new PluginManager;
967
+ const config = loadConfig(manager["configPath"]);
968
+ const id = resolvePluginId(config, nameOrId);
969
+ const plugin = config.plugins?.[id];
970
+ if (!plugin)
971
+ throw new Error(`Plugin ${id} not found`);
972
+ if (projectPath) {
973
+ if (!plugin.projectOverrides)
974
+ plugin.projectOverrides = {};
975
+ if (!plugin.projectOverrides[projectPath])
976
+ plugin.projectOverrides[projectPath] = {};
977
+ if (!plugin.projectOverrides[projectPath].config)
978
+ plugin.projectOverrides[projectPath].config = {};
979
+ plugin.projectOverrides[projectPath].config[key] = value;
980
+ } else {
981
+ if (!plugin.config)
982
+ plugin.config = {};
983
+ plugin.config[key] = value;
984
+ }
985
+ saveConfig(config, manager["configPath"]);
986
+ }
987
+ async function pluginSync() {
988
+ const config = loadConfig();
989
+ const secrets = new SecretsManager;
990
+ const summary = syncAllClients(config, secrets);
991
+ persistSyncState(summary, config);
992
+ saveConfig(config);
993
+ }
918
994
  async function preparePlugin(name) {
919
995
  const manager = new PluginManager;
920
996
  await manager.preparePlugin(name);
921
997
  }
922
998
 
923
- export { PluginCache, PluginDataManager, PluginLifecycle, parseSource, readManifest, discoverComponents, hasManifest, PluginManager, inspectPlugin, installPlugin, updatePlugin, uninstallPlugin, enablePlugin, disablePlugin, approvePluginComponent, getPluginStatus, listPlugins, preparePlugin };
999
+ export { PluginCache, PluginDataManager, PluginLifecycle, parseSource, readManifest, discoverComponents, hasManifest, resolvePluginVars, PluginManager, inspectPlugin, installPlugin, updatePlugin, uninstallPlugin, enablePlugin, disablePlugin, setPluginProjectOverride, approvePluginComponent, getPluginStatus, listPlugins, resolvePluginId, pluginConfigSet, pluginSync, preparePlugin };
@@ -94,6 +94,12 @@ function parseCliAddCommand(command) {
94
94
  if (parts[0] === "code" && parts[1] === "--add-mcp") {
95
95
  return parseVSCodeAdd(parts[2]);
96
96
  }
97
+ if (parts[0] === "openclaw" && parts[1] === "mcp" && parts[2] === "add") {
98
+ return parseOpenClawAdd(parts.slice(3));
99
+ }
100
+ if (parts[0] === "hermes" && parts[1] === "mcp" && parts[2] === "add") {
101
+ return parseHermesAdd(parts.slice(3));
102
+ }
97
103
  if (parts[0] === "add") {
98
104
  return parseStandardAdd(parts.slice(1));
99
105
  }
@@ -211,6 +217,48 @@ function parseVSCodeAdd(jsonPayload) {
211
217
  }
212
218
  throw new Error("JSON payload must include 'url' or 'command'");
213
219
  }
220
+ function parseOpenClawAdd(args) {
221
+ const header = [];
222
+ const env = [];
223
+ let cwd;
224
+ const values = [];
225
+ for (let i = 0;i < args.length; i++) {
226
+ const arg = args[i];
227
+ if (arg === "--header") {
228
+ header.push(args[++i]);
229
+ } else if (arg === "--env") {
230
+ env.push(args[++i]);
231
+ } else if (arg === "--cwd" || arg === "--workingDirectory") {
232
+ cwd = args[++i];
233
+ } else if (arg === "--arg") {
234
+ values.push(args[++i]);
235
+ } else if (arg === "--transport" || arg === "--auth" || arg === "--scope") {
236
+ i++;
237
+ } else {
238
+ values.push(arg);
239
+ }
240
+ }
241
+ return buildServerSpec(values, { header, env, cwd });
242
+ }
243
+ function parseHermesAdd(args) {
244
+ const env = [];
245
+ const values = [];
246
+ for (let i = 0;i < args.length; i++) {
247
+ const arg = args[i];
248
+ if (arg === "--env") {
249
+ env.push(args[++i]);
250
+ } else if (arg === "--args") {
251
+ while (i + 1 < args.length && !args[i + 1].startsWith("--")) {
252
+ values.push(args[++i]);
253
+ }
254
+ } else if (arg === "--auth") {
255
+ i++;
256
+ } else {
257
+ values.push(arg);
258
+ }
259
+ }
260
+ return buildServerSpec(values, { header: [], env });
261
+ }
214
262
  function buildServerSpec(values, options) {
215
263
  if (values.length < 2) {
216
264
  throw new Error("Usage: add [--transport auto|http|stdio] <name> <url|command> [args...]");
@@ -482,7 +530,7 @@ function loadConfig(configPath = getConfigPath()) {
482
530
  }
483
531
  const clientEntries = {};
484
532
  for (const [key, value] of Object.entries(parsed.data.clients)) {
485
- if (["claude", "claude-desktop", "codex", "cursor", "cline", "opencode", "kiro", "vscode", "qwen"].includes(key)) {
533
+ if (["claude", "claude-desktop", "codex", "cursor", "cline", "opencode", "kiro", "vscode", "qwen", "openclaw", "hermes"].includes(key)) {
486
534
  clientEntries[key] = value;
487
535
  }
488
536
  }
@@ -574,25 +622,49 @@ function migrateProjectServers(config, projectPath) {
574
622
  }
575
623
  function resolveActiveConfig(options = {}) {
576
624
  const globalPath = getConfigPath();
577
- const config = loadConfig(globalPath);
625
+ const globalConfig = loadConfig(globalPath);
578
626
  if (!options.global) {
579
627
  const projectConfigPath = findProjectConfigPath();
580
- if (options.local || projectConfigPath) {
628
+ if (options.local) {
581
629
  const projectPath = projectConfigPath ? path.dirname(projectConfigPath) : process.cwd();
630
+ const localPath = path.join(projectPath, ".mcpx.json");
631
+ const projectConfig = loadProjectConfig(localPath);
632
+ const mergedConfig = {
633
+ ...globalConfig,
634
+ servers: { ...globalConfig.servers, ...projectConfig.servers }
635
+ };
636
+ return {
637
+ type: "project",
638
+ configPath: localPath,
639
+ projectPath,
640
+ config: mergedConfig,
641
+ save: () => {
642
+ const localServers = {};
643
+ for (const [name, spec] of Object.entries(mergedConfig.servers)) {
644
+ if (!(name in globalConfig.servers)) {
645
+ localServers[name] = spec;
646
+ }
647
+ }
648
+ saveProjectConfig({ ...projectConfig, servers: localServers }, localPath);
649
+ }
650
+ };
651
+ }
652
+ if (projectConfigPath) {
653
+ const projectPath = path.dirname(projectConfigPath);
582
654
  return {
583
655
  type: "project",
584
656
  configPath: globalPath,
585
657
  projectPath,
586
- config,
587
- save: () => saveConfig(config, globalPath)
658
+ config: globalConfig,
659
+ save: () => saveConfig(globalConfig, globalPath)
588
660
  };
589
661
  }
590
662
  }
591
663
  return {
592
664
  type: "global",
593
665
  configPath: globalPath,
594
- config,
595
- save: () => saveConfig(config, globalPath)
666
+ config: globalConfig,
667
+ save: () => saveConfig(globalConfig, globalPath)
596
668
  };
597
669
  }
598
670