0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Azure Functions で McpToolTrigger を使ったらビルドできなかった話(SDK 2.0.2 に上げればOK)

Last updated at Posted at 2025-05-02

以下を参考に Azure Functions の McpToolTrigger を試そうとして個人的にハマったので備忘録としてまとめておきます。

環境

Windows 11
Visual Studio 2022 Version 17.13.6

問題: McpToolTrigger の Function を定義すると何故かビルドエラーになった

初めて MCP を使ってみたので、公式ドキュメントの内容をほぼコピペで進めていました。
プロジェクトは .NET 9 の「分離プロセス Worker」テンプレートを使用し、Microsoft.Azure.Functions.Extensions.Mcp の 1.0.0-preview.2 を参照に追加。ここまではビルド成功。

ところが、McpToolTrigger を定義した途端、以下のようなエラーでビルドが失敗:

1>C:\r\trash\FunctionApp2\FunctionApp1\obj\Debug\net9.0\WorkerExtensions\WorkerExtensions.csproj : error NU1202: Package Microsoft.Azure.Functions.Extensions.Mcp 1.0.0-preview.2 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Microsoft.Azure.Functions.Extensions.Mcp 1.0.0-preview.2 supports: net8.0 (.NETCoreApp,Version=v8.0)

image.png

.NET 9 プロジェクトにも関わらず、McpToolTrigger を定義したことでビルド時に生成される WorkerExtensions.csproj のターゲットフレームワークが net6.0 になっていました。

そのため、.NET 9 専用の Microsoft.Azure.Functions.Extensions.Mcp パッケージがビルドに失敗していたという原因のようです。

解決策 : Microsoft.Azure.Functions.Worker.Sdk を 2.0.2 以上にする

テンプレートでは Microsoft.Azure.Functions.Worker.Sdk の 2.0.0 が使われていましたが、このバージョンでは WorkerExtensions.csproj が net6.0 固定。

WorkerExtensions.csproj の ターゲットフレームワークを .NET 8 にあげる修正が 2.0.2 にて取り込まれたようなので、それを指定することでビルドが通るようになりました。

まとめ

  • Microsoft.Azure.Functions.Worker.Sdk が 2.0.0 だと .NET 6 ターゲットになり、ビルド失敗
  • 2.0.2 以上に更新すれば .NET 8 ターゲットでビルド成功
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?