mcp-server-kubernetes 1.6.2 → 2.0.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.
Files changed (96) hide show
  1. package/README.md +46 -22
  2. package/dist/config/container-templates.d.ts +2 -2
  3. package/dist/index.d.ts +314 -736
  4. package/dist/index.js +93 -200
  5. package/dist/models/resource-models.d.ts +6 -6
  6. package/dist/tools/kubectl-apply.d.ts +46 -0
  7. package/dist/tools/kubectl-apply.js +110 -0
  8. package/dist/tools/kubectl-context.d.ts +49 -0
  9. package/dist/tools/kubectl-context.js +233 -0
  10. package/dist/tools/kubectl-create.d.ts +150 -0
  11. package/dist/tools/kubectl-create.js +321 -0
  12. package/dist/tools/kubectl-delete.d.ts +77 -0
  13. package/dist/tools/kubectl-delete.js +177 -0
  14. package/dist/tools/kubectl-describe.d.ts +47 -0
  15. package/dist/tools/kubectl-describe.js +96 -0
  16. package/dist/tools/kubectl-generic.d.ts +71 -0
  17. package/dist/tools/kubectl-generic.js +121 -0
  18. package/dist/tools/kubectl-get.d.ts +72 -0
  19. package/dist/tools/kubectl-get.js +251 -0
  20. package/dist/tools/kubectl-list.d.ts +61 -0
  21. package/dist/tools/kubectl-list.js +189 -0
  22. package/dist/tools/{get_logs.d.ts → kubectl-logs.d.ts} +35 -19
  23. package/dist/tools/kubectl-logs.js +312 -0
  24. package/dist/tools/kubectl-patch.d.ts +57 -0
  25. package/dist/tools/kubectl-patch.js +128 -0
  26. package/dist/tools/kubectl-rollout.d.ts +67 -0
  27. package/dist/tools/kubectl-rollout.js +115 -0
  28. package/dist/tools/{scale_deployment.d.ts → kubectl-scale.d.ts} +13 -3
  29. package/dist/tools/kubectl-scale.js +73 -0
  30. package/package.json +1 -1
  31. package/dist/tools/create_configmap.d.ts +0 -33
  32. package/dist/tools/create_configmap.js +0 -66
  33. package/dist/tools/create_cronjob.d.ts +0 -47
  34. package/dist/tools/create_cronjob.js +0 -93
  35. package/dist/tools/create_deployment.d.ts +0 -135
  36. package/dist/tools/create_deployment.js +0 -162
  37. package/dist/tools/create_namespace.d.ts +0 -22
  38. package/dist/tools/create_namespace.js +0 -48
  39. package/dist/tools/create_pod.d.ts +0 -130
  40. package/dist/tools/create_pod.js +0 -153
  41. package/dist/tools/create_service.d.ts +0 -74
  42. package/dist/tools/create_service.js +0 -102
  43. package/dist/tools/delete_configmap.d.ts +0 -26
  44. package/dist/tools/delete_configmap.js +0 -49
  45. package/dist/tools/delete_cronjob.d.ts +0 -26
  46. package/dist/tools/delete_cronjob.js +0 -48
  47. package/dist/tools/delete_deployment.d.ts +0 -31
  48. package/dist/tools/delete_deployment.js +0 -47
  49. package/dist/tools/delete_namespace.d.ts +0 -27
  50. package/dist/tools/delete_namespace.js +0 -44
  51. package/dist/tools/delete_pod.d.ts +0 -31
  52. package/dist/tools/delete_pod.js +0 -45
  53. package/dist/tools/delete_service.d.ts +0 -32
  54. package/dist/tools/delete_service.js +0 -46
  55. package/dist/tools/describe_cronjob.d.ts +0 -27
  56. package/dist/tools/describe_cronjob.js +0 -83
  57. package/dist/tools/describe_deployment.d.ts +0 -26
  58. package/dist/tools/describe_deployment.js +0 -40
  59. package/dist/tools/describe_node.d.ts +0 -22
  60. package/dist/tools/describe_node.js +0 -84
  61. package/dist/tools/describe_pod.d.ts +0 -33
  62. package/dist/tools/describe_pod.js +0 -81
  63. package/dist/tools/describe_service.d.ts +0 -34
  64. package/dist/tools/describe_service.js +0 -85
  65. package/dist/tools/get_configmap.d.ts +0 -27
  66. package/dist/tools/get_configmap.js +0 -48
  67. package/dist/tools/get_current_context.d.ts +0 -23
  68. package/dist/tools/get_current_context.js +0 -55
  69. package/dist/tools/get_events.d.ts +0 -28
  70. package/dist/tools/get_events.js +0 -66
  71. package/dist/tools/get_job_logs.d.ts +0 -40
  72. package/dist/tools/get_job_logs.js +0 -104
  73. package/dist/tools/get_logs.js +0 -150
  74. package/dist/tools/list_contexts.d.ts +0 -23
  75. package/dist/tools/list_contexts.js +0 -39
  76. package/dist/tools/list_cronjobs.d.ts +0 -23
  77. package/dist/tools/list_cronjobs.js +0 -35
  78. package/dist/tools/list_deployments.d.ts +0 -23
  79. package/dist/tools/list_deployments.js +0 -30
  80. package/dist/tools/list_jobs.d.ts +0 -29
  81. package/dist/tools/list_jobs.js +0 -77
  82. package/dist/tools/list_nodes.d.ts +0 -15
  83. package/dist/tools/list_nodes.js +0 -21
  84. package/dist/tools/list_pods.d.ts +0 -23
  85. package/dist/tools/list_pods.js +0 -29
  86. package/dist/tools/list_services.d.ts +0 -23
  87. package/dist/tools/list_services.js +0 -31
  88. package/dist/tools/scale_deployment.js +0 -50
  89. package/dist/tools/set_current_context.d.ts +0 -23
  90. package/dist/tools/set_current_context.js +0 -35
  91. package/dist/tools/update_configmap.d.ts +0 -33
  92. package/dist/tools/update_configmap.js +0 -71
  93. package/dist/tools/update_deployment.d.ts +0 -113
  94. package/dist/tools/update_deployment.js +0 -155
  95. package/dist/tools/update_service.d.ts +0 -72
  96. package/dist/tools/update_service.js +0 -125
