@anurag134/nexusmcp 0.0.0-stage → 1.0.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.
Files changed (33) hide show
  1. package/README.md +84 -2
  2. package/dist/index.js +208 -0
  3. package/dist/samples/mock-gitlab.js +88 -0
  4. package/dist/src/common/type.js +1 -0
  5. package/dist/src/common/utils.js +28 -0
  6. package/dist/src/database/db.js +151 -0
  7. package/dist/src/database/type.js +1 -0
  8. package/dist/src/module/checkpoint/controller.js +30 -0
  9. package/dist/src/module/checkpoint/service.js +59 -0
  10. package/dist/src/module/checkpoint/type.js +1 -0
  11. package/dist/src/module/checkpoint/utils.js +41 -0
  12. package/dist/src/module/dashboard/controller.js +39 -0
  13. package/dist/src/module/dashboard/service.js +86 -0
  14. package/dist/src/module/dashboard/type.js +1 -0
  15. package/dist/src/module/dashboard/utils.js +874 -0
  16. package/dist/src/module/mcp/controller.js +35 -0
  17. package/dist/src/module/mcp/service.js +254 -0
  18. package/dist/src/module/mcp/type.js +1 -0
  19. package/dist/src/module/mcp/utils.js +24 -0
  20. package/dist/src/module/router/controller.js +16 -0
  21. package/dist/src/module/router/service.js +56 -0
  22. package/dist/src/module/router/type.js +1 -0
  23. package/dist/src/module/router/utils.js +77 -0
  24. package/dist/src/module/security/controller.js +15 -0
  25. package/dist/src/module/security/service.js +124 -0
  26. package/dist/src/module/security/type.js +6 -0
  27. package/dist/src/module/security/utils.js +210 -0
  28. package/dist/src/module/upstream/controller.js +353 -0
  29. package/dist/src/module/upstream/service.js +344 -0
  30. package/dist/src/module/upstream/type.js +1 -0
  31. package/dist/src/module/upstream/utils.js +135 -0
  32. package/dist/tools/github-publisher/index.js +187 -0
  33. package/package.json +47 -4
