@mgsoftwarebv/mg-dashboard-mcp 3.3.0 → 3.4.0
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/index.js +19 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
|
9
9
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
10
10
|
import { ListToolsRequestSchema, CallToolRequestSchema, isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
11
11
|
import { createServer } from 'http';
|
|
12
|
-
import { randomUUID,
|
|
12
|
+
import { randomUUID, createHash, randomBytes, createCipheriv, createDecipheriv } from 'crypto';
|
|
13
13
|
import { createClient } from '@supabase/supabase-js';
|
|
14
14
|
import { readFile, mkdtemp, writeFile, rm } from 'fs/promises';
|
|
15
15
|
import { tmpdir } from 'os';
|
|
@@ -1173,8 +1173,8 @@ var encryptionKey = getArg2("encryption-key") || process.env.ENCRYPTION_KEY;
|
|
|
1173
1173
|
var mijnhostApiKey = getArg2("mijnhost-api-key") || process.env.MIJNHOST_API_KEY;
|
|
1174
1174
|
var httpMode = args.includes("--http");
|
|
1175
1175
|
var httpPort = Number(getArg2("port")) || 3100;
|
|
1176
|
-
if (!apiKey
|
|
1177
|
-
console.error("Authentication required. Use --api-key=dk_xxx
|
|
1176
|
+
if (!apiKey || !sshKeyPath) {
|
|
1177
|
+
console.error("Authentication required. Use both --api-key=dk_xxx and --ssh-key=PATH (path to your SSH private or public key), or set MG_DASHBOARD_API_KEY and MG_DASHBOARD_SSH_KEY.");
|
|
1178
1178
|
process.exit(1);
|
|
1179
1179
|
}
|
|
1180
1180
|
if (!supabaseUrl || !supabaseKey) {
|
|
@@ -1466,7 +1466,7 @@ async function sshKeygenVerify(pubkeyLine, signature, challenge, namespace) {
|
|
|
1466
1466
|
await rm(dir, { recursive: true, force: true }).catch(() => void 0);
|
|
1467
1467
|
}
|
|
1468
1468
|
}
|
|
1469
|
-
async function validateSshKey(pubkeyPathInput) {
|
|
1469
|
+
async function validateSshKey(pubkeyPathInput, expectedApiKeyId) {
|
|
1470
1470
|
let pubPath;
|
|
1471
1471
|
let pubText;
|
|
1472
1472
|
try {
|
|
@@ -1513,6 +1513,12 @@ async function validateSshKey(pubkeyPathInput) {
|
|
|
1513
1513
|
);
|
|
1514
1514
|
return null;
|
|
1515
1515
|
}
|
|
1516
|
+
if (keyRow.api_key_id !== expectedApiKeyId) {
|
|
1517
|
+
console.error(
|
|
1518
|
+
`SSH key "${keyRow.name}" is registered, but it is not linked to the provided MCP API key. Add this SSH key under the same MCP API Key entry used by --api-key.`
|
|
1519
|
+
);
|
|
1520
|
+
return null;
|
|
1521
|
+
}
|
|
1516
1522
|
const { data: apiRow, error: apiErr } = await supabase.from("dashboard_mcp_api_key").select("id, name, created_by, allowed_server_ids, is_active, expires_at").eq("id", keyRow.api_key_id).eq("is_active", true).maybeSingle();
|
|
1517
1523
|
if (apiErr || !apiRow) {
|
|
1518
1524
|
console.error("SSH key is linked to an inactive or missing MCP API key entry.");
|
|
@@ -3177,18 +3183,15 @@ function createMcpServer() {
|
|
|
3177
3183
|
var server = createMcpServer();
|
|
3178
3184
|
async function main() {
|
|
3179
3185
|
console.error("Starting MG Dashboard MCP Server...");
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
console.error("API key validation failed");
|
|
3190
|
-
process.exit(1);
|
|
3191
|
-
}
|
|
3186
|
+
const apiAuthContext = await validateApiKey(apiKey);
|
|
3187
|
+
if (!apiAuthContext) {
|
|
3188
|
+
console.error("API key validation failed");
|
|
3189
|
+
process.exit(1);
|
|
3190
|
+
}
|
|
3191
|
+
authContext = await validateSshKey(sshKeyPath, apiAuthContext.apiKeyId);
|
|
3192
|
+
if (!authContext) {
|
|
3193
|
+
console.error("SSH-key authentication failed");
|
|
3194
|
+
process.exit(1);
|
|
3192
3195
|
}
|
|
3193
3196
|
console.error(`[Security] MCP v${MCP_VERSION} | Key: ${authContext.apiKeyName}`);
|
|
3194
3197
|
const toolNames = TOOLS.map((t) => t.name).join(", ");
|