azure_java_sdk_code_samples
Access code samples for Azure Java SDK packages to implement Azure services in Java applications. Provide the package name to retrieve working examples.
Instructions
Get code samples for Azure Java SDK, the package name usually starts with 'azure-'
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| package | Yes | package name of the Azure SDK, for example: 'azure-ai-inference' |
Implementation Reference
- index.js:64-98 (handler)Handler logic that fetches the latest version of the Azure Java SDK package from Maven repository, retrieves its README.md, and returns the content as text.case "azure_java_sdk_code_samples": const { package: packageName } = args; if (!packageName) { throw new McpError( ErrorCode.InvalidRequest, "Package name is required" ); } const groupId = "com.azure"; const groupPath = groupId.replace(/\./g, "/"); const artifactId = packageName; // Get latest version const artifactUrl = "https://repo1.maven.org/maven2/" + groupPath + "/" + artifactId; let response = await fetch(artifactUrl + "/maven-metadata.xml"); const listData = await response.text(); // Extract version from <latest>version</latest> tag const versionRegex = /<latest>(.*?)<\/latest>/; const versionMatch = listData.match(versionRegex); const latestVersion = versionMatch[1]; // Get the readme.md of the SDK const readmeUrl = artifactUrl + "/" + latestVersion + "/" + artifactId + "-" + latestVersion + "-readme.md"; response = await fetch(readmeUrl); const readmeData = await response.text(); return { content: [ { type: "text", text: readmeData, }, ], };
- index.js:43-52 (schema)Input schema defining the required 'package' parameter as a string.inputSchema: { type: "object", properties: { package: { type: "string", description: "package name of the Azure SDK, for example: 'azure-ai-inference'", }, }, required: ["package"], },
- index.js:40-53 (registration)Registration of the tool in the ListToolsRequestSchema handler, including name, description, and input schema.{ name: "azure_java_sdk_code_samples", description: "Get code samples for Azure Java SDK, the package name usually starts with 'azure-'", inputSchema: { type: "object", properties: { package: { type: "string", description: "package name of the Azure SDK, for example: 'azure-ai-inference'", }, }, required: ["package"], }, },