mcp-server-kubernetes 3.5.1 → 3.6.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/dist/index.js +20 -14
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -36,6 +36,21 @@ import { withTelemetry } from "./middleware/telemetry-middleware.js";
|
|
|
36
36
|
const allowOnlyReadonlyTools = process.env.ALLOW_ONLY_READONLY_TOOLS === "true";
|
|
37
37
|
const allowedToolsEnv = process.env.ALLOWED_TOOLS;
|
|
38
38
|
const nonDestructiveTools = process.env.ALLOW_ONLY_NON_DESTRUCTIVE_TOOLS === "true";
|
|
39
|
+
const explicitlyAllowedToolNames = allowedToolsEnv
|
|
40
|
+
? new Set(allowedToolsEnv.split(",").map((t) => t.trim()).filter(Boolean))
|
|
41
|
+
: null;
|
|
42
|
+
const isToolAllowed = (name) => {
|
|
43
|
+
if (explicitlyAllowedToolNames) {
|
|
44
|
+
return explicitlyAllowedToolNames.has(name);
|
|
45
|
+
}
|
|
46
|
+
if (allowOnlyReadonlyTools) {
|
|
47
|
+
return readonlyTools.some((t) => t.name === name);
|
|
48
|
+
}
|
|
49
|
+
if (nonDestructiveTools) {
|
|
50
|
+
return !destructiveTools.some((dt) => dt.name === name);
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
};
|
|
39
54
|
// Define readonly tools
|
|
40
55
|
const readonlyTools = [
|
|
41
56
|
kubectlGetSchema,
|
|
@@ -109,25 +124,16 @@ server.setRequestHandler(ReadResourceRequestSchema, resourceHandlers.readResourc
|
|
|
109
124
|
registerPromptHandlers(server, k8sManager);
|
|
110
125
|
// Tools handlers
|
|
111
126
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const allowedToolNames = allowedToolsEnv.split(",").map((t) => t.trim());
|
|
115
|
-
tools = allTools.filter((tool) => allowedToolNames.includes(tool.name));
|
|
116
|
-
}
|
|
117
|
-
else if (allowOnlyReadonlyTools) {
|
|
118
|
-
tools = readonlyTools;
|
|
119
|
-
}
|
|
120
|
-
else if (nonDestructiveTools) {
|
|
121
|
-
tools = allTools.filter((tool) => !destructiveTools.some((dt) => dt.name === tool.name));
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
tools = allTools;
|
|
125
|
-
}
|
|
127
|
+
const baseTools = allowOnlyReadonlyTools ? readonlyTools : allTools;
|
|
128
|
+
const tools = baseTools.filter((tool) => isToolAllowed(tool.name));
|
|
126
129
|
return { tools };
|
|
127
130
|
});
|
|
128
131
|
server.setRequestHandler(CallToolRequestSchema, withTelemetry(async (request) => {
|
|
129
132
|
try {
|
|
130
133
|
const { name, arguments: input = {} } = request.params;
|
|
134
|
+
if (!isToolAllowed(name)) {
|
|
135
|
+
throw new McpError(ErrorCode.InvalidRequest, `Tool '${name}' is not allowed under the current server configuration`);
|
|
136
|
+
}
|
|
131
137
|
// Handle new kubectl-style commands
|
|
132
138
|
if (name === "kubectl_context") {
|
|
133
139
|
return await kubectlContext(k8sManager, input);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-server-kubernetes",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.1",
|
|
4
4
|
"description": "MCP server for interacting with Kubernetes clusters via kubectl",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@kubernetes/client-node": "1.3.0",
|
|
41
41
|
"@modelcontextprotocol/sdk": "1.26.0",
|
|
42
|
-
"@opentelemetry/api": "
|
|
43
|
-
"@opentelemetry/auto-instrumentations-node": "
|
|
44
|
-
"@opentelemetry/exporter-trace-otlp-grpc": "
|
|
45
|
-
"@opentelemetry/resources": "
|
|
46
|
-
"@opentelemetry/sdk-node": "
|
|
47
|
-
"@opentelemetry/semantic-conventions": "
|
|
42
|
+
"@opentelemetry/api": "1.9.1",
|
|
43
|
+
"@opentelemetry/auto-instrumentations-node": "0.69.0",
|
|
44
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "0.211.0",
|
|
45
|
+
"@opentelemetry/resources": "2.7.1",
|
|
46
|
+
"@opentelemetry/sdk-node": "0.217.0",
|
|
47
|
+
"@opentelemetry/semantic-conventions": "1.40.0",
|
|
48
48
|
"express": "4.21.2",
|
|
49
49
|
"js-yaml": "4.1.1",
|
|
50
50
|
"yaml": "2.8.3",
|