Azure APIM + MCP Server Demo

Azure APIM + MCP Server Demo

Exposes backend APIs through Azure API Management as an MCP server to enable AI assistants to interact with product catalogs and order systems. It provides standardized tools for searching products, retrieving details, and managing orders via the Model Context Protocol.

Category
Visit Server

README

Azure APIM + MCP Server Demo

This project demonstrates how to expose backend APIs through Azure API Management (APIM) as a Model Context Protocol (MCP) Server, enabling AI assistants and tools to interact with your APIs using the standardized MCP protocol.

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   MCP Client     │────▢│   Azure API Management  │────▢│   Azure App Service     β”‚
β”‚  (AI Assistant)  β”‚     β”‚      (Gateway)          β”‚     β”‚   (Express.js API)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚                         β”‚                              β”‚
        β”‚  MCP Protocol           β”‚  Subscription Key            β”‚  REST API
        β”‚  (JSON-RPC 2.0)         β”‚  Rate Limiting               β”‚  Products/Orders
        β”‚                         β”‚  Monitoring                  β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“¦ Components

Backend API (backend-api/)

  • Express.js application with TypeScript
  • REST API endpoints for products and orders
  • MCP JSON-RPC endpoint handler
  • 5 MCP tools:
    • get_products - List all products in the catalog
    • get_product_by_id - Get product details by ID
    • search_products - Search products by query string
    • get_orders - List all orders
    • create_order - Create a new order

Infrastructure (infrastructure/)

  • Bicep templates for Azure deployment
  • Azure App Service (Linux, Node.js 20 LTS, B1 Basic)
  • Azure API Management (Developer SKU)
  • Application Insights for monitoring
  • Log Analytics workspace

🌐 Endpoints

Endpoint Description
https://apimmcp-api-dev.azurewebsites.net/ Backend root
https://apimmcp-api-dev.azurewebsites.net/api/health Health check
https://apimmcp-api-dev.azurewebsites.net/api/products Products REST API
https://apimmcp-api-dev.azurewebsites.net/api/orders Orders REST API
https://apimmcp-api-dev.azurewebsites.net/api/mcp MCP endpoint (direct)
https://apimmcp-apim-dev.azure-api.net/mcp MCP endpoint (via APIM) ⭐

πŸ“‘ MCP Protocol

The server implements the Model Context Protocol (version 2024-11-05):

Initialize

{
  "jsonrpc": "2.0",
  "method": "initialize",
  "id": 1,
  "params": {
    "protocolVersion": "2024-11-05",
    "capabilities": {},
    "clientInfo": { "name": "client", "version": "1.0.0" }
  }
}

List Tools

{
  "jsonrpc": "2.0",
  "method": "tools/list",
  "id": 2
}

Call Tool

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "id": 3,
  "params": {
    "name": "get_products"
  }
}

Example: Search Products

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "id": 4,
  "params": {
    "name": "search_products",
    "arguments": { "query": "smart" }
  }
}

Example: Create Order

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "id": 5,
  "params": {
    "name": "create_order",
    "arguments": { "productId": "prod-001", "quantity": 2 }
  }
}

πŸš€ Deployment

Prerequisites

  • Azure CLI installed and logged in
  • Azure subscription
  • Node.js 18+ installed locally

1. Create Resource Group

az group create --name apim-mcp-demo-rg --location eastus

2. Deploy Infrastructure

az deployment group create `
  --resource-group apim-mcp-demo-rg `
  --template-file ./infrastructure/main-appservice.bicep `
  --parameters location=eastus namePrefix=apimmcp environment=dev apimPublisherEmail="your-email@example.com"

⚠️ Note: APIM provisioning takes 15-30 minutes on first deployment.

3. Build Backend API

cd backend-api
npm install
npm run build

4. Deploy Backend API

Compress-Archive -Path "dist\*", "package.json", "web.config", "node_modules" -DestinationPath "deploy.zip" -Force
az webapp deploy --resource-group apim-mcp-demo-rg --name apimmcp-api-dev --src-path deploy.zip --type zip

5. Get APIM Subscription Key

az rest --method post `
  --uri "https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/apim-mcp-demo-rg/providers/Microsoft.ApiManagement/service/apimmcp-apim-dev/subscriptions/mcp-subscription/listSecrets?api-version=2022-08-01" `
  --query "primaryKey" -o tsv

πŸ§ͺ Testing

Run Test Script

.\test-mcp.ps1

Expected Output

========================================
  MCP Server Test Suite
========================================

Endpoint: https://apimmcp-apim-dev.azure-api.net/mcp

1. Testing initialize...
   Server: azure-product-catalog-server v1.0.0
   Protocol: 2024-11-05

2. Testing tools/list...
   Found 5 tools:
     - get_products: Retrieve a list of all products in the catalog
     - get_product_by_id: Get details of a specific product by its ID
     ...

3. Testing tools/call (get_products)...
   Found 8 products:
     - Widget Pro: $29.99
     - Gadget Plus: $49.99
     ...

Manual Testing

$headers = @{
  "Ocp-Apim-Subscription-Key" = "YOUR_SUBSCRIPTION_KEY"
  "Content-Type" = "application/json"
}

$body = '{"jsonrpc":"2.0","method":"initialize","id":1,"params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'

Invoke-RestMethod -Uri "https://apimmcp-apim-dev.azure-api.net/mcp" -Method POST -Headers $headers -Body $body

πŸ› οΈ Development

Local Development

cd backend-api
npm install
npm run dev

The server will start on http://localhost:3000.

Project Structure

APIM-MCP/
β”œβ”€β”€ backend-api/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ index.ts      # Express server entry
β”‚   β”‚   β”œβ”€β”€ routes.ts     # REST API routes
β”‚   β”‚   β”œβ”€β”€ mcp.ts        # MCP endpoint handler
β”‚   β”‚   └── data.ts       # Mock data store
β”‚   β”œβ”€β”€ dist/             # Compiled JavaScript
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ tsconfig.json
β”‚   └── web.config        # IIS configuration for Azure
β”œβ”€β”€ infrastructure/
β”‚   └── main-appservice.bicep   # Azure resources
β”œβ”€β”€ test-mcp.ps1          # Test script
└── README.md

πŸ”§ Configuration

APIM Settings

  • Subscription Required: Yes
  • Rate Limiting: Configurable via APIM policies
  • Authentication: Subscription key header (Ocp-Apim-Subscription-Key)

App Service Settings

  • SKU: B1 Basic (Linux)
  • Node Version: 20 LTS
  • Startup Command: node index.js

πŸ“Š Monitoring

  • Application Insights integrated with both App Service and APIM
  • Access logs in Log Analytics workspace
  • Health endpoint available at /api/health

πŸ”— Resources

πŸ“„ License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured