Skip to content

Commit d1c4f30

Browse files
eng. mcp, remove clean_java_source tool (#46050)
1 parent 4cdd775 commit d1c4f30

File tree

4 files changed

+42
-57
lines changed

4 files changed

+42
-57
lines changed

.github/copilot-instructions.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ The Azure SDK for Java repository contains client libraries for Azure services,
2727
ACTION: Use azure-sdk-java-mcp sdk tools to generate the SDK.
2828
ACTION: Do not use pure `mvn` command to compile, build or package SDK, use `build_java_sdk` tool instead, it runs `mvn` command inside.
2929
ACTION: Use azure-sdk-java-mcp sdk tool `update_client_name` to update client name.
30-
ACTION: Do not clean Java source before generating the SDK because the generated code may have manual written customized code.
3130
ACTION: Only update the manual written code or class when you fix compile errors. Manual written class does not have `// Code generated by Microsoft (R) TypeSpec Code Generator.` header. Manual written functions or properties do not have `@Generated` annotation.
3231

3332

eng/tools/mcp/azure-sdk-java-mcp/README.md

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ This MCP server provides the following tools:
88

99
1. **sync_typespec_source_files** - Synchronize/Download TypeSpec source files for Java SDK generation from local or remote sources
1010
2. **generate_java_sdk** - Generate or update Java SDK code from TypeSpec definitions
11-
3. **clean_java_source** - Clean and remove generated Java source files from SDK directory
12-
4. **build_java_sdk** - Compile and build the Java SDK with Maven for Azure services
13-
5. **get_java_sdk_changelog** - Generate and retrieve changelog information for the Java SDK
14-
6. **update_java_sdk_changelog** - Update the CHANGELOG.md file for a Java SDK module
15-
7. **instruction_migrate_typespec** - Provide step-by-step instructions for migrating from Swagger to TypeSpec
16-
8. **update_client_name** - Guide through updating client class and property names in TypeSpec and Java SDK
17-
9. **prepare_java_sdk_environment** - Provide environment setup instructions and dependency requirements
11+
3. **build_java_sdk** - Compile and build the Java SDK with Maven for Azure services
12+
4. **get_java_sdk_changelog** - Generate and retrieve changelog information for the Java SDK
13+
5. **update_java_sdk_changelog** - Update the CHANGELOG.md file for a Java SDK module
14+
6. **instruction_migrate_typespec** - Provide step-by-step instructions for migrating from Swagger to TypeSpec
15+
7. **update_client_name** - Guide through updating client class and property names in TypeSpec and Java SDK
16+
8. **prepare_java_sdk_environment** - Provide environment setup instructions and dependency requirements
1817

1918
## Prerequisites
2019

@@ -58,7 +57,6 @@ Here are some example prompts you can use with GitHub Copilot to interact with t
5857

5958
### Environment and Tooling
6059
- `prepare java sdk environment`
61-
- `clean java source files for azure-ai-openai`
6260

6361
### Client Name Updates
6462
- `update client name: EnableBatchJobOptions to BatchJobEnableOptions`
@@ -120,23 +118,8 @@ Generate SDK from TypeSpec source from 'TempTypeSpecFiles' for a target service
120118
}
121119
```
122120

123-
### 3. clean_java_source
124-
Clean the Java source code for a module, removing all generated source files and directories.
125121

126-
**Parameters:**
127-
- `cwd` (required): The absolute path to the directory where tsp-location.yaml is located
128-
129-
**Example:**
130-
```json
131-
{
132-
"name": "clean_java_source",
133-
"arguments": {
134-
"cwd": "/path/to/java/sdk/module"
135-
}
136-
}
137-
```
138-
139-
### 4. build_java_sdk
122+
### 3. build_java_sdk
140123
Build the Java SDK for a service sub module whose groupId starts with `com.azure`. The tool takes the module directory, root directory, groupId and artifactId as input parameters.
141124

142125
**Parameters:**
@@ -158,7 +141,7 @@ Build the Java SDK for a service sub module whose groupId starts with `com.azure
158141
}
159142
```
160143

161-
### 5. get_java_sdk_changelog
144+
### 4. get_java_sdk_changelog
162145
Get the changelog for a service sub module whose groupId starts with `com.azure`. The tool takes the jarPath, groupId and artifactId as input parameters.
163146

164147
**Parameters:**
@@ -178,7 +161,7 @@ Get the changelog for a service sub module whose groupId starts with `com.azure`
178161
}
179162
```
180163

181-
### 6. update_java_sdk_changelog
164+
### 5. update_java_sdk_changelog
182165
Update the CHANGELOG.md file for a service sub module whose groupId starts with `com.azure`. The tool takes the absolute path to the JAR file, groupId and artifactId as input parameters.
183166

184167
**Parameters:**
@@ -198,7 +181,7 @@ Update the CHANGELOG.md file for a service sub module whose groupId starts with
198181
}
199182
```
200183

201-
### 7. instruction_migrate_typespec
184+
### 6. instruction_migrate_typespec
202185
Get instructions for generating Java SDK after migrating from Swagger to TypeSpec.
203186

204187
**Parameters:**
@@ -212,7 +195,7 @@ Get instructions for generating Java SDK after migrating from Swagger to TypeSpe
212195
}
213196
```
214197

215-
### 8. update_client_name
198+
### 7. update_client_name
216199
Update client name for both client.tsp and the generated java sdk. Follow the returned instruction to update old client name to new client name, be sure to ask for old client name and new client name. e.g. MediaMessageContent.mediaUri to MediaMessageContent.mediaUrl
217200

