Commit 3107359
Add build_bicep and build_bicepparam tools to the MCP server (#19602)
The MCP server lacked dedicated tools for compiling Bicep files and
returning the compiled output. This PR replaces
`get_bicep_file_diagnostics` with two dedicated build tools that both
compile and return results.
## Changes
- **Two new MCP tools** in `BicepCompilerTools`:
- `build_bicep` — compiles a `.bicep` file via
`compilation.Emitter.Template()`, returns `{ success, template,
diagnostics }`
- `build_bicepparam` — compiles a `.bicepparam` file via
`compilation.Emitter.Parameters()`, returns `{ success, parameters,
template, diagnostics }`
- **Removed `get_bicep_file_diagnostics`** — superseded by the new build
tools, which already include diagnostics in their responses
- **Shared helper** `GetDiagnostics()` extracted to avoid duplicating
the diagnostic projection logic
- **New result records** `BuildBicepResult` and `BuildBicepparamResult`
with inline `[Description]` annotations for MCP schema generation
- **Unit tests** for both tools covering successful compilation and
error cases
- **`tools.json` baseline** updated to reflect the tool changes
## Example
```bicep
// main.bicep
param location string = 'westus'
output loc string = location
```
Calling `build_bicep` returns:
```json
{
"success": true,
"template": "{ \"$schema\": \"...\", ... }",
"diagnostics": []
}
```
On error, `success` is `false`, `template`/`parameters` is `null`, and
`diagnostics` contains the full error list.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: anthony-c-martin <38542602+anthony-c-martin@users.noreply.github.com>1 parent a442118 commit 3107359
5 files changed
Lines changed: 339 additions & 123 deletions
File tree
- src
- Bicep.McpServer.Core
- Bicep.McpServer.UnitTests
- Files/ServerTests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
42 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
43 | 63 | | |
44 | | - | |
45 | | - | |
| 64 | + | |
| 65 | + | |
46 | 66 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
54 | 73 | | |
55 | | - | |
56 | | - | |
| 74 | + | |
| 75 | + | |
57 | 76 | | |
58 | 77 | | |
59 | | - | |
| 78 | + | |
60 | 79 | | |
61 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
62 | 108 | | |
63 | 109 | | |
64 | 110 | | |
| 111 | + | |
65 | 112 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
| 113 | + | |
76 | 114 | | |
77 | 115 | | |
78 | 116 | | |
| |||
148 | 186 | | |
149 | 187 | | |
150 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
151 | 201 | | |
Lines changed: 79 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | | - | |
7 | | - | |
8 | 5 | | |
9 | | - | |
10 | 6 | | |
11 | 7 | | |
12 | 8 | | |
| |||
30 | 26 | | |
31 | 27 | | |
32 | 28 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | 29 | | |
53 | 30 | | |
54 | 31 | | |
| |||
88 | 65 | | |
89 | 66 | | |
90 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
91 | 147 | | |
0 commit comments