azure_java_sdk_code_samples
Access ready-to-use Java code samples for Azure SDK packages to simplify integration and development tasks. Enter the package name to retrieve relevant examples.
Instructions
Get code samples for Azure Java SDK, the package name usually starts with 'azure-'
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| package | Yes | package name of the Azure SDK, for example: 'azure-ai-inference' |
Input Schema (JSON Schema)
{
"properties": {
"package": {
"description": "package name of the Azure SDK, for example: 'azure-ai-inference'",
"type": "string"
}
},
"required": [
"package"
],
"type": "object"
}
Implementation Reference
- index.js:64-98 (handler)Handler function that fetches the latest version of the Azure Java SDK package from Maven repository, retrieves the README.md, and returns its content.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 for the tool, requiring a 'package' string parameter.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)Tool registration in the ListTools response, including name, description, and 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"], }, },