Skip to content

Commit 7bbac6f

Browse files
committed
feat: Improve user experience of az aks agent with aks-mcp
1 parent 37358a1 commit 7bbac6f

28 files changed

+7415
-108
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,7 @@ _az_debug/
127127

128128
# Ignore test results
129129
test_results.xml
130+
131+
# Ignore poetry files
132+
pyproject.toml
133+
poetry.lock

src/aks-preview/HISTORY.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ Pending
1414

1515
18.0.0b28
1616
+++++++
17+
* Improve user experience of `az aks agent` with enhanced MCP (Model Context Protocol) integration.
18+
* Use aks-mcp by default for `az aks agent`.
19+
* Add comprehensive error handling, status management, and user feedback systems for the agent debugging tool.
20+
* Implement smart binary management and configuration generation for improved agent reliability.
21+
22+
18.0.0b27
23+
+++++++
1724
* Add interactive AI-powered debugging tool `az aks agent`.
1825

1926
18.0.0b27
@@ -1948,4 +1955,4 @@ Pending
19481955
+++++
19491956

19501957
* new feature `enable-cluster-autoscaler`
1951-
* default agentType is VMSS
1958+
* default agentType is VMSS

src/aks-preview/azext_aks_preview/_consts.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,10 @@
379379
CONST_AGENT_NAME = "AKS AGENT"
380380
CONST_AGENT_NAME_ENV_KEY = "AGENT_NAME"
381381
CONST_AGENT_CONFIG_FILE_NAME = "aksAgent.yaml"
382+
# MCP Integration Constants
383+
CONST_MCP_BINARY_NAME = "aks-mcp"
384+
CONST_MCP_DEFAULT_PORT = 8003
385+
CONST_MCP_DEFAULT_URL = "http://localhost:8003/sse"
386+
CONST_MCP_MIN_VERSION = "0.0.7"
387+
CONST_MCP_GITHUB_REPO = "Azure/aks-mcp"
388+
CONST_MCP_BINARY_DIR = "bin"

