You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MKP is a Model Context Protocol (MCP) server for Kubernetes that allows LLM-powered applications to interact with Kubernetes clusters. It provides tools for listing and applying Kubernetes resources through the MCP protocol.
7
+
MKP is a Model Context Protocol (MCP) server for Kubernetes that allows
8
+
LLM-powered applications to interact with Kubernetes clusters. It provides tools
9
+
for listing and applying Kubernetes resources through the MCP protocol.
8
10
9
11
## Features
10
12
@@ -20,33 +22,39 @@ MKP is a Model Context Protocol (MCP) server for Kubernetes that allows LLM-powe
20
22
21
23
## Why MKP?
22
24
23
-
MKP offers several key advantages as a Model Context Protocol server for Kubernetes:
25
+
MKP offers several key advantages as a Model Context Protocol server for
26
+
Kubernetes:
24
27
25
28
### Native Go Implementation
29
+
26
30
- Built with the same language as Kubernetes itself
27
31
- Excellent performance characteristics for server applications
28
32
- Strong type safety and concurrency support
29
33
- Seamless integration with Kubernetes libraries
30
34
31
35
### Direct API Integration
36
+
32
37
- Uses Kubernetes API machinery directly without external dependencies
33
38
- No reliance on kubectl, helm, or other CLI tools
34
39
- Communicates directly with the Kubernetes API server
35
40
- Reduced overhead and improved reliability
36
41
37
42
### Universal Resource Support
43
+
38
44
- Works with any Kubernetes resource type through the unstructured client
39
45
- No hardcoded resource schemas or specialized handlers needed
@@ -110,6 +119,7 @@ The MKP server provides the following MCP tools:
110
119
Get a Kubernetes resource or its subresource.
111
120
112
121
Parameters:
122
+
113
123
-`resource_type` (required): Type of resource to get (clustered or namespaced)
114
124
-`group`: API group (e.g., apps, networking.k8s.io)
115
125
-`version` (required): API version (e.g., v1, v1beta1)
@@ -160,6 +170,7 @@ Example of getting logs from a specific container with parameters:
160
170
```
161
171
162
172
Available parameters for pod logs:
173
+
163
174
-`container`: Specify which container to get logs from
164
175
-`previous`: Get logs from previous container instance (true/false)
165
176
-`sinceSeconds`: Only return logs newer than a relative duration in seconds
@@ -168,16 +179,21 @@ Available parameters for pod logs:
168
179
-`limitBytes`: Maximum number of bytes to return
169
180
-`tailLines`: Number of lines to return from the end of the logs
170
181
171
-
By default, pod logs are limited to the last 100 lines and 32KB to avoid overwhelming the LLM's context window. These defaults can be overridden using the parameters above.
182
+
By default, pod logs are limited to the last 100 lines and 32KB to avoid
183
+
overwhelming the LLM's context window. These defaults can be overridden using
184
+
the parameters above.
172
185
173
186
Available parameters for regular resources:
174
-
-`resourceVersion`: When specified, shows the resource at that particular version
187
+
188
+
-`resourceVersion`: When specified, shows the resource at that particular
189
+
version
175
190
176
191
#### list_resources
177
192
178
193
Lists Kubernetes resources of a specific type.
179
194
180
195
Parameters:
196
+
181
197
-`resource_type` (required): Type of resource to list (clustered or namespaced)
182
198
-`group`: API group (e.g., apps, networking.k8s.io)
183
199
-`version` (required): API version (e.g., v1, v1beta1)
@@ -204,7 +220,9 @@ Example:
204
220
Applies (creates or updates) a Kubernetes resource.
205
221
206
222
Parameters:
207
-
-`resource_type` (required): Type of resource to apply (clustered or namespaced)
223
+
224
+
-`resource_type` (required): Type of resource to apply (clustered or
225
+
namespaced)
208
226
-`group`: API group (e.g., apps, networking.k8s.io)
209
227
-`version` (required): API version (e.g., v1, v1beta1)
210
228
-`resource` (required): Resource name (e.g., deployments, services)
@@ -264,10 +282,13 @@ Example:
264
282
265
283
#### post_resource
266
284
267
-
Posts to a Kubernetes resource or its subresource, particularly useful for executing commands in pods.
285
+
Posts to a Kubernetes resource or its subresource, particularly useful for
286
+
executing commands in pods.
268
287
269
288
Parameters:
270
-
-`resource_type` (required): Type of resource to post to (clustered or namespaced)
289
+
290
+
-`resource_type` (required): Type of resource to post to (clustered or
291
+
namespaced)
271
292
-`group`: API group (e.g., apps, networking.k8s.io)
272
293
-`version` (required): API version (e.g., v1, v1beta1)
273
294
-`resource` (required): Resource name (e.g., deployments, services)
@@ -300,11 +321,16 @@ Example of executing a command in a pod:
300
321
```
301
322
302
323
The `body` for pod exec supports the following fields:
303
-
-`command` (required): Command to execute, either as a string or an array of strings
304
-
-`container` (optional): Container name to execute the command in (defaults to the first container)
305
-
-`timeout` (optional): Timeout in seconds (defaults to 15 seconds, maximum 60 seconds)
324
+
325
+
-`command` (required): Command to execute, either as a string or an array of
326
+
strings
327
+
-`container` (optional): Container name to execute the command in (defaults to
328
+
the first container)
329
+
-`timeout` (optional): Timeout in seconds (defaults to 15 seconds, maximum 60
330
+
seconds)
306
331
307
332
Note on timeouts:
333
+
308
334
- Default timeout: 15 seconds if not specified
309
335
- Maximum timeout: 60 seconds (any larger value will be capped)
310
336
- Commands that exceed the timeout will be terminated and return a timeout error
@@ -332,16 +358,20 @@ The response includes stdout, stderr, and any error message:
332
358
333
359
### MCP Resources
334
360
335
-
The MKP server provides access to Kubernetes resources through MCP resources. The resource URIs follow these formats:
361
+
The MKP server provides access to Kubernetes resources through MCP resources.
By default, MKP serves all Kubernetes resources as MCP resources, which provides useful context for LLMs. However, in large clusters with many resources, this can consume significant context space in the LLM.
372
+
By default, MKP serves all Kubernetes resources as MCP resources, which provides
373
+
useful context for LLMs. However, in large clusters with many resources, this
374
+
can consume significant context space in the LLM.
345
375
346
376
You can disable this behavior by using the `--serve-resources` flag:
347
377
@@ -353,11 +383,16 @@ You can disable this behavior by using the `--serve-resources` flag:
Even with resource discovery disabled, the MCP tools (`get_resource`, `list_resources`, `apply_resource`, `delete_resource`, and `post_resource`) remain fully functional, allowing you to interact with your Kubernetes cluster.
386
+
Even with resource discovery disabled, the MCP tools (`get_resource`,
387
+
`list_resources`, `apply_resource`, `delete_resource`, and `post_resource`)
388
+
remain fully functional, allowing you to interact with your Kubernetes cluster.
357
389
358
390
#### Enabling Write Operations
359
391
360
-
By default, MKP operates in read-only mode, meaning it does not allow write operations on the cluster, i.e. the `apply_resource`, `delete_resource`, and `post_resource` tools will not be available. You can enable write operations by using the `--read-write` flag:
392
+
By default, MKP operates in read-only mode, meaning it does not allow write
393
+
operations on the cluster, i.e. the `apply_resource`, `delete_resource`, and
394
+
`post_resource` tools will not be available. You can enable write operations by
395
+
using the `--read-write` flag:
361
396
362
397
```bash
363
398
# Run with write operations enabled
@@ -369,13 +404,18 @@ By default, MKP operates in read-only mode, meaning it does not allow write oper
369
404
370
405
### Rate Limiting
371
406
372
-
MKP includes a built-in rate limiting mechanism to protect the server from excessive API calls, which is particularly important when used with AI agents. The rate limiter uses a token bucket algorithm and applies different limits based on the operation type:
407
+
MKP includes a built-in rate limiting mechanism to protect the server from
408
+
excessive API calls, which is particularly important when used with AI agents.
409
+
The rate limiter uses a token bucket algorithm and applies different limits
410
+
based on the operation type:
373
411
374
412
- Read operations (list_resources, get_resource): 120 requests per minute
375
413
- Write operations (apply_resource, delete_resource): 30 requests per minute
376
414
- Default for other operations: 60 requests per minute
377
415
378
-
Rate limits are applied per client session, ensuring fair resource allocation across multiple clients. The rate limiting feature can be enabled or disabled via the command line flag:
416
+
Rate limits are applied per client session, ensuring fair resource allocation
417
+
across multiple clients. The rate limiting feature can be enabled or disabled
418
+
via the command line flag:
379
419
380
420
```bash
381
421
# Run with rate limiting enabled (default)
@@ -413,21 +453,26 @@ task deps
413
453
414
454
## Running as an MCP Server with ToolHive
415
455
416
-
MKP can be run as a Model Context Protocol (MCP) server using [ToolHive](https://github.com/stacklok/toolhive), which simplifies the deployment and management of MCP servers.
456
+
MKP can be run as a Model Context Protocol (MCP) server using
457
+
[ToolHive](https://github.com/stacklok/toolhive), which simplifies the
458
+
deployment and management of MCP servers.
417
459
418
460
### Prerequisites
419
461
420
-
1. Install ToolHive by following the [installation instructions](https://github.com/stacklok/toolhive#installation).
0 commit comments