Skip to content

Commit 5c654f2

Browse files
[azure-sdk-java-mcp] Fix typos and address comments on the initial pr (#46011)
* update according to comments * fix the issue that pure `mvn` commands are run after running build java sdk * Update eng/tools/mcp/azure-sdk-java-mcp/src/index.ts Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 36b850a commit 5c654f2

File tree

6 files changed

+28
-23
lines changed

6 files changed

+28
-23
lines changed

.github/copilot-instructions.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ The Azure SDK for Java repository contains client libraries for Azure services,
2222
- **Management Libraries**: Libraries with Maven group `com.azure.resourcemanager`
2323
- **Spring Libraries**: Libraries with Maven group `com.azure.spring`
2424

25-
## SDK Generation Guildlines
25+
## SDK Generation Guidelines
2626

2727
ACTION: Use azure-sdk-java-mcp sdk tools to generate the SDK.
28-
ACTION: Use azure-sdk-java-mcp sdk tools to build the SDK.
28+
ACTION: Do not use pure `mvn` command to compile, build or package SDK, use `build_java_sdk` tool instead, it runs `mvn` command inside.
29+
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.
31+
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.
32+
2933

3034
## Behavior
3135

.github/workflows/azure-java-sdk-mcp-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Setup Node.js
2222
uses: actions/setup-node@v4
2323
with:
24-
node-version: '20'
24+
node-version: '22.x'
2525
cache: 'npm'
2626
cache-dependency-path: 'eng/tools/mcp/azure-sdk-java-mcp/package-lock.json'
2727

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A Model Context Protocol (MCP) server that provides comprehensive tools for gene
66

77
This MCP server provides the following tools:
88

9-
1. **sync_java_sdk** - Synchronize/Download TypeSpec source files for Java SDK generation from local or remote sources
9+
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
1111
3. **clean_java_source** - Clean and remove generated Java source files from SDK directory
1212
4. **build_java_sdk** - Compile and build the Java SDK with Maven for Azure services
@@ -23,7 +23,8 @@ Before using this MCP server, ensure you have:
2323
1. **Project Structure** - The tools can be run from either:
2424
- A service module directory containing `tsp-location.yaml` (e.g., `/azure-sdk-for-java/sdk/batch/azure-compute-batch`)
2525
- The SDK root directory (e.g., `/azure-sdk-for-java`)
26-
2. **Nodejs** installed.
26+
2. **Node.js** - Version 20.0.0 or higher installed.
27+
3. **MCP Client** - A compatible MCP client such as GitHub Copilot or Claude Desktop
2728

2829
## Configure MCP Server in VSCode
2930

@@ -84,7 +85,7 @@ npm run test:run # Run tests once
8485

8586
## Tools Documentation
8687

87-
### 1. sync_java_sdk
88+
### 1. sync_typespec_source_files
8889
Synchronize/Download the TypeSpec source for a target service to generate Java SDK from. Always ask user to provide local tspconfig.yaml path or remote tspconfig.yaml url. The tool takes local tspconfig.yaml path or remote tspconfig.yaml url as input parameter.
8990

9091
**Parameters:**
@@ -96,7 +97,7 @@ Synchronize/Download the TypeSpec source for a target service to generate Java S
9697
**Example:**
9798
```json
9899
{
99-
"name": "sync_java_sdk",
100+
"name": "sync_typespec_source_files",
100101
"arguments": {
101102
"localTspConfigPath": "C:\\workspace\\azure-rest-api-specs\\specification\\communication\\Communication.Messages\\tspconfig.yaml"
102103
}
@@ -260,7 +261,9 @@ This flexibility allows you to work at the level that best suits your workflow.
260261
2. Add tests for new functionality in `src/**/*.spec.ts`
261262
3. Build the project with `npm run build`
262263
4. Test your changes with `npm test` and `npm start`
264+
5. Format and lint your code with `npm run format` and `npm run lint`
263265

264266
## License
265267

266268
MIT
269+

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export async function buildJavaSdk(
1414

1515
const mvnCmd = process.platform === "win32" ? "mvn.cmd" : "mvn";
1616

17-
// Run the Java SDK generation command
18-
const generateResult = await spawnAsync(
17+
// Run the Java SDK Build command
18+
const buildResult = await spawnAsync(
1919
mvnCmd,
2020
[
2121
"--no-transfer-progress",
@@ -33,24 +33,24 @@ export async function buildJavaSdk(
3333
],
3434
{
3535
cwd: process.cwd(),
36-
shell: true, // Use shell to allow tsp-client command
36+
shell: true,
3737
timeout: 600000, // 10 minute timeout
3838
},
3939
);
4040

4141
let result = `Java SDK Build Results:\n\n`;
4242

43-
if (generateResult.success) {
43+
if (buildResult.success) {
4444
result += `✅ SDK build completed successfully!\n\n`;
4545
} else {
46-
result += `❌ SDK build failed with exit code ${generateResult.exitCode}\n\n`;
46+
result += `❌ SDK build failed with exit code ${buildResult.exitCode}\n\n`;
4747

48-
if (generateResult.stdout) {
49-
result += `Output:\n${generateResult.stdout}\n`;
48+
if (buildResult.stdout) {
49+
result += `Output:\n${buildResult.stdout}\n`;
5050
}
5151

52-
if (generateResult.stderr) {
53-
result += `\nErrors:\n${generateResult.stderr}\n`;
52+
if (buildResult.stderr) {
53+
result += `\nErrors:\n${buildResult.stderr}\n`;
5454
}
5555
}
5656

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ server.registerTool(
146146
},
147147
);
148148

149-
// Tool: sync_java_sdk
149+
// Tool: sync_typespec_source_files
150150
server.registerTool(
151-
"sync_java_sdk",
151+
"sync_typespec_source_files",
152152
{
153153
description:
154154
"Synchronize or download the TypeSpec source for a target service to enable Java SDK generation. Accepts either a local absolute path to tspconfig.yaml or a remote URL (with commit id, not branch name).",
@@ -167,11 +167,11 @@ server.registerTool(
167167
),
168168
},
169169
annotations: {
170-
title: "Sync Java SDK",
170+
title: "Sync TypeSpec Source Files",
171171
},
172172
},
173173
async (args) => {
174-
logToolCall("sync_java_sdk");
174+
logToolCall("sync_typespec_source_files");
175175
const result = await initJavaSdk(args.localTspConfigPath, args.remoteTspConfigUrl);
176176
return result;
177177
},
@@ -182,7 +182,7 @@ server.registerTool(
182182
"generate_java_sdk",
183183
{
184184
description:
185-
"Generate the Java SDK from TypeSpec source files located in the 'TempTypeSpecFiles' directory within the specified working directory. If 'TempTypeSpecFiles' is not present, prompt the user to specify whether to generate from a local or remote TypeSpec source, and use the sync_java_sdk tool as needed before proceeding.",
185+
"Generate the Java SDK from TypeSpec source files located in the 'TempTypeSpecFiles' directory within the specified working directory. If 'TempTypeSpecFiles' is not present, prompt the user to specify whether to generate from a local or remote TypeSpec source, and use the sync_typespec_source_files tool as needed before proceeding.",
186186
inputSchema: {
187187
cwd: z
188188
.string()

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ export async function initJavaSdk(localTspConfigPath?: string, remoteTspConfigUr
1919
localTspConfigPath,
2020
"--local-spec-repo",
2121
localTspConfigPath,
22-
"--commit",
23-
"123",
2422
"--save-inputs",
2523
],
2624
{

0 commit comments

Comments
 (0)