@trops/dash-core 0.1.79 → 0.1.81
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/electron/index.js +50 -12
- package/dist/electron/index.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/servers/{servers/google-drive.js → google-drive.js} +32 -27
- package/package.json +2 -2
|
@@ -21,6 +21,10 @@ const { Server } = require("@modelcontextprotocol/sdk/server/index.js");
|
|
|
21
21
|
const {
|
|
22
22
|
StdioServerTransport,
|
|
23
23
|
} = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
24
|
+
const {
|
|
25
|
+
CallToolRequestSchema,
|
|
26
|
+
ListToolsRequestSchema,
|
|
27
|
+
} = require("@modelcontextprotocol/sdk/types.js");
|
|
24
28
|
const fs = require("fs");
|
|
25
29
|
const https = require("https");
|
|
26
30
|
const path = require("path");
|
|
@@ -149,33 +153,12 @@ if (process.argv[2] === "auth") {
|
|
|
149
153
|
const { URL } = require("url");
|
|
150
154
|
const { client_id, client_secret } = getClientCredentials();
|
|
151
155
|
|
|
152
|
-
const keysFile = JSON.parse(fs.readFileSync(oauthKeysPath, "utf8"));
|
|
153
|
-
const keyData = keysFile.installed || keysFile.web;
|
|
154
|
-
const redirectUri =
|
|
155
|
-
keyData.redirect_uris?.[0] || "http://localhost:3000/oauth2callback";
|
|
156
|
-
|
|
157
|
-
// Extract port from redirect URI
|
|
158
|
-
const redirectUrl = new URL(redirectUri);
|
|
159
|
-
const port = parseInt(redirectUrl.port, 10) || 3000;
|
|
160
|
-
|
|
161
156
|
const scopes = ["https://www.googleapis.com/auth/drive.readonly"];
|
|
162
|
-
|
|
163
|
-
const authUrl =
|
|
164
|
-
`https://accounts.google.com/o/oauth2/v2/auth?` +
|
|
165
|
-
`client_id=${encodeURIComponent(client_id)}` +
|
|
166
|
-
`&redirect_uri=${encodeURIComponent(redirectUri)}` +
|
|
167
|
-
`&response_type=code` +
|
|
168
|
-
`&scope=${encodeURIComponent(scopes.join(" "))}` +
|
|
169
|
-
`&access_type=offline` +
|
|
170
|
-
`&prompt=consent`;
|
|
171
|
-
|
|
172
|
-
console.log(
|
|
173
|
-
`\nOpen this URL in your browser to authorize:\n\n${authUrl}\n`,
|
|
174
|
-
);
|
|
157
|
+
let redirectUri;
|
|
175
158
|
|
|
176
159
|
// Start local server to catch the callback
|
|
177
160
|
const server = http.createServer(async (req, res) => {
|
|
178
|
-
const reqUrl = new URL(req.url,
|
|
161
|
+
const reqUrl = new URL(req.url, redirectUri);
|
|
179
162
|
const code = reqUrl.searchParams.get("code");
|
|
180
163
|
if (!code) {
|
|
181
164
|
res.writeHead(400);
|
|
@@ -251,8 +234,30 @@ if (process.argv[2] === "auth") {
|
|
|
251
234
|
}
|
|
252
235
|
});
|
|
253
236
|
|
|
254
|
-
server.
|
|
255
|
-
console.
|
|
237
|
+
server.on("error", (err) => {
|
|
238
|
+
console.error("OAuth server error:", err.message);
|
|
239
|
+
process.exit(1);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
// Use ephemeral port (0) — OS assigns a free port
|
|
243
|
+
server.listen(0, () => {
|
|
244
|
+
const actualPort = server.address().port;
|
|
245
|
+
redirectUri = `http://localhost:${actualPort}`;
|
|
246
|
+
|
|
247
|
+
const authUrl =
|
|
248
|
+
`https://accounts.google.com/o/oauth2/v2/auth?` +
|
|
249
|
+
`client_id=${encodeURIComponent(client_id)}` +
|
|
250
|
+
`&redirect_uri=${encodeURIComponent(redirectUri)}` +
|
|
251
|
+
`&response_type=code` +
|
|
252
|
+
`&scope=${encodeURIComponent(scopes.join(" "))}` +
|
|
253
|
+
`&access_type=offline` +
|
|
254
|
+
`&prompt=consent`;
|
|
255
|
+
|
|
256
|
+
const { exec } = require("child_process");
|
|
257
|
+
exec(`open "${authUrl}"`);
|
|
258
|
+
console.log(
|
|
259
|
+
`\nOpening browser for authorization (port ${actualPort})...\n`,
|
|
260
|
+
);
|
|
256
261
|
});
|
|
257
262
|
} catch (err) {
|
|
258
263
|
console.error("Auth error:", err.message);
|
|
@@ -267,7 +272,7 @@ if (process.argv[2] === "auth") {
|
|
|
267
272
|
{ capabilities: { tools: {} } },
|
|
268
273
|
);
|
|
269
274
|
|
|
270
|
-
server.setRequestHandler(
|
|
275
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
271
276
|
tools: [
|
|
272
277
|
{
|
|
273
278
|
name: "search",
|
|
@@ -286,7 +291,7 @@ if (process.argv[2] === "auth") {
|
|
|
286
291
|
],
|
|
287
292
|
}));
|
|
288
293
|
|
|
289
|
-
server.setRequestHandler(
|
|
294
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
290
295
|
if (request.params.name !== "search") {
|
|
291
296
|
return {
|
|
292
297
|
content: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trops/dash-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.81",
|
|
4
4
|
"description": "Core framework for Dash dashboard applications",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "npm run build:renderer && npm run build:electron",
|
|
21
21
|
"build:renderer": "rollup -c rollup.config.renderer.mjs",
|
|
22
|
-
"build:electron": "rollup -c rollup.config.electron.mjs && mkdir -p dist/mcp
|
|
22
|
+
"build:electron": "rollup -c rollup.config.electron.mjs && mkdir -p dist/mcp && cp electron/mcp/mcpServerCatalog.json dist/mcp/ && rm -rf dist/mcp/servers && cp -r electron/mcp/servers dist/mcp/",
|
|
23
23
|
"clean": "rm -rf dist",
|
|
24
24
|
"prepublishOnly": "npm run clean && npm run build",
|
|
25
25
|
"test:mcp": "node --test electron/controller/mcpController.test.js electron/mcp/mcpServerCatalog.test.js",
|