Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
Azure Kubernetes Service logo

Azure Kubernetes Service

ByAzure·93

Interact with Azure Kubernetes Service (AKS) from MCP clients.

The AKS-MCP is a Model Context Protocol (MCP) server that enables AI assistantsto interact with Azure Kubernetes Service (AKS) clusters. It serves as a bridgebetween AI tools (like GitHub Copilot, Claude, and other MCP-compatible AIassistants) and AKS, translating natural language requests into AKS operationsand returning the results in a format the AI tools can understand.

It allows AI tools to:

  • Operate (CRUD) AKS resources
  • Retrieve details related to AKS clusters (VNets, Subnets, NSGs, Route Tables, etc.)
  • Manage Azure Fleet operations for multi-cluster scenarios

How it works

AKS-MCP connects to Azure using the Azure SDK and provides a set of tools thatAI assistants can use to interact with AKS resources. It leverages the ModelContext Protocol (MCP) to facilitate this communication, enabling AI tools tomake API calls to Azure and interpret the responses.

Azure CLI Authentication

AKS-MCP uses Azure CLI (az) for AKS operations. Azure CLI authentication is attempted in this order:

  1. Service Principal (client secret): WhenAZURE_CLIENT_ID,AZURE_CLIENT_SECRET,AZURE_TENANT_ID environment variables are present, a service principal login is performed using the following command:az login --service-principal -u CLIENT_ID -p CLIENT_SECRET --tenant TENANT_ID

  2. Workload Identity (federated token): WhenAZURE_CLIENT_ID,AZURE_TENANT_ID,AZURE_FEDERATED_TOKEN_FILE environment variables are present, a federated token login is performed using the following command:az login --service-principal -u CLIENT_ID --tenant TENANT_ID --federated-token TOKEN

  3. User-assigned Managed Identity (managed identity client ID): When onlyAZURE_CLIENT_ID environment variable is present, a user-assigned managed identity login is performed using the following command:az login --identity -u CLIENT_ID

  4. System-assigned Managed Identity: WhenAZURE_MANAGED_IDENTITY is set tosystem, a system-assigned managed identity login is performed using the following command:az login --identity

  5. Existing Login: When none of the above environment variables are set, AKS-MCP assumes you have already authenticated (for example, viaaz login) and uses the existing session.

Optional subscription selection:

  • IfAZURE_SUBSCRIPTION_ID is set, AKS-MCP will runaz account set --subscription SUBSCRIPTION_ID after login.

Notes and security:

  • The federated token file must be exactly/var/run/secrets/azure/tokens/azure-identity-token and is strictly validated; other paths are rejected.
  • After each login, AKS-MCP verifies authentication withaz account show --query id -o tsv.
  • Ensure the Azure CLI is installed and on PATH.

Environment variables used:

  • AZURE_TENANT_ID
  • AZURE_CLIENT_ID
  • AZURE_CLIENT_SECRET
  • AZURE_FEDERATED_TOKEN_FILE
  • AZURE_SUBSCRIPTION_ID
  • AZURE_MANAGED_IDENTITY (set tosystem to opt into system-assigned managed identity)

Available Tools

The AKS-MCP server provides consolidated tools for interacting with AKSclusters. Some tools will require read-write or admin permissions to run debugging pods on your cluster. To enable read-write or admin permissions for the AKS-MCP server, add theaccess level parameter to your MCP configuration file:

  1. Navigate to yourmcp.json file, or go to MCP: List Servers -> AKS-MCP -> Show Configuration Details in theCommand Palette (Ctrl+Shift+P on Windows/Linux orCmd+Shift+P on macOS).
  2. In the "args" section of AKS-MCP, add the following parameters: "--access-level", "readwrite" / "admin"

For example:

"args": [  "--transport",  "stdio",  "--access-level",  "readwrite"]

These tools have been designed to provide comprehensive functionalitythrough unified interfaces:

AKS Cluster Management

Tool:az_aks_operations

Unified tool for managing Azure Kubernetes Service (AKS) clusters and related operations.

