Remote MCP Server

MIT License
23
  • Linux
  • Apple

Integrations

  • Offers a similar MCP server implementation available in .NET/C# for developers preferring that ecosystem.

  • Supports running Azure Storage Emulator through Docker during local development for testing blob storage operations.

  • Supports development in GitHub Codespaces for a ready-to-use development environment without local setup.

Azure Functions를 사용하여 원격 MCP 서버 시작하기(Node.js/TypeScript)

Azure Functions를 사용하여 사용자 지정 원격 MCP 서버를 클라우드에 쉽게 구축하고 배포할 수 있는 빠른 시작 템플릿입니다. 디버깅을 통해 로컬 컴퓨터에서 복제/복원/실행하고, 몇 분 안에 클라우드에 배포 azd up . MCP 서버는 키와 HTTP를 사용하여 보안이 강화되었으며, EasyAuth 및/또는 API Management를 사용한 OAuth 및 VNET을 사용한 네트워크 격리 등 다양한 옵션을 제공합니다.

비디오 개요를 시청하세요

더 많은 언어로 이 샘플을 찾고 있다면 .NET/C#Python 버전을 확인해보세요.

Azure Functions를 사용하는 원격 MCP 서버에 대한 아키텍처 다이어그램은 다음과 같습니다.

필수 조건

지역 환경을 준비하세요

이 특정 샘플에는 Blob 저장소에서 스니펫을 저장하고 가져오기 때문에 Azure Storage Emulator가 필요합니다.

  1. Azurite 시작하기지엑스피1

VS Code 확장 프로그램에서 Azurite를 사용하는 경우 Azurite: Start 하지 않으면 오류가 발생합니다.

터미널에서 로컬로 MCP 서버를 실행하세요.

  1. 종속성 설치
    npm install
  2. 프로젝트를 빌드하세요
    npm run build
  3. 로컬에서 Functions 호스트를 시작합니다.
    func start