@@ -1,83 +0,0 @@
1
- export const describeCronJobSchema = {
2
- name: "describe_cronjob",
3
- description: "Get detailed information about a Kubernetes CronJob including recent job history",
4
- inputSchema: {
5
- type: "object",
6
- properties: {
7
- name: { type: "string" },
8
- namespace: { type: "string", default: "default" },
9
- },
10
- required: ["name", "namespace"],
11
- },
12
- };
13
- export async function describeCronJob(k8sManager, input) {
14
- try {
15
- // Get the CronJob details
16
- const batchV1Api = k8sManager.getBatchApi();
17
- const cronJobResponse = await batchV1Api.readNamespacedCronJob(input.name, input.namespace);
18
- const cronJob = cronJobResponse.body;
19
- // Get recent Jobs associated with this CronJob
20
- const labelSelector = `app=${input.name},cronjob-name=${input.name}`;
21
- const jobsResponse = await batchV1Api.listNamespacedJob(input.namespace, undefined, // pretty
22
- undefined, // allowWatchBookmarks
23
- undefined, // _continue
24
- undefined, // fieldSelector
25
- labelSelector);
26
- // Sort jobs by creation time (newest first)
27
- const jobs = jobsResponse.body.items.sort((a, b) => {
28
- const aTime = a.metadata?.creationTimestamp
29
- ? new Date(a.metadata.creationTimestamp)
30
- : new Date(0);
31
- const bTime = b.metadata?.creationTimestamp
32
- ? new Date(b.metadata.creationTimestamp)
33
- : new Date(0);
34
- return bTime.getTime() - aTime.getTime();
35
- });
36
- // Limit to 5 most recent jobs
37
- const recentJobs = jobs.slice(0, 5).map((job) => ({
38
- name: job.metadata?.name || "",
39
- creationTime: job.metadata?.creationTimestamp || "",
40
- status: {
41
- active: job.status?.active || 0,
42
- succeeded: job.status?.succeeded || 0,
43
- failed: job.status?.failed || 0,
44
- completionTime: job.status?.completionTime || null,
45
- },
46
- }));
47
- // Format the response with CronJob details and recent jobs
48
- const cronJobDetails = {
49
- name: cronJob.metadata?.name || "",
50
- namespace: cronJob.metadata?.namespace || "",
51
- schedule: cronJob.spec?.schedule || "",
52
- suspend: cronJob.spec?.suspend || false,
53
- concurrencyPolicy: cronJob.spec?.concurrencyPolicy || "Allow",
54
- lastScheduleTime: cronJob.status?.lastScheduleTime || null,
55
- lastSuccessfulTime: cronJob.status?.lastSuccessfulTime || null,
56
- creationTimestamp: cronJob.metadata?.creationTimestamp || "",
57
- recentJobs: recentJobs,
58
- jobTemplate: {
59
- image: cronJob.spec?.jobTemplate?.spec?.template?.spec?.containers?.[0]
60
- ?.image || "",
61
- command: cronJob.spec?.jobTemplate?.spec?.template?.spec?.containers?.[0]
62
- ?.command || [],
63
- restartPolicy: cronJob.spec?.jobTemplate?.spec?.template?.spec?.restartPolicy || "",
64
- },
65
- };
66
- return {
67
- content: [
68
- {
69
- type: "text",
70
- text: JSON.stringify(cronJobDetails, null, 2),
71
- },
72
- ],
73
- };
74
- }
75
- catch (error) {
76
- console.error("Error describing CronJob:", {
77
- status: error.response?.statusCode,
78
- message: error.response?.body?.message || error.message,
79
- details: error.response?.body,
80
- });
81
- throw error;
82
- }
83
- }
@@ -1,26 +0,0 @@
1
- import { KubernetesManager } from "../types.js";
2
- export declare const describeDeploymentSchema: {
3
- readonly name: "describe_deployment";
4
- readonly description: "Get details about a Kubernetes deployment";
5
- readonly inputSchema: {
6
- readonly type: "object";
7
- readonly properties: {
8
- readonly name: {
9
- readonly type: "string";
10
- };
11
- readonly namespace: {
12
- readonly type: "string";
13
- };
14
- };
15
- readonly required: readonly ["name", "namespace"];
16
- };
17
- };
18
- export declare function describeDeployment(k8sManager: KubernetesManager, input: {
19
- name: string;
20
- namespace: string;
21
- }): Promise<{
22
- content: {
23
- type: string;
24
- text: string;
25
- }[];
26
- }>;
@@ -1,40 +0,0 @@
1
- export const describeDeploymentSchema = {
2
- name: "describe_deployment",
3
- description: "Get details about a Kubernetes deployment",
4
- inputSchema: {
5
- type: "object",
6
- properties: {
7
- name: { type: "string" },
8
- namespace: { type: "string" },
9
- },
10
- required: ["name", "namespace"],
11
- },
12
- };
13
- export async function describeDeployment(k8sManager, input) {
14
- const { body } = await k8sManager
15
- .getAppsApi()
16
- .readNamespacedDeployment(input.name, input.namespace)
17
- .catch((error) => {
18
- console.error("Deployment description error:", {
19
- status: error.response?.statusCode,
20
- message: error.response?.body?.message || error.message,
21
- details: error.response?.body,
22
- });
23
- throw error;
24
- });
25
- return {
26
- content: [
27
- {
28
- type: "text",
29
- text: JSON.stringify({
30
- name: body.metadata?.name,
31
- namespace: body.metadata?.namespace,
32
- replicas: body.spec?.replicas,
33
- availableReplicas: body.status?.availableReplicas,
34
- spec: body.spec,
35
- status: body.status,
36
- }, null, 2),
37
- },
38
- ],
39
- };
40
- }
@@ -1,22 +0,0 @@
1
- import { KubernetesManager } from "../types.js";
2
- export declare const describeNodeSchema: {
3
- readonly name: "describe_node";
4
- readonly description: "Describe a Kubernetes node (read details like status, capacity, conditions, etc.)";
5
- readonly inputSchema: {
6
- readonly type: "object";
7
- readonly properties: {
8
- readonly name: {
9
- readonly type: "string";
10
- };
11
- };
12
- readonly required: readonly ["name"];
13
- };
14
- };
15
- export declare function describeNode(k8sManager: KubernetesManager, input: {
16
- name: string;
17
- }): Promise<{
18
- content: {
19
- type: string;
20
- text: string;
21
- }[];
22
- }>;
@@ -1,84 +0,0 @@
1
- import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
2
- export const describeNodeSchema = {
3
- name: "describe_node",
4
- description: "Describe a Kubernetes node (read details like status, capacity, conditions, etc.)",
5
- inputSchema: {
6
- type: "object",
7
- properties: {
8
- name: { type: "string" },
9
- },
10
- required: ["name"],
11
- },
12
- };
13
- export async function describeNode(k8sManager, input) {
14
- try {
15
- const { body } = await k8sManager.getCoreApi().readNode(input.name);
16
- if (!body) {
17
- return {
18
- content: [
19
- {
20
- type: "text",
21
- text: JSON.stringify({
22
- error: "Node not found",
23
- status: "not_found",
24
- }, null, 2),
25
- },
26
- ],
27
- };
28
- }
29
- // Format the node details for better readability
30
- const nodeDetails = {
31
- kind: body.kind,
32
- metadata: {
33
- name: body.metadata?.name,
34
- creationTimestamp: body.metadata?.creationTimestamp,
35
- labels: body.metadata?.labels,
36
- annotations: body.metadata?.annotations,
37
- },
38
- spec: {
39
- podCIDR: body.spec?.podCIDR,
40
- podCIDRs: body.spec?.podCIDRs,
41
- taints: body.spec?.taints,
42
- unschedulable: body.spec?.unschedulable,
43
- },
44
- status: {
45
- capacity: body.status?.capacity,
46
- allocatable: body.status?.allocatable,
47
- conditions: body.status?.conditions,
48
- nodeInfo: {
49
- architecture: body.status?.nodeInfo?.architecture,
50
- containerRuntimeVersion: body.status?.nodeInfo?.containerRuntimeVersion,
51
- kernelVersion: body.status?.nodeInfo?.kernelVersion,
52
- kubeletVersion: body.status?.nodeInfo?.kubeletVersion,
53
- operatingSystem: body.status?.nodeInfo?.operatingSystem,
54
- osImage: body.status?.nodeInfo?.osImage,
55
- },
56
- addresses: body.status?.addresses,
57
- },
58
- };
59
- return {
60
- content: [
61
- {
62
- type: "text",
63
- text: JSON.stringify(nodeDetails, null, 2),
64
- },
65
- ],
66
- };
67
- }
68
- catch (error) {
69
- if (error.response?.statusCode === 404) {
70
- return {
71
- content: [
72
- {
73
- type: "text",
74
- text: JSON.stringify({
75
- error: "Node not found",
76
- status: "not_found",
77
- }, null, 2),
78
- },
79
- ],
80
- };
81
- }
82
- throw new McpError(ErrorCode.InternalError, `Failed to describe node: ${error.response?.body?.message || error.message}`);
83
- }
84
- }
@@ -1,33 +0,0 @@
1
- import { KubernetesManager } from "../types.js";
2
- export declare const describePodSchema: {
3
- readonly name: "describe_pod";
4
- readonly description: "Describe a Kubernetes pod (read details like status, containers, etc.)";
5
- readonly inputSchema: {
6
- readonly type: "object";
7
- readonly properties: {
8
- readonly name: {
9
- readonly type: "string";
10
- };
11
- readonly namespace: {
12
- readonly type: "string";
13
- };
14
- };
15
- readonly required: readonly ["name", "namespace"];
16
- };
17
- };
18
- export declare function describePod(k8sManager: KubernetesManager, input: {
19
- name: string;
20
- namespace: string;
21
- }): Promise<{
22
- content: {
23
- type: string;
24
- text: string;
25
- }[];
26
- isError: boolean;
27
- } | {
28
- content: {
29
- type: string;
30
- text: string;
31
- }[];
32
- isError?: undefined;
33
- }>;
@@ -1,81 +0,0 @@
1
- import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
2
- export const describePodSchema = {
3
- name: "describe_pod",
4
- description: "Describe a Kubernetes pod (read details like status, containers, etc.)",
5
- inputSchema: {
6
- type: "object",
7
- properties: {
8
- name: { type: "string" },
9
- namespace: { type: "string" },
10
- },
11
- required: ["name", "namespace"],
12
- },
13
- };
14
- export async function describePod(k8sManager, input) {
15
- try {
16
- const { body } = await k8sManager.getCoreApi().readNamespacedPod(input.name, input.namespace);
17
- if (!body) {
18
- return {
19
- content: [
20
- {
21
- type: "text",
22
- text: JSON.stringify({
23
- error: "Pod not found",
24
- status: "not_found",
25
- }, null, 2),
26
- },
27
- ],
28
- isError: true,
29
- };
30
- }
31
- // Format the pod details for better readability
32
- const podDetails = {
33
- kind: body.kind,
34
- metadata: {
35
- name: body.metadata?.name,
36
- namespace: body.metadata?.namespace,
37
- creationTimestamp: body.metadata?.creationTimestamp,
38
- labels: body.metadata?.labels,
39
- },
40
- spec: {
41
- containers: body.spec?.containers.map((container) => ({
42
- name: container.name,
43
- image: container.image,
44
- ports: container.ports,
45
- resources: container.resources,
46
- })),
47
- nodeName: body.spec?.nodeName,
48
- },
49
- status: {
50
- phase: body.status?.phase,
51
- conditions: body.status?.conditions,
52
- containerStatuses: body.status?.containerStatuses,
53
- },
54
- };
55
- return {
56
- content: [
57
- {
58
- type: "text",
59
- text: JSON.stringify(podDetails, null, 2),
60
- },
61
- ],
62
- };
63
- }
64
- catch (error) {
65
- if (error.response?.statusCode === 404) {
66
- return {
67
- content: [
68
- {
69
- type: "text",
70
- text: JSON.stringify({
71
- error: "Pod not found",
72
- status: "not_found",
73
- }, null, 2),
74
- },
75
- ],
76
- isError: true,
77
- };
78
- }
79
- throw new McpError(ErrorCode.InternalError, `Failed to describe pod: ${error.response?.body?.message || error.message}`);
80
- }
81
- }
@@ -1,34 +0,0 @@
1
- import { KubernetesManager } from "../types.js";
2
- export declare const describeServiceSchema: {
3
- readonly name: "describe_service";
4
- readonly description: "Describe a Kubernetes service (read details like status, ports, selectors, etc.)";
5
- readonly inputSchema: {
6
- readonly type: "object";
7
- readonly properties: {
8
- readonly name: {
9
- readonly type: "string";
10
- };
11
- readonly namespace: {
12
- readonly type: "string";
13
- readonly default: "default";
14
- };
15
- };
16
- readonly required: readonly ["name"];
17
- };
18
- };
19
- export declare function describeService(k8sManager: KubernetesManager, input: {
20
- name: string;
21
- namespace?: string;
22
- }): Promise<{
23
- content: {
24
- type: string;
25
- text: string;
26
- }[];
27
- isError: boolean;
28
- } | {
29
- content: {
30
- type: string;
31
- text: string;
32
- }[];
33
- isError?: undefined;
34
- }>;
@@ -1,85 +0,0 @@
1
- import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
2
- export const describeServiceSchema = {
3
- name: "describe_service",
4
- description: "Describe a Kubernetes service (read details like status, ports, selectors, etc.)",
5
- inputSchema: {
6
- type: "object",
7
- properties: {
8
- name: { type: "string" },
9
- namespace: { type: "string", default: "default" },
10
- },
11
- required: ["name"],
12
- },
13
- };
14
- export async function describeService(k8sManager, input) {
15
- const namespace = input.namespace || "default";
16
- try {
17
- const { body } = await k8sManager.getCoreApi().readNamespacedService(input.name, namespace);
18
- if (!body) {
19
- return {
20
- content: [
21
- {
22
- type: "text",
23
- text: JSON.stringify({
24
- error: "Service not found",
25
- status: "not_found",
26
- }, null, 2),
27
- },
28
- ],
29
- isError: true,
30
- };
31
- }
32
- // Format service details for better readability
33
- const serviceDetails = {
34
- kind: body.kind,
35
- metadata: {
36
- name: body.metadata?.name,
37
- namespace: body.metadata?.namespace,
38
- creationTimestamp: body.metadata?.creationTimestamp,
39
- labels: body.metadata?.labels,
40
- },
41
- spec: {
42
- type: body.spec?.type,
43
- selector: body.spec?.selector,
44
- ports: body.spec?.ports?.map((port) => ({
45
- name: port.name,
46
- protocol: port.protocol,
47
- port: port.port,
48
- targetPort: port.targetPort,
49
- nodePort: port.nodePort,
50
- })),
51
- clusterIP: body.spec?.clusterIP,
52
- externalIPs: body.spec?.externalIPs,
53
- loadBalancerIP: body.spec?.loadBalancerIP,
54
- },
55
- status: {
56
- loadBalancer: body.status?.loadBalancer,
57
- },
58
- };
59
- return {
60
- content: [
61
- {
62
- type: "text",
63
- text: JSON.stringify(serviceDetails, null, 2),
64
- },
65
- ],
66
- };
67
- }
68
- catch (error) {
69
- if (error.response?.statusCode === 404) {
70
- return {
71
- content: [
72
- {
73
- type: "text",
74
- text: JSON.stringify({
75
- error: "Service not found",
76
- status: "not_found",
77
- }, null, 2),
78
- },
79
- ],
80
- isError: true,
81
- };
82
- }
83
- throw new McpError(ErrorCode.InternalError, `Failed to describe service: ${error.response?.body?.message || error.message}`);
84
- }
85
- }
@@ -1,27 +0,0 @@
1
- import { KubernetesManager } from "../types.js";
2
- export declare const GetConfigMapSchema: {
3
- name: string;
4
- description: string;
5
- inputSchema: {
6
- type: string;
7
- properties: {
8
- name: {
9
- type: string;
10
- };
11
- namespace: {
12
- type: string;
13
- };
14
- };
15
- required: string[];
16
- };
17
- };
18
- export declare function getConfigMap(k8sManager: KubernetesManager, input: {
19
- name: string;
20
- namespace: string;
21
- }): Promise<{
22
- content: {
23
- success: boolean;
24
- message: string;
25
- data?: Record<string, string>;
26
- }[];
27
- }>;
@@ -1,48 +0,0 @@
1
- export const GetConfigMapSchema = {
2
- name: "get_configmap",
3
- description: "Get a Kubernetes ConfigMap",
4
- inputSchema: {
5
- type: "object",
6
- properties: {
7
- name: { type: "string" },
8
- namespace: { type: "string" },
9
- },
10
- required: ["name", "namespace"],
11
- },
12
- };
13
- export async function getConfigMap(k8sManager, input) {
14
- try {
15
- const response = await k8sManager.getCoreApi().readNamespacedConfigMap(input.name, input.namespace);
16
- if (response.body && response.body.data) {
17
- return {
18
- content: [
19
- {
20
- success: true,
21
- message: `Fetched ConfigMap ${input.name} in namespace ${input.namespace}`,
22
- data: response.body.data,
23
- },
24
- ],
25
- };
26
- }
27
- else {
28
- return {
29
- content: [
30
- {
31
- success: false,
32
- message: `ConfigMap ${input.name} in namespace ${input.namespace} not found or has no data.`,
33
- },
34
- ],
35
- };
36
- }
37
- }
38
- catch (error) {
39
- return {
40
- content: [
41
- {
42
- success: false,
43
- message: `Failed to get ConfigMap ${input.name} in namespace ${input.namespace}. Error: ${error.message}`,
44
- },
45
- ],
46
- };
47
- }
48
- }
@@ -1,23 +0,0 @@
1
- import { KubernetesManager } from "../types.js";
2
- export declare const getCurrentContextSchema: {
3
- readonly name: "get_current_context";
4
- readonly description: "Get the current Kubernetes context";
5
- readonly inputSchema: {
6
- readonly type: "object";
7
- readonly properties: {
8
- readonly detailed: {
9
- readonly type: "boolean";
10
- readonly description: "Include detailed information about the current context";
11
- readonly default: false;
12
- };
13
- };
14
- };
15
- };
16
- export declare function getCurrentContext(k8sManager: KubernetesManager, input: {
17
- detailed?: boolean;
18
- }): Promise<{
19
- content: {
20
- type: string;
21
- text: string;
22
- }[];
23
- }>;
@@ -1,55 +0,0 @@
1
- export const getCurrentContextSchema = {
2
- name: "get_current_context",
3
- description: "Get the current Kubernetes context",
4
- inputSchema: {
5
- type: "object",
6
- properties: {
7
- detailed: {
8
- type: "boolean",
9
- description: "Include detailed information about the current context",
10
- default: false
11
- }
12
- }
13
- },
14
- };
15
- export async function getCurrentContext(k8sManager, input) {
16
- try {
17
- // Get the KubeConfig from the KubernetesManager
18
- const kc = k8sManager.getKubeConfig();
19
- // Get the current context name
20
- const currentContextName = kc.getCurrentContext();
21
- // If detailed is true, get more information about the context
22
- if (input.detailed) {
23
- const contexts = kc.getContexts();
24
- const currentContext = contexts.find(context => context.name === currentContextName);
25
- if (!currentContext) {
26
- throw new Error(`Current context '${currentContextName}' not found in available contexts`);
27
- }
28
- return {
29
- content: [
30
- {
31
- type: "text",
32
- text: JSON.stringify({
33
- name: currentContextName,
34
- cluster: currentContext.cluster,
35
- user: currentContext.user,
36
- namespace: currentContext.namespace || "default"
37
- }, null, 2),
38
- },
39
- ],
40
- };
41
- }
42
- // Simple response with just the context name
43
- return {
44
- content: [
45
- {
46
- type: "text",
47
- text: JSON.stringify({ currentContext: currentContextName }, null, 2),
48
- },
49
- ],
50
- };
51
- }
52
- catch (error) {
53
- throw new Error(`Failed to get current context: ${error.message}`);
54
- }
55
- }
@@ -1,28 +0,0 @@
1
- import { KubernetesManager } from "../types.js";
2
- export declare const getEventsSchema: {
3
- name: string;
4
- description: string;
5
- inputSchema: {
6
- type: string;
7
- properties: {
8
- namespace: {
9
- type: string;
10
- description: string;
11
- };
12
- fieldSelector: {
13
- type: string;
14
- description: string;
15
- };
16
- };
17
- required: never[];
18
- };
19
- };
20
- export declare function getEvents(k8sManager: KubernetesManager, params: {
21
- namespace?: string;
22
- fieldSelector?: string;
23
- }): Promise<{
24
- content: {
25
- type: string;
26
- text: string;
27
- }[];
28
- }>;