Skip to content

Add build_bicep and build_bicepparam tools to the MCP server#19602

Merged
anthony-c-martin merged 3 commits intomainfrom
copilot/add-build-bicep-tools
May 6, 2026
Merged

Add build_bicep and build_bicepparam tools to the MCP server#19602
anthony-c-martin merged 3 commits intomainfrom
copilot/add-build-bicep-tools

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 5, 2026

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

// main.bicep
param location string = 'westus'
output loc string = location

Calling build_bicep returns:

{
  "success": true,
  "template": "{ \"$schema\": \"...\", ... }",
  "diagnostics": []
}

On error, success is false, template/parameters is null, and diagnostics contains the full error list.

Copilot AI changed the title [WIP] Add build_bicep and build_bicepparam tools to MCP server Add build_bicep and build_bicepparam tools to the MCP server May 5, 2026
Copilot AI requested a review from anthony-c-martin May 5, 2026 17:44
@anthony-c-martin anthony-c-martin marked this pull request as ready for review May 5, 2026 20:47
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot remove this tool, it's not needed any more

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 03f962a. Removed GetBicepFileDiagnostics and its associated test, and updated the Error_filter_returns_error_information test in ServerTests.cs to use build_bicep instead.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 5, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • aka.ms
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec /home/REDACTED/work/bicep/bicep/src/Bicep.McpServer.UnitTests/bin/Debug/net10.0/Bicep.McpServer.UnitTests.dll --internal-msbuild-node /tmp/297b29e2a27a49a0b72bc809034ff974/.p --ignore-exit-code 8 --test-parameter SetBaseLine=true (dns block)
  • westcentralus.data.mcr.microsoft.com
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec /home/REDACTED/work/bicep/bicep/src/Bicep.McpServer.UnitTests/bin/Debug/net10.0/Bicep.McpServer.UnitTests.dll --internal-msbuild-node /tmp/297b29e2a27a49a0b72bc809034ff974/.p --ignore-exit-code 8 --test-parameter SetBaseLine=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Test this change out locally with the following install scripts (Action run 25416326898)

VSCode
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-vsix.sh) --run-id 25416326898
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-vsix.ps1) } -RunId 25416326898"
Azure CLI
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh) --run-id 25416326898
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -RunId 25416326898"

@anthony-c-martin anthony-c-martin merged commit 3107359 into main May 6, 2026
41 of 42 checks passed
@anthony-c-martin anthony-c-martin deleted the copilot/add-build-bicep-tools branch May 6, 2026 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add build_bicep and build_bicepparam tools to the MCP server

3 participants