list-resource-groups
Retrieve all resource groups within your Azure subscription to manage and organize cloud resources effectively.
Instructions
List all resource groups in the selected subscription
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list-resource-groups"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/AzureServer.ts:353-360 (registration)Tool registration defining the name, description, and empty input schema in the listTools response.
{ name: "list-resource-groups", description: "List all resource groups in the selected subscription", inputSchema: { type: "object", properties: {}, required: [], }, - src/AzureServer.ts:580-601 (handler)Wrapper handler method that implements caching and error handling, delegating to AzureOperations.listResourceGroups()
private async handleListResourceGroups() { if (!this.context.resourceClient) { throw new AzureMCPError("Client not initialized", "NO_CLIENT"); } try { const cacheKey = `resource-groups-${this.context.selectedSubscription}`; return await this.getCachedResource( cacheKey, async () => { // Use azureOperations to handle the business logic return await this.azureOperations.listResourceGroups(); }, 30000 ); } catch (error) { this.logWithContext("error", `Error listing resource groups: ${error}`, { error, }); throw new AzureResourceError(`Failed to list resource groups: ${error}`); } } - src/AzureServer.ts:963-979 (handler)Core implementation in AzureOperations class that iterates over ResourceManagementClient.resourceGroups.list() to collect and return resource group details (id, name, location, tags).
async listResourceGroups() { if (!this.context.resourceClient) { throw new AzureMCPError("Client not initialized", "NO_CLIENT"); } const resourceGroups = []; for await (const group of this.context.resourceClient.resourceGroups.list()) { resourceGroups.push({ id: group.id, name: group.name, location: group.location, tags: group.tags || {}, }); } return resourceGroups; }