mcp-server-kubernetes
Version:
MCP server for interacting with Kubernetes clusters via kubectl
33 lines (32 loc) • 1.12 kB
JavaScript
import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
export const kubectlReconnectSchema = {
name: "kubectl_reconnect",
description: "Reconnect to the Kubernetes API server by recreating all API clients. Use this after cluster upgrades (e.g., EKS control plane upgrades that rotate ENIs/IPs) to force fresh DNS resolution and new TCP connections.",
annotations: {
readOnlyHint: false,
},
inputSchema: {
type: "object",
properties: {},
required: [],
},
};
export async function kubectlReconnect(k8sManager) {
try {
k8sManager.refreshApiClients();
return {
content: [
{
type: "text",
text: JSON.stringify({
success: true,
message: "API clients refreshed. DNS will be re-resolved on the next request.",
}, null, 2),
},
],
};
}
catch (error) {
throw new McpError(ErrorCode.InternalError, `Failed to reconnect: ${error.message}`);
}
}