Hosting Azure MCP Server in VS Code: My Experience with the MCP Server
7 min read

Introduction
Azure's Model Context Protocol (MCP) provides a standardized way to serve domain-specific context to large language models. In this post, I’ll walk you through how I set up my own MCP Server in VS Code and what tools are vailable in preview version of the server
Azure MCP Server
The Azure MCP Server enables AI agents and other types of clients to interact with Azure resources through natural language commands. It implements the Model Context Protocol (MCP) to provide these key features:
MCP support: Because the Azure MCP Server implements the Model Context Protocol, it works with MCP clients such as GitHub Copilot agent mode, the OpenAI Agents SDK, and Semantic Kernel.
Entra ID support: The Azure MCP Server uses Entra ID through the Azure Identity library to follow Azure authentication best practices.
Service and tool support: The Azure MCP Server supports Azure services and tools such as the Azure CLI and Azure Developer CLI (azd).
Introduction to the Model Context Protocol (MCP)
The Model Context Protocol (MCP) is an open protocol designed to manage how language models interact with external tools, memory, and context in a safe, structured, and stateful way. MCP defines a client-server architecture with several components:
Hosts: Apps that use MCP clients to connect to and consume data from MCP servers.
Clients: Components of MCP hosts that manage connections and retrieve data from MCP servers.
Servers: Programs that provide features like data resources, tools for performing actions, and prompts to guide interactions.
For example, VS Code is considered a host, and GitHub Copilot agent mode in VS Code acts as an MCP client that connects to MCP servers. You might also build a custom intelligent app that hosts its own MCP client that connects to MCP servers.
The Azure MCP Server implements a set of tools per the Model Context Protocol. AI agents and other types of clients use these tools to interact with Azure resources.
Spin Up Your Own Azure MCP Server in VS Code
I followed the Microsoft documentation. According to the documentation following are prerequisites I installed. I am using Windows subsystem for Linux, this tutorial will provide steps for Ubuntu.
Prerequisites
Azure Account
Python 3.9 or higher
Node JS installed locally
Installing Nodejs and dependencies for VS Code in WSL
#!/bin/bash
# --- 1. Setting up NVM (Node Version Manager) and Node.js ---
echo "## 1. NVM and Node.js Installation"
echo "NVM allows you to manage multiple Node.js versions on your system."
echo "# Core Dependencies for NVM (often pre-installed in modern Ubuntu WSL)"
echo "sudo apt update"
echo "sudo apt install -y curl" # curl is used to download the nvm install script
echo "# NVM Installation (downloads the nvm script and sources it in your .bashrc/.zshrc)"
echo "curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash"
echo ""
echo "# After installation, you must source your shell config or open a new terminal"
echo "source ~/.bashrc # or ~/.zshrc if you use zsh"
echo ""
echo "# Node.js Installation (via NVM)"
echo "nvm install --lts # Installs the latest Long Term Support version of Node.js"
echo "nvm use --lts # Sets the LTS version as the default for the current shell session"
echo ""
echo "# Core components installed with Node.js:"
echo " - node: The JavaScript runtime itself."
echo " - npm: Node Package Manager, used for installing and managing Node.js packages."
echo " - npx: Node Package Execute, used for executing Node.js package binaries (often temporary)."
echo ""
# --- 2. Configuring VS Code for WSL ---
echo "## 2. VS Code WSL Integration"
echo "The 'Remote - WSL' extension bridges VS Code on Windows to your WSL environment."
echo "# VS Code Extension Installation (done from VS Code Extensions view on Windows side)"
echo " - Remote - WSL Extension (Microsoft)"
echo ""
echo "# WSL-side Configuration for VS Code Server"
echo " - ~/.vscode-server/ (directory created by VS Code, contains VS Code Server binaries and extensions)"
echo " - ~/.vscode-server/server-env-setup (custom file for setting environment variables for VS Code Server)"
echo " - Inside this file, you manually added:"
echo " export NVM_DIR=\"$HOME/.nvm\""
echo " [ -s \"\$NVM_DIR/nvm.sh\" ] && \\. \"\$NVM_DIR/nvm.sh\""
echo " [ -s \"\$NVM_DIR/bash_completion\" ] && \\. \"\$NVM_DIR/bash_completion\""
echo " nvm use --silent <your_node_version>"
echo ""
# --- 3. Installing Azure CLI ---
echo "## 3. Azure CLI Installation"
echo "Azure CLI allows interaction with Azure resources from the command line."
echo "# System Dependencies for Azure CLI (specific to apt-based distributions like Ubuntu)"
echo "sudo apt update"
echo "sudo apt install -y ca-certificates curl apt-transport-https lsb-release gnupg"
echo " - ca-certificates: Provides root certificates for secure communication (HTTPS)."
echo " - curl: Tool for transferring data with URLs (used to download the Microsoft GPG key)."
echo " - apt-transport-https: Enables apt to fetch packages over HTTPS."
echo " - lsb-release: Provides information about the Linux distribution (used to get codename)."
echo " - gnupg: GNU Privacy Guard, used for managing cryptographic keys (for verifying package authenticity)."
echo ""
echo "# Adding Microsoft GPG key and Azure CLI repository"
echo "curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/keyrings/microsoft.gpg > /dev/null"
echo " - This imports Microsoft's public key to authenticate Azure CLI packages."
echo "AZ_REPO=\$(lsb_release -cs)"
echo "echo \"deb [arch=amd64 signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/azure-cli/ \$AZ_REPO main\" | sudo tee /etc/apt/sources.list.d/azure-cli.list"
echo " - This adds the official Azure CLI repository to your system's package sources."
echo ""
echo "# Azure CLI Package Installation"
echo "sudo apt update" # Updates package lists to include the new Azure CLI repository
echo "sudo apt install azure-cli"
echo " - This command installs the main Azure CLI package and its core Python dependencies (Azure CLI is primarily Python-based)."
echo ""
echo "# Core Dependencies of Azure CLI (handled by apt):"
echo " - Python (version 3.8 or higher, usually installed as a dependency by apt if not present)."
echo " - Various Python libraries and modules that the Azure CLI uses (e.g., requests, msrest, knack, azure-common, etc. - these are pulled in automatically)."
echo ""
echo "--- End of Outline ---"
Global Install
I installed Azure MCP server Globally on my device. Directory Install is also supported
To install the Azure MCP Server for Visual Studio Code in your user settings, select the following link:
A list of installation options opens inside Visual Studio Code. Select Install Server to add the server configuration to your user settings.
Open GitHub Copilot and select Agent Mode. To learn more about Agent Mode.
Refresh the tools list to see Azure MCP Server as an available option:
Use prompts to test the Azure MCP Server
Open GitHub Copilot and select Agent Mode.
I will authenticate by signing into my Azure Account
az login --use-device-code
After Authenticating I will ask Co-pilot To list my resource groups
Copilot requests permission to run the necessary Azure MCP Server operation for your prompt. Select Continue or use the arrow to select a more specific behavior:
Current session always runs the operation in the current GitHub Copilot Agent Mode session.
Current workspace always runs the command for current Visual Studio Code workspace.
Always allow sets the operation to always run for any GitHub Copilot Agent Mode session or any Visual Studio Code workspace.
Copilot will run MCP server, will use Resource Group tool and provide context to LLM and run the query and give you output
Future Integration with Operation
The Azure Model Context Protocol (MCP) Server exposes many tools you can use from an existing client to interact with Azure services through natural language prompts. For example, you can use the Azure MCP Server to interact with Azure resources conversationally from GitHub Copilot agent mode in Visual Studio Code or other AI agents with commands like these:
"Show me all my resource groups"
"List blobs in my storage container named 'documents'"
"What's the value of the 'ConnectionString' key in my app configuration?"
"Query my log analytics workspace for errors in the last hour"
"Show me all my Cosmos DB databases"
Azure MCP server is in preview and most of the tools it exposes are Get tools. These tools help in Listing resources in Azure.
Agent Integration with Operation and Incident Response in Azure
I believe the next stage in the evolution of the Azure MCP Server lies in Operations and Incident Response.
Consider a scenario where a virtual machine triggers an alert due to a failed service. By integrating this alert into an AI-powered workflow using the Azure MCP Server and a connected agent, the system could automatically investigate the issue and suggest remediation steps to an Operations Engineer.
The engineer would then have the flexibility to review, accept, or even revert the recommended actions — enabling a more efficient and intelligent approach to managing operational incidents.
###