@codeconductorai/harmony-mcp 1.0.6 → 1.0.7
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/package.json +1 -1
- package/src/deviceAuth.js +31 -0
- package/src/index.js +5 -11
package/package.json
CHANGED
package/src/deviceAuth.js
CHANGED
|
@@ -23,6 +23,36 @@ let pendingPollInterval = 5;
|
|
|
23
23
|
let loginInitiatedAt = 0;
|
|
24
24
|
|
|
25
25
|
const MIN_SECONDS_BEFORE_CONFIRM = 10;
|
|
26
|
+
const SESSION_FILE = path.join(os.homedir(), ".harmony-mcp", "session.json");
|
|
27
|
+
|
|
28
|
+
function loadSession() {
|
|
29
|
+
try {
|
|
30
|
+
const data = JSON.parse(fs.readFileSync(SESSION_FILE, "utf8"));
|
|
31
|
+
if (data.accessToken && data.expiresAt > Math.floor(Date.now() / 1000)) {
|
|
32
|
+
userToken = data.accessToken;
|
|
33
|
+
userTokenExpiresAt = data.expiresAt;
|
|
34
|
+
loggedInUser = data.user || null;
|
|
35
|
+
log(`[deviceAuth] Restored session for ${loggedInUser?.username || "unknown"} from ${SESSION_FILE}`);
|
|
36
|
+
}
|
|
37
|
+
} catch {
|
|
38
|
+
// No saved session yet, or it's invalid/expired — fall through to requiring login.
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function saveSession() {
|
|
43
|
+
try {
|
|
44
|
+
fs.mkdirSync(path.dirname(SESSION_FILE), { recursive: true });
|
|
45
|
+
fs.writeFileSync(
|
|
46
|
+
SESSION_FILE,
|
|
47
|
+
JSON.stringify({ accessToken: userToken, expiresAt: userTokenExpiresAt, user: loggedInUser }),
|
|
48
|
+
{ mode: 0o600 }
|
|
49
|
+
);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
log(`[deviceAuth] Failed to persist session: ${err.message}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
loadSession();
|
|
26
56
|
|
|
27
57
|
export function secondsSinceLoginInitiated() {
|
|
28
58
|
if (!loginInitiatedAt) return Infinity;
|
|
@@ -116,6 +146,7 @@ export async function pollDeviceLogin(timeoutSeconds = 300) {
|
|
|
116
146
|
name: claims?.name || claims?.preferred_username || "unknown",
|
|
117
147
|
email: claims?.email || null,
|
|
118
148
|
};
|
|
149
|
+
saveSession();
|
|
119
150
|
|
|
120
151
|
return {
|
|
121
152
|
expiresIn,
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import packageJson from "../package.json" with { type: "json" };
|
|
3
|
-
|
|
4
2
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
5
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
4
|
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
@@ -12,6 +10,9 @@ import crypto from "crypto";
|
|
|
12
10
|
import archiver from "archiver";
|
|
13
11
|
import FormData from "form-data";
|
|
14
12
|
import fetch from "node-fetch";
|
|
13
|
+
import { createRequire } from "module";
|
|
14
|
+
|
|
15
|
+
const packageJson = createRequire(import.meta.url)("../package.json");
|
|
15
16
|
|
|
16
17
|
import { getAccessToken, initiateDeviceLogin, pollDeviceLogin, isLoggedIn, getLoggedInUser, secondsSinceLoginInitiated, minSecondsBeforeConfirm } from "./deviceAuth.js";
|
|
17
18
|
|
|
@@ -183,7 +184,7 @@ async function uploadWorkspace(zipPath, workspaceId, language, buildTool) {
|
|
|
183
184
|
form.append("projectName", projectName);
|
|
184
185
|
|
|
185
186
|
// buildIndex check - setting it to false so that scip-ns is used.
|
|
186
|
-
form.append("buildIndex", "
|
|
187
|
+
form.append("buildIndex", "false");
|
|
187
188
|
|
|
188
189
|
// Indexing params
|
|
189
190
|
form.append("language", language);
|
|
@@ -282,7 +283,7 @@ async function sendFileUpdate(filePath, workspaceId, language, buildTool) {
|
|
|
282
283
|
form.append("workspaceAlias", getWorkspaceAlias(projectName));
|
|
283
284
|
|
|
284
285
|
// buildIndex check - setting it to false so that scip-ns is used.
|
|
285
|
-
form.append("buildIndex", "
|
|
286
|
+
form.append("buildIndex", "false");
|
|
286
287
|
|
|
287
288
|
// Indexing params
|
|
288
289
|
form.append("language", language);
|
|
@@ -643,13 +644,6 @@ function buildMcpServer() {
|
|
|
643
644
|
workspacePath: process.cwd(),
|
|
644
645
|
projectName: getProjectName(),
|
|
645
646
|
},
|
|
646
|
-
|
|
647
|
-
//tokenBudgetingEnabled: args.tokenBudgetingEnabled ?? true,
|
|
648
|
-
tokenBudgetingEnabled: false,
|
|
649
|
-
|
|
650
|
-
//maxTokenBudget: args.maxTokenBudget ?? 4000,
|
|
651
|
-
maxTokenBudget: 200000,
|
|
652
|
-
activeLandmarkLineCount: args.activeLandmarkLineCount ?? 15,
|
|
653
647
|
};
|
|
654
648
|
|
|
655
649
|
log("[bundle] Request body:", JSON.stringify(requestBody, null, 2));
|