Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .devcontainer/Dockerfile
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
17 changes: 17 additions & 0 deletions .devcontainer/devcontainer.json
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"
}
}
74 changes: 74 additions & 0 deletions .devcontainer/init.sh
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
38 changes: 38 additions & 0 deletions .devcontainer/mcp.json
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"
}
}
}
}
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/doc/ @jiasli @kairu-ms @jsntcy
/tools/ @kairu-ms @jiasli @wangzelin007 @calvinhzy @bebound
/tools/aaz-flow @a0x1ab @necusjz @yanzhudd
/scripts/ @kairu-ms @jiasli @wangzelin007 @calvinhzy @bebound
/scripts/live_test @kairu-ms @wangzelin007
/src/azure-cli-testsdk/ @jsntcy @jiasli @kairu-ms @wangzelin007 @bebound
Expand Down
12 changes: 12 additions & 0 deletions tools/aaz-flow/README.md
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.
Comment thread
necusjz marked this conversation as resolved.

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:
Comment thread
necusjz marked this conversation as resolved.
36 changes: 36 additions & 0 deletions tools/aaz-flow/main.py
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")
9 changes: 9 additions & 0 deletions tools/aaz-flow/pyproject.toml
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",
]
Loading