-
Notifications
You must be signed in to change notification settings - Fork 3.4k
{Misc.} Enhance the development experience of AAZ #32025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bf33d58
feat: init aaz-flow
necusjz af86147
refactor: check aaz-dev in advance
necusjz e137b84
add required inputs and a tool for mcp server
yanzhudd fcf201a
doc: add draft README.md
necusjz e4b8c7f
chore: install mcp outside .venv
necusjz edc11e8
fix default env
yanzhudd 609aa17
chore: add user-friendly prompts
necusjz 4ddbbad
add support for generating model from swagger
yanzhudd 6f8896e
perf: minimize clone
necusjz f8a650f
chore: use full copy
necusjz 81c7350
fix split file path
yanzhudd 5fbf83f
fix: add license header
necusjz 4a8d620
chore: add code owners
necusjz dc7b4fd
chore: add code owners
necusjz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| FROM mcr.microsoft.com/devcontainers/python:3.12 | ||
|
|
||
| # Copy binaries from the official | ||
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ | ||
|
|
||
| # Remove after production | ||
| RUN pip install --no-cache-dir mcp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "name": "Azure CLI Dev Container", | ||
| "build": { | ||
| "dockerfile": "Dockerfile" | ||
| }, | ||
| "features": { | ||
| "ghcr.io/devcontainers/features/github-cli:1": {} | ||
| }, | ||
| "workspaceFolder": "/workspaces", | ||
| "onCreateCommand": "uv venv .venv --seed", | ||
| "postCreateCommand": "REPO_NAME=$(basename $GITHUB_REPOSITORY) && cat $REPO_NAME/.devcontainer/init.sh >> ~/.bashrc && mkdir .vscode && cp $REPO_NAME/.devcontainer/mcp.json .vscode/", | ||
| "hostRequirements": { | ||
| "cpus": 16, | ||
| "memory": "64gb", | ||
| "storage": "128gb" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
|
|
||
| source .venv/bin/activate | ||
|
|
||
| # Logout default account | ||
| export GITHUB_TOKEN= | ||
|
|
||
| # Check `repo` scope exists or not | ||
| if gh auth status -a 2>/dev/null | grep "Token scopes: " | grep -q "repo"; then | ||
| echo "You now have access to GitHub." | ||
| else | ||
| gh auth login -p https -w | ||
| fi | ||
|
|
||
| # Check `aaz-dev` is available or not | ||
| if ! command -v aaz-dev &> /dev/null; then | ||
| GREEN="\033[0;32m" | ||
| YELLOW="\033[0;33m" | ||
| NC="\033[0m" # no color | ||
|
|
||
| set_or_add_remote() { | ||
| local REPO=$1 | ||
| local REMOTE=$2 | ||
| local DIR="/workspaces/$REPO" | ||
| local OWNER=$([ "$REMOTE" = "origin" ] && echo "$GITHUB_USER" || echo "Azure") | ||
| local URL="https://github.com/$OWNER/$REPO.git" | ||
|
|
||
| git -C "$DIR" remote get-url "$REMOTE" &>/dev/null || git -C "$DIR" remote add "$REMOTE" "$URL" | ||
| git -C "$DIR" remote set-url "$REMOTE" "$URL" | ||
| } | ||
|
|
||
| setup_repo() { | ||
| local REPO=$1 | ||
| local DIR="/workspaces/$REPO" | ||
|
|
||
| echo | ||
| gh repo fork "Azure/$REPO" --clone=false --default-branch-only | ||
|
|
||
| if [ -d "$DIR" ]; then | ||
| set_or_add_remote "$REPO" origin | ||
| set_or_add_remote "$REPO" upstream | ||
| else | ||
| git clone "https://github.com/$GITHUB_USER/$REPO.git" --single-branch --no-tags | ||
| set_or_add_remote "$REPO" upstream | ||
|
|
||
| # Synchronize with upstream | ||
| BRANCH=$(git -C "$DIR" remote show upstream | grep "HEAD branch" | awk '{print $NF}') | ||
| git -C "$DIR" pull -r upstream "$BRANCH" | ||
| fi | ||
| } | ||
|
|
||
| SECONDS=0 | ||
|
|
||
| echo | ||
| uv pip install aaz-dev --link-mode=copy | ||
|
|
||
| # `azdev` repositories | ||
| setup_repo "azure-cli" | ||
| setup_repo "azure-cli-extensions" | ||
|
|
||
| azdev setup -c -r ./azure-cli-extensions | ||
|
|
||
| # `aaz-dev` repositories | ||
| setup_repo "aaz" | ||
| setup_repo "azure-rest-api-specs" | ||
|
|
||
| ELAPSED_TIME=$SECONDS | ||
|
|
||
| echo -e "\n${YELLOW}Elapsed time: $((ELAPSED_TIME / 60))m $((ELAPSED_TIME % 60))s.${NC}" | ||
| echo -e "\n${GREEN}Finished setup! Please launch the codegen tool via:${NC}" | ||
| echo -e "${GREEN}\$ aaz-dev run -c azure-cli -e azure-cli-extensions -s azure-rest-api-specs -a aaz${NC}\n" | ||
| else | ||
| echo -e "\nPlease launch the codegen tool via:" | ||
| echo -e "$ aaz-dev run -c azure-cli -e azure-cli-extensions -s azure-rest-api-specs -a aaz\n" | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| { | ||
| "inputs": [ | ||
| { | ||
| "type": "promptString", | ||
| "id": "extension_or_module_name", | ||
| "description": "The name of the Azure CLI extension or module to generate commands for." | ||
| }, | ||
| { | ||
| "type": "promptString", | ||
| "id": "swagger_module_path", | ||
| "description": "The file path to the Swagger module." | ||
| }, | ||
| { | ||
| "type": "promptString", | ||
| "id": "resource_provider", | ||
| "description": "The Azure resource provider for which to generate commands." | ||
| }, | ||
| { | ||
| "type": "promptString", | ||
| "id": "swagger_tag", | ||
| "description": "The Swagger tag to use for command generation." | ||
| } | ||
| ], | ||
| "servers": { | ||
| "AAZ Flow": { | ||
| "command": "python", | ||
| "args": [ | ||
| "azure-cli/tools/aaz-flow/main.py" | ||
| ], | ||
| "env": { | ||
| "AAZ_PATH": "/workspaces/aaz", | ||
| "CLI_PATH": "/workspaces/azure-cli", | ||
| "CLI_EXTENSION_PATH": "/workspaces/azure-cli-extensions", | ||
| "SWAGGER_PATH": "/workspaces/azure-rest-api-specs" | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| ## AAZ MCP Server | ||
| MCP Server for the AAZ API, enabling prune command-line interface, implement custom logic, generate meaningful example, and more. | ||
|
|
||
| Please note that AAZ Flow is currently in early development. The functionality and available tools are subject to change and expansion as we continue to develop and improve the server. | ||
|
|
||
| ### Tools | ||
| 1. `generate_code` | ||
| - xx | ||
| - Inputs: | ||
| - xx | ||
| - xx | ||
| - Returns: | ||
|
necusjz marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
| import os | ||
| from mcp.server.fastmcp import FastMCP | ||
|
|
||
| # Initialize MCP server | ||
| mcp = FastMCP("AAZ Flow") | ||
|
|
||
|
|
||
| @mcp.tool() | ||
| def generate_code( | ||
| extension_or_module_name: str, | ||
| swagger_module_path: str, | ||
| resource_provider: str, | ||
| swagger_tag: str, | ||
| ): | ||
| # Generate Azure CLI commands based on Swagger specifications | ||
| aaz_path = os.getenv("AAZ_PATH", "/workspaces/aaz") | ||
| cli_path = os.getenv("CLI_PATH", "/workspaces/azure-cli") | ||
| cli_extension_path = os.getenv("CLI_EXTENSION_PATH", "/workspaces/azure-cli-extensions") | ||
| swagger_path = os.getenv("SWAGGER_PATH", "/workspaces/azure-rest-api-specs") | ||
|
|
||
| swagger_module = os.path.split(swagger_module_path)[-1] | ||
|
|
||
| des = ( | ||
| f"Just run the following command in the terminal: 'aaz-dev command-model generate-from-swagger --swagger-path {swagger_path} --swagger-module-path {swagger_module_path} --aaz-path {aaz_path} --module {swagger_module} --resource-provider {resource_provider} --swagger-tag {swagger_tag}'", | ||
| f"After the command is run successfully, then run the following command: 'aaz-dev cli generate-by-swagger-tag --aaz-path {aaz_path} --cli-path {cli_path} --cli-extension-path {cli_extension_path} --extension-or-module-name {extension_or_module_name} --swagger-module-path {swagger_module_path} --resource-provider {resource_provider} --swagger-tag {swagger_tag} --profile latest'", | ||
| f"After the command is run successfully, this task will be marked as completed.", | ||
| ) | ||
| return des | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| mcp.run(transport="stdio") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| [project] | ||
| name = "aaz-flow" | ||
| version = "0.1.0" | ||
| description = "The MCP server utilized for code generation in Azure CLI (AAZ)." | ||
| readme = "README.md" | ||
| requires-python = ">=3.12" | ||
| dependencies = [ | ||
| "mcp>=1.12.0", | ||
| ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.