Available Operations:

  • Read-Only (all access levels):

    • show: Show cluster details
    • list: List clusters in subscription/resource group
    • get-versions: Get available Kubernetes versions
    • check-network: Perform outbound network connectivity check
    • nodepool-list: List node pools in cluster
    • nodepool-show: Show node pool details
    • account-list: List Azure subscriptions
  • Read-Write (readwrite/admin access levels):

    • create: Create new cluster
    • delete: Delete cluster
    • scale: Scale cluster node count
    • start: Start a stopped cluster
    • stop: Stop a running cluster
    • update: Update cluster configuration
    • upgrade: Upgrade Kubernetes version
    • nodepool-add: Add node pool to cluster
    • nodepool-delete: Delete node pool
    • nodepool-scale: Scale node pool
    • nodepool-upgrade: Upgrade node pool
    • account-set: Set active subscription
    • login: Azure authentication
  • Admin-Only (admin access level):

    • get-credentials: Get cluster credentials for kubectl access
Network Resource Management

Tool:az_network_resources

Unified tool for getting Azure network resource information used by AKS clusters.

Available Resource Types:

  • all: Get information about all network resources
  • vnet: Virtual Network information
  • subnet: Subnet information
  • nsg: Network Security Group information
  • route_table: Route Table information
  • load_balancer: Load Balancer information
  • private_endpoint: Private endpoint information
Monitoring and Diagnostics

Tool:az_monitoring

Unified tool for Azure monitoring and diagnostics operations for AKS clusters.

Available Operations:

  • metrics: List metric values for resources
  • resource_health: Retrieve resource health events for AKS clusters
  • app_insights: Execute KQL queries against Application Insights telemetry data
  • diagnostics: Check if AKS cluster has diagnostic settings configured
  • control_plane_logs: Query AKS control plane logs with safety constraintsand time range validation
Compute Resources

Tool:get_aks_vmss_info

  • Get detailed VMSS configuration for node pools in the AKS cluster

Tool:az_compute_operations

Unified tool for managing Azure Virtual Machines (VMs) and Virtual Machine Scale Sets (VMSS) used by AKS.

Available Operations:

  • show: Get details of a VM/VMSS
  • list: List VMs/VMSS in subscription or resource group
  • get-instance-view: Get runtime status
  • start: Start VM
  • stop: Stop VM
  • restart: Restart VM/VMSS instances
  • reimage: Reimage VMSS instances (VM not supported for reimage)

Resource Types:vm (single virtual machines),vmss (virtual machine scale sets)

Fleet Management

Tool:az_fleet

Comprehensive Azure Fleet management for multi-cluster scenarios.

Available Operations:

  • Fleet Operations: list, show, create, update, delete, get-credentials
  • Member Operations: list, show, create, update, delete
  • Update Run Operations: list, show, create, start, stop, delete
  • Update Strategy Operations: list, show, create, delete
  • ClusterResourcePlacement Operations: list, show, get, create, delete

Supports both Azure Fleet management and Kubernetes ClusterResourcePlacementCRD operations.

Diagnostic Detectors

Tool:list_detectors

  • List all available AKS cluster detectors

Tool:run_detector

  • Run a specific AKS diagnostic detector

Tool:run_detectors_by_category

  • Run all detectors in a specific category
  • Categories: Best Practices, Cluster and Control Plane Availability andPerformance, Connectivity Issues, Create/Upgrade/Delete and Scale,Deprecations, Identity and Security, Node Health, Storage
Azure Advisor

Tool:az_advisor_recommendation

Retrieve and manage Azure Advisor recommendations for AKS clusters.

Available Operations:

  • list: List recommendations with filtering options
  • report: Generate recommendation reports
  • Filter Options: resource_group, cluster_names, category (Cost,HighAvailability, Performance, Security), severity (High, Medium, Low)
Kubernetes Tools

Note: kubectl commands are available with all access levels. Additional toolsrequire explicit enablement via--additional-tools