기본적 으로 웹훅 경로( /runtime/webhooks/mcp/sse 사용합니다. 나중에 Azure에서 이 경로를 사용하여 클라이언트/호스트 호출 시 키를 설정합니다( /runtime/webhooks/mcp/sse?code=<system_key>

클라이언트/호스트 내에서 로컬 MCP 서버를 사용합니다.

VS 코드 - Copilot 편집

  1. 명령 팔레트에서 MCP 서버를 추가하고 실행 중인 함수 앱의 SSE 엔드포인트에 URL을 추가합니다.
    http://0.0.0.0:7071/runtime/webhooks/mcp/sse
  2. 추가할 MCP 서버 유형으로 HTTP(서버에서 보낸 이벤트)를 선택합니다.
  3. 실행 중인 함수 앱의 SSE 엔드포인트에 대한 URL을 입력하세요.
  4. 서버 ID를 입력하세요. (원하는 이름을 입력하세요)
  5. 사용자 설정(모든 앱에서 사용 가능)에서 실행할지, 작업 공간 설정(이 앱에서만 사용 가능)에서 실행할지 선택하세요.
  6. 명령 팔레트에서 MCP 서버를 나열 하고 서버를 시작하세요. 이전 단계에서 로컬 서버가 이미 시작되었을 수 있습니다. 그렇다면 이 단계를 건너뛸 수 있습니다.
  7. Copilot 채팅 에이전트 모드에서 도구를 트리거하기 위한 프롬프트를 입력합니다. 예를 들어, 일부 코드를 선택하고 이 프롬프트를 입력합니다.
    Say Hello
    Save this snippet as snippet1
    Retrieve snippet1 and apply to newFile.ts
  8. 도구를 실행하라는 메시지가 표시되면 계속을 클릭하여 동의합니다.
  9. 완료되면 터미널 창에서 Ctrl+C를 눌러 func.exe 호스트 프로세스를 중지하고 명령 팔레트에서 MCP 서버 목록을 표시하여 로컬 서버를 중지합니다.

MCP 검사관

  1. 새 터미널 창 에서 MCP Inspector를 설치하고 실행하세요.
    npx @modelcontextprotocol/inspector node build/index.js
  2. 이전에 함수 앱을 중지한 경우 로컬에서 함수 호스트를 시작합니다.
    func start
  3. CTRL을 클릭하면 앱에 표시된 URL(예: http://0.0.0.0:5173/#resources )에서 MCP Inspector 웹 앱을 로드합니다.
  4. 전송 유형을 SSE 로 설정하세요
  5. 실행 중인 Function 앱의 SSE 엔드포인트에 URL을 설정하고 Connect를 실행합니다 .
    http://0.0.0.0:7071/runtime/webhooks/mcp/sse
  6. 도구 목록 . 도구를 클릭하고 도구 실행 .
  7. 완료되면 터미널 창에서 Ctrl+C를 눌러 func.exe 호스트 프로세스를 중지하고, 터미널 창에서 Ctrl+C를 눌러 @modelcontextprotocol/inspector 호스트 프로세스를 중지합니다.

원격 MCP를 위해 Azure에 배포

선택적으로 샘플에서 사용되는 VNet에 옵트인할 수 있습니다. (선택하는 경우 azd up 전에 옵트인하세요.)

azd env set VNET_ENABLED true

azd 명령을 실행하여 필요한 Azure 리소스로 함수 앱을 프로비저닝하고 코드를 배포합니다.

azd up

API 관리를 사용 하면 MCP 서버의 보안과 정책을 개선할 수 있으며App Service 내장 인증을 사용하여 Entra를 포함한 원하는 OAuth 공급자를 설정할 수 있습니다.

클라이언트에서 원격 MCP 서버 기능 앱에 연결

클라이언트는 새로 호스팅된 SSE 엔드포인트를 호출하기 위해 키가 필요합니다. 키는 https://<funcappname>.azurewebsites.net/runtime/webhooks/mcp/sse 형식입니다. 호스팅된 함수에는 기본적으로 시스템 키가 필요하며, 포털 이나 CLI( az functionapp keys list --resource-group <resource_group> --name <function_app_name> )에서 얻을 수 있습니다. mcp_extension 이라는 이름의 시스템 키를 가져오세요.

MCP Inspector에서 원격 MCP 서버에 연결

MCP Inspector의 경우 URL에 키를 포함할 수 있습니다.

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

VS Code에서 원격 MCP 서버에 연결 - GitHub Copilot

VS Code 내 GitHub Copilot의 경우, mcp.jsonx-functions-key 헤더에 키를 설정하고 URL에는 https://<funcappname>.azurewebsites.net/runtime/webhooks/mcp/sse 사용해야 합니다. 다음 예시는 이 저장소에 포함된 mcp.json 파일에서 가져온 것으로, VS Code에서 서버를 시작할 때 입력을 통해 키를 입력하라는 메시지를 표시합니다. 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 Functions App Name" } ], "servers": { "remote-mcp-function": { "type": "sse", "url": "https://${input:functionapp-name}.azurewebsites.net/runtime/webhooks/mcp/sse", "headers": { "x-functions-key": "${input:functions-mcp-extension-system-key}" } }, "local-mcp-function": { "type": "sse", "url": "http://0.0.0.0:7071/runtime/webhooks/mcp/sse" } } }
  1. mcp.json 파일 내부의 remote-mcp-function 서버에서 시작을 클릭합니다.
  2. VS Code에서 메시지가 표시되면 Azure Portal에서 만든 함수 앱의 이름을 입력합니다.
  3. 프롬프트에 Azure Functions MCP Extension System Key 입력하세요. 함수 앱의 Azure Portal에서 이 키를 복사하려면 함수 메뉴 항목 > 앱 키로 이동한 후 시스템 키에서 mcp_extension 키를 복사하세요.
  4. Copilot 채팅 에이전트 모드에서 도구를 트리거하기 위한 프롬프트를 입력합니다. 예를 들어, 일부 코드를 선택하고 이 프롬프트를 입력합니다.
    Say Hello
    Save this snippet as snippet1
    Retrieve snippet1 and apply to newFile.ts

코드를 다시 배포하세요

Azure 리소스를 프로비저닝하고 함수 앱에 코드 업데이트를 배포하기 위해 필요한 만큼 azd up 명령을 실행할 수 있습니다.

[!NOTE] 배포된 코드 파일은 항상 최신 배포 패키지로 덮어쓰여집니다.

자원 정리

함수 앱과 관련 리소스 작업이 끝나면 이 명령을 사용하여 Azure에서 함수 앱과 관련 리소스를 삭제하고 추가 비용이 발생하지 않도록 할 수 있습니다.

azd down

소스 코드

getSnippetsaveSnippet 엔드포인트에 대한 함수 코드는 src 디렉터리의 TypeScript 파일에 정의되어 있습니다. MCP 함수 애노테이션은 이러한 함수를 MCP 서버 도구로 제공합니다.

다음은 몇 가지 MCP 서버 예제(문자열 가져오기, 객체 가져오기, 객체 저장)에 대한 코드입니다.

// Hello function - responds with hello message export async function mcpToolHello(context: InvocationContext): Promise<string> { return "Hello I am MCP Tool!"; } // Register the hello tool app.mcpTool('hello', { toolName: 'hello', description: 'Simple hello world MCP Tool that responses with a hello message.', handler: mcpToolHello }); // GetSnippet function - retrieves a snippet by name export async function getSnippet(_message: unknown, context: InvocationContext): Promise<string> { console.info('Getting snippet'); // Get snippet name from the tool arguments const mcptoolargs = context.triggerMetadata.mcptoolargs as { snippetname?: string }; const snippetName = mcptoolargs?.snippetname; console.info(`Snippet name: ${snippetName}`); if (!snippetName) { return "No snippet name provided"; } // Get the content from blob binding - properly retrieving from extraInputs const snippetContent = context.extraInputs.get(blobInputBinding); if (!snippetContent) { return `Snippet '${snippetName}' not found`; } console.info(`Retrieved snippet: ${snippetName}`); return snippetContent as string; } // Register the GetSnippet tool app.mcpTool('getsnippet', { toolName: GET_SNIPPET_TOOL_NAME, description: GET_SNIPPET_TOOL_DESCRIPTION, toolProperties: [ { propertyName: SNIPPET_NAME_PROPERTY_NAME, propertyValue: PROPERTY_TYPE, description: SNIPPET_NAME_PROPERTY_DESCRIPTION, } ], extraInputs: [blobInputBinding], handler: getSnippet }); // SaveSnippet function - saves a snippet with a name export async function saveSnippet(_message: unknown, context: InvocationContext): Promise<string> { console.info('Saving snippet'); // Get snippet name and content from the tool arguments const mcptoolargs = context.triggerMetadata.mcptoolargs as { snippetname?: string; snippet?: string; }; const snippetName = mcptoolargs?.snippetname; const snippet = mcptoolargs?.snippet; if (!snippetName) { return "No snippet name provided"; } if (!snippet) { return "No snippet content provided"; } // Save the snippet to blob storage using the output binding context.extraOutputs.set(blobOutputBinding, snippet); console.info(`Saved snippet: ${snippetName}`); return snippet; } // Register the SaveSnippet tool app.mcpTool('savesnippet', { toolName: SAVE_SNIPPET_TOOL_NAME, description: SAVE_SNIPPET_TOOL_DESCRIPTION, toolProperties: [ { propertyName: SNIPPET_NAME_PROPERTY_NAME, propertyValue: PROPERTY_TYPE, description: SNIPPET_NAME_PROPERTY_DESCRIPTION, }, { propertyName: SNIPPET_PROPERTY_NAME, propertyValue: PROPERTY_TYPE, description: SNIPPET_PROPERTY_DESCRIPTION, } ], extraOutputs: [blobOutputBinding], handler: saveSnippet });

host.json 파일에는 이 기능을 사용하는 앱에 필요한 실험 번들에 대한 참조도 포함되어 있습니다.

"extensionBundle": { "id": "Microsoft.Azure.Functions.ExtensionBundle.Experimental", "version": "[4.*, 5.0.0)" }

다음 단계

-
security - not tested
A
license - permissive license
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

키, HTTPS, OAuth 및 네트워크 격리 옵션을 통한 보안 통신으로 코드 조각을 저장하고 검색할 수 있는 Azure Functions를 사용하는 클라우드 기반 사용자 지정 MCP 서버입니다.

  1. 필수 조건
    1. 지역 환경을 준비하세요
      1. 터미널에서 로컬로 MCP 서버를 실행하세요.
        1. 클라이언트/호스트 내에서 로컬 MCP 서버를 사용합니다.
          1. VS 코드 - Copilot 편집
          2. MCP 검사관
        2. 원격 MCP를 위해 Azure에 배포
          1. 클라이언트에서 원격 MCP 서버 기능 앱에 연결
            1. MCP Inspector에서 원격 MCP 서버에 연결
            2. VS Code에서 원격 MCP 서버에 연결 - GitHub Copilot
          2. 코드를 다시 배포하세요
            1. 자원 정리
              1. 소스 코드
                1. 다음 단계

                  Related MCP Servers

                  • A
                    security
                    A
                    license
                    A
                    quality
                    A MCP server for managing and storing code snippets in various programming languages, allowing users to create, list, and delete snippets via a standardized interface.
                    Last updated -
                    3
                    4
                    JavaScript
                    MIT License
                  • -
                    security
                    A
                    license
                    -
                    quality
                    An MCP server to create secure code sandbox environment for executing code within Docker containers.
                    Last updated -
                    69
                    Go
                    MIT License
                    • Linux
                    • Apple
                  • -
                    security
                    F
                    license
                    -
                    quality
                    A personal MCP server for securely storing and accessing API keys across projects using the macOS Keychain, letting AI assistants and applications retrieve credentials through natural language.
                    Last updated -
                    10
                    TypeScript
                    • Apple
                  • -
                    security
                    A
                    license
                    -
                    quality
                    An MCP server for interacting with Azure. Contains some common Compute and Networking actions, and extensible to add many more.
                    Last updated -
                    Python
                    Apache 2.0

                  View all related MCP servers

                  ID: 9khl8qvtum