azuresfimcpagent 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. azuresfimcpagent-1.0.0/LICENSE +21 -0
  2. azuresfimcpagent-1.0.0/MANIFEST.in +10 -0
  3. azuresfimcpagent-1.0.0/PKG-INFO +173 -0
  4. azuresfimcpagent-1.0.0/README.md +151 -0
  5. azuresfimcpagent-1.0.0/agent/AGENT_INSTRUCTIONS.md +176 -0
  6. azuresfimcpagent-1.0.0/agent/__init__.py +9 -0
  7. azuresfimcpagent-1.0.0/agent/scripts/attach-log-analytics.ps1 +26 -0
  8. azuresfimcpagent-1.0.0/agent/scripts/attach-nsp.ps1 +65 -0
  9. azuresfimcpagent-1.0.0/agent/scripts/check-log-analytics.ps1 +24 -0
  10. azuresfimcpagent-1.0.0/agent/scripts/check-nsp.ps1 +17 -0
  11. azuresfimcpagent-1.0.0/agent/scripts/create-resourcegroup.ps1 +33 -0
  12. azuresfimcpagent-1.0.0/agent/scripts/deploy-bicep.ps1 +56 -0
  13. azuresfimcpagent-1.0.0/agent/scripts/list-permissions.ps1 +14 -0
  14. azuresfimcpagent-1.0.0/agent/scripts/list-resources.ps1 +42 -0
  15. azuresfimcpagent-1.0.0/agent/server.py +799 -0
  16. azuresfimcpagent-1.0.0/agent/templates/ai-foundry.bicep +63 -0
  17. azuresfimcpagent-1.0.0/agent/templates/ai-search.bicep +48 -0
  18. azuresfimcpagent-1.0.0/agent/templates/azure-key-vaults.bicep +50 -0
  19. azuresfimcpagent-1.0.0/agent/templates/azure-openai.bicep +58 -0
  20. azuresfimcpagent-1.0.0/agent/templates/cosmos-db.bicep +84 -0
  21. azuresfimcpagent-1.0.0/agent/templates/log-analytics.bicep +58 -0
  22. azuresfimcpagent-1.0.0/agent/templates/nsp.bicep +21 -0
  23. azuresfimcpagent-1.0.0/agent/templates/storage-account.bicep +51 -0
  24. azuresfimcpagent-1.0.0/agent/templates/user-assigned-managed-identity.bicep +21 -0
  25. azuresfimcpagent-1.0.0/azuresfimcpagent.egg-info/PKG-INFO +173 -0
  26. azuresfimcpagent-1.0.0/azuresfimcpagent.egg-info/SOURCES.txt +30 -0
  27. azuresfimcpagent-1.0.0/azuresfimcpagent.egg-info/dependency_links.txt +1 -0
  28. azuresfimcpagent-1.0.0/azuresfimcpagent.egg-info/entry_points.txt +2 -0
  29. azuresfimcpagent-1.0.0/azuresfimcpagent.egg-info/requires.txt +1 -0
  30. azuresfimcpagent-1.0.0/azuresfimcpagent.egg-info/top_level.txt +1 -0
  31. azuresfimcpagent-1.0.0/pyproject.toml +46 -0
  32. azuresfimcpagent-1.0.0/setup.cfg +4 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Azure SFI Agent Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,10 @@
