Remote MCP with Azure Functions

Remote MCP with Azure Functions

A quickstart template for building and deploying secure, remote MCP servers to the cloud using Azure Functions and Node.js/TypeScript. It features integrated blob storage for snippet management and supports advanced security options like OAuth and VNET isolation.

Category
访问服务器

README

Prerequisites

Prepare your local environment

  1. Clone or navigate to your project directory
  2. Install dependencies:
    npm install
    

Available MCP Tools

This MCP server provides three tools for managing project contributions:

  • list_projects - Enumerate all projects with contribution counts and team member information
  • get_contributions - Filter and retrieve contributions by project name or team member
  • add_contribution - Record a new contribution with project, member, summary, and optional attachments

Run your MCP Server locally from the terminal

  1. Install dependencies (if not already done)

    npm install
    
  2. Build the project

    npm run build
    
  3. Start the Functions host locally:

    func start
    

The local MCP endpoint will be available at: http://0.0.0.0:7071/runtime/webhooks/mcp

Note: In Azure, the endpoint includes authentication: /runtime/webhooks/mcp?code=<system_key>

Test the MCP Server locally

Using MCP Inspector

  1. In a new terminal window, install and run MCP Inspector

    npx @modelcontextprotocol/inspector node build/index.js
    
  2. CTRL+Click the displayed URL (typically http://0.0.0.0:5173/#resources) to open MCP Inspector

  3. Set the transport type to http

  4. Set the URL to your local MCP endpoint:

    http://0.0.0.0:7071/runtime/webhooks/mcp
    
  5. Click Connect and then List Tools to see all available tools

  6. Test each tool by clicking it and providing sample parameters:

    • list_projects - No parameters needed, returns all projects
    • get_contributions - Optional: filter by project_name or author_name
    • add_contribution - Required: MemberId, ProjectId, Summary, Description; Optional: AttachmentUrl

When finished, press Ctrl+C in both terminal windows to stop the processes.

Using VS Code GitHub Copilot

  1. Start the Functions host locally (as shown above)
  2. In VS Code, open the Chat panel with GitHub Copilot
  3. Ask Copilot to use the MCP tools:
    List all the projects we have
    
    Show me all contributions from Marcus Thorne
    
    Add a new contribution to the Sorsogon Community Innovation Labs project
    
  4. When prompted, click Continue to allow the tool execution
  5. Copilot will execute the MCP tool and display the results

Deploy to Azure for Remote MCP

Optionally, enable VNet for additional network isolation before deployment:

azd env set VNET_ENABLED true

Run these azd commands to provision Azure resources and deploy your code:

azd provision

Wait a few minutes for access permissions to take effect, then deploy:

azd deploy

This will:

  • Create an Azure Function App with your MCP server
  • Set up all required infrastructure (App Service plan, Storage, etc.)
  • Deploy your TypeScript code to Azure
  • Configure the MCP system key for secure access

Note API Management and App Service built-in authentication can be used for enhanced security and OAuth provider integration.

Get your MCP System Key

After azd deploy completes, you need the MCP system key to authenticate requests.

Option 1: Get from Azure CLI (Recommended)

# Get your function app name from azd
FUNCTION_APP_NAME=$(azd env get-values | grep AZURE_FUNCTION_APP_NAME | cut -d'=' -f2)
RESOURCE_GROUP=$(azd env get-values | grep AZURE_RESOURCE_GROUP | cut -d'=' -f2)

# Retrieve the mcp_extension system key
MCP_KEY=$(az functionapp keys list \
  --resource-group $RESOURCE_GROUP \
  --name $FUNCTION_APP_NAME \
  --query "systemKeys.mcp_extension" -o tsv)

echo "MCP Extension Key: $MCP_KEY"

Option 2: Get from Azure Portal

  1. Go to Azure Portal
  2. Search for your Function App (name from azd env get-values)
  3. Navigate to FunctionsApp Keys
  4. Copy the mcp_extension key from the System Keys section

Connect to your remote MCP server in Azure

After deployment, your MCP server is accessible at:

https://<funcappname>.azurewebsites.net/runtime/webhooks/mcp?code=<your-mcp-extension-system-key>

Example with actual values:

https://mcp-scil-aegccgcze5bsdkez.azurewebsites.net/runtime/webhooks/mcp?code=X9kL2mN5pQ8rT3vW6xY1zA4bC7dE0fG9hI2jK5mL8nO1pR4sT7uV0wX3yZ6aB9cD==

Test in MCP Inspector

Use the key in the URL:

https://<funcappname>.azurewebsites.net/runtime/webhooks/mcp?code=<your-mcp-extension-system-key>

Connect in Azure AI Foundry

  1. Go to Azure AI Foundry
  2. Create or open your AI project
  3. Navigate to ToolsMCP Servers
  4. Add your remote MCP server with:
    • URL: https://<funcappname>.azurewebsites.net/runtime/webhooks/mcp
    • Headers: x-functions-key: <your-mcp-extension-system-key>
  5. Your AI models can now call the list_projects, get_contributions, and add_contribution tools

Configure Agent with Context

To help your AI agent understand how to use the MCP tools effectively:

  1. Create a new Agent in your project

  2. In the Configuration panel, set:

    • Display name: "Contribution Manager"
    • Description:
      A contribution tracking assistant that helps manage project contributions 
      across the Sorsogon Community Innovation Labs ecosystem. I can help you:
      - List all available projects and see who's contributing
      - Search for specific contributions by project or team member
      - Record new contributions with details like summary, description, and attachments
      
      Use me to track community engagement, project progress, and team member activities.
      
    • Starter prompts (optional examples):
      1. "List all projects and show me the contribution counts"
      2. "Show me all contributions from Marcus Thorne"
      3. "Add a new contribution to the Sorsogon Community Innovation Labs project"
  3. Enable the MCP tools in your agent's Tools configuration

  4. Test the agent with your starter prompts

Connect in VS Code GitHub Copilot

Set up in your mcp.json:

{
    "inputs": [
        {
            "type": "promptString",
            "id": "functions-mcp-extension-system-key",
            "description": "Azure Functions MCP Extension System Key",
            "password": true
        },
        {
            "type": "promptString",
            "id": "functionapp-name",
            "description": "Azure Function App Name"
        }
    ],
    "servers": {
        "remote-mcp-function": {
            "type": "http",
            "url": "https://${input:functionapp-name}.azurewebsites.net/runtime/webhooks/mcp",
            "headers": {
                "x-functions-key": "${input:functions-mcp-extension-system-key}"
            }
        }
    }
}

Redeploy your code updates

After making changes to your MCP tools or handlers, rebuild and redeploy:

npm run build
azd deploy

Note: Your function app code is always updated with the latest deployment package. No manual file replacement needed.

Clean up resources

When you're done working with your function app and related resources, you can use this command to delete the function app and its related resources from Azure and avoid incurring any further costs:

azd down

Source Code Structure

The MCP server is organized with Azure Functions' native decorator pattern:

src/
├── index.ts                 # Entry point - imports all tools
├── functions/
│   ├── data/
│   │   └── contributionData.ts    # Shared mock data (projects, contributions, members)
│   └── tools/
│       ├── listProjectsTool.ts    # list_projects MCP tool handler
│       ├── addContributionTool.ts # add_contribution MCP tool handler
│       └── getContributionsTool.ts# get_contributions MCP tool handler

Next Steps

  • Enhance Functionality: Add more tools for project management or analytics
  • Persist Data: Replace in-memory mock data with a database (Cosmos DB, SQL, etc.)
  • Add Security: Enable Azure API Management or App Service authentication
  • Enable VNet: Use azd env set VNET_ENABLED true for network isolation
  • Monitor & Log: Check Azure Application Insights for tool usage patterns
  • Scale: Optimize performance with higher tier App Service plans
  • Learn more: Explore MCP documentation and Azure Functions with MCP

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选