kubectl Tools (Unified Interface):

  • Read-Only (all access levels):

    • kubectl_resources: View resources (get, describe) - filtered to read-only operations in readonly mode
    • kubectl_diagnostics: Debug and diagnose (logs, events, top, exec, cp)
    • kubectl_cluster: Cluster information (cluster-info, api-resources, api-versions, explain)
    • kubectl_config: Configuration management (diff, auth, config) - filtered to read-only operations in readonly mode
  • Read-Write/Admin (readwrite/admin access levels):

    • kubectl_resources: Full resource management (get, describe, create, delete, apply, patch, replace, cordon, uncordon, drain, taint)
    • kubectl_workloads: Workload lifecycle (run, expose, scale, autoscale, rollout)
    • kubectl_metadata: Metadata management (label, annotate, set)
    • kubectl_config: Full configuration management (diff, auth, certificate, config)

Additional Tools (Optional):

  • helm: Helm package manager (requires--additional-tools helm)
  • cilium: Cilium CLI for eBPF networking (requires--additional-tools cilium)
Real-time Observability

Tool:inspektor_gadget_observability

Real-time observability tool for Azure Kubernetes Service (AKS) clusters usingeBPF.

Available Actions:

  • deploy: Deploy Inspektor Gadget to cluster (requiresreadwrite/admin access)
  • undeploy: Remove Inspektor Gadget from cluster (requiresreadwrite/admin access)
  • is_deployed: Check deployment status
  • run: Run one-shot gadgets
  • start: Start continuous gadgets
  • stop: Stop running gadgets
  • get_results: Retrieve gadget results
  • list_gadgets: List available gadgets

Available Gadgets:

  • observe_dns: Monitor DNS requests and responses
  • observe_tcp: Monitor TCP connections
  • observe_file_open: Monitor file system operations
  • observe_process_execution: Monitor process execution
  • observe_signal: Monitor signal delivery
  • observe_system_calls: Monitor system calls
  • top_file: Top files by I/O operations
  • top_tcp: Top TCP connections by traffic

How to install

Prerequisites

  1. Set upAzure CLI and authenticate:

    az login

VS Code with GitHub Copilot (Recommended)

🚀 One-Click Installation with the AKS Extension

The easiest way to get started with AKS-MCP is through theAzure Kubernetes Service Extension for VS Code.

Step 1: Install the AKS Extension

  1. Open VS Code and go to Extensions (Ctrl+Shift+X on Windows/Linux orCmd+Shift+X on macOS).
  2. Search forAzure Kubernetes Service.
  3. Install the official Microsoft AKS extension.

Step 2: Launch the AKS-MCP Server

  1. Open theCommand Palette (Ctrl+Shift+P on Windows/Linux orCmd+Shift+P on macOS).
  2. Search and run:AKS: Setup AKS MCP Server.

Upon successful installation, the server will now be visible inMCP: List Servers (via Command Palette). From there, you can start the MCP server or view its status.

Step 3: Start Using AKS-MCP

Once started, the MCP server will appear in theCopilot Chat: Configure Tools dropdown underMCP Server: AKS MCP, ready to enhance contextual prompts based on your AKS environment. By default, all AKS-MCP server tools are enabled. You can review the list of available tools and disable any that are not required for your specific scenario.

Try a prompt like"List all my AKS clusters", which will start using tools from the AKS-MCP server.

WSL Configuration

The MCP configuration differs depending on whether VS Code is running on Windows or inside WSL:

🪟 Windows Host (VS Code on Windows): Use"command": "wsl" to invoke the WSL binary from Windows:

{"servers": {"aks-mcp": {"type":"stdio","command":"wsl","args": ["--","/home/you/.vs-kubernetes/tools/aks-mcp/aks-mcp","--transport","stdio"      ]    }  }}

🐧 Remote-WSL (VS Code running inside WSL): Call the binary directly or use a shell wrapper:

{"servers": {"aks-mcp": {"type":"stdio","command":"bash","args": ["-c","/home/you/.vs-kubernetes/tools/aks-mcp/aks-mcp --transport stdio"      ]    }  }}

🔧 Troubleshooting ENOENT Errors

If you see "spawn ENOENT" errors, verify your VS Code environment:

  • Windows host: Check if the WSL binary path is correct and accessible viawsl -- ls /path/to/aks-mcp
  • Remote-WSL: Do NOT use"command": "wsl" - use direct paths or bash wrapper as shown above