218201
**Parameters:**
@@ -226,7 +209,7 @@ Update client name for both client.tsp and the generated java sdk. Follow the re
226209
}
227210
```
228211

229-
### 9. prepare_java_sdk_environment
212+
### 8. prepare_java_sdk_environment
230213
Prepare the development environment for Java SDK generation, including 3 main areas: Node.js/npm, Java environment, and TypeSpec tools.
231214

232215
**Parameters:**

eng/tools/mcp/azure-sdk-java-mcp/src/brownfield-migrate.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@ import { CallToolResult } from "@modelcontextprotocol/sdk/types";
33
export async function brownfieldMigration(): Promise<CallToolResult> {
44
const cookbook = `Follow the instructions below to migrate the Java SDK to generate from TypeSpec.
55
6+
DO NOT SKIP STEP 3, IN ANY CONDITION.
7+
68
1. Initiate the Java SDK with the given URL to the "tspconfig.yaml" file.
79
Use the tool to initiate the Java SDK, from tspconfig.yaml URL. This tool create a "tsp-location.yaml" file.
810
911
2. Find the path to SDK module and its "pom.xml" file.
1012
Run "git status --porcelain" to find the "tsp-location.yaml" file. The path to the SDK module is the directory containing the "tsp-location.yaml" file. The "pom.xml" file is located in the same directory.
1113
1214
3. Clean the Java source in SDK module.
13-
Use the tool to clean the Java source in the SDK module.
15+
Delete folder "src/main" in the SDK module. Delete folder "src/samples/**/generated" and "src/test/**/generated" in the SDK module.
1416
15-
4. Synchronize the TypeSpec source for Java SDK.
16-
Use the tool to synchronize the TypeSpec source for the Java SDK. This will download the the TypeSpec source specified in the "tsp-location.yaml" file.
17+
4. Generate Java SDK from the TypeSpec source.
18+
Use the tool to generate the Java SDK. This will generate the Java SDK from existing TypeSpec source in "TempTypeSpecFiles" folder.
1719
1820
5. Build the Java SDK.
1921
Use the tool to build the Java SDK. This will compile the Java code and generate the necessary artifacts, e.g. JAR file.
@@ -28,7 +30,9 @@ export async function brownfieldMigration(): Promise<CallToolResult> {
2830
If there is no such candidates, the migration is completed, and you can skip all the next steps.
2931
3032
8. Apply the changes to the TypeSpec source.
31-
Use the tool to apply the rename changes to the TypeSpec source. Ask it to e.g. "Update client name, rename model from <old_name> to <new_name>".
33+
Use the tool to apply the rename changes to the TypeSpec source, so that it can keep the original naming.
34+
Ask it to e.g. "Update client name, rename model from <name_after_codegen> to <name_before_codegen>".
35+
Java SDK is following the convention of e.g. "username", "hostname", "Ip", "Id". Hence, the tool should keep using these naming patterns.
3236
3337
9. Go to step 5.
3438
`;

eng/tools/mcp/azure-sdk-java-mcp/src/index.ts

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { initJavaSdk } from "./init-java-sdk.js";
1010
import { prepareJavaSdkEnvironmentCookbook } from "./prepare-environment.js";
1111
import { buildJavaSdk } from "./build-java-sdk.js";
1212
import { getJavaSdkChangelog } from "./java-sdk-changelog.js";
13-
import { cleanJavaSource } from "./clean-java-source.js";
1413
import { updateChangelogMd } from "./update-changelog-md.js";
1514

1615
// Create the MCP server
@@ -25,28 +24,28 @@ const logToolCall = (toolName: string) => {
2524
process.stderr.write(logMsg);
2625
};
2726

28-
// Tool: clean_java_source
29-
server.registerTool(
30-
"clean_java_source",
31-
{
32-
description:
33-
"Remove all generated Java source files and directories for a given module. This tool is typically used to clean up the output of previous SDK generations before a new build. It should only be applied to packages with the prefix `azure-resourcemanager-*`.",
34-
inputSchema: {
35-
cwd: z
36-
.string()
37-
.describe(
38-
"The absolute path to the module directory containing tsp-location.yaml. Example: C:\\workspace\\azure-sdk-for-java\\sdk\\devcenter\\azure-resourcemanager-devcenter",
39-
),
40-
},
41-
annotations: {
42-
title: "Clean Java Source",
43-
},
44-
},
45-
async (args) => {
46-
logToolCall("clean_java_source");
47-
return await cleanJavaSource(args.cwd);
48-
},
49-
);
27+
// // Tool: clean_java_source
28+
// server.registerTool(
29+
// "clean_java_source",
30+
// {
31+
// description:
32+
// "Remove all generated Java source files and directories for a given module. This tool is typically used to clean up the output of previous SDK generations before a new build. It should only be applied to packages with the prefix `azure-resourcemanager-*`.",
33+
// inputSchema: {
34+
// cwd: z
35+
// .string()
36+
// .describe(
37+
// "The absolute path to the module directory containing tsp-location.yaml. Example: C:\\workspace\\azure-sdk-for-java\\sdk\\devcenter\\azure-resourcemanager-devcenter",
38+
// ),
39+
// },
40+
// annotations: {
41+
// title: "Clean Java Source",
42+
// },
43+
// },
44+
// async (args) => {
45+
// logToolCall("clean_java_source");
46+
// return await cleanJavaSource(args.cwd);
47+
// },
48+
// );
5049

5150
// Tool: build_java_sdk
5251
server.registerTool(

0 commit comments

Comments
 (0)