@muggleai/works 4.7.0 → 4.8.1

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.
@@ -754,8 +754,53 @@ async function extractTarGz(tarPath, destDir) {
754
754
  });
755
755
  }
756
756
 
757
+ /**
758
+ * Upsert the muggle MCP server entry into ~/.cursor/mcp.json.
759
+ * Reads the existing config, merges in the muggle server, and writes back.
760
+ * Preserves any other MCP servers the user has configured.
761
+ */
762
+ function upsertCursorMcpConfig() {
763
+ const cursorMcpConfigPath = join(homedir(), ".cursor", "mcp.json");
764
+ const cursorDir = join(homedir(), ".cursor");
765
+
766
+ /** @type {{ mcpServers?: Record<string, unknown> }} */
767
+ let config = {};
768
+
769
+ if (existsSync(cursorMcpConfigPath)) {
770
+ try {
771
+ const raw = readFileSync(cursorMcpConfigPath, "utf-8");
772
+ const parsed = JSON.parse(raw);
773
+
774
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
775
+ log(`Warning: ~/.cursor/mcp.json has unexpected shape, skipping MCP config upsert.`);
776
+ return;
777
+ }
778
+
779
+ config = parsed;
780
+ } catch (error) {
781
+ log(`Warning: ~/.cursor/mcp.json is invalid JSON, skipping MCP config upsert.`);
782
+ log(` Parse error: ${error.message}`);
783
+ return;
784
+ }
785
+ }
786
+
787
+ if (!config.mcpServers) {
788
+ config.mcpServers = {};
789
+ }
790
+
791
+ config.mcpServers.muggle = {
792
+ command: "muggle",
793
+ args: ["serve"],
794
+ };
795
+
796
+ mkdirSync(cursorDir, { recursive: true });
797
+ writeFileSync(cursorMcpConfigPath, `${JSON.stringify(config, null, 2)}\n`, "utf-8");
798
+ log(`Cursor MCP config updated at ${cursorMcpConfigPath}`);
799
+ }
800
+
757
801
  // Run postinstall
758
802
  initLogFile();
759
803
  removeVersionOverrideFile();
760
804
  syncCursorSkills();
805
+ upsertCursorMcpConfig();
761
806
  downloadElectronApp().catch(logError);