@mgsoftwarebv/mg-dashboard-mcp 7.4.19 → 7.4.20
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 +17 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9029,6 +9029,11 @@ function normalizeAllowedTools(value) {
|
|
|
9029
9029
|
const tools = value.filter((t) => typeof t === "string").map((t) => t.trim()).filter(Boolean);
|
|
9030
9030
|
return tools.length > 0 ? tools : null;
|
|
9031
9031
|
}
|
|
9032
|
+
function isMcpToolAllowed(name, allowed, denied) {
|
|
9033
|
+
if (denied?.includes(name)) return false;
|
|
9034
|
+
if (allowed && allowed.length > 0) return allowed.includes(name);
|
|
9035
|
+
return true;
|
|
9036
|
+
}
|
|
9032
9037
|
var authContext = null;
|
|
9033
9038
|
var currentClientIp;
|
|
9034
9039
|
function extractClientIp(req) {
|
|
@@ -9057,7 +9062,7 @@ async function validateApiKey(key) {
|
|
|
9057
9062
|
return null;
|
|
9058
9063
|
}
|
|
9059
9064
|
const apiKeyRows = await db.execute(sql`
|
|
9060
|
-
SELECT id, name, created_by, allowed_server_ids, allowed_tools, is_active, expires_at
|
|
9065
|
+
SELECT id, name, created_by, allowed_server_ids, allowed_tools, denied_tools, is_active, expires_at
|
|
9061
9066
|
FROM dashboard_mcp_api_key
|
|
9062
9067
|
WHERE api_key_hash = ${keyHash} AND is_active = true
|
|
9063
9068
|
LIMIT 1
|
|
@@ -9110,6 +9115,7 @@ async function validateApiKey(key) {
|
|
|
9110
9115
|
userId: data.created_by,
|
|
9111
9116
|
allowedServerIds,
|
|
9112
9117
|
allowedTools: normalizeAllowedTools(data.allowed_tools),
|
|
9118
|
+
deniedTools: normalizeAllowedTools(data.denied_tools),
|
|
9113
9119
|
permissions,
|
|
9114
9120
|
roleName
|
|
9115
9121
|
};
|
|
@@ -9304,7 +9310,7 @@ async function validateSshKey(pubkeyPathInput, expectedApiKeyId) {
|
|
|
9304
9310
|
return null;
|
|
9305
9311
|
}
|
|
9306
9312
|
const apiRows = await db.execute(sql`
|
|
9307
|
-
SELECT id, name, created_by, allowed_server_ids, allowed_tools, is_active, expires_at
|
|
9313
|
+
SELECT id, name, created_by, allowed_server_ids, allowed_tools, denied_tools, is_active, expires_at
|
|
9308
9314
|
FROM dashboard_mcp_api_key
|
|
9309
9315
|
WHERE id = ${keyRow.api_key_id} AND is_active = true
|
|
9310
9316
|
LIMIT 1
|
|
@@ -9359,6 +9365,7 @@ async function validateSshKey(pubkeyPathInput, expectedApiKeyId) {
|
|
|
9359
9365
|
userId: apiRow.created_by,
|
|
9360
9366
|
allowedServerIds,
|
|
9361
9367
|
allowedTools: normalizeAllowedTools(apiRow.allowed_tools),
|
|
9368
|
+
deniedTools: normalizeAllowedTools(apiRow.denied_tools),
|
|
9362
9369
|
permissions,
|
|
9363
9370
|
roleName
|
|
9364
9371
|
};
|
|
@@ -13650,7 +13657,8 @@ async function handleListTools() {
|
|
|
13650
13657
|
const allowedTools = authContext.allowedTools;
|
|
13651
13658
|
const isSuperadmin = authContext.roleName === "superadmin";
|
|
13652
13659
|
const accessible = TOOLS.filter((tool) => {
|
|
13653
|
-
if (
|
|
13660
|
+
if (!isMcpToolAllowed(tool.name, allowedTools, authContext.deniedTools))
|
|
13661
|
+
return false;
|
|
13654
13662
|
if (SUPERADMIN_ONLY_TOOLS.has(tool.name) && !isSuperadmin) return false;
|
|
13655
13663
|
const requiredModule = TOOL_MODULE_MAP[tool.name];
|
|
13656
13664
|
if (!requiredModule) return true;
|
|
@@ -13664,12 +13672,16 @@ async function handleCallTool(request) {
|
|
|
13664
13672
|
}
|
|
13665
13673
|
const { name, arguments: toolArgs } = request.params;
|
|
13666
13674
|
const a = toolArgs || {};
|
|
13667
|
-
if (
|
|
13675
|
+
if (!isMcpToolAllowed(
|
|
13676
|
+
name,
|
|
13677
|
+
authContext.allowedTools,
|
|
13678
|
+
authContext.deniedTools
|
|
13679
|
+
)) {
|
|
13668
13680
|
return {
|
|
13669
13681
|
content: [
|
|
13670
13682
|
{
|
|
13671
13683
|
type: "text",
|
|
13672
|
-
text: `Access denied: this API key
|
|
13684
|
+
text: `Access denied: this API key may not call "${name}".`
|
|
13673
13685
|
}
|
|
13674
13686
|
]
|
|
13675
13687
|
};
|
package/package.json
CHANGED