Cover image
Try Now
2025-04-14

3 years

Works with Finder

0

Github Watches

0

Github Forks

0

Github Stars

EKS Model Context Protocol (MCP) Server

A lightweight, efficient server that implements the Model Context Protocol for EKS operations. This server provides a standardized interface for GenAI agents to interact with EKS clusters.

Features

  • Fast response times with proper timeout handling
  • Comprehensive EKS operations support
  • Kubernetes resource management (pods, services, deployments, etc.)
  • Multiple authentication methods for EKS clusters
  • Robust error handling and logging
  • Docker containerization for easy deployment
  • ECS deployment support

Project Structure

  • main.py: Main server implementation with FastAPI
  • eks_operations.py: EKS API operations implementation
  • k8s_operations.py: Kubernetes API operations implementation
  • k8s_operations_sdk_v4.py: SDK-based Kubernetes operations implementation
  • k8s_operations_kubectl.py: Kubectl-based Kubernetes operations with proper authentication
  • k8s_auth_config.py: Authentication configuration for Kubernetes
  • direct_k8s_client.py: Direct Kubernetes API client implementation
  • test_*.py: Various test scripts for different implementations
  • Dockerfile and Dockerfile.amd64: Docker configuration files
  • docker-compose.yml: Docker Compose configuration
  • requirements.txt: Python dependencies
  • client/: Client implementation directory (Client README)
  • ecs-deployment/: ECS deployment scripts and configuration (ECS Deployment README)

API Endpoints

  • GET /health - Health check endpoint
  • GET /mcp/v1/operations - List available operations
  • POST /mcp/v1/query - Execute MCP operations

Supported Operations

EKS Cluster Operations

  • list_clusters - List EKS clusters in a region
  • describe_cluster - Get detailed information about a cluster
  • list_nodegroups - List nodegroups for a cluster
  • describe_nodegroup - Get detailed information about a nodegroup

Kubernetes Operations

  • list_namespaces - List Kubernetes namespaces
  • list_pods - List pods in a namespace
  • describe_pod - Get detailed information about a pod
  • get_deployments - List deployments in a namespace
  • describe_deployment - Get detailed information about a deployment
  • get_services - List services in a namespace
  • describe_service - Get detailed information about a service
  • get_pod_logs - Get logs from a pod

Authentication Methods

The server supports multiple authentication methods for EKS clusters:

  1. AWS SDK Authentication: Uses the AWS SDK to authenticate with EKS and get cluster information
  2. Kubectl with Generated Kubeconfig: Creates a temporary kubeconfig file and uses kubectl
  3. Direct Kubernetes API Calls: Makes direct API calls to the Kubernetes API server

The current implementation uses the Kubectl method with proper authentication, which provides the most reliable results.

Getting Started

Prerequisites

  • Docker
  • AWS credentials (for production use)
  • Python 3.8+ (for local development)

Running Locally

# Install dependencies
pip install -r requirements.txt

# Run the server
python main.py

Running with Docker

# Build the Docker image
docker build -t eks-mcp-server .

# Run the container
docker run -d -p 8000:8000 --name mcp-server eks-mcp-server

Running with Docker Compose

# Start the server
docker-compose up -d

# Stop the server
docker-compose down

Deploying to ECS

See the ECS Deployment README for detailed instructions.

# Deploy to ECS
cd ecs-deployment
./deploy.sh

# Update existing ECS deployment
./update-service.sh

Testing

Use the included test scripts to verify the server is working correctly:

# Basic tests
python test_mcp.py

# Comprehensive operation tests
python test_mcp_operations.py

# Test namespace integration
python test_mcp_namespace.py
python test_mcp_namespace_2.py

# Test kubectl integration
python test_kubectl_operations.py

# Test SDK v3 operations
python test_v3_operations.py

# Test SDK v4 operations
python test_v4_operations.py

Client Usage

The project includes a client implementation that uses Amazon Bedrock for conversational interaction with the MCP server. See the Client README for details.

# Run the client
cd client
python mcp_chat_client_v6.py

Example Requests

List Clusters

curl -X POST http://localhost:8000/mcp/v1/query \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-api-key" \
  -d '{
    "operation": "list_clusters",
    "parameters": {
      "region": "us-east-1"
    }
  }'

List Pods

