Skip to content

Commit ae54486

Browse files
Az SDK Tools MCP: Guidelines for CLI command grouping (#12071)
* Az SDK Tools MCP: Guidelines for CLI command grouping
1 parent 7fdcf7c commit ae54486

2 files changed

Lines changed: 114 additions & 1 deletion

File tree

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Azure SDK Tools CLI Command Guidelines
2+
3+
This document provides comprehensive guidelines for creating CLI commands in the `Azure.Sdk.Tools.Cli` project. All CLI commands must follow these established patterns and conventions to ensure consistency, maintainability, and proper integration with both CLI and MCP (Model Context Protocol) server functionality.
4+
Azure SDK developers and service team can use these CLI commands to generate, build, test and release Azure SDK.
5+
6+
## Namespace Organization
7+
8+
### Directory Structure
9+
10+
```
11+
Tools/
12+
├── Package/ # Package-level operations
13+
├── ReleasePlan/ # Release planning operations
14+
├── TypeSpec/ # TypeSpec operations
15+
```
16+
17+
## Command Hierarchy
18+
19+
All CLI commands must follow a predefined top-level command hierarchy. Commands are organized into the following categories:
20+
21+
### 1. **package** - Package Operations
22+
23+
**Namespace:** `Azure.Sdk.Tools.Cli.Tools.Package`
24+
**Command Group:** `SharedCommandGroups.Package`
25+
**Verb:** `package` or `pkg`
26+
27+
For operations at the SDK package level. The package group has further sub-grouping for better organization:
28+
29+
#### Core Package Operations:
30+
31+
- Build/compile SDK code
32+
- Generate SDKs
33+
- Release packages
34+
- Update version information
35+
- Validate packages
36+
37+
#### Sub-Groups:
38+
39+
##### **readme** - README Operations
40+
41+
For generating and updating README files:
42+
43+
- Generate README
44+
- Update README
45+
46+
##### **sample** - Sample Operations
47+
48+
For generating and updating SDK samples:
49+
50+
- Create samples
51+
- Update samples
52+
53+
##### **test** - Test Operations
54+
55+
For creating, updating, and running tests for SDK packages:
56+
57+
- Create tests
58+
- Update tests
59+
- Run tests for specific packages
60+
61+
**Examples:**
62+
63+
- `package build --package-path ./sdk/storage`
64+
- `package generate --typespec-project ./specification/storage`
65+
- `package readme generate --package-path ./sdk/compute`
66+
- `package readme update --package-path ./sdk/keyvault --section getting-started`
67+
- `package release --package-name azure-core`
68+
- `package sample generate --package-path ./sdk/compute`
69+
- `package sample update --package-path ./sdk/storage --sample-name basic-usage`
70+
- `package test generate --package-path ./sdk/storage --test-type <type>`
71+
- `package test run --package-path ./sdk/keyvault --test-suite integration`
72+
- `package validate --package-path ./sdk/keyvault`
73+
74+
### 2. **release-plan** - Release Plan
75+
76+
**Namespace:** `Azure.Sdk.Tools.Cli.Tools.ReleasePlan`
77+
**Command Group:** Custom (no predefined group)
78+
**Verb:** `release-plan`
79+
80+
For release planning and SDK coordination:
81+
82+
- Create release plans
83+
- Link SDK pull requests to release plan
84+
- Get release plan details
85+
86+
**Examples:**
87+
88+
- `release-plan get --workitem-id 456`
89+
- `release-plan link-sdk-pr --release-plan-id 123 --pr 789`
90+
91+
### 3. **typespec** - TypeSpec Operations and TypeSpec Client Operations
92+
93+
**Namespace:** `Azure.Sdk.Tools.Cli.Tools.TypeSpec`
94+
**Command Group:** `SharedCommandGroups.TypeSpec`
95+
**Verb:** `tsp`
96+
97+
For TypeSpec-related operations:
98+
99+
- Create TypeSpec projects
100+
- Convert Swagger to TypeSpec
101+
- Validate TypeSpec projects
102+
- Common TypeSpec workflows
103+
104+
**Examples:**
105+
106+
- `tsp convert --swagger-file ./swagger.json`
107+
- `tsp init --name MyService`
108+
- `tsp validate --project-path ./typespec`

tools/azsdk-cli/docs/new-tool.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Help me create a new tool using #new-tool.md as a reference
1212

1313
* [Tool Architecture Overview](#tool-architecture-overview)
1414
* [Step-by-Step Implementation Guide](#step-by-step-implementation-guide)
15+
* [CLI Command Hierarchy](#cli-command-hierarchy)
1516
* [Code Examples and Templates](#code-examples-and-templates)
1617
* [Dependency Injection](#dependency-injection)
1718
* [Response Handling](#response-handling)
@@ -103,6 +104,10 @@ public override CommandGroup[] CommandHierarchy { get; set; } = [
103104
- `IDevOpsService` - For Azure DevOps operations
104105
- Custom service interfaces for your tool's specific needs
105106

107+
## CLI command hierarchy
108+
109+
Refer to [CLI command hierarchy](cli-commands-guidelines.md) for guidelines on CLI command structure.
110+
106111
## Code Examples and Templates
107112

108113
A working example of multiple tool types and usage of services can be found at [`ExampleTool.cs`](../Azure.Sdk.Tools.Cli/Tools/Example/ExampleTool.cs)
@@ -644,4 +649,4 @@ catch (Exception ex)
644649
{
645650
return $"Exception: {ex.Message}";
646651
}
647-
```
652+
```

0 commit comments

Comments
 (0)