azure-functions-mcp-server-sample

satodayo/azure-functions-mcp-server-sample

3.2

If you are the rightful owner of azure-functions-mcp-server-sample and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

This project demonstrates the implementation of a Model Context Protocol (MCP) server using Azure Functions (.NET 8).

Tools
1
Resources
0
Prompts
0

Azure Functions MCP Server (.NET)

Azure Functions (.NET 8) を使った Model Context Protocol (MCP) サーバーの実装例です。

概要

このプロジェクトは、Azure Functions の MCP 拡張機能を使用して、Tour de Azure のタイトル情報を取得する MCP ツールを提供します。

必要な環境

  • .NET 8.0 SDK
  • Azure Functions Core Tools
  • Docker & Docker Compose (Dev Container使用時)

セットアップ

Dev Container を使用する場合

  1. このリポジトリをクローン
  2. VS Code で開く
  3. "Reopen in Container" を選択

Dev Container が起動すると、自動的に以下が実行されます:

  • 必要な拡張機能のインストール
  • NuGet パッケージの復元 (dotnet restore)

ローカル環境で実行する場合

  1. local.settings.json ファイルを作成します:
cd mcp-server

local.settings.json を以下の内容で作成:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
  }
}
  1. プロジェクトをビルドして実行:
dotnet restore
dotnet build
func start

プロジェクト構成

azure-functions-dotnet/
├── .devcontainer/          # Dev Container設定
├── .vscode/                # VS Code設定(tasks, launch)
├── mcp-server/             # Azure Functions プロジェクト
│   ├── Program.cs          # アプリケーションエントリポイント
│   ├── TourDeAzureTrigger.cs   # MCP ツール実装
│   ├── mcp-server.csproj   # プロジェクトファイル
│   ├── host.json           # Functions ホスト設定
│   └── local.settings.json # ローカル開発設定(要作成)
└── README.md

使用しているパッケージ

  • Microsoft.Azure.Functions.Worker (v2.1.0)
  • Microsoft.Azure.Functions.Worker.Extensions.Mcp (v1.0.0)
  • Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore (v2.1.0)
  • Microsoft.ApplicationInsights.WorkerService (v2.23.0)

MCP ツール

get_tour_de_azure_title

Tour de Azure の各回のタイトルを取得します。

パラメータ:

  • edition (int, required): 回数(1, 2, 3...)

使用例:

{
  "edition": 1
}

レスポンス:

AI Document Intelligenceに入門しよう!

開発

ビルド

cd mcp-server
dotnet build

ローカル実行

cd mcp-server
func start

注意: 初回実行時は local.settings.json ファイルが必要です。上記のセットアップセクションを参照してください。

ローカルストレージエミュレータ(Azurite)が自動的に起動します:

デバッグ

VS Code のデバッグ機能を使用:

  1. F5 キーを押す
  2. または、デバッグビューから "Attach to .NET Functions" を選択

ライセンス

このプロジェクトはサンプルコードです。