|
| 1 | +# eksctl MCP (Model Context Protocol) Package |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The `pkg/ctl/mcp` package implements a [Model Context Protocol (MCP)](https://github.com/modelcontextprotocol) server for eksctl. This server enables AI assistants like Amazon Q to interact with eksctl functionality directly through a standardized protocol, allowing for seamless integration of eksctl commands into AI-powered workflows. |
| 6 | + |
| 7 | +## What is MCP? |
| 8 | + |
| 9 | +Model Context Protocol (MCP) is an open protocol that standardizes how applications provide context and tools to Large Language Models (LLMs). It enables AI assistants to: |
| 10 | + |
| 11 | +1. Discover available tools and their capabilities |
| 12 | +2. Execute commands and receive structured responses |
| 13 | +3. Provide contextual information to enhance AI interactions |
| 14 | + |
| 15 | +## How the eksctl MCP Server Works |
| 16 | + |
| 17 | +The eksctl MCP server exposes all eksctl commands as tools that can be invoked by AI assistants. The implementation consists of several key components: |
| 18 | + |
| 19 | +### Core Components |
| 20 | + |
| 21 | +1. **`mcp.go`**: Entry point that defines the `mcp` command and starts the MCP server |
| 22 | +2. **`server.go`**: Creates and configures the MCP server with all eksctl commands |
| 23 | +3. **`tools.go`**: Handles the registration of eksctl commands as MCP tools |
| 24 | +4. **`types.go`**: Defines types and interfaces used by the MCP implementation |
| 25 | + |
| 26 | +### Implementation Details |
| 27 | + |
| 28 | +- The server uses the `mcp-go` library to implement the Model Context Protocol |
| 29 | +- It dynamically registers all eksctl commands (create, get, delete, etc.) as MCP tools |
| 30 | +- Each command's help text, flags, and parameters are exposed through the protocol |
| 31 | +- The server runs as a stdio server, communicating through standard input/output |
| 32 | + |
| 33 | +### Command Registration Process |
| 34 | + |
| 35 | +1. The server recursively traverses the eksctl command tree |
| 36 | +2. For each command, it extracts: |
| 37 | + - Command description and usage information |
| 38 | + - Available flags and their descriptions |
| 39 | + - Required and optional parameters |
| 40 | + |
| 41 | +## Using the eksctl MCP Server with Amazon Q Chat |
| 42 | + |
| 43 | +To use the eksctl MCP server with Amazon Q Chat, you need to register it in the Amazon Q configuration file. |
| 44 | + |
| 45 | +Create or edit the file at `$HOME/.aws/amazonq/mcp.json` with the following content: |
| 46 | + |
| 47 | +```json |
| 48 | +{ |
| 49 | + "mcpServers": { |
| 50 | + "eks-tools": { |
| 51 | + "command": "eksctl", |
| 52 | + "args": [ |
| 53 | + "mcp" |
| 54 | + ] |
| 55 | + } |
| 56 | + } |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +This configuration tells Amazon Q Chat to: |
| 61 | +1. Register a server named "eks-tools" |
| 62 | +2. Use the `eksctl mcp` command to start the MCP server |
| 63 | +3. Make all eksctl commands available as tools with the prefix `eks___` |
| 64 | + |
| 65 | +## Benefits |
| 66 | + |
| 67 | +- **Seamless Integration**: AI assistants can execute eksctl commands directly |
| 68 | +- **Structured Responses**: Commands return structured data that can be parsed by AI models |
| 69 | +- **Discoverability**: AI assistants can discover available commands and their parameters |
| 70 | +- **Context-Aware**: Provides rich context about EKS clusters and resources |
| 71 | + |
| 72 | +## Development |
| 73 | + |
| 74 | +When extending the MCP server functionality: |
| 75 | + |
| 76 | +1. Add new command registrations in `server.go` if new eksctl commands are created |
| 77 | +2. Extend type definitions in `types.go` as needed |
| 78 | +3. Modify `tools.go` if changes to tool registration logic are required |
| 79 | + |
| 80 | +## Example Usage in Amazon Q Chat |
| 81 | + |
| 82 | +Once configured, users can interact with eksctl through Amazon Q Chat: |
| 83 | + |
| 84 | +``` |
| 85 | +User: What EKS clusters do I have? |
| 86 | +Amazon Q: Let me check your EKS clusters. |
| 87 | +[Amazon Q executes the eksctl get cluster command and displays the results] |
| 88 | +
|
| 89 | +User: Create a new EKS cluster |
| 90 | +Amazon Q: [Guides the user through cluster creation using eksctl commands] |
| 91 | +``` |
| 92 | + |
| 93 | +The MCP server enables these interactions by providing Amazon Q with the ability to execute eksctl commands and interpret their results. |
| 94 | + |
| 95 | +## Quick test for MCP server |
| 96 | +To quickly test the MCP server, you can run the following command in your terminal: |
| 97 | + |
| 98 | +```bash |
| 99 | +echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | eksctl mcp | jq |
| 100 | +``` |
| 101 | + |
| 102 | +## Recommendations |
| 103 | +- Monitor background operations for long-running commands. Commands such as cluster creations have a 45-second timeout for command responses but the processes continue in background. |
0 commit comments