💡 Benefits: The AKS extension handles binary downloads, updates, and configuration automatically, ensuring you always have the latest version with optimal settings.

Alternative Installation Methods

Manual Binary Installation

Step 1: Download the Binary

Choose your platform and download the latest AKS-MCP binary:

PlatformArchitectureDownload Link
WindowsAMD64📥 aks-mcp-windows-amd64.exe
ARM64📥 aks-mcp-windows-arm64.exe
macOSIntel (AMD64)📥 aks-mcp-darwin-amd64
Apple Silicon (ARM64)📥 aks-mcp-darwin-arm64
LinuxAMD64📥 aks-mcp-linux-amd64
ARM64📥 aks-mcp-linux-arm64

Step 2: Configure VS Code

After downloading, create a.vscode/mcp.json file in your workspace root with the path to your downloaded binary.

Option A: Automated Setup Script

For quick setup, you can use these one-liner scripts that download the binaryand create the configuration:

Windows (PowerShell):

# Download binary and create VS Code configurationmkdir-p .vscode ;Invoke-WebRequest-Uri"https://github.com/Azure/aks-mcp/releases/latest/download/aks-mcp-windows-amd64.exe"-OutFile"aks-mcp.exe" ;@{servers=@{"aks-mcp-server"=@{type="stdio";command="$PWD\aks-mcp.exe";args=@("--transport","stdio")}}}|ConvertTo-Json-Depth3|Out-File".vscode/mcp.json"-Encoding UTF8

macOS/Linux (Bash):

# Download binary and create VS Code configurationmkdir -p .vscode&& curl -sL https://github.com/Azure/aks-mcp/releases/latest/download/aks-mcp-linux-amd64 -o aks-mcp&& chmod +x aks-mcp&&echo'{"servers":{"aks-mcp-server":{"type":"stdio","command":"'$PWD'/aks-mcp","args":["--transport","stdio"]}}}'> .vscode/mcp.json
Option B: Manual Configuration

✨ Simple Setup: Download the binary for your platform, then use the manual configuration below to set up the MCP server in VS Code.

Manual VS Code Configuration

You can configure the AKS-MCP server in two ways:

1. Workspace-specific configuration (recommended for project-specific usage):

Create a.vscode/mcp.json file in your workspace with the path to your downloaded binary:

{"servers": {"aks-mcp-server": {"type":"stdio","command":"<enter the file path>","args": ["--transport","stdio"      ]    }  }}

2. User-level configuration (persistent across all workspaces):

For a persistent configuration that works across all your VS Code workspaces, add the MCP server to your VS Code user settings:

  1. Open VS Code Settings (Ctrl+, or Cmd+,)
  2. Search for "mcp" in the settings
  3. Add the following to your User Settings JSON:
{"github.copilot.chat.mcp.servers": {"aks-mcp-server": {"type":"stdio","command":"<enter the file path>","args": ["--transport","stdio"      ]    }  }}

Step 3: Load the AKS-MCP server tools to Github Copilot

  1. If running on an older version of VS Code: restart VS Code i.e. close andreopen VS Code to load the new MCP server configuration.
  2. Open GitHub Copilot in VS Code andswitch to Agent mode
  3. Click theTools button or run /list in the Github Copilot window to see the list of available tools
  4. You should see the AKS-MCP tools in the list
  5. Try a prompt like:"List all my AKS clusters in subscription xxx"
  6. The agent will automatically use AKS-MCP tools to complete your request

💡 Tip: If you don't see the AKS-MCP tools after restarting, check the VS Code output panel for any MCP server connection errors and verify your binary path in.vscode/mcp.json.

Note: Ensure you have authenticated with Azure CLI (az login) for the server to access your Azure resources.

Other MCP-Compatible Clients

Docker and Custom Client Installation

For other MCP-compatible AI clients likeClaude Desktop, configure the server in your MCP configuration:

{"mcpServers": {"aks": {"command":"<path of binary aks-mcp>","args": ["--transport","stdio"      ]    }  }}

