Getting Started with Remote MCP Servers using Azure Functions (Node.js/TypeScript)

Getting Started with Remote MCP Servers using Azure Functions (Node.js/TypeScript)

site icon
2025.04.16 19
Bicep远程MCP服务器Azure Functions开发工具开发效率
这是一个基于Azure Functions的远程MCP服务器模板,使用Node.js/TypeScript编写。它允许用户快速构建和部署自定义的远程MCP服务器到云端,支持本地调试和云端部署。该服务器通过密钥和HTTPS进行安全保护,并支持OAuth和网络隔离。
View on GitHub

Overview

基本能力

产品定位

该产品是一个远程MCP服务器模板,旨在帮助开发者快速构建和部署自定义的MCP服务器到云端,支持本地调试和云端运行。

核心功能

  1. 远程MCP服务器:支持在Azure Functions上运行MCP服务器。
  2. 安全保护:通过密钥和HTTPS进行安全保护,支持OAuth和网络隔离。
  3. 本地调试:支持在本地环境中运行和调试MCP服务器。
  4. 云端部署:使用Azure Developer CLI (azd)快速部署到云端。
  5. 工具支持:提供VS Code和MCP Inspector工具支持。

适用场景

  1. 开发效率工具:用于构建和部署自定义的MCP服务器,提升开发效率。
  2. 云端服务:需要在云端运行MCP服务器的场景。
  3. 本地调试:开发者需要在本地环境中调试MCP服务器的场景。

工具列表

  1. VS Code - Copilot Edits:用于添加和管理MCP服务器,支持通过SSE端点连接。
  2. MCP Inspector:用于调试和运行MCP工具,支持SSE传输类型。

常见问题解答

  1. 如何获取系统密钥:可以从Azure门户或使用CLI命令获取系统密钥。
  2. 如何连接远程MCP服务器:需要在URL中包含系统密钥或设置x-functions-key头。
  3. 如何清理资源:使用azd down命令删除Azure资源。

使用教程

使用依赖

  1. 安装Node.js 18或更高版本: shell https://nodejs.org/en/download/
  2. 安装Azure Functions Core Tools: shell https://learn.microsoft.com/azure/azure-functions/functions-run-local?pivots=programming-language-javascript#install-the-azure-functions-core-tools
  3. 安装Azure Developer CLI: shell https://aka.ms/azd
  4. 安装Docker(可选): shell https://www.docker.com/

安装教程

  1. 启动Azurite(Azure Storage Emulator): shell docker run -p 10000:10000 -p 10001:10001 -p 10002:10002 mcr.microsoft.com/azure-storage/azurite
  2. 安装依赖: shell npm install
  3. 构建项目: shell npm run build
  4. 启动Functions主机: shell func start

调试方式

  1. 使用VS Code - Copilot Edits:
  2. 添加MCP服务器: shell http://0.0.0.0:7071/runtime/webhooks/mcp/sse
  3. 运行工具: plaintext Say Hello
  4. 使用MCP Inspector:
  5. 安装并运行MCP Inspector: shell npx @modelcontextprotocol/inspector node build/index.js
  6. 设置传输类型为SSE,并连接URL: shell http://0.0.0.0:7071/runtime/webhooks/mcp/sse
  7. 运行工具。

部署到Azure

  1. 使用azd up命令部署: shell azd up
  2. 清理资源: shell azd down

许可证

该项目遵循 MIT 开源许可条款,请参阅 MIT 了解完整条款。