1
+ # Manifest file to include non-Python files in the package
2
+ include LICENSE
3
+ include README.md
4
+ include pyproject.toml
5
+ recursive-include agent/scripts *.ps1
6
+ recursive-include agent/templates *.bicep
7
+ include agent/AGENT_INSTRUCTIONS.md
8
+ global-exclude __pycache__
9
+ global-exclude *.py[co]
10
+ global-exclude .DS_Store
@@ -0,0 +1,173 @@
1
+ Metadata-Version: 2.1
2
+ Name: azuresfimcpagent
3
+ Version: 1.0.0
4
+ Summary: Azure MCP Agent for secure, compliant resource deployment
5
+ Author: Siddhant Jha
6
+ Project-URL: Homepage, https://github.com/yourusername/azure-sfi-agent
7
+ Project-URL: Repository, https://github.com/yourusername/azure-sfi-agent
8
+ Project-URL: Issues, https://github.com/yourusername/azure-sfi-agent/issues
9
+ Keywords: mcp,azure,deployment,bicep,agent,sfi
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Operating System :: OS Independent
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: mcp>=0.1.0
22
+
23
+ # Azure SFI MCP Agent - Installation Guide
24
+
25
+ ## Description
26
+
27
+ **Azure SFI MCP Agent** is a Model Context Protocol (MCP) server that enables secure, compliant Azure resource deployment directly from VS Code using GitHub Copilot Chat. This agent helps you create SFI compliant Azure resources with automatic compliance orchestration.
28
+
29
+ ### Capabilities
30
+
31
+ 1. **List Azure Permissions** - View your active role assignments and access levels
32
+ 2. **List Azure Resources** - Browse resources across subscriptions and resource groups
33
+ 3. **Create SFI-Compliant Resources** - Deploy Azure resources with automatic compliance features:
34
+ - Storage Accounts (ADLS Gen2)
35
+ - Key Vaults
36
+ - Azure OpenAI
37
+ - AI Search
38
+ - AI Foundry
39
+ - Cosmos DB
40
+ - Log Analytics Workspaces
41
+ - Network Security Perimeters (NSP)
42
+ - User Assigned Managed Identity (UAMI)
43
+ 4. **Add Diagnostic Settings** - Automatically configure Log Analytics monitoring
44
+ 5. **NSP Attachment** - Automatic Network Security Perimeter attachment for supported resources
45
+
46
+ ---
47
+
48
+ ## Prerequisites
49
+
50
+ Before installing the Azure SFI MCP Agent, ensure you have the following installed:
51
+
52
+ ### Required Software
53
+
54
+ 1. **Visual Studio Code** - [Download](https://code.visualstudio.com/download)
55
+ 2. **PowerShell Core (pwsh)** - [Download](https://learn.microsoft.com/en-us/powershell/scripting/install/install-powershell-on-windows?view=powershell-7.5)
56
+ 3. **Azure CLI** - [Download](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest&pivots=winget)
57
+ 4. **Python 3.10+** - [Download](https://www.python.org/downloads/)
58
+ 5. **uvx** - [Download](https://docs.astral.sh/uv/getting-started/installation/)
59
+ 6. **GitHub Copilot Chat Extension** - [Install from VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot-chat)
60
+
61
+ ### Azure Requirements
62
+
63
+ - Active Azure subscription
64
+ - Appropriate Azure RBAC permissions for resource creation
65
+ - Azure CLI authenticated (`az login`)
66
+
67
+ ---
68
+
69
+ ## Installation Steps
70
+
71
+ ### Step 1: Open GitHub Copilot Chat
72
+
73
+ 1. Launch **Visual Studio Code**
74
+ 2. Open **GitHub Copilot Chat** (click the chat icon in the sidebar or press `Ctrl+Alt+I`)
75
+
76
+ ### Step 2: Access MCP Tools Menu
77
+
78
+ 1. In the Copilot Chat window, click on the **🔧 Tools** button
79
+ 2. Select **"Install MCP Server from PyPI"** or similar option
80
+
81
+ ### Step 3: Install the Package
82
+
83
+ 1. When prompted for the package name, enter:
84
+ ```
85
+ azuresfimcpagent
86
+ ```
87
+ 2. Select the **latest version** when prompted
88
+ 3. Wait for the installation to complete
89
+
90
+ ### Step 4: Configure MCP Settings
91
+ Add the following configuration to the `mcp.json` file:
92
+
93
+ ```json
94
+ {
95
+ "mcpServers": {
96
+ "azuresfimcpagent": {
97
+ "type": "stdio",
98
+ "command": "uvx",
99
+ "args": [
100
+ "azuresfimcpagent==1.0.0"
101
+ ]
102
+ }
103
+ }
104
+ }
105
+ ```
106
+
107
+ > **Note**: Replace `1.0.0` with the latest version number you installed.
108
+
109
+ ### Step 5: Restart VS Code
110
+
111
+ 1. Close and reopen Visual Studio Code to load the MCP server configuration
112
+ 2. Open GitHub Copilot Chat again
113
+ 3. Select the MCP Tool installed
114
+
115
+ ### Step 6: Verify Installation
116
+
117
+ In GitHub Copilot Chat, type:
118
+ ```
119
+ show menu
120
+ ```
121
+
122
+ You should see the available actions menu confirming successful installation.
123
+
124
+ ---
125
+
126
+ ## 💡 Usage Examples
127
+
128
+ ### List Your Azure Permissions
129
+ ```
130
+ list my azure permissions
131
+ ```
132
+
133
+ ### List Azure Resources
134
+ ```
135
+ list resources in resource-group-name
136
+ ```
137
+
138
+ ### Create a Storage Account
139
+ ```
140
+ create storage account
141
+ ```
142
+
143
+ ### Create a Key Vault
144
+ ```
145
+ create key vault
146
+ ```
147
+
148
+ The agent will interactively prompt you for required parameters and automatically:
149
+ - ✅ Deploy the SFI compliant resources
150
+ - ✅ Configure Log Analytics diagnostic settings
151
+ - ✅ Apply security best practices and compliance controls
152
+
153
+ ---
154
+
155
+ ### Azure CLI Authentication
156
+
157
+ Ensure you're logged into Azure CLI:
158
+ ```bash
159
+ az login
160
+ az account show
161
+ ```
162
+
163
+ ### PowerShell Core Required
164
+
165
+ This agent requires PowerShell Core (pwsh), not Windows PowerShell. Verify:
166
+ ```bash
167
+ pwsh --version
168
+ ```
169
+ ---
170
+
171
+ ## 📄 License
172
+
173
+ MIT License - see LICENSE file for details
@@ -0,0 +1,151 @@
1
+ # Azure SFI MCP Agent - Installation Guide
2
+
3
+ ## Description
4
+
5
+ **Azure SFI MCP Agent** is a Model Context Protocol (MCP) server that enables secure, compliant Azure resource deployment directly from VS Code using GitHub Copilot Chat. This agent helps you create SFI compliant Azure resources with automatic compliance orchestration.
6
+
7
+ ### Capabilities
8
+
9
+ 1. **List Azure Permissions** - View your active role assignments and access levels
10
+ 2. **List Azure Resources** - Browse resources across subscriptions and resource groups
11
+ 3. **Create SFI-Compliant Resources** - Deploy Azure resources with automatic compliance features:
12
+ - Storage Accounts (ADLS Gen2)
13
+ - Key Vaults
14
+ - Azure OpenAI
15
+ - AI Search
16
+ - AI Foundry
17
+ - Cosmos DB
18
+ - Log Analytics Workspaces
19
+ - Network Security Perimeters (NSP)
20
+ - User Assigned Managed Identity (UAMI)
21
+ 4. **Add Diagnostic Settings** - Automatically configure Log Analytics monitoring
22
+ 5. **NSP Attachment** - Automatic Network Security Perimeter attachment for supported resources
23
+
24
+ ---
25
+
26
+ ## Prerequisites
27
+
28
+ Before installing the Azure SFI MCP Agent, ensure you have the following installed:
29
+
30
+ ### Required Software
31
+
32
+ 1. **Visual Studio Code** - [Download](https://code.visualstudio.com/download)
33
+ 2. **PowerShell Core (pwsh)** - [Download](https://learn.microsoft.com/en-us/powershell/scripting/install/install-powershell-on-windows?view=powershell-7.5)
34
+ 3. **Azure CLI** - [Download](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest&pivots=winget)
35
+ 4. **Python 3.10+** - [Download](https://www.python.org/downloads/)
36
+ 5. **uvx** - [Download](https://docs.astral.sh/uv/getting-started/installation/)
37
+ 6. **GitHub Copilot Chat Extension** - [Install from VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot-chat)
38
+
39
+ ### Azure Requirements
40
+
41
+ - Active Azure subscription
42
+ - Appropriate Azure RBAC permissions for resource creation
43
+ - Azure CLI authenticated (`az login`)
44
+
45
+ ---
46
+
47
+ ## Installation Steps
48
+
49
+ ### Step 1: Open GitHub Copilot Chat
50
+
51
+ 1. Launch **Visual Studio Code**
52
+ 2. Open **GitHub Copilot Chat** (click the chat icon in the sidebar or press `Ctrl+Alt+I`)
53
+
54
+ ### Step 2: Access MCP Tools Menu
55
+
56
+ 1. In the Copilot Chat window, click on the **🔧 Tools** button
57
+ 2. Select **"Install MCP Server from PyPI"** or similar option
58
+
59
+ ### Step 3: Install the Package
60
+
61
+ 1. When prompted for the package name, enter:
62
+ ```
63
+ azuresfimcpagent
64
+ ```
65
+ 2. Select the **latest version** when prompted
66
+ 3. Wait for the installation to complete
67
+
68
+ ### Step 4: Configure MCP Settings
69
+ Add the following configuration to the `mcp.json` file:
70
+
71
+ ```json
72
+ {
73
+ "mcpServers": {
74
+ "azuresfimcpagent": {
75
+ "type": "stdio",
76
+ "command": "uvx",
77
+ "args": [
78
+ "azuresfimcpagent==1.0.0"
79
+ ]
80
+ }
81
+ }
82
+ }
83
+ ```
84
+
85
+ > **Note**: Replace `1.0.0` with the latest version number you installed.
86
+
87
+ ### Step 5: Restart VS Code
88
+
89
+ 1. Close and reopen Visual Studio Code to load the MCP server configuration
90
+ 2. Open GitHub Copilot Chat again
91
+ 3. Select the MCP Tool installed
92
+
93
+ ### Step 6: Verify Installation
94
+
95
+ In GitHub Copilot Chat, type:
96
+ ```
97
+ show menu
98
+ ```
99
+
100
+ You should see the available actions menu confirming successful installation.
101
+
102
+ ---
103
+
104
+ ## 💡 Usage Examples
105
+
106
+ ### List Your Azure Permissions
107
+ ```
108
+ list my azure permissions
109
+ ```
110
+
111
+ ### List Azure Resources
112
+ ```
113
+ list resources in resource-group-name
114
+ ```
115
+
116
+ ### Create a Storage Account
117
+ ```
118
+ create storage account
119
+ ```
120
+
121
+ ### Create a Key Vault
122
+ ```
123
+ create key vault
124
+ ```
125
+
126
+ The agent will interactively prompt you for required parameters and automatically:
127
+ - ✅ Deploy the SFI compliant resources
128
+ - ✅ Configure Log Analytics diagnostic settings
129
+ - ✅ Apply security best practices and compliance controls
130
+
131
+ ---
132
+
133
+ ### Azure CLI Authentication
134
+
135
+ Ensure you're logged into Azure CLI:
136
+ ```bash
137
+ az login
138
+ az account show
139
+ ```
140
+
141
+ ### PowerShell Core Required
142
+
143
+ This agent requires PowerShell Core (pwsh), not Windows PowerShell. Verify:
144
+ ```bash
145
+ pwsh --version
146
+ ```
147
+ ---
148
+
149
+ ## 📄 License
150
+
151
+ MIT License - see LICENSE file for details
@@ -0,0 +1,176 @@
1
+ name: Azure SFI Compliance Agent Instructions
2
+ version: 2.0.0
3
+ description: Interactive deployment with automatic NSP and Log Analytics orchestration
4
+ applyTo: '**'
5
+ ---
6
+
7
+ ## CRITICAL DEPLOYMENT RULE
8
+ **ALL Azure resource deployments MUST use the interactive MCP tool workflow.**
9
+ - NEVER use manual `az deployment` commands
10
+ - NEVER use direct Azure CLI for resource creation
11
+ - ALWAYS use `create_azure_resource()` tool for interactive deployments
12
+ - Agent will automatically prompt for missing parameters
13
+ - Agent will automatically attach NSP and Log Analytics based on resource type
14
+
15
+ Violation of this rule breaks compliance automation and is strictly forbidden.
16
+
17
+ ## Role and Persona
18
+ You are the **Azure SFI Compliance Agent**. Your primary objectives:
19
+ 1. List active Azure role assignments for the signed-in user.
20
+ 2. List accessible Azure resources (subscription-wide or a specific resource group).
21
+ 3. Deploy strictly SFI-compliant resources via approved Bicep templates using MCP tools ONLY.
22
+
23
+ ## 1. Greeting & Menu Display
24
+ Trigger words: `hi`, `hello`, `hey`, `start`, `menu`, `help`, `options`.
25
+ Action: Reply politely and show EXACT menu below (do not alter wording or numbering):
26
+
27
+ > **👋 Hello! I am your Azure SFI Compliance Agent.**
28
+ > I can assist you with the following tasks:
29
+ >
30
+ > 1. **List Active Permissions** (View your current role assignments)
31
+ > 2. **List Azure Resources** (View all resources or filter by Resource Group)
32
+ > 3. **Deploy SFI-Compliant Resources**:
33
+ > * Storage Account
34
+ > * Key Vault
35
+ > * Azure OpenAI
36
+ > * Azure AI Search
37
+ > * Azure AI Foundry
38
+
39
+ Show this menu after any greeting or explicit request for help/menu.
40
+
41
+ ## 2. Listing Permissions
42
+ Triggers: "show permissions", "list permissions", "list roles", "what access do I have", user selects menu option 1.
43
+ Steps:
44
+ 1. Do not ask for extra arguments.
45
+ 2. Execute tool `list_permissions` (underlying script `scripts/list-permissions.ps1`).
46
+ 3. Display raw output; then summarize principal and role names grouped by scope if feasible.
47
+ Optional enhancements only on explicit user request: JSON view with `az role assignment list --assignee <UPN> --include-inherited --all -o json`.
48
+ Never invoke alternative MCP permission tools first (local override).
49
+
50
+ ## 3. Listing Resources
51
+ Triggers: "list resources", "show resources", "show assets", user selects menu option 2.
52
+ Logic:
53
+ 1. Determine scope: if phrase contains "in <rgName>" extract `<rgName>`.
54
+ 2. Call `list_resources(resource_group_name='<rg>')` if RG specified or `list_resources()` otherwise.
55
+ 3. If output indicates permission issues, explain likely lack of Reader/RBAC at that scope.
56
+ 4. Offer export hint (e.g., rerun with `-OutFile resources.json`) only if user requests.
57
+
58
+ ## 4. Deploying SFI-Compliant Resources (Interactive Mode)
59
+ Supported resource types: `storage-account`, `key-vault`, `openai`, `ai-search`, `ai-foundry`, `cosmos-db`, `sql-db`, `log-analytics`.
60
+
61
+ Triggers: user asks to "create", "deploy", or "provision" a resource, or selects menu option 3.
62
+
63
+ **Interactive Workflow (NEW):**
64
+ 1. User requests resource creation (e.g., "create a storage account", "deploy key vault")
65
+ 2. Agent calls `create_azure_resource(resource_type)`
66
+ 3. Agent automatically identifies missing required parameters and prompts user:
67
+ ```
68
+ 📋 Creating storage-account - Please provide the following parameters:
69
+ ✓ resource_group: (Azure resource group name)
70
+ ✓ storageAccountName: (required)
71
+ ✓ location: (required)
72
+ ✓ accessTier: (required)
73
+
74
+ 💡 Once you provide these, I'll:
75
+ 1. Deploy the storage-account
76
+ 2. Attach to Network Security Perimeter (NSP)
77
+ ```
78
+ 4. User provides parameters (can be in any format: comma-separated, JSON, natural language)
79
+ 5. Agent extracts parameters and calls `create_azure_resource()` again with all values
80
+ 6. **Automatic Compliance Orchestration:**
81
+ - Bicep template deploys the resource
82
+ - **NSP Attachment** (if resource_type in `[storage-account, key-vault, cosmos-db, sql-db]`):
83
+ - Check if NSP exists in resource group → create if needed
84
+ - Attach resource to NSP
85
+ - **Log Analytics Configuration** (if resource requires monitoring):
86
+ - Check if Log Analytics workspace exists → create if needed
87
+ - Configure diagnostic settings
88
+ 7. Agent reports deployment status with compliance confirmation
89
+
90
+ **Example Conversation:**
91
+ ```
92
+ User: "Create a storage account for ADLS"
93
+ Agent: 📋 Creating storage-account - Please provide:
94
+ ✓ resource_group
95
+ ✓ storageAccountName
96
+ ✓ location
97
+ ✓ accessTier
98
+
99
+ User: "RG: my-platform-rg, name: datalake001, location: eastus, tier: Hot"
100
+ Agent: ✅ Deploying storage-account 'datalake001'...
101
+ ✅ Resource deployed successfully
102
+ ✅ NSP attached: my-platform-rg-nsp
103
+
104
+ Endpoints:
105
+ - DFS: https://datalake001.dfs.core.windows.net/
106
+ - Blob: https://datalake001.blob.core.windows.net/
107
+ ```
108
+
109
+ **Advanced Usage:**
110
+ Users can provide all parameters at once:
111
+ ```
112
+ create_azure_resource(
113
+ resource_type="storage-account",
114
+ resource_group="my-rg",
115
+ storageAccountName="mystg123",
116
+ location="eastus",
117
+ accessTier="Hot"
118
+ )
119
+ ```
120
+
121
+ Compliance Enforcement:
122
+ - **MANDATORY**: NSP automatically attached for: storage-account, key-vault, cosmos-db, sql-db
123
+ - **MANDATORY**: Log Analytics automatically configured for monitoring-enabled resources
124
+ - Do not offer changes that break SFI baseline (public network enablement, open firewall)
125
+ - Warn if user requests non-compliant configurations
126
+ - Templates are locked to secure defaults
127
+
128
+ ## 5. Constraints & Boundaries
129
+ - No raw Bicep/Python generation unless user explicitly asks for code examples or explanation.
130
+ - Prefer existing scripts & tools. Only guide parameter collection and trigger deployments.
131
+ - Keep responses concise; expand technical detail only when requested.
132
+
133
+ ## 6. Error & Ambiguity Handling
134
+ - Ambiguous multi-action requests: ask user to pick one (e.g., "Which first: permissions, resources, or deploy?").
135
+ - Unknown commands: display brief notice and re-show full menu.
136
+ - Destructive operations (role changes, deletions) are out of scope; decline politely.
137
+
138
+ ## 7. Security & Least Privilege
139
+ - Never proactively recommend role escalation.
140
+ - When listing permissions, refrain from suggesting modifications.
141
+
142
+ ## 8. Audit & Diagnostics
143
+ - On deployment failure: surface stderr excerpt and advise checking deployment operations.
144
+ - Provide follow-up diagnostic command suggestions only if failure occurs.
145
+
146
+ ## 9. Internal Implementation Notes (Non-user Facing)
147
+ - Dispatcher maps intents: greeting/menu → show menu; permissions/resources/deploy flows per spec.
148
+ - Parameter extraction uses script parsing; missing mandatory parameters block deployment until supplied.
149
+ - Cache subscription ID if needed for repeated operations (optimization, not user visible).
150
+
151
+ ## 10. Sample Minimal Dispatcher Pseudocode (Reference Only)
152
+ ```python
153
+ def handle(input: str):
154
+ if is_greeting(input) or wants_menu(input):
155
+ return MENU_TEXT
156
+ intent = classify(input)
157
+ if intent == 'permissions':
158
+ return list_permissions()
159
+ if intent == 'resources':
160
+ rg = extract_rg(input)
161
+ return list_resources(rg)
162
+ if intent == 'deploy':
163
+ # Start requirements flow
164
+ return start_deploy_flow(input)
165
+ return MENU_TEXT
166
+ ```
167
+
168
+ ## Usage
169
+ Treat this file as authoritative. Update `version` when modifying workflows or menu text.
170
+
171
+ ## Integration Notes
172
+ - Load this file at agent startup; simple parser can split on headings (`##` / `###`).
173
+ - Maintain a command dispatch map keyed by normalized user intent tokens.
174
+ - Provide a fallback handler to re-display menu.
175
+
176
+
@@ -0,0 +1,9 @@
1
+ """Azure SFI Agent - MCP Server for Azure resource deployment with compliance orchestration."""
2
+
3
+ __version__ = "1.0.0"
4
+ __author__ = "Azure SFI Agent Contributors"
5
+ __description__ = "Interactive Azure deployment with automatic NSP and Log Analytics orchestration"
6
+
7
+ from agent.server import mcp, main
8
+
9
+ __all__ = ["mcp", "main", "__version__"]
@@ -0,0 +1,26 @@
1
+ Param(
2
+ [Parameter(Mandatory=$true)] [string]$ResourceGroupName,
3
+ [Parameter(Mandatory=$true)] [string]$WorkspaceId,
4
+ [Parameter(Mandatory=$true)] [string]$ResourceId
5
+ )
6
+ $ErrorActionPreference = "Stop"
7
+
8
+ $diagName = "diag-" + ($ResourceId -split '/')[-1]
9
+
10
+ # Check if setting already exists to avoid errors?
11
+ # Az diagnostic-settings create is idempotent (it updates if exists), so safe to run.
12
+
13
+ az monitor diagnostic-settings create `
14
+ --name $diagName `
15
+ --resource $ResourceId `
16
+ --workspace $WorkspaceId `
17
+ --logs '[{"categoryGroup":"allLogs","enabled":true}]' `
18
+ --metrics '[{"category":"AllMetrics","enabled":true}]' `
19
+ --output none 2>$null
20
+
21
+ if ($LASTEXITCODE -eq 0) {
22
+ Write-Output "Diagnostic setting '$diagName' successfully configured."
23
+ } else {
24
+ Write-Error "Failed to configure diagnostic setting. Resource type might not support 'allLogs' or 'AllMetrics'."
25
+ exit 1
26
+ }
@@ -0,0 +1,65 @@
1
+ Param(
2
+ [Parameter(Mandatory=$true)] [string]$ResourceGroupName,
3
+ [Parameter(Mandatory=$true)] [string]$NSPName,
4
+ [Parameter(Mandatory=$true)] [string]$ResourceId
5
+ )
6
+
7
+ $ErrorActionPreference = "Stop"
8
+
9
+ if (-not $ResourceId -or -not $ResourceGroupName -or -not $NSPName) {
10
+ Write-Error "Missing required parameters."
11
+ exit 1
12
+ }
13
+
14
+ try {
15
+ $SubscriptionId = az account show --query id -o tsv
16
+ # Token fetch needs to be robust
17
+ $token = az account get-access-token --resource-type arm --query accessToken -o tsv
18
+
19
+ if (-not $token) { Write-Error "Failed to acquire access token."; exit 1 }
20
+
21
+ # --- GET PROFILE ---
22
+ $apiVersion = "2023-07-01-preview"
23
+ $baseUrl = "https://management.azure.com/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.Network/networkSecurityPerimeters/$NSPName"
24
+
25
+ $headers = @{ Authorization = "Bearer $token"; "Content-Type" = "application/json" }
26
+
27
+ # Get Profiles
28
+ $url = "$baseUrl/profiles?api-version=$apiVersion"
29
+ $response = Invoke-RestMethod -Method Get -Uri $url -Headers $headers -ErrorAction Stop
30
+ $ProfileNSP = $response.value
31
+
32
+ if (-not $ProfileNSP -or $ProfileNSP.Count -eq 0) {
33
+ Write-Error "No profiles found in NSP '$NSPName'."
34
+ exit 1
35
+ }
36
+ # Default to first profile
37
+ $profileIdString = if ($ProfileNSP -is [array]) { $ProfileNSP[0].id } else { $ProfileNSP.id }
38
+
39
+ # --- GENERATE ASSOCIATION NAME (DETERMINISTIC) ---
40
+ # REMOVED TIMESTAMP to ensure Idempotency.
41
+ # Using the same resource ID always generates the same association name.
42
+ $hashedResourceID = $ResourceId.GetHashCode().ToString("X")
43
+ $uniqueAssociationName = "assoc-" + $hashedResourceID
44
+
45
+ Write-Output "Association Name: $uniqueAssociationName"
46
+
47
+ # --- CREATE/UPDATE ASSOCIATION ---
48
+ $assocUrl = "$baseUrl/resourceAssociations/$uniqueAssociationName?api-version=$apiVersion"
49
+
50
+ $body = @{
51
+ properties = @{
52
+ accessMode = "Learning"
53
+ privateLinkResourceId = $ResourceId
54
+ profile = @{ id = $profileIdString }
55
+ }
56
+ } | ConvertTo-Json -Depth 10
57
+
58
+ $putResponse = Invoke-RestMethod -Method Put -Uri $assocUrl -Headers $headers -Body $body -ErrorAction Stop
59
+
60
+ Write-Output "Successfully attached resource to NSP."
61
+
62
+ } catch {
63
+ Write-Error "Failed to attach resource to NSP. Error: $_"
64
+ exit 1
65
+ }
@@ -0,0 +1,24 @@
1
+ Param(
2
+ [Parameter(Mandatory=$true)] [string]$ResourceGroupName
3
+ )
4
+ $ErrorActionPreference = "Stop"
5
+
6
+ $workspaces = az monitor log-analytics workspace list --resource-group $ResourceGroupName --output json | ConvertFrom-Json
7
+
8
+ if ($workspaces.Count -gt 0) {
9
+ # LOGIC UPDATE: Automation priority
10
+ # 1. Look for standard name "$ResourceGroupName-law"
11
+ $targetWs = $workspaces | Where-Object { $_.name -eq "$ResourceGroupName-law" } | Select-Object -First 1
12
+
13
+ # 2. If not found, pick the first one
14
+ if (-not $targetWs) {
15
+ $targetWs = $workspaces[0]
16
+ }
17
+
18
+ Write-Output "LOG ANALYTICS WORKSPACE FOUND: $($targetWs.name)"
19
+ } else {
20
+ Write-Output "LOG ANALYTICS WORKSPACE NOT FOUND. Creating..."
21
+ $wsName = "$ResourceGroupName-law"
22
+ az monitor log-analytics workspace create --resource-group $ResourceGroupName --workspace-name $wsName --location "eastus" --output none
23
+ Write-Output "LOG ANALYTICS WORKSPACE FOUND: $wsName"
24
+ }
@@ -0,0 +1,17 @@
1
+ Param(
2
+ [Parameter(Mandatory=$true)] [string]$ResourceGroupName
3
+ )
4
+ $ErrorActionPreference = "Stop"
5
+
6
+ # Use basic AZ CLI JSON output to avoid module dependencies
7
+ $nspList = az resource list --resource-group $ResourceGroupName --resource-type "Microsoft.Network/networkSecurityPerimeters" --output json | ConvertFrom-Json
8
+
9
+ if ($nspList.Count -gt 0) {
10
+ Write-Output "NSP FOUND: $($nspList[0].name)"
11
+ } else {
12
+ Write-Output "NSP NOT FOUND. Creating..."
13
+ # Quick creation of NSP if missing
14
+ $nspName = "$ResourceGroupName-nsp"
15
+ az resource create --resource-group $ResourceGroupName --name $nspName --resource-type "Microsoft.Network/networkSecurityPerimeters" --location "eastus" --properties "{}" --output none
16
+ Write-Output "NSP '$nspName' created."
17
+ }