DotnetFastMCP v2.1 fixes silent runtime crash in .NET MCP tool class injection
Developers building MCP servers in .NET using constructor-injected tool classes faced a runtime crash — System.Reflection.TargetException — with no compile-time warning when AI models invoked their tools. The root cause was that the WithComponentsFrom method registered tool methods but never added their declaring classes to ASP.NET Core's dependency injection container, forcing developers to manually register each class. Version 2.1.1 of the DotnetFastMCP package resolves this by automatically registering all non-static tool classes via TryAddTransient during assembly scanning. The update also improves tool parameter schemas by supporting descriptions, reducing ambiguity when AI models interpret tool inputs. Developers can apply the fix by upgrading to DotnetFastMCP 2.1.1 via the .NET CLI without changing their Program.cs structure.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in