@sassoftware/sas-score-mcp-serverjs 0.3.1-0 → 0.3.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.
- package/package.json +1 -1
- package/src/handleRequest.js +4 -0
- package/src/hapiMcpServer.js +21 -7
package/package.json
CHANGED
package/src/handleRequest.js
CHANGED
|
@@ -35,6 +35,10 @@ async function handleRequest(mcpServer, cache, req, h, credentials) {
|
|
|
35
35
|
console.error("[Note] Creating new app context for session ID:", sessionId);
|
|
36
36
|
let appEnvTemplate = cache.get("appEnvTemplate");
|
|
37
37
|
_appContext = Object.assign({}, appEnvTemplate, headerCache);
|
|
38
|
+
if (headerCache.AUTHFLOW === 'bearer') {
|
|
39
|
+
_appContext.contexts.AUTHFLOW = 'bearer';
|
|
40
|
+
_appContext.contexts.bearerToken = headerCache.bearerToken;
|
|
41
|
+
}
|
|
38
42
|
_appContext.contexts.oauthInfo = credentials;
|
|
39
43
|
cache.set(sessionId, _appContext);
|
|
40
44
|
}
|
package/src/hapiMcpServer.js
CHANGED
|
@@ -6,20 +6,21 @@ import appServer from "@sassoftware/viya-serverjs";
|
|
|
6
6
|
import handleRequest from "./handleRequest.js";
|
|
7
7
|
import handleGetDelete from "./handleGetDelete.js";
|
|
8
8
|
import urlOpen from "./urlOpen.js";
|
|
9
|
+
import fs from "fs";
|
|
9
10
|
|
|
10
11
|
async function hapiMcpServer(mcpServer, cache, baseAppEnvContext) {
|
|
11
12
|
|
|
12
13
|
console.error('Starting Hapi MCP server...');
|
|
13
14
|
console.error("[Note]: Hapi MCP server started...", baseAppEnvContext.AUTHFLOW);
|
|
14
|
-
process.env.REDIRECT
|
|
15
|
-
process.env.APPHOST='0.0.0.0';
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
process.env.REDIRECT = `/status`;
|
|
16
|
+
process.env.APPHOST = '0.0.0.0';
|
|
17
|
+
let r = await appServer.asyncCore(mcpHandlers, true, 'app', null);
|
|
18
|
+
console.error('Hapi server running result:', r);
|
|
18
19
|
if (baseAppEnvContext.AUTHFLOW === 'code' && baseAppEnvContext.AUTOLOGON !== 'FALSE') {
|
|
19
20
|
await urlOpen(r);
|
|
20
21
|
}
|
|
21
22
|
return r;
|
|
22
|
-
|
|
23
|
+
|
|
23
24
|
// add MCP handlers to the app server
|
|
24
25
|
|
|
25
26
|
function mcpHandlers() {
|
|
@@ -96,7 +97,7 @@ async function hapiMcpServer(mcpServer, cache, baseAppEnvContext) {
|
|
|
96
97
|
</body>
|
|
97
98
|
</html>
|
|
98
99
|
`;
|
|
99
|
-
|
|
100
|
+
|
|
100
101
|
}
|
|
101
102
|
let routes = [
|
|
102
103
|
{
|
|
@@ -124,6 +125,19 @@ async function hapiMcpServer(mcpServer, cache, baseAppEnvContext) {
|
|
|
124
125
|
tags: ["mcp"],
|
|
125
126
|
}
|
|
126
127
|
},
|
|
128
|
+
{
|
|
129
|
+
method: ["GET"],
|
|
130
|
+
path: "/apiMeta",
|
|
131
|
+
options: {
|
|
132
|
+
handler: async (req, h) => {
|
|
133
|
+
let spec = fs.readFileSync("./openApi.json", "utf8");
|
|
134
|
+
let specJson = JSON.parse(spec);
|
|
135
|
+
return h.response(specJson).code(200).type('application/json');
|
|
136
|
+
},
|
|
137
|
+
auth: false,
|
|
138
|
+
description: "API Metadata"
|
|
139
|
+
}
|
|
140
|
+
},
|
|
127
141
|
{
|
|
128
142
|
method: ["GET"],
|
|
129
143
|
path: `/${baseAppEnvContext.contexts.APPNAME}/status`,
|
|
@@ -131,7 +145,7 @@ async function hapiMcpServer(mcpServer, cache, baseAppEnvContext) {
|
|
|
131
145
|
handler: async (req, h) => {
|
|
132
146
|
let ht = getHtml();
|
|
133
147
|
return h.response(ht).code(200).type('text/html');
|
|
134
|
-
|
|
148
|
+
// return h.abandon;
|
|
135
149
|
},
|
|
136
150
|
auth: false,
|
|
137
151
|
description: "Help",
|