mcp-server-kubernetes 0.1.5 → 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.
Files changed (49) hide show
  1. package/README.md +29 -9
  2. package/dist/config/cleanup-config.d.ts +8 -0
  3. package/dist/config/cleanup-config.js +8 -0
  4. package/dist/config/container-templates.d.ts +5 -0
  5. package/dist/config/container-templates.js +109 -0
  6. package/dist/config/deployment-config.d.ts +31 -0
  7. package/dist/config/deployment-config.js +23 -0
  8. package/dist/config/namespace-config.d.ts +8 -0
  9. package/dist/config/namespace-config.js +8 -0
  10. package/dist/config/server-config.d.ts +8 -0
  11. package/dist/config/server-config.js +8 -0
  12. package/dist/index.js +49 -928
  13. package/dist/models/helm-models.d.ts +39 -0
  14. package/dist/models/helm-models.js +8 -0
  15. package/dist/models/resource-models.d.ts +94 -0
  16. package/dist/models/resource-models.js +17 -0
  17. package/dist/models/response-schemas.d.ts +221 -0
  18. package/dist/models/response-schemas.js +36 -0
  19. package/dist/models/tool-models.d.ts +42 -0
  20. package/dist/models/tool-models.js +10 -0
  21. package/dist/resources/handlers.d.ts +22 -0
  22. package/dist/resources/handlers.js +112 -0
  23. package/dist/tools/create_pod.d.ts +39 -0
  24. package/dist/tools/create_pod.js +71 -0
  25. package/dist/tools/delete_pod.d.ts +31 -0
  26. package/dist/tools/delete_pod.js +45 -0
  27. package/dist/tools/describe_pod.d.ts +33 -0
  28. package/dist/tools/describe_pod.js +81 -0
  29. package/dist/tools/get_logs.d.ts +67 -0
  30. package/dist/tools/get_logs.js +150 -0
  31. package/dist/tools/helm-operations.d.ts +99 -0
  32. package/dist/tools/helm-operations.js +198 -0
  33. package/dist/tools/list_deployments.d.ts +23 -0
  34. package/dist/tools/list_deployments.js +30 -0
  35. package/dist/tools/list_nodes.d.ts +15 -0
  36. package/dist/tools/list_nodes.js +21 -0
  37. package/dist/tools/list_pods.d.ts +23 -0
  38. package/dist/tools/list_pods.js +29 -0
  39. package/dist/tools/list_services.d.ts +23 -0
  40. package/dist/tools/list_services.js +31 -0
  41. package/dist/types.d.ts +4 -433
  42. package/dist/types.js +6 -120
  43. package/dist/utils/kubernetes-manager.d.ts +21 -0
  44. package/dist/utils/kubernetes-manager.js +68 -0
  45. package/package.json +3 -2
  46. package/dist/helm.test.d.ts +0 -1
  47. package/dist/helm.test.js +0 -208
  48. package/dist/unit.test.d.ts +0 -1
  49. package/dist/unit.test.js +0 -293
package/README.md CHANGED
@@ -24,11 +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)
27
+ 4. Helm v3 installed and in your PATH (no Tiller required). Optional if you don't plan to use Helm.
28
28
 
29
29
  You can verify your connection by asking Claude to list your pods or create a test deployment.
30
30
 
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
+ 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.
32
32
 
33
33
  ## Features
34
34
 
@@ -41,7 +41,7 @@ If you have errors, open up a standard terminal and run `kubectl get pods` to se
41
41
  - [x] Delete a pod
42
42
  - [x] Describe a pod
43
43
  - [x] List all namespaces
44
- - [x] Get logs from a pod for debugging (supports pods, deployments, jobs, and label selectors)
44
+ - [x] Get logs from a pod for debugging (supports pods deployments jobs and label selectors)
45
45
  - [x] Support Helm v3 for installing charts
46
46
  - Install charts with custom values
47
47
  - Uninstall releases
@@ -90,11 +90,31 @@ npx @modelcontextprotocol/inspector node build/index.js
90
90
  ### Project Structure
91
91
 
92
92
  ```
93
- src/
94
- ├── index.ts # Main server implementation
95
- ├── types.ts # TypeScript type definitions
96
- ├── helm.test.ts # Helm chart installation tests
97
- └── unit.test.ts # Unit tests
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
+ └── ...
98
118
  ```
99
119
 
100
120
  ### Contributing
@@ -106,7 +126,7 @@ src/
106
126
  5. Ensure all tests pass
107
127
  6. Submit a pull request
108
128
 
109
- For bigger changes, please open an issue first to discuss the proposed changes.
129
+ For bigger changes please open an issue first to discuss the proposed changes.
110
130
 
111
131
  ## Architecture
112
132
 
@@ -0,0 +1,8 @@
1
+ export declare const cleanupSchema: {
2
+ readonly name: "cleanup";
3
+ readonly description: "Cleanup all managed resources";
4
+ readonly inputSchema: {
5
+ readonly type: "object";
6
+ readonly properties: {};
7
+ };
8
+ };
@@ -0,0 +1,8 @@
1
+ export const cleanupSchema = {
2
+ name: "cleanup",
3
+ description: "Cleanup all managed resources",
4
+ inputSchema: {
5
+ type: "object",
6
+ properties: {},
7
+ },
8
+ };
@@ -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
+ };
@@ -0,0 +1,8 @@
1
+ export declare const listNamespacesSchema: {
2
+ readonly name: "list_namespaces";
3
+ readonly description: "List all namespaces";
4
+ readonly inputSchema: {
5
+ readonly type: "object";
6
+ readonly properties: {};
7
+ };
8
+ };
@@ -0,0 +1,8 @@
1
+ export const listNamespacesSchema = {
2
+ name: "list_namespaces",
3
+ description: "List all namespaces",
4
+ inputSchema: {
5
+ type: "object",
6
+ properties: {},
7
+ },
8
+ };
@@ -0,0 +1,8 @@
1
+ export declare const serverConfig: {
2
+ readonly name: "kubernetes";
3
+ readonly version: "0.1.0";
4
+ readonly capabilities: {
5
+ readonly resources: {};
6
+ readonly tools: {};
7
+ };
8
+ };
@@ -0,0 +1,8 @@
1
+ export const serverConfig = {
2
+ name: "kubernetes",
3
+ version: "0.1.0",
4
+ capabilities: {
5
+ resources: {},
6
+ tools: {},
7
+ },
8
+ };