get-resource-details
Retrieve comprehensive details for a specific Azure resource by providing its Resource ID, enabling efficient resource management and insights through the Azure MCP Server.
Instructions
Get detailed information about a specific resource
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| resourceId | Yes | Azure Resource ID |
Implementation Reference
- src/AzureServer.ts:603-645 (handler)Main handler method for the 'get-resource-details' tool. Performs input validation, caching, error handling, delegates to AzureOperations.getResource, and returns formatted resource details.private async handleGetResourceDetails(args: any) { const { resourceId } = z .object({ resourceId: z.string().min(1, "Resource ID cannot be empty"), }) .parse(args); if (!this.context.resourceClient) { throw new AzureMCPError("Client not initialized", "NO_CLIENT"); } try { // The resource ID format is: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{provider}/{resourceType}/{resourceName} const parts = resourceId.split("/"); if (parts.length < 8) { throw new AzureResourceError("Invalid resource ID format"); } const cacheKey = `resource-${resourceId}`; const resource = await this.getCachedResource( cacheKey, async () => { // Use azureOperations to get the resource return await this.azureOperations.getResource(resourceId); }, 60000 ); // Cache for 1 minute return { id: resource.id, name: resource.name, type: resource.type, location: resource.location, tags: resource.tags || {}, properties: resource.properties || {}, }; } catch (error) { this.logWithContext("error", `Error getting resource details: ${error}`, { error, }); throw new AzureResourceError(`Failed to get resource details: ${error}`); } }
- src/AzureServer.ts:981-990 (helper)Helper method in AzureOperations class that performs the actual Azure SDK call to retrieve resource details by ID using ResourceManagementClient.resources.getById.async getResource(resourceId: string) { if (!this.context.resourceClient) { throw new AzureMCPError("Client not initialized", "NO_CLIENT"); } return await this.context.resourceClient.resources.getById( resourceId, "latest" ); }
- src/AzureServer.ts:362-375 (registration)Tool registration in the handleListTools method, defining the tool name, description, and input schema for 'get-resource-details'.{ name: "get-resource-details", description: "Get detailed information about a specific resource", inputSchema: { type: "object", properties: { resourceId: { type: "string", description: "Azure Resource ID", }, }, required: ["resourceId"], }, },
- src/AzureServer.ts:604-608 (schema)Zod schema validation for input arguments within the handler function.const { resourceId } = z .object({ resourceId: z.string().min(1, "Resource ID cannot be empty"), }) .parse(args);