@@ -0,0 +1,41 @@
1
+ import { execSync } from "node:child_process";
2
+ export class CheckpointUtils {
3
+ static isGitRepository(cwd) {
4
+ try {
5
+ execSync("git rev-parse --is-inside-work-tree", { cwd, stdio: "ignore" });
6
+ return true;
7
+ }
8
+ catch {
9
+ return false;
10
+ }
11
+ }
12
+ static createStashCommit(cwd) {
13
+ try {
14
+ const output = execSync("git stash create", { cwd, encoding: "utf-8" }).trim();
15
+ if (output.length > 0) {
16
+ return output;
17
+ }
18
+ return execSync("git rev-parse HEAD", { cwd, encoding: "utf-8" }).trim();
19
+ }
20
+ catch {
21
+ return null;
22
+ }
23
+ }
24
+ static restoreCommit(cwd, commitHash) {
25
+ try {
26
+ execSync(`git read-tree --reset -u ${commitHash}`, { cwd, stdio: "ignore" });
27
+ return true;
28
+ }
29
+ catch {
30
+ return false;
31
+ }
32
+ }
33
+ static getGitDiff(cwd) {
34
+ try {
35
+ return execSync("git diff HEAD", { cwd, encoding: "utf-8" }).trim();
36
+ }
37
+ catch {
38
+ return "";
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,39 @@
1
+ import { DashboardUtils } from "./utils.js";
2
+ import { CommonUtils } from "../../common/utils.js";
3
+ export class DashboardController {
4
+ dashboardService;
5
+ constructor(dashboardService) {
6
+ this.dashboardService = dashboardService;
7
+ }
8
+ registerRoutes(server) {
9
+ server.get("/", this.serveDashboardHtml.bind(this));
10
+ server.get("/api/dashboard/stats", this.getStats.bind(this));
11
+ server.post("/api/dashboard/wrap", this.wrapConfig.bind(this));
12
+ server.post("/api/dashboard/unwrap", this.unwrapConfig.bind(this));
13
+ }
14
+ async serveDashboardHtml(_req, reply) {
15
+ reply.type("text/html").send(DashboardUtils.getDashboardHtml());
16
+ }
17
+ async getStats(_req, reply) {
18
+ const stats = this.dashboardService.getStats();
19
+ reply.send(CommonUtils.successResponse(stats));
20
+ }
21
+ async wrapConfig(_req, reply) {
22
+ try {
23
+ const result = this.dashboardService.wrapIdeConfig();
24
+ reply.send(CommonUtils.successResponse(result));
25
+ }
26
+ catch (err) {
27
+ reply.status(400).send(CommonUtils.errorResponse(err instanceof Error ? err.message : String(err)));
28
+ }
29
+ }
30
+ async unwrapConfig(_req, reply) {
31
+ try {
32
+ this.dashboardService.unwrapIdeConfig();
33
+ reply.send(CommonUtils.successResponse({ restored: true }));
34
+ }
35
+ catch (err) {
36
+ reply.status(400).send(CommonUtils.errorResponse(err instanceof Error ? err.message : String(err)));
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,86 @@
1
+ import fs from "node:fs";
2
+ import { DashboardUtils } from "./utils.js";
3
+ import { CommonUtils } from "../../common/utils.js";
4
+ export class DashboardService {
5
+ db;
6
+ router;
7
+ security;
8
+ activePort = Number(process.env.PORT || 3000);
9
+ constructor(db, router, security) {
10
+ this.db = db;
11
+ this.router = router;
12
+ this.security = security;
13
+ }
14
+ setPort(port) {
15
+ this.activePort = port;
16
+ }
17
+ getStats() {
18
+ const servers = this.db.getAllServers();
19
+ const connected = servers.filter(s => s.status === "connected").length;
20
+ const auditStats = this.db.getAuditStats();
21
+ return {
22
+ totalServers: servers.length,
23
+ connectedServers: connected,
24
+ totalTools: this.router.getIndexedCount(),
25
+ totalExecutions: auditStats.total_calls,
26
+ tokensSaved: auditStats.tokens_saved
27
+ };
28
+ }
29
+ wrapIdeConfig() {
30
+ const configPath = DashboardUtils.getCursorMcpConfigPath();
31
+ if (!fs.existsSync(configPath)) {
32
+ throw new Error(`Cursor configuration file not found at ${configPath}`);
33
+ }
34
+ const raw = fs.readFileSync(configPath, "utf-8");
35
+ const parsed = CommonUtils.safeJsonParse(raw, {});
36
+ const existingServers = parsed.mcpServers || {};
37
+ const backupPath = `${configPath}.backup`;
38
+ fs.writeFileSync(backupPath, raw, "utf-8");
39
+ let count = 0;
40
+ for (const [name, cfg] of Object.entries(existingServers)) {
41
+ if (name.toLowerCase() === "nexus" || name.toLowerCase() === "nexusmcp") {
42
+ continue;
43
+ }
44
+ const serverObj = cfg;
45
+ const serverId = CommonUtils.generateId("srv");
46
+ const envMarkers = this.security.persistSecretsAndReturnMarkers(serverId, serverObj.env || {});
47
+ this.db.upsertServer({
48
+ id: serverId,
49
+ name,
50
+ transport: serverObj.url ? "sse" : "stdio",
51
+ command: serverObj.command || null,
52
+ args: JSON.stringify(serverObj.args || []),
53
+ url: serverObj.url || null,
54
+ env: JSON.stringify(envMarkers),
55
+ status: "disconnected",
56
+ error_message: null,
57
+ created_at: Date.now(),
58
+ updated_at: Date.now()
59
+ });
60
+ count++;
61
+ }
62
+ const wrappedConfig = {
63
+ mcpServers: {
64
+ nexus: {
65
+ url: `http://localhost:${this.activePort}/mcp/sse`
66
+ }
67
+ }
68
+ };
69
+ fs.writeFileSync(configPath, JSON.stringify(wrappedConfig, null, 2), "utf-8");
70
+ return {
71
+ ideConfigPath: configPath,
72
+ serversImported: count,
73
+ backupPath
74
+ };
75
+ }
76
+ unwrapIdeConfig() {
77
+ const configPath = DashboardUtils.getCursorMcpConfigPath();
78
+ const backupPath = `${configPath}.backup`;
79
+ if (!fs.existsSync(backupPath)) {
80
+ throw new Error("No backup file found to restore from.");
81
+ }
82
+ const backupContent = fs.readFileSync(backupPath, "utf-8");
83
+ fs.writeFileSync(configPath, backupContent, "utf-8");
84
+ return true;
85
+ }
86
+ }
@@ -0,0 +1 @@
1
+ export {};