Skip to content

Commit 0c2d60f

Browse files
authored
Merge pull request #60 from StacklokLabs/update-readme
Update README
2 parents 45858da + 032af6a commit 0c2d60f

File tree

1 file changed

+92
-42
lines changed

1 file changed

+92
-42
lines changed

README.md

Lines changed: 92 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
<img src="docs/assets/mkp-logo.png" width="400" alt="MKP Logo">
55
</p>
66

7-
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.
810

911
## Features
1012

@@ -20,33 +22,39 @@ MKP is a Model Context Protocol (MCP) server for Kubernetes that allows LLM-powe
2022

2123
## Why MKP?
2224

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:
2427

2528
### Native Go Implementation
29+
2630
- Built with the same language as Kubernetes itself
2731
- Excellent performance characteristics for server applications
2832
- Strong type safety and concurrency support
2933
- Seamless integration with Kubernetes libraries
3034

3135
### Direct API Integration
36+
3237
- Uses Kubernetes API machinery directly without external dependencies
3338
- No reliance on kubectl, helm, or other CLI tools
3439
- Communicates directly with the Kubernetes API server
3540
- Reduced overhead and improved reliability
3641

3742
### Universal Resource Support
43+
3844
- Works with any Kubernetes resource type through the unstructured client
3945
- No hardcoded resource schemas or specialized handlers needed
4046
- Automatically supports Custom Resource Definitions (CRDs)
4147
- Future-proof for new Kubernetes resources
4248

4349
### Minimalist Design
50+
4451
- Focused on core Kubernetes resource operations
4552
- Clean, maintainable codebase with clear separation of concerns
4653
- Lightweight with minimal dependencies
4754
- Easy to understand, extend, and contribute to
4855

4956
### Production-Ready Architecture
57+
5058
- Designed for reliability and performance in production environments
5159
- Proper error handling and resource management
5260
- Built-in rate limiting to protect against excessive API calls
@@ -63,22 +71,22 @@ MKP offers several key advantages as a Model Context Protocol server for Kuberne
6371

6472
1. Clone the repository:
6573

66-
```bash
67-
git clone https://github.com/StacklokLabs/mkp.git
68-
cd mkp
69-
```
74+
```bash
75+
git clone https://github.com/StacklokLabs/mkp.git
76+
cd mkp
77+
```
7078

7179
2. Install dependencies:
7280

73-
```bash
74-
task install
75-
```
81+
```bash
82+
task install
83+
```
7684

7785
3. Build the server:
7886

79-
```bash
80-
task build
81-
```
87+
```bash
88+
task build
89+
```
8290

8391
## Usage
8492

@@ -97,6 +105,7 @@ KUBECONFIG=/path/to/kubeconfig task run-with-kubeconfig
97105
```
98106

99107
To run the server on a specific port:
108+
100109
```bash
101110
MCP_PORT=9091 task run
102111
```
@@ -110,6 +119,7 @@ The MKP server provides the following MCP tools:
110119
Get a Kubernetes resource or its subresource.
111120

112121
Parameters:
122+
113123
- `resource_type` (required): Type of resource to get (clustered or namespaced)
114124
- `group`: API group (e.g., apps, networking.k8s.io)
115125
- `version` (required): API version (e.g., v1, v1beta1)
@@ -160,6 +170,7 @@ Example of getting logs from a specific container with parameters:
160170
```
161171

162172
Available parameters for pod logs:
173+
163174
- `container`: Specify which container to get logs from
164175
- `previous`: Get logs from previous container instance (true/false)
165176
- `sinceSeconds`: Only return logs newer than a relative duration in seconds
@@ -168,16 +179,21 @@ Available parameters for pod logs:
168179
- `limitBytes`: Maximum number of bytes to return
169180
- `tailLines`: Number of lines to return from the end of the logs
170181

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.
172185

173186
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
175190

176191
#### list_resources
177192

178193
Lists Kubernetes resources of a specific type.
179194

180195
Parameters:
196+
181197
- `resource_type` (required): Type of resource to list (clustered or namespaced)
182198
- `group`: API group (e.g., apps, networking.k8s.io)
183199
- `version` (required): API version (e.g., v1, v1beta1)
@@ -204,7 +220,9 @@ Example:
204220
Applies (creates or updates) a Kubernetes resource.
205221

206222
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)
208226
- `group`: API group (e.g., apps, networking.k8s.io)
209227
- `version` (required): API version (e.g., v1, v1beta1)
210228
- `resource` (required): Resource name (e.g., deployments, services)
@@ -264,10 +282,13 @@ Example:
264282

265283
#### post_resource
266284

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.
268287

269288
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)
271292
- `group`: API group (e.g., apps, networking.k8s.io)
272293
- `version` (required): API version (e.g., v1, v1beta1)
273294
- `resource` (required): Resource name (e.g., deployments, services)
@@ -300,11 +321,16 @@ Example of executing a command in a pod:
300321
```
301322

302323
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)
306331

307332
Note on timeouts:
333+
308334
- Default timeout: 15 seconds if not specified
309335
- Maximum timeout: 60 seconds (any larger value will be capped)
310336
- 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:
332358

333359
### MCP Resources
334360

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.
362+
The resource URIs follow these formats:
336363

337364
- Clustered resources: `k8s://clustered/{group}/{version}/{resource}/{name}`
338-
- Namespaced resources: `k8s://namespaced/{namespace}/{group}/{version}/{resource}/{name}`
365+
- Namespaced resources:
366+
`k8s://namespaced/{namespace}/{group}/{version}/{resource}/{name}`
339367

