create-resource-group
Create a new Azure resource group to organize and manage cloud resources by specifying name, location, and optional tags.
Instructions
Create a new resource group
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Resource group name | |
| location | Yes | Azure region | |
| tags | No | Resource tags (optional) |
Implementation Reference
- src/AzureServer.ts:992-1005 (handler)Core handler function in AzureOperations class that performs the actual resource group creation using Azure ResourceManagementClient's createOrUpdate method.async createResourceGroup( name: string, location: string, tags?: Record<string, string> ) { if (!this.context.resourceClient) { throw new AzureMCPError("Client not initialized", "NO_CLIENT"); } return await this.context.resourceClient.resourceGroups.createOrUpdate( name, { location, tags } ); }
- src/AzureServer.ts:647-686 (handler)Primary MCP tool handler method that validates input arguments using Zod, delegates to AzureOperations.createResourceGroup, invalidates cache, and formats the response.private async handleCreateResourceGroup(args: any) { const { name, location, tags } = z .object({ name: z.string().min(1, "Resource group name cannot be empty"), location: z.string().min(1, "Location cannot be empty"), tags: z.record(z.string()).optional(), }) .parse(args); if (!this.context.resourceClient) { throw new AzureMCPError("Client not initialized", "NO_CLIENT"); } try { // Use azureOperations to create the resource group const result = await this.azureOperations.createResourceGroup( name, location, tags ); // Invalidate cache for resource groups list this.resourceCache.delete( `resource-groups-${this.context.selectedSubscription}` ); return { id: result.id, name: result.name, location: result.location, tags: result.tags || {}, provisioningState: result.properties?.provisioningState, }; } catch (error) { this.logWithContext("error", `Error creating resource group: ${error}`, { error, }); throw new AzureResourceError(`Failed to create resource group: ${error}`); } }
- src/AzureServer.ts:376-397 (registration)Tool registration in handleListTools method, defining the tool name, description, and input schema for MCP protocol.{ name: "create-resource-group", description: "Create a new resource group", inputSchema: { type: "object", properties: { name: { type: "string", description: "Resource group name", }, location: { type: "string", description: "Azure region", }, tags: { type: "object", description: "Resource tags (optional)", }, }, required: ["name", "location"], }, },
- src/AzureServer.ts:451-453 (registration)Switch case in handleCallTool that dispatches calls to the specific handler for 'create-resource-group' tool.case "create-resource-group": result = await this.handleCreateResourceGroup(args); break;
- src/AzureServer.ts:648-654 (schema)Zod schema validation for input arguments in the handler function, providing additional runtime type checking.const { name, location, tags } = z .object({ name: z.string().min(1, "Resource group name cannot be empty"), location: z.string().min(1, "Location cannot be empty"), tags: z.record(z.string()).optional(), }) .parse(args);