src/aks-preview/azext_aks_preview/_help.py

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3960,6 +3960,14 @@
39603960
short-summary: Run AI assistant to analyze and troubleshoot Kubernetes clusters.
39613961
long-summary: |-
39623962
This command allows you to ask questions about your Azure Kubernetes cluster and get answers using AI models.
3963+
By default, the agent uses enhanced MCP (Model Context Protocol) integration for improved capabilities.
3964+
Use --no-aks-mcp to disable MCP and use traditional built-in toolsets.
3965+
3966+
The agent uses smart refresh to optimize performance:
3967+
• First run or mode changes: Toolsets are refreshed automatically
3968+
• Subsequent runs in same mode: Uses cached toolsets for faster startup
3969+
• If expected capabilities are missing: Use --refresh-toolsets to force refresh
3970+
39633971
Environment variables must be set to use the AI model, please refer to https://docs.litellm.ai/docs/providers to learn more about supported AI providers and models and required environment variables.
39643972
parameters:
39653973
- name: --name -n
@@ -3991,22 +3999,59 @@
39913999
short-summary: Show the output of each tool that was called during the analysis.
39924000
- name: --refresh-toolsets
39934001
type: bool
3994-
short-summary: Refresh the toolsets status.
4002+
short-summary: Force refresh of toolsets even when using cached configuration.
4003+
long-summary: |-
4004+
By default, the agent uses smart refresh to optimize performance. This flag forces
4005+
a complete toolset refresh, which is useful if:
4006+
• Expected tools or capabilities are missing
4007+
• You've updated your environment or configuration
4008+
• Troubleshooting toolset-related issues
4009+
Note: This may increase startup time but ensures all available tools are loaded.
4010+
- name: --no-aks-mcp
4011+
type: bool
4012+
short-summary: Disable AKS MCP integration and use traditional built-in toolsets.
4013+
is_preview: true
4014+
- name: --status
4015+
type: bool
4016+
short-summary: Show AKS agent configuration and status.
4017+
long-summary: |-
4018+
Display information about AKS agent configuration, MCP binary status, server health,
4019+
and active toolsets. This command helps diagnose agent setup and operational status.
4020+
4021+
The status output shows:
4022+
• Current operation mode (MCP enhanced vs traditional)
4023+
• MCP binary availability and version information
4024+
• MCP server status and health (when applicable)
4025+
• Component-specific error messages and recommendations
4026+
4027+
Use this option to:
4028+
• Verify the agent is properly configured
4029+
• Troubleshoot MCP integration issues
4030+
• Check if enhanced capabilities are available
4031+
• Get recommendations for resolving configuration problems
39954032
39964033
examples:
3997-
- name: Ask about pod issues in the cluster with Azure OpenAI
4034+
- name: Ask about pod issues in the cluster with Azure OpenAI (MCP mode - default)
39984035
text: |-
39994036
export AZURE_API_BASE="https://my-azureopenai-service.openai.azure.com/"
40004037
export AZURE_API_VERSION="2025-01-01-preview"
40014038
export AZURE_API_KEY="sk-xxx"
40024039
az aks agent "Why are my pods not starting?" --name MyManagedCluster --resource-group MyResourceGroup --model azure/my-gpt4.1-deployment
4003-
- name: Ask about pod issues in the cluster with OpenAI
4040+
- name: Ask about pod issues using traditional toolsets (no MCP)
4041+
text: |-
4042+
export AZURE_API_BASE="https://my-azureopenai-service.openai.azure.com/"
4043+
export AZURE_API_VERSION="2025-01-01-preview"
4044+
export AZURE_API_KEY="sk-xxx"
4045+
az aks agent "Why are my pods not starting?" --name MyManagedCluster --resource-group MyResourceGroup --model azure/my-gpt4.1-deployment --no-aks-mcp
4046+
- name: Ask about pod issues in the cluster with OpenAI (MCP mode - default)
40044047
text: |-
40054048
export OPENAI_API_KEY="sk-xxx"
40064049
az aks agent "Why are my pods not starting?" --name MyManagedCluster --resource-group MyResourceGroup --model gpt-4o
40074050
- name: Run in interactive mode without a question
40084051
text: az aks agent "Check the pod status in my cluster" --name MyManagedCluster --resource-group MyResourceGroup --model azure/my-gpt4.1-deployment --api-key "sk-xxx"
4009-
- name: Run in non-interactive batch mode
4052+
- name: Run in non-interactive batch mode (traditional toolsets)
4053+
text: az aks agent "Diagnose networking issues" --no-interactive --max-steps 15 --model azure/my-gpt4.1-deployment --no-aks-mcp
4054+
- name: Run in non-interactive batch mode (MCP mode - default)
40104055
text: az aks agent "Diagnose networking issues" --no-interactive --max-steps 15 --model azure/my-gpt4.1-deployment
40114056
- name: Show detailed tool output during analysis
40124057
text: az aks agent "Why is my service workload unavailable in namespace workload-ns?" --show-tool-output --model azure/my-gpt4.1-deployment
@@ -4016,6 +4061,21 @@
40164061
text: az aks agent "What is the status of my cluster?" --no-echo-request --model azure/my-gpt4.1-deployment
40174062
- name: Refresh toolsets to get the latest available tools
40184063
text: az aks agent "What is the status of my cluster?" --refresh-toolsets --model azure/my-gpt4.1-deployment
4064+
- name: Troubleshoot missing capabilities by forcing toolset refresh
4065+
text: |-
4066+
# If the agent seems to be missing expected capabilities, force a refresh:
4067+
az aks agent "Debug my networking issues" --refresh-toolsets --show-tool-output --model azure/my-gpt4.1-deployment
4068+
- name: Show basic agent status
4069+
text: az aks agent --status
4070+
- name: Check if MCP integration is working
4071+
text: |-
4072+
# This will show if the MCP binary is downloaded and server is healthy
4073+
az aks agent --status
4074+
- name: Troubleshoot agent setup issues
4075+
text: |-
4076+
# Use status output to identify configuration problems
4077+
az aks agent --status
4078+
# Follow the recommendations shown in the output
40194079
- name: Run agent with config file
40204080
text: |
40214081
az aks agent "Check kubernetes pod resource usage" --config-file /path/to/custom.yaml

src/aks-preview/azext_aks_preview/_params.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2785,6 +2785,7 @@ def load_arguments(self, _):
27852785
c.positional(
27862786
"prompt",
27872787
help="Ask any question and answer using available tools.",
2788+
nargs="?",
27882789
)
27892790
c.argument(
27902791
"resource_group_name",
@@ -2844,6 +2845,19 @@ def load_arguments(self, _):
28442845
help="Refresh the toolsets status.",
28452846
action="store_true",
28462847
)
2848+
c.argument(
2849+
"no_aks_mcp",
2850+
options_list=["--no-aks-mcp"],
2851+
action="store_true",
2852+
help="Disable AKS MCP integration and use traditional built-in toolsets",
2853+
is_preview=True,
2854+
)
2855+
c.argument(
2856+
"status",
2857+
options_list=["--status"],
2858+
action="store_true",
2859+
help="Show AKS agent configuration and status information",
2860+
)
28472861

28482862

28492863
def _get_default_install_location(exe_name):

0 commit comments

Comments
 (0)