@egain/egain-mcp-server 1.0.13 → 1.0.16
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/bin/mcp-server.js +80 -100
- package/bin/mcp-server.js.map +6 -6
- package/esm/src/hooks/auth-hook.d.ts +0 -4
- package/esm/src/hooks/auth-hook.d.ts.map +1 -1
- package/esm/src/hooks/auth-hook.js +109 -117
- package/esm/src/hooks/auth-hook.js.map +1 -1
- package/esm/src/lib/config.d.ts +2 -2
- package/esm/src/lib/config.js +2 -2
- package/esm/src/mcp-server/mcp-server.js +1 -1
- package/esm/src/mcp-server/server.js +1 -1
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/src/hooks/auth-hook.ts +108 -122
- package/src/hooks/auth-pages/browser-error.html +282 -0
- package/src/hooks/auth-pages/config-page.html +490 -0
- package/src/hooks/auth-pages/config-page.js +4 -26
- package/src/hooks/img/accesstoken-tooltip.png +0 -0
- package/src/hooks/img/apidomain-tooltip.png +0 -0
- package/src/hooks/img/authurl-tooltip.png +0 -0
- package/src/hooks/img/clientid-tooltip.png +0 -0
- package/src/hooks/img/clientsecret-tooltip.png +0 -0
- package/src/hooks/img/env-tooltip.png +0 -0
- package/src/hooks/img/redirect-tooltip.png +0 -0
- package/src/hooks/img/scopeprefix-tooltip.png +0 -0
- package/src/lib/config.ts +2 -2
- package/src/mcp-server/mcp-server.ts +1 -1
- package/src/mcp-server/server.ts +1 -1
package/bin/mcp-server.js
CHANGED
|
@@ -4046,9 +4046,9 @@ var init_config = __esm(() => {
|
|
|
4046
4046
|
SDK_METADATA = {
|
|
4047
4047
|
language: "typescript",
|
|
4048
4048
|
openapiDocVersion: "1.0.0",
|
|
4049
|
-
sdkVersion: "1.0.
|
|
4049
|
+
sdkVersion: "1.0.16",
|
|
4050
4050
|
genVersion: "2.723.8",
|
|
4051
|
-
userAgent: "speakeasy-sdk/mcp-typescript 1.0.
|
|
4051
|
+
userAgent: "speakeasy-sdk/mcp-typescript 1.0.16 2.723.8 1.0.0 @egain/egain-mcp-server"
|
|
4052
4052
|
};
|
|
4053
4053
|
});
|
|
4054
4054
|
|
|
@@ -40865,9 +40865,6 @@ class AuthenticationHook {
|
|
|
40865
40865
|
case "CLIENT_ID":
|
|
40866
40866
|
config.clientId = cleanValue;
|
|
40867
40867
|
break;
|
|
40868
|
-
case "CLIENT_SECRET":
|
|
40869
|
-
config.clientSecret = cleanValue;
|
|
40870
|
-
break;
|
|
40871
40868
|
case "REDIRECT_URL":
|
|
40872
40869
|
config.redirectUri = cleanValue;
|
|
40873
40870
|
break;
|
|
@@ -40886,9 +40883,6 @@ class AuthenticationHook {
|
|
|
40886
40883
|
case "EGAIN_CLIENT_ID":
|
|
40887
40884
|
config.clientId = cleanValue;
|
|
40888
40885
|
break;
|
|
40889
|
-
case "EGAIN_CLIENT_SECRET":
|
|
40890
|
-
config.clientSecret = cleanValue;
|
|
40891
|
-
break;
|
|
40892
40886
|
case "EGAIN_REDIRECT_URI":
|
|
40893
40887
|
config.redirectUri = cleanValue;
|
|
40894
40888
|
break;
|
|
@@ -40909,16 +40903,6 @@ class AuthenticationHook {
|
|
|
40909
40903
|
}
|
|
40910
40904
|
return {};
|
|
40911
40905
|
}
|
|
40912
|
-
getSafariWarningPage() {
|
|
40913
|
-
try {
|
|
40914
|
-
const projectRoot = getProjectRoot();
|
|
40915
|
-
const htmlPath = path.join(projectRoot, "src", "hooks", "auth-pages", "safari-warning.html");
|
|
40916
|
-
return fs.readFileSync(htmlPath, "utf8");
|
|
40917
|
-
} catch (error) {
|
|
40918
|
-
console.error("⚠️ Could not load Safari warning page:", error);
|
|
40919
|
-
return "<html><body><h1>Safari Not Supported</h1><p>Safari does not support private browsing mode via command line.</p></body></html>";
|
|
40920
|
-
}
|
|
40921
|
-
}
|
|
40922
40906
|
getConfigPage() {
|
|
40923
40907
|
try {
|
|
40924
40908
|
const projectRoot = getProjectRoot();
|
|
@@ -40982,19 +40966,15 @@ class AuthenticationHook {
|
|
|
40982
40966
|
existingParams.set("scope", scope);
|
|
40983
40967
|
existingParams.set("forceLogin", "yes");
|
|
40984
40968
|
existingParams.set("prompt", "login");
|
|
40985
|
-
|
|
40986
|
-
|
|
40987
|
-
|
|
40988
|
-
console.error("\uD83D\uDD10 Using PKCE flow (public client)");
|
|
40989
|
-
} else {
|
|
40990
|
-
console.error("\uD83D\uDD10 Using SSO/confidential client flow (no PKCE)");
|
|
40991
|
-
}
|
|
40969
|
+
existingParams.set("code_challenge", this.codeChallenge);
|
|
40970
|
+
existingParams.set("code_challenge_method", "S256");
|
|
40971
|
+
console.error("\uD83D\uDD10 Using PKCE flow (public client)");
|
|
40992
40972
|
const fullUrl = `${baseUrl}?${existingParams.toString()}`;
|
|
40993
40973
|
return fullUrl;
|
|
40994
40974
|
}
|
|
40995
40975
|
async getUserAccessToken(code) {
|
|
40996
|
-
const { clientId,
|
|
40997
|
-
console.error("\uD83D\uDD04 Starting token exchange...");
|
|
40976
|
+
const { clientId, redirectUri, accessUrl } = this.authConfig;
|
|
40977
|
+
console.error("\uD83D\uDD04 Starting token exchange with PKCE...");
|
|
40998
40978
|
if (accessUrl && !accessUrl.toLowerCase().includes("token")) {
|
|
40999
40979
|
console.error('⚠️ WARNING: Access Token URL does not contain "token" - verify this is correct!');
|
|
41000
40980
|
}
|
|
@@ -41004,64 +40984,33 @@ class AuthenticationHook {
|
|
|
41004
40984
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
41005
40985
|
};
|
|
41006
40986
|
try {
|
|
41007
|
-
|
|
41008
|
-
|
|
41009
|
-
|
|
41010
|
-
|
|
41011
|
-
|
|
41012
|
-
|
|
41013
|
-
|
|
41014
|
-
|
|
41015
|
-
|
|
41016
|
-
|
|
41017
|
-
|
|
41018
|
-
|
|
41019
|
-
|
|
41020
|
-
|
|
41021
|
-
|
|
41022
|
-
|
|
41023
|
-
|
|
41024
|
-
|
|
41025
|
-
|
|
41026
|
-
|
|
41027
|
-
return data.access_token;
|
|
41028
|
-
} else {
|
|
41029
|
-
throw new Error("No access_token in confidential client response");
|
|
41030
|
-
}
|
|
40987
|
+
console.error("\uD83D\uDD04 Using PKCE flow (code_verifier)...");
|
|
40988
|
+
const publicClientBody = new URLSearchParams({
|
|
40989
|
+
code,
|
|
40990
|
+
grant_type: "authorization_code",
|
|
40991
|
+
redirect_uri: redirectUri,
|
|
40992
|
+
client_id: clientId,
|
|
40993
|
+
code_verifier: this.codeVerifier
|
|
40994
|
+
});
|
|
40995
|
+
const publicResponse = await fetch(accessUrl, {
|
|
40996
|
+
method: "POST",
|
|
40997
|
+
headers,
|
|
40998
|
+
body: publicClientBody
|
|
40999
|
+
});
|
|
41000
|
+
console.error("\uD83D\uDCE8 Token response received:", publicResponse.status, publicResponse.statusText);
|
|
41001
|
+
if (publicResponse.ok) {
|
|
41002
|
+
const data = await publicResponse.json();
|
|
41003
|
+
if (data.access_token) {
|
|
41004
|
+
console.error("✅ Token received");
|
|
41005
|
+
await this.saveTokenWithExpiration(data.access_token, data.expires_in);
|
|
41006
|
+
return data.access_token;
|
|
41031
41007
|
} else {
|
|
41032
|
-
|
|
41033
|
-
console.error("❌ Confidential client failed:", confidentialResponse.status);
|
|
41034
|
-
throw new Error(`Token request failed: ${confidentialResponse.status} - ${errorText}`);
|
|
41008
|
+
throw new Error("No access_token in response");
|
|
41035
41009
|
}
|
|
41036
41010
|
} else {
|
|
41037
|
-
|
|
41038
|
-
|
|
41039
|
-
|
|
41040
|
-
grant_type: "authorization_code",
|
|
41041
|
-
redirect_uri: redirectUri,
|
|
41042
|
-
client_id: clientId,
|
|
41043
|
-
code_verifier: this.codeVerifier
|
|
41044
|
-
});
|
|
41045
|
-
const publicResponse = await fetch(accessUrl, {
|
|
41046
|
-
method: "POST",
|
|
41047
|
-
headers,
|
|
41048
|
-
body: publicClientBody
|
|
41049
|
-
});
|
|
41050
|
-
console.error("\uD83D\uDCE8 Token response received (public client):", publicResponse.status, publicResponse.statusText);
|
|
41051
|
-
if (publicResponse.ok) {
|
|
41052
|
-
const data = await publicResponse.json();
|
|
41053
|
-
if (data.access_token) {
|
|
41054
|
-
console.error("✅ Token received (public client)");
|
|
41055
|
-
await this.saveTokenWithExpiration(data.access_token, data.expires_in);
|
|
41056
|
-
return data.access_token;
|
|
41057
|
-
} else {
|
|
41058
|
-
throw new Error("No access_token in public client response");
|
|
41059
|
-
}
|
|
41060
|
-
} else {
|
|
41061
|
-
const errorText = await publicResponse.text();
|
|
41062
|
-
console.error("❌ Public client failed:", publicResponse.status);
|
|
41063
|
-
throw new Error(`Token request failed (public client): ${publicResponse.status} - ${errorText}`);
|
|
41064
|
-
}
|
|
41011
|
+
const errorText = await publicResponse.text();
|
|
41012
|
+
console.error("❌ Token exchange failed:", publicResponse.status);
|
|
41013
|
+
throw new Error(`Token request failed: ${publicResponse.status} - ${errorText}`);
|
|
41065
41014
|
}
|
|
41066
41015
|
} catch (error) {
|
|
41067
41016
|
console.error("\uD83D\uDCA5 Token exchange error:", error);
|
|
@@ -41229,11 +41178,6 @@ class AuthenticationHook {
|
|
|
41229
41178
|
res.end(this.getConfigPage());
|
|
41230
41179
|
return;
|
|
41231
41180
|
}
|
|
41232
|
-
if (url.pathname === "/safari-warning") {
|
|
41233
|
-
res.writeHead(200, { "Content-Type": "text/html" });
|
|
41234
|
-
res.end(this.getSafariWarningPage());
|
|
41235
|
-
return;
|
|
41236
|
-
}
|
|
41237
41181
|
if (url.pathname === "/browser-error") {
|
|
41238
41182
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
41239
41183
|
res.end(this.getBrowserErrorPage());
|
|
@@ -41255,7 +41199,6 @@ class AuthenticationHook {
|
|
|
41255
41199
|
accessTokenUrl: this.authConfig.accessUrl,
|
|
41256
41200
|
clientId: this.authConfig.clientId,
|
|
41257
41201
|
redirectUrl: this.authConfig.redirectUri,
|
|
41258
|
-
clientSecret: this.authConfig.clientSecret,
|
|
41259
41202
|
scopePrefix: this.authConfig.scopePrefix
|
|
41260
41203
|
}
|
|
41261
41204
|
}));
|
|
@@ -41346,7 +41289,6 @@ class AuthenticationHook {
|
|
|
41346
41289
|
accessUrl: config.accessTokenUrl,
|
|
41347
41290
|
clientId: config.clientId,
|
|
41348
41291
|
redirectUri: config.redirectUrl,
|
|
41349
|
-
clientSecret: config.clientSecret || undefined,
|
|
41350
41292
|
scopePrefix: config.scopePrefix || undefined
|
|
41351
41293
|
};
|
|
41352
41294
|
try {
|
|
@@ -41436,9 +41378,16 @@ class AuthenticationHook {
|
|
|
41436
41378
|
console.error("\uD83C\uDF89 Authentication complete! Stopping config server...");
|
|
41437
41379
|
this.stopConfigServer();
|
|
41438
41380
|
} catch (authError) {
|
|
41439
|
-
const
|
|
41440
|
-
|
|
41441
|
-
|
|
41381
|
+
const errorMessage = authError.message || String(authError);
|
|
41382
|
+
const isScopeError = errorMessage.includes("invalid_scope") || errorMessage.toLowerCase().includes("scope");
|
|
41383
|
+
const isRetryableError = errorMessage.includes("access_denied") || errorMessage.includes("invalid_grant") || errorMessage.toLowerCase().includes("password") || errorMessage.toLowerCase().includes("username") || errorMessage.toLowerCase().includes("credential");
|
|
41384
|
+
if (isScopeError) {
|
|
41385
|
+
console.error("❌ OAuth scope error:", errorMessage);
|
|
41386
|
+
console.error("\uD83D\uDCA1 This is a configuration error. Please check your scope settings.");
|
|
41387
|
+
console.error("\uD83D\uDED1 Stopping server - please fix the configuration and try again.");
|
|
41388
|
+
this.stopConfigServer();
|
|
41389
|
+
} else if (isRetryableError) {
|
|
41390
|
+
console.error("❌ OAuth authentication error:", errorMessage);
|
|
41442
41391
|
console.error("\uD83D\uDCA1 The configuration server will remain running. Please try again with correct credentials.");
|
|
41443
41392
|
} else {
|
|
41444
41393
|
console.error("❌ Token exchange error:", authError);
|
|
@@ -41674,11 +41623,27 @@ class AuthenticationHook {
|
|
|
41674
41623
|
const errorDescMatch = currentUrl.match(/error_description=([^&]+)/);
|
|
41675
41624
|
const error = errorMatch && errorMatch[1] ? decodeURIComponent(errorMatch[1]) : "unknown_error";
|
|
41676
41625
|
const errorDesc = errorDescMatch && errorDescMatch[1] ? decodeURIComponent(errorDescMatch[1]) : "No description";
|
|
41626
|
+
const isScopeError = error === "invalid_scope" || errorDesc.toLowerCase().includes("scope");
|
|
41627
|
+
const isRetryableError = error === "access_denied" || error === "invalid_grant" || errorDesc.toLowerCase().includes("password") || errorDesc.toLowerCase().includes("username") || errorDesc.toLowerCase().includes("credential");
|
|
41677
41628
|
if (!oAuthErrorLogged) {
|
|
41678
41629
|
console.error("❌ OAuth authentication error:", `${error} - ${errorDesc}`);
|
|
41679
|
-
|
|
41680
|
-
|
|
41681
|
-
|
|
41630
|
+
if (isScopeError) {
|
|
41631
|
+
console.error("\uD83D\uDCA1 This is a configuration error. Please check your scope settings and close this window.");
|
|
41632
|
+
console.error("\uD83D\uDED1 Stopping monitoring - please fix the configuration and try again.");
|
|
41633
|
+
oAuthErrorLogged = true;
|
|
41634
|
+
this.stopConfigServer();
|
|
41635
|
+
return;
|
|
41636
|
+
} else if (isRetryableError) {
|
|
41637
|
+
console.error("\uD83D\uDCA1 The configuration server will remain running. Please try again with correct credentials.");
|
|
41638
|
+
console.error("\uD83D\uDD0D Continuing to monitor browser for authorization code...");
|
|
41639
|
+
oAuthErrorLogged = true;
|
|
41640
|
+
} else {
|
|
41641
|
+
console.error("\uD83D\uDCA1 Please check the error message displayed in your browser and close the window.");
|
|
41642
|
+
console.error("\uD83D\uDED1 Stopping monitoring.");
|
|
41643
|
+
oAuthErrorLogged = true;
|
|
41644
|
+
this.stopConfigServer();
|
|
41645
|
+
return;
|
|
41646
|
+
}
|
|
41682
41647
|
}
|
|
41683
41648
|
}
|
|
41684
41649
|
} else {
|
|
@@ -41712,9 +41677,9 @@ class AuthenticationHook {
|
|
|
41712
41677
|
await this.detectDefaultBrowser();
|
|
41713
41678
|
}
|
|
41714
41679
|
console.error(`\uD83C\uDF10 Browser: ${this.detectedBrowser}`);
|
|
41715
|
-
const configUrl = this.detectedBrowser === "Safari" ? `http://${CONFIG_SERVER_HOST}:${CONFIG_SERVER_PORT}/
|
|
41680
|
+
const configUrl = this.detectedBrowser === "Safari" ? `http://${CONFIG_SERVER_HOST}:${CONFIG_SERVER_PORT}/browser-error?type=notsupported&browser=${encodeURIComponent(this.detectedBrowser)}` : `http://${CONFIG_SERVER_HOST}:${CONFIG_SERVER_PORT}/config`;
|
|
41716
41681
|
if (this.detectedBrowser === "Safari") {
|
|
41717
|
-
console.error("⚠️ Safari detected -
|
|
41682
|
+
console.error("⚠️ Safari detected - Safari is not supported for authentication");
|
|
41718
41683
|
} else {
|
|
41719
41684
|
console.error("\uD83D\uDCCB Opening browser for configuration...");
|
|
41720
41685
|
}
|
|
@@ -41775,6 +41740,21 @@ class AuthenticationHook {
|
|
|
41775
41740
|
await execAsync(`open -a "Firefox" "${configUrl}"`);
|
|
41776
41741
|
}
|
|
41777
41742
|
}
|
|
41743
|
+
} else if (this.detectedBrowser === "Opera") {
|
|
41744
|
+
console.error(` Opening Opera in private mode...`);
|
|
41745
|
+
try {
|
|
41746
|
+
const args = incognitoFlag ? `--args ${incognitoFlag} "${configUrl}"` : `"${configUrl}"`;
|
|
41747
|
+
await execAsync(`open -n -a "Opera" ${args}`);
|
|
41748
|
+
} catch (error) {
|
|
41749
|
+
console.error(` First attempt failed, trying with existing instance...`);
|
|
41750
|
+
try {
|
|
41751
|
+
const args = incognitoFlag ? `--args ${incognitoFlag} "${configUrl}"` : `"${configUrl}"`;
|
|
41752
|
+
await execAsync(`open -a "Opera" ${args}`);
|
|
41753
|
+
} catch (fallbackError) {
|
|
41754
|
+
console.error(` ⚠️ Could not open Opera in private mode automatically`);
|
|
41755
|
+
await execAsync(`open -a "Opera" "${configUrl}"`);
|
|
41756
|
+
}
|
|
41757
|
+
}
|
|
41778
41758
|
} else {
|
|
41779
41759
|
const args = incognitoFlag ? `--args ${incognitoFlag} --app="${configUrl}" --window-size=${windowWidth},${windowHeight} --window-position=100,100` : `"${configUrl}"`;
|
|
41780
41760
|
const command = `open -n -a "${this.detectedBrowser}" ${args}`;
|
|
@@ -46810,7 +46790,7 @@ The Search API is a hybrid search service that combines semantic understanding w
|
|
|
46810
46790
|
function createMCPServer(deps) {
|
|
46811
46791
|
const server = new McpServer({
|
|
46812
46792
|
name: "EgainMcp",
|
|
46813
|
-
version: "1.0.
|
|
46793
|
+
version: "1.0.16"
|
|
46814
46794
|
});
|
|
46815
46795
|
const getClient = deps.getSDK || (() => new EgainMcpCore({
|
|
46816
46796
|
security: deps.security,
|
|
@@ -48057,7 +48037,7 @@ var routes = ln({
|
|
|
48057
48037
|
var app = _e(routes, {
|
|
48058
48038
|
name: "mcp",
|
|
48059
48039
|
versionInfo: {
|
|
48060
|
-
currentVersion: "1.0.
|
|
48040
|
+
currentVersion: "1.0.16"
|
|
48061
48041
|
}
|
|
48062
48042
|
});
|
|
48063
48043
|
Yt(app, process3.argv.slice(2), buildContext(process3));
|
|
@@ -48065,5 +48045,5 @@ export {
|
|
|
48065
48045
|
app
|
|
48066
48046
|
};
|
|
48067
48047
|
|
|
48068
|
-
//# debugId=
|
|
48048
|
+
//# debugId=EBFE61A4F0D0DC0664756E2164756E21
|
|
48069
48049
|
//# sourceMappingURL=mcp-server.js.map
|