@mgsoftwarebv/mg-dashboard-mcp 7.0.14 → 7.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/dist/index.js CHANGED
@@ -6578,6 +6578,11 @@ var TOOL_MODULE_MAP = {
6578
6578
  "cursor-remote-run": "cursor_remote",
6579
6579
  ...TRIGGER_TOOL_MODULE_MAP
6580
6580
  };
6581
+ function normalizeAllowedTools(value) {
6582
+ if (!Array.isArray(value)) return null;
6583
+ const tools = value.filter((t) => typeof t === "string").map((t) => t.trim()).filter(Boolean);
6584
+ return tools.length > 0 ? tools : null;
6585
+ }
6581
6586
  var authContext = null;
6582
6587
  var currentClientIp;
6583
6588
  function extractClientIp(req) {
@@ -6606,7 +6611,7 @@ async function validateApiKey(key) {
6606
6611
  return null;
6607
6612
  }
6608
6613
  const apiKeyRows = await db.execute(sql`
6609
- SELECT id, name, created_by, allowed_server_ids, is_active, expires_at
6614
+ SELECT id, name, created_by, allowed_server_ids, allowed_tools, is_active, expires_at
6610
6615
  FROM dashboard_mcp_api_key
6611
6616
  WHERE api_key_hash = ${keyHash} AND is_active = true
6612
6617
  LIMIT 1
@@ -6658,6 +6663,7 @@ async function validateApiKey(key) {
6658
6663
  apiKeyName: data.name || "Unknown",
6659
6664
  userId: data.created_by,
6660
6665
  allowedServerIds,
6666
+ allowedTools: normalizeAllowedTools(data.allowed_tools),
6661
6667
  permissions,
6662
6668
  roleName
6663
6669
  };
@@ -6852,7 +6858,7 @@ async function validateSshKey(pubkeyPathInput, expectedApiKeyId) {
6852
6858
  return null;
6853
6859
  }
6854
6860
  const apiRows = await db.execute(sql`
6855
- SELECT id, name, created_by, allowed_server_ids, is_active, expires_at
6861
+ SELECT id, name, created_by, allowed_server_ids, allowed_tools, is_active, expires_at
6856
6862
  FROM dashboard_mcp_api_key
6857
6863
  WHERE id = ${keyRow.api_key_id} AND is_active = true
6858
6864
  LIMIT 1
@@ -6906,6 +6912,7 @@ async function validateSshKey(pubkeyPathInput, expectedApiKeyId) {
6906
6912
  apiKeyName: `${apiRow.name || "Unknown"} (ssh: ${keyRow.name})`,
6907
6913
  userId: apiRow.created_by,
6908
6914
  allowedServerIds,
6915
+ allowedTools: normalizeAllowedTools(apiRow.allowed_tools),
6909
6916
  permissions,
6910
6917
  roleName
6911
6918
  };
@@ -9138,7 +9145,7 @@ function normaliseMigrationSql(sql25) {
9138
9145
  return sql25.replace(/\r\n/g, "\n").trim() + "\n";
9139
9146
  }
9140
9147
  function migrationSha256(sql25) {
9141
- return createHash("sha256").update(normaliseMigrationSql(sql25), "utf8").digest("hex");
9148
+ return createHash("sha256").update(sql25.replace(/\r\n/g, "\n"), "utf8").digest("hex");
9142
9149
  }
9143
9150
  function dollarQuoteTag(value) {
9144
9151
  let tag = "_mcp";
@@ -10398,7 +10405,9 @@ var TOOLS = [
10398
10405
  var MCP_VERSION = "7.0.5";
10399
10406
  async function handleListTools() {
10400
10407
  if (!authContext) return { tools: TOOLS };
10408
+ const allowedTools = authContext.allowedTools;
10401
10409
  const accessible = TOOLS.filter((tool) => {
10410
+ if (allowedTools && !allowedTools.includes(tool.name)) return false;
10402
10411
  const requiredModule = TOOL_MODULE_MAP[tool.name];
10403
10412
  if (!requiredModule) return true;
10404
10413
  return authContext.permissions.modules[requiredModule] === true;
@@ -10411,6 +10420,16 @@ async function handleCallTool(request) {
10411
10420
  }
10412
10421
  const { name, arguments: toolArgs } = request.params;
10413
10422
  const a = toolArgs || {};
10423
+ if (authContext.allowedTools && !authContext.allowedTools.includes(name)) {
10424
+ return {
10425
+ content: [
10426
+ {
10427
+ type: "text",
10428
+ text: `Access denied: this API key is restricted to a specific tool allowlist and may not call "${name}". Allowed: ${authContext.allowedTools.join(", ")}`
10429
+ }
10430
+ ]
10431
+ };
10432
+ }
10414
10433
  const requiredModule = TOOL_MODULE_MAP[name];
10415
10434
  if (requiredModule && authContext.permissions.modules[requiredModule] !== true) {
10416
10435
  return {