curl -X POST http://localhost:8000/mcp/v1/query \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-api-key" \
  -d '{
    "operation": "list_pods",
    "parameters": {
      "cluster_name": "my-cluster",
      "namespace": "default",
      "region": "us-east-1"
    }
  }'

Architecture

The server is built with FastAPI and uses a combination of synchronous and asynchronous operations for improved performance. It includes:

  • Timeout handling for AWS API calls
  • Multiple authentication methods for EKS clusters
  • Comprehensive logging
  • Response time tracking
  • Error handling with detailed error codes

EKS Authentication

For the server to authenticate with EKS clusters, the ECS task role needs to be added to the EKS cluster's aws-auth ConfigMap. See the ECS Deployment README for detailed instructions.

Current Deployment

The server is currently deployed to ECS and accessible at:

Test Namespaces

The project includes test namespaces in the EKS cluster:

  • mcp-test-namespace: Contains a deployment with 2 nginx pods
  • mcp-test-namespace-2: Contains a deployment with 3 nginx pods

License

MIT

相关推荐

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

  • rulego
  • ⛓️Rulego是一种轻巧,高性能,嵌入式,下一代组件编排规则引擎框架。

  • sigoden
  • 使用普通的bash/javascript/python函数轻松创建LLM工具和代理。

  • hkr04
  • 轻巧的C ++ MCP(模型上下文协议)SDK

  • RockChinQ
  • 😎简单易用、🧩丰富生态 -大模型原生即时通信机器人平台| 适配QQ / 微信(企业微信、个人微信) /飞书 /钉钉 / discord / telegram / slack等平台| 支持chatgpt,deepseek,dify,claude,基于LLM的即时消息机器人平台,支持Discord,Telegram,微信,Lark,Dingtalk,QQ,Slack

  • dmayboroda
  • 带有可配置容器的本地对话抹布

  • paulwing
  • 使用MCP服务创建的测试存储库

    Reviews

    2.4 (7)
    Avatar
    user_vMhcsPzx
    2025-04-24

    I've been using eks-mcp-server-new from mahmoudsalah84 and it's been fantastic! The server is robust and reliable, making my MCP applications run seamlessly. The user interface is intuitive, and the support documentation is incredibly helpful. Highly recommend it to anyone looking for a top-notch MCP server solution!

    Avatar
    user_E7cj0Mnr
    2025-04-24

    As an avid user of MCP applications, I am thrilled with the eks-mcp-server-new by mahmoudsalah84. It's a well-constructed server solution that has significantly simplified my workflow. The interface is intuitive, and the setup process was seamless. This product stands out for its reliability and efficiency. Highly recommend it for anyone looking to enhance their server management experience!

    Avatar
    user_uALWrSLD
    2025-04-24

    I've been using eks-mcp-server-new by mahmoudsalah84 and it has significantly streamlined my workflow. It provides robust functionalities and integrates seamlessly into my existing setup. The user interface is intuitive, making it accessible even for those new to MCP applications. Highly recommended for anyone looking to enhance their server management experience!

    Avatar
    user_nRRL2hjF
    2025-04-24

    As a dedicated user of the mcp application, I must say that the eks-mcp-server-new by mahmoudsalah84 is a remarkable addition. It integrates seamlessly into my workflow, providing a smooth and efficient experience. The server's performance is outstanding, ensuring reliability and speed. Highly recommended for anyone looking to enhance their mcp-based projects!

    Avatar
    user_jQsJyKrk
    2025-04-24

    The eks-mcp-server-new by mahmoudsalah84 is an outstanding tool for managing and deploying Kubernetes clusters. The integration with existing MCP applications is seamless, and the user interface is intuitive. It greatly simplifies cluster management tasks and boosts productivity. Highly recommended for developers looking to streamline their Kubernetes workflows!

    Avatar
    user_Na8nVY6w
    2025-04-24

    I've been using eks-mcp-server-new by mahmoudsalah84, and it's been a game-changer for my Kubernetes management. The intuitive interface and powerful features make it easy to deploy, scale, and manage clusters seamlessly. Highly recommend this tool for developers and DevOps professionals looking to streamline their workflows!

    Avatar
    user_VZYICf7M
    2025-04-24

    As a loyal user of MCP applications, I am thoroughly impressed by the eks-mcp-server-new. Developed by mahmoudsalah84, this product has significantly streamlined my server management tasks. The user interface is intuitive, and the performance improvements have been noticeable. I highly recommend it to anyone in need of an efficient and reliable server management tool.