🐳 Docker MCP Toolkit

You can enable theAKS-MCP server directly from MCP Toolkit:

  1. Open Docker Desktop
  2. Click "MCP Toolkit" in the left sidebar
  3. Search for "aks" in Catalog tab
  4. Click on the AKS-MCP server card
  5. Enable the server by clicking "+" in the top right corner
  6. Configure the server using "Configuration" tab:
    • azure_dir[REQUIRED]: Path to your Azure credentials directory e.g/home/user/.azure (must be absolute – without$HOME or~)
    • kubeconfig[REQUIRED]: Path to your kubeconfig file e.g/home/user/.kube/config (must be absolute – without$HOME or~)
    • access_level[REQUIRED]: Set toreadonly,readwrite, oradmin as needed
    • container_user[OPTIONAL]: Username or UID to run the container as (default ismcp), e.g. use1000 to match your host user ID (see note below). Only needed if you are using docker engine on Linux.
  7. You are now ready to use the AKS-MCP server with yourpreferred MCP client, see an examplehere. (requires>= v0.16.0 for MCP gateway)

Note: When running the MCP gateway using Docker Engine, you have to set thecontainer_user to match your host user ID (e.g usingid -u) to ensure proper file permissions for accessing mounted volumes.On Docker Desktop, this is handled automatically if you usedesktop-* contexts, confirmed by runningdocker context ls.

OnWindows, the Azure credentials won't work by default, but you have two options:

  1. Long-lived servers: Configure theMCP gateway to use long-lived servers using--long-lived flag and then authenticate with Azure CLI in the container, see option B in Containerized MCP configuration below on how to fetch credentials inside the container.

  2. Custom Azure Directory: Set up a custom Azure directory:

    # Set custom Azure config directory$env:AZURE_CONFIG_DIR="$env:USERPROFILE\.azure-for-docker"# Disable token cache encryption (to match behavior with Linux/macOS)$env:AZURE_CORE_ENCRYPT_TOKEN_CACHE="false"# Login to Azure CLIaz login

    This will store the credentials in$env:USERPROFILE\.azure-for-docker (e.g.C:\Users\<username>\.azure-for-docker),use this path in the AKS-MCP server configurationazure_dir.

You can also use theMCP Gateway to enable the AKS-MCP server directly using:

# Enable AKS-MCP server in Docker MCP Gatewaydocker mcp serverenable aks

Note: You still need to configure the server (e.g. usingdocker mcp config) with your Azure credentials, kubeconfig file, and access level.

🐋 Containerized MCP configuration

For containerized deployment, you can run AKS-MCP server using the official Docker image:

Option A: Mount credentials from host (recommended):

{"mcpServers": {"aks": {"type":"stdio","command":"docker","args": ["run","-i","--rm","--user","<your-user-id (e.g. id -u)>","-v","~/.azure:/home/mcp/.azure","-v","~/.kube:/home/mcp/.kube","ghcr.io/azure/aks-mcp:latest","--transport","stdio"        ]    }  }}

Option B: fetch the credentials inside the container:

{"mcpServers": {"aks": {"type":"stdio","command":"docker","args": ["run","-i","--rm","ghcr.io/azure/aks-mcp:latest","--transport","stdio"        ]    }  }}

Start the MCP server container first per above command, and then run the following commands to fetch the credentials:

  • Login to Azure CLI:docker exec -it <container-id> az login --use-device-code
  • Get kubeconfig:docker exec -it <container-id> az aks get-credentials -g <resource-group> -n <cluster-name>

Note that:

  • Host Azure CLI logins don’t automatically propagate into containers without mounting~/.azure.
  • User ID should be set for option A, orelse the mcp user inside container won't be able to access the mounted files.

🤖 Custom MCP Client Installation

You can configure any MCP-compatible client to use the AKS-MCP server by running the binary directly:

# Run the server directly./aks-mcp --transport stdio

🔧 Manual Binary Installation

For direct binary usage without package managers:

  1. Download the latest release from thereleases page
  2. Extract the binary to your preferred location
  3. Make it executable (on Unix systems):
    chmod +x aks-mcp
  4. Configure your MCP client to use the binary path

