ctx7 0.4.1 → 0.4.2

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.js CHANGED
@@ -2603,6 +2603,15 @@ var AUTH_MODE_LABELS = {
2603
2603
  "api-key": "API Key"
2604
2604
  };
2605
2605
  var MCP_BASE_URL = "https://mcp.context7.com";
2606
+ function claudeConfigDir() {
2607
+ return process.env.CLAUDE_CONFIG_DIR || join8(homedir5(), ".claude");
2608
+ }
2609
+ function claudeGlobalMcpPath() {
2610
+ if (process.env.CLAUDE_CONFIG_DIR) {
2611
+ return join8(claudeConfigDir(), ".claude.json");
2612
+ }
2613
+ return join8(homedir5(), ".claude.json");
2614
+ }
2606
2615
  function mcpUrl(auth) {
2607
2616
  return auth.mode === "oauth" ? `${MCP_BASE_URL}/mcp/oauth` : `${MCP_BASE_URL}/mcp`;
2608
2617
  }
@@ -2618,22 +2627,26 @@ var agents = {
2618
2627
  displayName: "Claude Code",
2619
2628
  mcp: {
2620
2629
  projectPaths: [".mcp.json"],
2621
- globalPaths: [join8(homedir5(), ".claude.json")],
2630
+ get globalPaths() {
2631
+ return [claudeGlobalMcpPath()];
2632
+ },
2622
2633
  configKey: "mcpServers",
2623
2634
  buildEntry: (auth) => withHeaders({ type: "http", url: mcpUrl(auth) }, auth)
2624
2635
  },
2625
2636
  rule: {
2626
2637
  kind: "file",
2627
- dir: (scope) => scope === "global" ? join8(homedir5(), ".claude", "rules") : join8(".claude", "rules"),
2638
+ dir: (scope) => scope === "global" ? join8(claudeConfigDir(), "rules") : join8(".claude", "rules"),
2628
2639
  filename: "context7.md"
2629
2640
  },
2630
2641
  skill: {
2631
2642
  name: "context7-mcp",
2632
- dir: (scope) => scope === "global" ? join8(homedir5(), ".claude", "skills") : join8(".claude", "skills")
2643
+ dir: (scope) => scope === "global" ? join8(claudeConfigDir(), "skills") : join8(".claude", "skills")
2633
2644
  },
2634
2645
  detect: {
2635
2646
  projectPaths: [".mcp.json", ".claude"],
2636
- globalPaths: [join8(homedir5(), ".claude")]
2647
+ get globalPaths() {
2648
+ return [claudeConfigDir()];
2649
+ }
2637
2650
  }
2638
2651
  },
2639
2652
  cursor: {
@@ -3488,7 +3501,15 @@ async function hasMcpConfig(agentName, scope) {
3488
3501
  if (mcpPath.endsWith(".toml")) {
3489
3502
  return readTomlServerExists(mcpPath, "context7");
3490
3503
  }
3491
- const existing = await readJsonConfig(mcpPath);
3504
+ let existing;
3505
+ try {
3506
+ existing = await readJsonConfig(mcpPath);
3507
+ } catch (err) {
3508
+ log.warn(
3509
+ `Skipped ${mcpPath}: could not parse (${err instanceof Error ? err.message : String(err)})`
3510
+ );
3511
+ return false;
3512
+ }
3492
3513
  const section = existing[agent.mcp.configKey];
3493
3514
  return !!section && typeof section === "object" && !Array.isArray(section) && "context7" in section;
3494
3515
  }