|
| 1 | +# Using the Bicep MCP Server |
| 2 | + |
| 3 | +## What is it |
| 4 | + |
| 5 | +We have built a Bicep MCP server with agentic tools to support Bicep code generation for AI agents in VS Code. To find out more about MCP, see [Use MCP servers in VS Code][00]. |
| 6 | + |
| 7 | +### Available Bicep MCP tools |
| 8 | + |
| 9 | +- `get_bicep_best_practices`: Lists up-to-date recommended Bicep best-practices for authoring templates. These practices help improve maintainability, security, and reliability of your Bicep files. This is helpful additional context if you've been asked to generate Bicep code. |
| 10 | +- `list_az_resource_types_for_provider`: Lists all available Azure resource types for a specific provider. The return value is a newline-separated list of resource types including their API version, e.g. `Microsoft.KeyVault/vaults@2024-11-01`. Such information is the most accurate and up-to-date as it is sourced from the Azure Resource Provider APIs. |
| 11 | +- `get_az_resource_type_schema`: Gets the schema for a specific Azure resource type and API version. Such information is the most accurate and up-to-date as it is sourced from the Azure Resource Provider APIs. |
| 12 | +- `list_avm_metadata`: Lists up-to-date metadata for all Azure Verified Modules (AVM). The return value is a newline-separated list of AVM metadata. Each line includes the module name, description, versions, and documentation URI for a specific module. |
| 13 | +- `get_bicep_file_diagnostics`: Analyzes a Bicep file (`.bicep`) or Bicep parameters file (`.bicepparam`) and returns all compilation diagnostics including errors, warnings, and informational messages. |
| 14 | +- `format_bicep_file`: Formats a Bicep file (`.bicep`) or Bicep parameters file (`.bicepparam`) according to official Bicep formatting standards, respecting `bicepconfig.json` settings. |
| 15 | +- `get_file_references`: Analyzes a Bicep or Bicep parameters file and returns a list of all files it references, including modules, parameter files, and other dependencies. |
| 16 | +- `decompile_arm_template_file`: Converts an ARM template JSON file into Bicep syntax (`.bicep`). Accepts files with `.json`, `.jsonc`, or `.arm` extensions. |
| 17 | +- `decompile_arm_parameters_file`: Converts an ARM template parameters JSON file into Bicep parameters syntax (`.bicepparam`). Accepts files with `.json`, `.jsonc`, or `.arm` extensions. |
| 18 | +- `get_deployment_snapshot`: Creates a deployment snapshot from a Bicep parameters file (`.bicepparam`) by compiling and pre-expanding the ARM template, allowing you to preview predicted resources without running a deployment. |
| 19 | + |
| 20 | +Please see below on how to contribute to the Bicep best practices tool. |
| 21 | + |
| 22 | +## Transports |
| 23 | + |
| 24 | +The Bicep MCP Server supports two transports: |
| 25 | + |
| 26 | +- **stdio** (default): Used when the server is launched locally by a client process (e.g., VS Code, Claude Desktop). This is the default behavior. |
| 27 | +- **HTTP** (Streamable HTTP): Used for remote hosting scenarios. Start the server with the `--transport http` flag to enable HTTP transport on port 8080. |
| 28 | + |
| 29 | +To run the server locally with HTTP transport: |
| 30 | + |
| 31 | +``` |
| 32 | +dnx Azure.Bicep.McpServer --transport http |
| 33 | +``` |
| 34 | + |
| 35 | +Then configure your MCP client to connect to `http://localhost:8080/`. |
| 36 | + |
| 37 | +## Self-hosting with Docker |
| 38 | + |
| 39 | +You can self-host the Bicep MCP Server as a container using the published NuGet tool package. Create a `Dockerfile` with the following contents: |
| 40 | + |
| 41 | +```dockerfile |
| 42 | +FROM mcr.microsoft.com/dotnet/sdk:10.0 AS install |
| 43 | + |
| 44 | +RUN dotnet tool install --global Azure.Bicep.McpServer |
| 45 | + |
| 46 | +FROM mcr.microsoft.com/dotnet/aspnet:10.0 |
| 47 | + |
| 48 | +COPY --from=install /root/.dotnet/tools /opt/tools |
| 49 | + |
| 50 | +ENV PATH="$PATH:/opt/tools" |
| 51 | + |
| 52 | +USER $APP_UID |
| 53 | + |
| 54 | +EXPOSE 8080 |
| 55 | + |
| 56 | +ENTRYPOINT ["Azure.Bicep.McpServer", "--transport", "http"] |
| 57 | +``` |
| 58 | + |
| 59 | +Build and run the container: |
| 60 | + |
| 61 | +```bash |
| 62 | +docker build -t bicep-mcp-server . |
| 63 | +docker run -p 8080:8080 bicep-mcp-server |
| 64 | +``` |
| 65 | + |
| 66 | +> [!NOTE] |
| 67 | +> No authentication is included. If hosting on a network or in the cloud, secure the endpoint using a reverse proxy, VNet integration, or other infrastructure-level controls. |
| 68 | +
|
| 69 | +## Where can I use it? |
| 70 | + |
| 71 | +The Bicep MCP Server can be used directly in VS Code (preferred), but can also be run locally with other AI services such as Claude Desktop and Code, OpenAI Codex CLI, LMStudio, and other MCP-compatible services. |
| 72 | + |
| 73 | +## How to use the Bicep MCP Server directly in VS Code |
| 74 | + |
| 75 | +### Prerequisites |
| 76 | + |
| 77 | +- Install the latest version of the [Bicep VS Code Extension][01] |
| 78 | +- Confirm access to [Copilot in VS Code][02] |
| 79 | + |
| 80 | +### Installing |
| 81 | + |
| 82 | +Ensure you have the latest version of the Bicep extension installed. |
| 83 | + |
| 84 | +### Troubleshooting |
| 85 | + |
| 86 | +The Bicep server may not appear in your list of MCP servers and tools in VS Code until it has been triggered. If you do not see the server, try opening and saving a `.bicep` file and then try providing a Bicep related-prompt in the Copilot chat window in "Agent" mode (as shown in Step #3 of the Viewing and Using Bicep Tools in the Bicep MCP Server section below). You may also need to press the "Refresh" button in the Copilot chat box. |
| 87 | + |
| 88 | +![Refresh copilot tools][05] |
| 89 | + |
| 90 | +If any of the tools are missing from the list of available tools, start/restart the MCP server in VS Code, by hitting `Ctrl + Shift + P`, selecting `MCP: List Servers`, then choosing the Bicep MCP Server and clicking on `Start Server` or `Restart Server`. |
| 91 | + |
| 92 | +### Viewing and Using Bicep MCP Server Tools in VS Code |
| 93 | + |
| 94 | +1. Open the GitHub Copilot extension window and select "Agent Mode". |
| 95 | + |
| 96 | + ![Agent Mode Selection][06] |
| 97 | + |
| 98 | +1. Click on the tool icon in the GitHub Copilot chat window and search for "Bicep (PREVIEW)". |
| 99 | + |
| 100 | + ![Bicep MCP Tool Selection][07] |
| 101 | + |
| 102 | +1. Start using Agent Mode to help with your Bicep tasks! |
| 103 | + |
| 104 | + ![Bicep MCP Usage Example][08] |
| 105 | + |
| 106 | +## How to use the Bicep MCP Server locally with AI Agents |
| 107 | +Please refer to [this step by step tutorial](https://github.com/johnlokerse/azure-bicep-mcp-integration-setup) on how to integrate the Bicep MCP Server with Claude Code, Codex, LM Studio, and other AI tools. |
| 108 | + |
| 109 | +This article has all the tools you need to run the Bicep MCP Server locally, with pre-written commands, helper scripts, and client setup guides. |
| 110 | + |
| 111 | +Note: This is contributed by our community member [@johnlokerse](https://github.com/johnlokerse). Thanks John! |
| 112 | + |
| 113 | +## Limitations |
| 114 | + |
| 115 | +> [!NOTE] |
| 116 | +> It is your responsibility to review all code generated by an LLM and **deploy at your own risk**. |
| 117 | +
|
| 118 | +These tools provide additional context to help the chosen model generate semantically and syntactically correct Bicep code. These tools are not designed to deploy directly to Azure. |
| 119 | + |
| 120 | +There is no way to definitively guarantee whether the agent orchestrator will use any particular Bicep tool. As a workaround, you can view the available Bicep tools and use specific prompting to guide the agent orchestrator to invoke a tool (e.g. "Create a Bicep file to do X using Bicep best practices") |
| 121 | + |
| 122 | +## Contributing and providing feedback |
| 123 | + |
| 124 | +These tools are early on and we value and welcome feedback to improve them. See [`CONTRIBUTING.md`][09] for guidelines. |
| 125 | + |
| 126 | +In particular, we are looking to crowd source community wisdom on the `get_bicep_best_practices` tool. You can contribute to our forum on bicep best practices on [this Bicep Issue][03]. |
| 127 | + |
| 128 | +## Raising bugs or feature requests |
| 129 | + |
| 130 | +Please raise bug reports or feature requests under [Bicep Issues][04] and tag with "story: bicep MCP". |
| 131 | + |
| 132 | +<!-- Link reference definitions --> |
| 133 | +[00]: https://code.visualstudio.com/docs/copilot/chat/mcp-servers |
| 134 | +[01]: https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-bicep |
| 135 | +[02]: https://code.visualstudio.com/docs/copilot/overview |
| 136 | +[03]: https://github.com/Azure/bicep/issues/17660 |
| 137 | +[04]: https://github.com/Azure/bicep/issues |
| 138 | +[05]: ../images/refresh-mcp-tools.png |
| 139 | +[06]: ../images/mcp-agent-mode.png |
| 140 | +[07]: ../images/mcp-tools-selection.png |
| 141 | +[08]: ../images/use-agent-mode-with-bicep.png |
| 142 | +[09]: ../../CONTRIBUTING.md |
0 commit comments