Options

Command line arguments:

Usage of ./aks-mcp:      --access-level string       Access level (readonly, readwrite, admin) (default"readonly")      --additional-tools string   Comma-separated list of additional Kubernetes tools to support (kubectl is always enabled). Available: helm,cilium,hubble      --allow-namespaces string   Comma-separated list of allowed Kubernetes namespaces (empty means all namespaces)      --host string               Host to listenfor the server (only used with transport sse or streamable-http) (default"127.0.0.1")      --otlp-endpoint string      OTLP endpointfor OpenTelemetry traces (e.g. localhost:4317, default"")      --port int                  Port to listenfor the server (only used with transport sse or streamable-http) (default 8000)      --timeout int               Timeoutforcommand executionin seconds, default is 600s (default 600)      --transport string          Transport mechanism to use (stdio, sse or streamable-http) (default"stdio")      --log-level string          Log level (debug, info, warn, error) (default"info")

Environment variables:

  • Standard Azure authentication environment variables are supported (AZURE_TENANT_ID,AZURE_CLIENT_ID,AZURE_CLIENT_SECRET,AZURE_SUBSCRIPTION_ID)

Development

Prerequisites

  • Go1.24.x installed on your local machine
  • Bash available as/usr/bin/env bash (Makefile targets use multi-line recipes with fail-fast mode)
  • GNU Make4.x or later
  • Docker(optional, for container builds and testing)

Note: If your login shell is different (e.g.,zsh onmacOS), you donot need to change it — the Makefile sets variables to run all recipes inbash for consistent behavior across platforms.

Building from Source

This project includes a Makefile for convenient development, building, and testing. To see all available targets:

makehelp

Quick Start

# Build the binarymake build# Run testsmaketest# Run tests with coveragemake test-coverage# Format and lint codemake check# Build for all platformsmake release

Common Development Tasks

# Install dependenciesmake deps# Build and run with --helpmake run# Clean build artifactsmake clean# Install binary to GOBINmake install

Docker

# Build Docker imagemake docker-build# Run Docker containermake docker-run

Manual Build

If you prefer to build without the Makefile:

go build -o aks-mcp ./cmd/aks-mcp

Usage

Ask any questions about your AKS clusters in your AI client, for example:

List all my AKS clusters in my subscription xxx.What is the network configuration of my AKS cluster?Show me the network security groups associated with my cluster.Create a new Azure Fleet named prod-fleet in eastus region.List all members in my fleet.Create a placement to deploy nginx workloads to clusters with app=frontend label.Show me all ClusterResourcePlacements in my fleet.

Telemetry

Telemetry collection is on by default.

To opt out, set the environment variableAKS_MCP_COLLECT_TELEMETRY=false.

Contributing

We welcome contributions to AKS-MCP! Whether you're fixing bugs, adding features, or improving documentation, your help makes this project better.

📖Read our detailed Contributing Guide for comprehensive information on:

  • Setting up your development environment
  • Running AKS-MCP locally and testing with AI agents
  • Understanding the codebase architecture
  • Adding new MCP tools and features
  • Testing guidelines and best practices
  • Submitting pull requests

Quick Start for Contributors

  1. Prerequisites: Go ≥ 1.24.x, Azure CLI, Git
  2. Setup: Fork the repo, clone locally, runmake deps && make build
  3. Test: Runmake test andmake check
  4. Develop: Follow the component-based architecture inCONTRIBUTING.md

Contributor License Agreement

Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visithttps://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted theMicrosoft Open Source Code of Conduct. For more information see theCode of Conduct FAQ or contactopencode@microsoft.com with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsofttrademarks or logos is subject to and must followMicrosoft's Trademark & Brand Guidelines.Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.Any use of third-party trademarks or logos are subject to those third-party's policies.

About

Azure Kubernetes Service logo

Azure Kubernetes Service

ByAzure·93

Interact with Azure Kubernetes Service (AKS) from MCP clients.


[8]ページ先頭

©2009-2025 Movatter.jp