mcp-server-kubernetes 0.1.4 → 0.2.3-pre.fdc2e0b
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/README.md +36 -8
- package/dist/config/cleanup-config.d.ts +8 -0
- package/dist/config/cleanup-config.js +8 -0
- package/dist/config/container-templates.d.ts +5 -0
- package/dist/config/container-templates.js +109 -0
- package/dist/config/deployment-config.d.ts +31 -0
- package/dist/config/deployment-config.js +23 -0
- package/dist/config/namespace-config.d.ts +8 -0
- package/dist/config/namespace-config.js +8 -0
- package/dist/config/server-config.d.ts +8 -0
- package/dist/config/server-config.js +8 -0
- package/dist/index.js +53 -788
- package/dist/models/helm-models.d.ts +39 -0
- package/dist/models/helm-models.js +8 -0
- package/dist/models/resource-models.d.ts +94 -0
- package/dist/models/resource-models.js +17 -0
- package/dist/models/response-schemas.d.ts +221 -0
- package/dist/models/response-schemas.js +36 -0
- package/dist/models/tool-models.d.ts +42 -0
- package/dist/models/tool-models.js +10 -0
- package/dist/resources/handlers.d.ts +22 -0
- package/dist/resources/handlers.js +112 -0
- package/dist/tools/create_pod.d.ts +39 -0
- package/dist/tools/create_pod.js +71 -0
- package/dist/tools/delete_pod.d.ts +31 -0
- package/dist/tools/delete_pod.js +45 -0
- package/dist/tools/describe_pod.d.ts +33 -0
- package/dist/tools/describe_pod.js +81 -0
- package/dist/tools/get_logs.d.ts +67 -0
- package/dist/tools/get_logs.js +150 -0
- package/dist/tools/helm-operations.d.ts +99 -0
- package/dist/tools/helm-operations.js +198 -0
- package/dist/tools/list_deployments.d.ts +23 -0
- package/dist/tools/list_deployments.js +30 -0
- package/dist/tools/list_nodes.d.ts +15 -0
- package/dist/tools/list_nodes.js +21 -0
- package/dist/tools/list_pods.d.ts +23 -0
- package/dist/tools/list_pods.js +29 -0
- package/dist/tools/list_services.d.ts +23 -0
- package/dist/tools/list_services.js +31 -0
- package/dist/types.d.ts +4 -356
- package/dist/types.js +6 -94
- package/dist/utils/kubernetes-manager.d.ts +21 -0
- package/dist/utils/kubernetes-manager.js +68 -0
- package/package.json +5 -2
- package/dist/unit.test.d.ts +0 -1
- package/dist/unit.test.js +0 -289
package/README.md
CHANGED
|
@@ -24,10 +24,11 @@ The server will automatically connect to your current kubectl context. Make sure
|
|
|
24
24
|
1. kubectl installed and in your PATH
|
|
25
25
|
2. A valid kubeconfig file with contexts configured
|
|
26
26
|
3. Access to a Kubernetes cluster configured for kubectl (e.g. minikube, Rancher Desktop, GKE, etc.)
|
|
27
|
+
4. Helm v3 installed and in your PATH (no Tiller required). Optional if you don't plan to use Helm.
|
|
27
28
|
|
|
28
29
|
You can verify your connection by asking Claude to list your pods or create a test deployment.
|
|
29
30
|
|
|
30
|
-
If you have errors
|
|
31
|
+
If you have errors open up a standard terminal and run `kubectl get pods` to see if you can connect to your cluster without credentials issues.
|
|
31
32
|
|
|
32
33
|
## Features
|
|
33
34
|
|
|
@@ -40,10 +41,16 @@ If you have errors, open up a standard terminal and run `kubectl get pods` to se
|
|
|
40
41
|
- [x] Delete a pod
|
|
41
42
|
- [x] Describe a pod
|
|
42
43
|
- [x] List all namespaces
|
|
43
|
-
- [x] Get logs from a pod for debugging (supports pods
|
|
44
|
+
- [x] Get logs from a pod for debugging (supports pods deployments jobs and label selectors)
|
|
45
|
+
- [x] Support Helm v3 for installing charts
|
|
46
|
+
- Install charts with custom values
|
|
47
|
+
- Uninstall releases
|
|
48
|
+
- Upgrade existing releases
|
|
49
|
+
- Support for namespaces
|
|
50
|
+
- Support for version specification
|
|
51
|
+
- Support for custom repositories
|
|
44
52
|
- [ ] Port forward to a pod
|
|
45
53
|
- [ ] Choose namespace for next commands (memory)
|
|
46
|
-
- [ ] Support Helm for installing charts
|
|
47
54
|
|
|
48
55
|
## Local Development
|
|
49
56
|
|
|
@@ -83,10 +90,31 @@ npx @modelcontextprotocol/inspector node build/index.js
|
|
|
83
90
|
### Project Structure
|
|
84
91
|
|
|
85
92
|
```
|
|
86
|
-
src/
|
|
87
|
-
├── index.ts
|
|
88
|
-
├── types.ts
|
|
89
|
-
|
|
93
|
+
├── src/
|
|
94
|
+
│ ├── index.ts # Main server implementation
|
|
95
|
+
│ ├── types.ts # Type re-exports
|
|
96
|
+
│ ├── config/ # Configuration files
|
|
97
|
+
│ │ ├── container-templates.ts # Container configurations
|
|
98
|
+
│ │ ├── server-config.ts # Server settings
|
|
99
|
+
│ │ ├── deployment-config.ts # Deployment schemas
|
|
100
|
+
│ │ └── ...
|
|
101
|
+
│ ├── models/ # Data models and schemas
|
|
102
|
+
│ │ ├── response-schemas.ts # API response schemas
|
|
103
|
+
│ │ ├── resource-models.ts # Resource models
|
|
104
|
+
│ │ └── tool-models.ts # Tool schemas
|
|
105
|
+
│ ├── utils/ # Utility classes
|
|
106
|
+
│ │ └── kubernetes-manager.ts # K8s management
|
|
107
|
+
│ ├── resources/ # Resource handlers
|
|
108
|
+
│ │ └── handlers.ts # Resource implementation
|
|
109
|
+
│ └── tools/ # Tool implementations
|
|
110
|
+
│ ├── list_pods.ts
|
|
111
|
+
│ ├── list_services.ts
|
|
112
|
+
│ ├── list_deployments.ts
|
|
113
|
+
│ └── ...
|
|
114
|
+
├── tests/ # Test files
|
|
115
|
+
│ └── unit.test.ts # Unit tests
|
|
116
|
+
│ └── helm.test.ts # Helm tests
|
|
117
|
+
└── ...
|
|
90
118
|
```
|
|
91
119
|
|
|
92
120
|
### Contributing
|
|
@@ -98,7 +126,7 @@ src/
|
|
|
98
126
|
5. Ensure all tests pass
|
|
99
127
|
6. Submit a pull request
|
|
100
128
|
|
|
101
|
-
For bigger changes
|
|
129
|
+
For bigger changes please open an issue first to discuss the proposed changes.
|
|
102
130
|
|
|
103
131
|
## Architecture
|
|
104
132
|
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import * as k8s from "@kubernetes/client-node";
|
|
3
|
+
export declare const ContainerTemplate: z.ZodEnum<["ubuntu", "nginx", "busybox", "alpine"]>;
|
|
4
|
+
export type ContainerTemplateName = z.infer<typeof ContainerTemplate>;
|
|
5
|
+
export declare const containerTemplates: Record<string, k8s.V1Container>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// Container template types
|
|
3
|
+
export const ContainerTemplate = z.enum([
|
|
4
|
+
"ubuntu",
|
|
5
|
+
"nginx",
|
|
6
|
+
"busybox",
|
|
7
|
+
"alpine",
|
|
8
|
+
]);
|
|
9
|
+
// Container template configurations with resource limits and settings
|
|
10
|
+
export const containerTemplates = {
|
|
11
|
+
ubuntu: {
|
|
12
|
+
name: "main",
|
|
13
|
+
image: "ubuntu:latest",
|
|
14
|
+
command: ["/bin/bash"],
|
|
15
|
+
args: ["-c", "sleep infinity"],
|
|
16
|
+
resources: {
|
|
17
|
+
limits: {
|
|
18
|
+
cpu: "200m",
|
|
19
|
+
memory: "256Mi",
|
|
20
|
+
},
|
|
21
|
+
requests: {
|
|
22
|
+
cpu: "100m",
|
|
23
|
+
memory: "128Mi",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
livenessProbe: {
|
|
27
|
+
exec: {
|
|
28
|
+
command: ["cat", "/proc/1/status"],
|
|
29
|
+
},
|
|
30
|
+
initialDelaySeconds: 5,
|
|
31
|
+
periodSeconds: 10,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
nginx: {
|
|
35
|
+
name: "main",
|
|
36
|
+
image: "nginx:latest",
|
|
37
|
+
ports: [{ containerPort: 80 }],
|
|
38
|
+
resources: {
|
|
39
|
+
limits: {
|
|
40
|
+
cpu: "200m",
|
|
41
|
+
memory: "256Mi",
|
|
42
|
+
},
|
|
43
|
+
requests: {
|
|
44
|
+
cpu: "100m",
|
|
45
|
+
memory: "128Mi",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
livenessProbe: {
|
|
49
|
+
httpGet: {
|
|
50
|
+
path: "/",
|
|
51
|
+
port: 80,
|
|
52
|
+
},
|
|
53
|
+
initialDelaySeconds: 5,
|
|
54
|
+
periodSeconds: 10,
|
|
55
|
+
},
|
|
56
|
+
readinessProbe: {
|
|
57
|
+
httpGet: {
|
|
58
|
+
path: "/",
|
|
59
|
+
port: 80,
|
|
60
|
+
},
|
|
61
|
+
initialDelaySeconds: 2,
|
|
62
|
+
periodSeconds: 5,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
busybox: {
|
|
66
|
+
name: "main",
|
|
67
|
+
image: "busybox:latest",
|
|
68
|
+
command: ["sh"],
|
|
69
|
+
args: ["-c", "sleep infinity"],
|
|
70
|
+
resources: {
|
|
71
|
+
limits: {
|
|
72
|
+
cpu: "100m",
|
|
73
|
+
memory: "64Mi",
|
|
74
|
+
},
|
|
75
|
+
requests: {
|
|
76
|
+
cpu: "50m",
|
|
77
|
+
memory: "32Mi",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
livenessProbe: {
|
|
81
|
+
exec: {
|
|
82
|
+
command: ["true"],
|
|
83
|
+
},
|
|
84
|
+
periodSeconds: 10,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
alpine: {
|
|
88
|
+
name: "main",
|
|
89
|
+
image: "alpine:latest",
|
|
90
|
+
command: ["sh"],
|
|
91
|
+
args: ["-c", "sleep infinity"],
|
|
92
|
+
resources: {
|
|
93
|
+
limits: {
|
|
94
|
+
cpu: "100m",
|
|
95
|
+
memory: "64Mi",
|
|
96
|
+
},
|
|
97
|
+
requests: {
|
|
98
|
+
cpu: "50m",
|
|
99
|
+
memory: "32Mi",
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
livenessProbe: {
|
|
103
|
+
exec: {
|
|
104
|
+
command: ["true"],
|
|
105
|
+
},
|
|
106
|
+
periodSeconds: 10,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const createDeploymentSchema: {
|
|
2
|
+
readonly name: "create_deployment";
|
|
3
|
+
readonly description: "Create a new Kubernetes deployment";
|
|
4
|
+
readonly inputSchema: {
|
|
5
|
+
readonly type: "object";
|
|
6
|
+
readonly properties: {
|
|
7
|
+
readonly name: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
};
|
|
10
|
+
readonly namespace: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
};
|
|
13
|
+
readonly template: {
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
readonly enum: ["ubuntu", "nginx", "busybox", "alpine"];
|
|
16
|
+
};
|
|
17
|
+
readonly replicas: {
|
|
18
|
+
readonly type: "number";
|
|
19
|
+
readonly default: 1;
|
|
20
|
+
};
|
|
21
|
+
readonly ports: {
|
|
22
|
+
readonly type: "array";
|
|
23
|
+
readonly items: {
|
|
24
|
+
readonly type: "number";
|
|
25
|
+
};
|
|
26
|
+
readonly optional: true;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
readonly required: readonly ["name", "namespace", "template"];
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ContainerTemplate } from "./container-templates.js";
|
|
2
|
+
export const createDeploymentSchema = {
|
|
3
|
+
name: "create_deployment",
|
|
4
|
+
description: "Create a new Kubernetes deployment",
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object",
|
|
7
|
+
properties: {
|
|
8
|
+
name: { type: "string" },
|
|
9
|
+
namespace: { type: "string" },
|
|
10
|
+
template: {
|
|
11
|
+
type: "string",
|
|
12
|
+
enum: ContainerTemplate.options,
|
|
13
|
+
},
|
|
14
|
+
replicas: { type: "number", default: 1 },
|
|
15
|
+
ports: {
|
|
16
|
+
type: "array",
|
|
17
|
+
items: { type: "number" },
|
|
18
|
+
optional: true,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
required: ["name", "namespace", "template"],
|
|
22
|
+
},
|
|
23
|
+
};
|