[CLI as MCP] Integrate Script Insight MCP Features into CLI local MCP extension#9154
[CLI as MCP] Integrate Script Insight MCP Features into CLI local MCP extension#9154zhoxing-ms wants to merge 1 commit into
Conversation
|
Validation for Breaking Change Starting...
Thanks for your contribution! |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
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). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
There was a problem hiding this comment.
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=[ |
There was a problem hiding this comment.
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.
| self.cmd('mcp show - {rg} -n {name}', checks=[ | |
| self.cmd('mcp show -g {rg} -n {name}', checks=[ |
| @@ -0,0 +1,168 @@ | |||
| practices# Comprehensive Azure CLI Script Example | |||
There was a problem hiding this comment.
The first line contains a malformed comment. It should start with # but instead has practices#. This should be # Comprehensive Azure CLI Script Example.
| practices# Comprehensive Azure CLI Script Example | |
| # Comprehensive Azure CLI Script Example |
| } | ||
|
|
||
| # Validate that access token is provided (required for what-if operations) | ||
| # Get access token from Azure CLI |
There was a problem hiding this comment.
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.
| # Get access token from Azure CLI | |
| # Get access token from Azure CLI |
|
Hi @zhoxing-ms
|
4299d8e to
f59019e
Compare
f59019e to
1dc9f8b
Compare
1dc9f8b to
958f8a4
Compare
The integration work is based on #9013 from @ReaNAiveD
Integration code: 4299d8e
Result of what-if tool:

Result of best-practices tool:

Related command
General Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install wheel==0.30.0required)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.jsonautomatically.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.