Skip to content

[CLI as MCP] Integrate Script Insight MCP Features into CLI local MCP extension#9154

Open
zhoxing-ms wants to merge 1 commit into
Azure:mainfrom
zhoxing-ms:cli_script_insight_mcp
Open

[CLI as MCP] Integrate Script Insight MCP Features into CLI local MCP extension#9154
zhoxing-ms wants to merge 1 commit into
Azure:mainfrom
zhoxing-ms:cli_script_insight_mcp

Conversation

@zhoxing-ms
Copy link
Copy Markdown
Contributor

@zhoxing-ms zhoxing-ms commented Sep 11, 2025


The integration work is based on #9013 from @ReaNAiveD
Integration code: 4299d8e

image

Result of what-if tool:
image

Result of best-practices tool:
image

Related command

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install wheel==0.30.0 required)
  • My extension version conforms to the Extension version schema

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.

Copilot AI review requested due to automatic review settings September 11, 2025 03:00
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Breaking Change Starting...

Thanks for your contribution!

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Sep 11, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown
Contributor

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR integrates Script Insight MCP features into the Azure CLI local MCP extension, adding what-if preview and best practices analysis capabilities. The changes introduce a new mcp-server extension that provides MCP (Model Context Protocol) server functionality for Azure CLI commands with integrated script analysis tools.

Key Changes

  • Added what-if preview functionality that analyzes Azure CLI scripts and shows potential resource changes before execution
  • Integrated best practices analyzer that examines Azure CLI scripts for optimization opportunities and security recommendations
  • Implemented comprehensive MCP server with command introspection, schema generation, and prompt elicitation capabilities

Reviewed Changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/mcp-server/setup.py Package setup configuration with dependencies and metadata
src/mcp-server/azext_mcp/server.py Core MCP server implementation with Azure CLI bridge and script insight tools
src/mcp-server/azext_mcp/azcli_script_insight_client.py Client for Azure Function App endpoints providing script analysis capabilities
src/mcp-server/azext_mcp/command_introspection.py Command introspection utilities for Azure CLI schema generation
src/mcp-server/azext_mcp/prompt_elicitation.py Prompt handling system for interactive CLI operations through MCP
src/mcp-server/azext_mcp/tests/latest/test_mcp_scenario.py Scenario tests for MCP functionality
src/mcp-server/azext_mcp/tests/latest/example_*.azcli Example Azure CLI scripts for testing best practices and what-if analysis

self.check('tags.foo', 'boo')
])
count = len(self.cmd('mcp list').get_output_in_json())
self.cmd('mcp show - {rg} -n {name}', checks=[
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There appears to be a syntax error in the command string. The command has 'mcp show - {rg}' which contains an invalid dash character that should likely be '-g' to specify the resource group parameter.

Suggested change
self.cmd('mcp show - {rg} -n {name}', checks=[
self.cmd('mcp show -g {rg} -n {name}', checks=[

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,168 @@
practices# Comprehensive Azure CLI Script Example
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first line contains a malformed comment. It should start with # but instead has practices#. This should be # Comprehensive Azure CLI Script Example.

Suggested change
practices# Comprehensive Azure CLI Script Example
# Comprehensive Azure CLI Script Example

Copilot uses AI. Check for mistakes.
}

# Validate that access token is provided (required for what-if operations)
# Get access token from Azure CLI
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation is inconsistent. Line 124 is a comment that appears to be indented within a validation block, but line 125 has no indentation, making the code structure unclear. The comment and code should have consistent indentation.

Suggested change
# Get access token from Azure CLI
# Get access token from Azure CLI

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown
Contributor

Hi @zhoxing-ms

⚠️ Release Requirements

Module: mcp-server

  • ⚠️ Please update VERSION to be 1.0.0b1 in src/mcp-server/setup.py

Notes

@github-actions github-actions Bot added the release-version-block Updates do not qualify release version rules. NOTE: please do not edit it manually. label Sep 11, 2025
@zhoxing-ms zhoxing-ms force-pushed the cli_script_insight_mcp branch from 4299d8e to f59019e Compare September 11, 2025 03:03
@yonzhan yonzhan requested a review from jsntcy September 11, 2025 07:13
@zhoxing-ms zhoxing-ms force-pushed the cli_script_insight_mcp branch from f59019e to 1dc9f8b Compare September 11, 2025 09:05
@zhoxing-ms zhoxing-ms force-pushed the cli_script_insight_mcp branch from 1dc9f8b to 958f8a4 Compare September 19, 2025 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-version-block Updates do not qualify release version rules. NOTE: please do not edit it manually.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants