azure-mcp-server

azure-mcp-server

0

Azure MCP Server is a Model Context Protocol server designed to interface with various Azure services. It focuses on providing tools for managing Azure Storage, Virtual Machines, and App Services efficiently. The server uses mcp-framework for building capabilities, leveraging Azure's authentication methods.

Azure MCP Server

A Model Context Protocol (MCP) server built with mcp-framework that provides tools for interacting with Azure services.

Quick Start

# Install dependencies
npm install

# Build the project
npm run build

# Start the server
npm start

Project Structure

azure-mcp-server/
├── src/
│   ├── tools/                # MCP Tools
│   │   ├── Storage/          # Azure Storage tools
│   │   ├── VirtualMachine/   # Azure VM tools
│   │   └── AppService/      # Azure App Service tools
│   └── index.ts              # Server entry point
├── package.json
└── tsconfig.json

Azure Tools Overview

This server provides tools for interacting with multiple Azure services:

ServiceTool PrefixDescription
Storageazure_*Blob storage operations
Virtual Machinesazure_vms_*VM management operations
App Serviceazure_apps_*App Service operations

Authentication

All tools use DefaultAzureCredential from @azure/identity, which tries multiple authentication methods in the following order:

  1. Environment variables (AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET)
  2. Managed Identity
  3. Azure CLI credentials
  4. Visual Studio Code credentials
  5. Interactive browser login (as a fallback)

Available Tools

Azure Storage Tools

Required Permissions
  • Storage Account Contributor: For managing storage account settings
  • Storage Blob Data Contributor: For CRUD operations on blobs and containers
Container Operations
ToolDescriptionExample Input
azure_list_containersList containers{ "accountName": "yourstorageaccount" }
azure_create_containerCreate container{ "accountName": "yourstorageaccount", "containerName": "mycontainer" }
azure_delete_containerDelete container{ "accountName": "yourstorageaccount", "containerName": "mycontainer" }
Blob Operations
ToolDescriptionExample Input
azure_list_blobsList blobs{ "accountName": "yourstorageaccount", "containerName": "mycontainer" }
azure_upload_blobUpload blob{ "accountName": "yourstorageaccount", "containerName": "mycontainer", "blobName": "example.txt", "content": "This is the content" }
azure_download_blobDownload blob{ "accountName": "yourstorageaccount", "containerName": "mycontainer", "blobName": "example.txt" }
azure_delete_blobDelete blob{ "accountName": "yourstorageaccount", "containerName": "mycontainer", "blobName": "example.txt" }

Azure Virtual Machine Tools

Required Permissions
  • Virtual Machine Contributor: For managing VMs
  • Reader: For listing and viewing VM details
VM Operations
ToolDescriptionExample Input
azure_vms_listList VMs{ "subscriptionId": "your-subscription-id" }
azure_vms_startStart VM{ "subscriptionId": "your-subscription-id", "resourceGroupName": "your-resource-group", "vmName": "your-vm-name" }
azure_vms_stopStop VM{ "subscriptionId": "your-subscription-id", "resourceGroupName": "your-resource-group", "vmName": "your-vm-name" }
azure_vms_restartRestart VM{ "subscriptionId": "your-subscription-id", "resourceGroupName": "your-resource-group", "vmName": "your-vm-name" }
azure_vms_deleteDelete VM{ "subscriptionId": "your-subscription-id", "resourceGroupName": "your-resource-group", "vmName": "your-vm-name" }

Azure App Service Tools

Required Permissions
  • Website Contributor: For managing App Services
  • Reader: For listing and viewing App Service details
App Service Operations
ToolDescriptionExample Input
azure_apps_listList App Services{ "subscriptionId": "your-subscription-id" }
azure_apps_getGet App Service details{ "subscriptionId": "your-subscription-id", "resourceGroupName": "your-resource-group", "appName": "your-app-name" }
azure_apps_get_configGet App Service config{ "subscriptionId": "your-subscription-id", "resourceGroupName": "your-resource-group", "appName": "your-app-name" }
azure_apps_startStart App Service{ "subscriptionId": "your-subscription-id", "resourceGroupName": "your-resource-group", "appName": "your-app-name" }
azure_apps_stopStop App Service{ "subscriptionId": "your-subscription-id", "resourceGroupName": "your-resource-group", "appName": "your-app-name" }
azure_apps_restartRestart App Service{ "subscriptionId": "your-subscription-id", "resourceGroupName": "your-resource-group", "appName": "your-app-name" }

Tool Development

Creating a New Tool

import { MCPTool } from 'mcp-framework';
import { z } from 'zod';

interface MyToolInput {
  message: string;
}

class MyTool extends MCPTool<MyToolInput> {
  name = 'my_tool';
  description = 'Describes what your tool does';

  schema = {
    message: {
      type: z.string(),
      description: 'Description of this input parameter'
    }
  };

  async execute(input: MyToolInput) {
    // Your tool logic here
    return `Processed: ${input.message}`;
  }
}

export default MyTool;

Debugging

If you encounter issues with the Azure tools, check the console logs for detailed debugging information. Common issues include:

  • Authentication failures
  • Missing permissions
  • Non-existent resources
  • Network connectivity problems

Building and Testing

  1. Make changes to your tools
  2. Run npm run build to compile
  3. The server will automatically load your tools on startup

Learn More