@memoraone/mcp 0.1.23 → 0.1.24

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 (2) hide show
  1. package/dist/cli.cjs +53 -12
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -30,7 +30,7 @@ var require_package = __commonJS({
30
30
  "package.json"(exports2, module2) {
31
31
  module2.exports = {
32
32
  name: "@memoraone/mcp",
33
- version: "0.1.23",
33
+ version: "0.1.24",
34
34
  type: "module",
35
35
  main: "dist/index.cjs",
36
36
  bin: {
@@ -685,14 +685,44 @@ async function cliCleanup(argv) {
685
685
  return result.exitCode;
686
686
  }
687
687
 
688
+ // src/configUtils.ts
689
+ var PROD_API_URL = "https://api.memoraone.com";
690
+
688
691
  // src/setupIdeFiles.ts
689
692
  var MANAGED_MARKER = "<!-- MemoraOne managed IDE helper -->";
690
693
  var GITIGNORE_MEMORAONE_COMMENT = "# MemoraOne local project binding / API key";
691
694
  var GITIGNORE_MEMORAONE_ENTRY = "memoraone.m1";
692
- var MEMORAONE_MCP_SERVER = {
693
- command: "npx",
694
- args: ["-y", "@memoraone/mcp"]
695
- };
695
+ var MCP_PACKAGE_ARG = "@memoraone/mcp@latest";
696
+ var VSCODE_MCP_SERVERS_KEY = "servers";
697
+ function isProdBoundEnvironment(environment) {
698
+ if (environment === void 0) return true;
699
+ const lower = environment.toLowerCase();
700
+ return lower === "production" || lower === "prod";
701
+ }
702
+ async function readMemoraoneM1Environment(repoRoot) {
703
+ const m1Path = path4.join(repoRoot, "memoraone.m1");
704
+ try {
705
+ const content = await fs4.readFile(m1Path, "utf8");
706
+ const parsed = JSON.parse(content);
707
+ if (typeof parsed?.environment === "string") {
708
+ const trimmed = parsed.environment.trim();
709
+ if (trimmed !== "") return trimmed;
710
+ }
711
+ } catch {
712
+ }
713
+ return void 0;
714
+ }
715
+ async function buildMemoraoneMcpServerEntry(repoRoot) {
716
+ const entry = {
717
+ command: "npx",
718
+ args: ["-y", MCP_PACKAGE_ARG]
719
+ };
720
+ const environment = await readMemoraoneM1Environment(repoRoot);
721
+ if (isProdBoundEnvironment(environment)) {
722
+ entry.env = { MEMORAONE_API_URL: PROD_API_URL };
723
+ }
724
+ return entry;
725
+ }
696
726
  function assertUnderRepoRoot(repoRoot, absPath) {
697
727
  const normRoot = path4.resolve(repoRoot) + path4.sep;
698
728
  const normPath = path4.resolve(absPath);
@@ -800,11 +830,21 @@ function mcpJsonHeader() {
800
830
  return `// ${MANAGED_MARKER}
801
831
  `;
802
832
  }
803
- function buildMcpJsonBody(existing) {
804
- const base = existing && typeof existing === "object" ? { ...existing } : { mcpServers: {} };
805
- const servers = typeof base.mcpServers === "object" && base.mcpServers !== null && !Array.isArray(base.mcpServers) ? { ...base.mcpServers } : {};
806
- servers.memoraone = { ...MEMORAONE_MCP_SERVER };
807
- const merged = { ...base, mcpServers: servers };
833
+ function extractExistingMcpServers(existing) {
834
+ if (typeof existing.servers === "object" && existing.servers !== null && !Array.isArray(existing.servers)) {
835
+ return { ...existing.servers };
836
+ }
837
+ if (typeof existing.mcpServers === "object" && existing.mcpServers !== null && !Array.isArray(existing.mcpServers)) {
838
+ return { ...existing.mcpServers };
839
+ }
840
+ return {};
841
+ }
842
+ function buildMcpJsonBody(existing, memoraoneServer) {
843
+ const base = existing && typeof existing === "object" ? { ...existing } : { [VSCODE_MCP_SERVERS_KEY]: {} };
844
+ const servers = extractExistingMcpServers(base);
845
+ servers.memoraone = memoraoneServer;
846
+ const { mcpServers: _legacy, ...rest } = base;
847
+ const merged = { ...rest, [VSCODE_MCP_SERVERS_KEY]: servers };
808
848
  return mcpJsonHeader() + JSON.stringify(merged, null, 2) + "\n";
809
849
  }
810
850
  async function writeManagedMarkdown(repoRoot, relPath, fullContent, opts) {
@@ -848,8 +888,9 @@ async function writeMcpJson(repoRoot, opts) {
848
888
  } catch (err) {
849
889
  if (err?.code !== "ENOENT") throw err;
850
890
  }
891
+ const memoraoneServer = await buildMemoraoneMcpServerEntry(repoRoot);
851
892
  if (!existed) {
852
- const body = buildMcpJsonBody(null);
893
+ const body = buildMcpJsonBody(null, memoraoneServer);
853
894
  if (opts.dryRun) return "created";
854
895
  await fs4.mkdir(path4.dirname(abs), { recursive: true });
855
896
  await fs4.writeFile(abs, body, "utf8");
@@ -864,7 +905,7 @@ async function writeMcpJson(repoRoot, opts) {
864
905
  parsed = null;
865
906
  }
866
907
  if (!parsed && !opts.force) return "skipped-untracked";
867
- const next = buildMcpJsonBody(parsed);
908
+ const next = buildMcpJsonBody(parsed, memoraoneServer);
868
909
  if (managed && next === raw) return "skipped";
869
910
  if (opts.dryRun) return "updated";
870
911
  await fs4.mkdir(path4.dirname(abs), { recursive: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memoraone/mcp",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {