@mkacki98/chestnut-mcp 0.1.6 → 0.1.8
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/oauth.js +13 -11
- package/package.json +1 -1
package/dist/oauth.js
CHANGED
|
@@ -6,7 +6,7 @@ import path from "path";
|
|
|
6
6
|
import os from "os";
|
|
7
7
|
export async function initiateOAuth() {
|
|
8
8
|
const chestnutUrl = getChestnutUrl();
|
|
9
|
-
const authUrl = `${chestnutUrl}/
|
|
9
|
+
const authUrl = `${chestnutUrl}/api/claude-code/authorize`;
|
|
10
10
|
console.log("\nOpening browser for authorization...");
|
|
11
11
|
console.log(`If browser doesn't open, visit: ${authUrl}\n`);
|
|
12
12
|
try {
|
|
@@ -24,19 +24,14 @@ export async function initiateOAuth() {
|
|
|
24
24
|
}
|
|
25
25
|
// Validate token by making a test request
|
|
26
26
|
try {
|
|
27
|
-
const response = await fetch(`${chestnutUrl}/api/claude-code/
|
|
28
|
-
method: "
|
|
27
|
+
const response = await fetch(`${chestnutUrl}/api/claude-code/health`, {
|
|
28
|
+
method: "GET",
|
|
29
29
|
headers: {
|
|
30
30
|
Authorization: `Bearer ${token}`,
|
|
31
|
-
"Content-Type": "application/json",
|
|
32
31
|
},
|
|
33
|
-
body: JSON.stringify({
|
|
34
|
-
query: "_test_connection",
|
|
35
|
-
reason: "Testing MCP connection",
|
|
36
|
-
}),
|
|
37
32
|
});
|
|
38
|
-
if (response.ok
|
|
39
|
-
//
|
|
33
|
+
if (response.ok) {
|
|
34
|
+
// Health endpoint returns 200 for valid token, 401 for invalid
|
|
40
35
|
saveAccessToken(token);
|
|
41
36
|
console.log("✓ Authenticated successfully with Chestnut!");
|
|
42
37
|
console.log(`Token saved to: ${process.env.HOME}/.chestnut-mcp/config.json\n`);
|
|
@@ -44,7 +39,14 @@ export async function initiateOAuth() {
|
|
|
44
39
|
await configureGlobalClaude();
|
|
45
40
|
}
|
|
46
41
|
else {
|
|
47
|
-
console.log(
|
|
42
|
+
console.log(`❌ Invalid token. Server returned status: ${response.status}`);
|
|
43
|
+
try {
|
|
44
|
+
const body = await response.text();
|
|
45
|
+
console.log(`Response: ${body}`);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
console.log("(Could not read response body)");
|
|
49
|
+
}
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
catch (error) {
|