340368
### Configuration
341369

342370
#### Controlling Resource Discovery
343371

344-
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.
345375

346376
You can disable this behavior by using the `--serve-resources` flag:
347377

@@ -353,11 +383,16 @@ You can disable this behavior by using the `--serve-resources` flag:
353383
./build/mkp-server --kubeconfig=/path/to/kubeconfig --serve-resources=false
354384
```
355385

356-
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.
357389

358390
#### Enabling Write Operations
359391

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:
361396

362397
```bash
363398
# Run with write operations enabled
@@ -369,13 +404,18 @@ By default, MKP operates in read-only mode, meaning it does not allow write oper
369404

370405
### Rate Limiting
371406

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:
373411

374412
- Read operations (list_resources, get_resource): 120 requests per minute
375413
- Write operations (apply_resource, delete_resource): 30 requests per minute
376414
- Default for other operations: 60 requests per minute
377415

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:
379419

380420
```bash
381421
# Run with rate limiting enabled (default)
@@ -413,21 +453,26 @@ task deps
413453

414454
## Running as an MCP Server with ToolHive
415455

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.
417459

418460
### Prerequisites
419461

420-
1. Install ToolHive by following the [installation instructions](https://github.com/stacklok/toolhive#installation).
462+
1. Install ToolHive by following the
463+
[installation instructions](https://docs.stacklok.com/toolhive/guides-cli/install).
421464
2. Ensure you have Docker or Podman installed on your system.
422-
3. Configure your Kubernetes credentials (kubeconfig) for the cluster you want to interact with.
465+
3. Configure your Kubernetes credentials (kubeconfig) for the cluster you want
466+
to interact with.
423467

424468
### Running MKP with ToolHive (Recommended)
425469

426-
The easiest way to run MKP is using the packaged version available in ToolHive's registry:
470+
The easiest way to run MKP is using the packaged version available in ToolHive's
471+
registry:
427472

428473
```bash
429-
# Enable auto-discovery to automatically configure supported clients
430-
thv config auto-discovery true
474+
# Register a supported client so ToolHive can auto-configure your environment
475+
thv client setup
431476

432477
# Run the MKP server (packaged as 'k8s' in ToolHive)
433478
# Mount your kubeconfig so the server can access your Kubernetes cluster
@@ -440,18 +485,21 @@ thv list
440485
thv registry info k8s
441486
```
442487

443-
This will mount your Kubernetes credentials and make the server available to your MCP-compatible clients.
488+
This will mount your Kubernetes credentials and make the server available to
489+
your MCP-compatible clients.
444490

445491
### Advanced Usage with Custom Configuration
446492

447-
For advanced users who need custom configuration, you can also run MKP using the container image directly:
493+
For advanced users who need custom configuration, you can also run MKP using the
494+
container image directly:
448495

449496
```bash
450497
# Run the MKP server using the published container image
451498
thv run --name mkp --transport sse --target-port 8080 --volume $HOME/.kube:/home/nonroot/.kube:ro ghcr.io/stackloklabs/mkp/server:latest
452499
```
453500

454501
This command:
502+
455503
- Names the server instance "mkp"
456504
- Uses the SSE transport protocol
457505
- Mounts your local kubeconfig into the container (read-only)
@@ -471,7 +519,8 @@ To verify that the MKP server is running:
471519
thv list
472520
```
473521

474-
This will show all running MCP servers managed by ToolHive, including the MKP server.
522+
This will show all running MCP servers managed by ToolHive, including the MKP
523+
server.
475524

476525
To stop the MKP server:
477526

@@ -493,17 +542,18 @@ thv rm k8s
493542
thv rm mkp
494543
```
495544

496-
497545
## Contributing
498546

499-
We welcome contributions to this MCP server! If you'd like to contribute, please review
500-
the [CONTRIBUTING guide](./CONTRIBUTING.md) for details on how to get started.
547+
We welcome contributions to this MCP server! If you'd like to contribute, please
548+
review the [CONTRIBUTING guide](./CONTRIBUTING.md) for details on how to get
549+
started.
501550

502551
If you run into a bug or have a feature request, please
503-
[open an issue](https://github.com/StacklokLabs/mkp/issues) in the
504-
repository or join us in the `#mcp-servers` channel on our
552+
[open an issue](https://github.com/StacklokLabs/mkp/issues) in the repository or
553+
join us in the `#mcp-servers` channel on our
505554
[community Discord server](https://discord.gg/stacklok).
506555

507556
## License
508557

509-
This project is licensed under the Apache v2 License - see the LICENSE file for details.
558+
This project is licensed under the Apache v2 License - see the LICENSE file for
559+
details.

0 commit comments

Comments
 (0)