HeadlinesBriefing favicon HeadlinesBriefing.com

FatAdvisor .NET Nutrition AI Agent: Plugin Integration

DEV Community •
×

The second installment of the FatAdvisor series extends a . NET nutrition assistant built on Microsoft Semantic Kernel by adding a native code plugin that connects the AI to external data. The article explains the concept of plugins as API wrappers that enable large language models to fetch information, and it details why a native C# implementation was chosen over OpenAPI, MCP, or Logic Apps for this prototype.

Developers are guided through creating interface contracts (IFatSecretApiClient, IFatSecretOAuth, IProfileTokenStorage) and stub classes that simulate FatSecret API responses using static JSON files for food logs and weight diaries. The FatSecretProfileDataPlugin class is annotated with KernelFunction and Description attributes, allowing the LLM to invoke get_consumed_food and get_weight_diary functions automatically. Dependency injection is configured via Autofac modules, registering the kernel, plugin, and stub services as singletons.

Finally, the console runner demonstrates how the agent formulates system prompts, triggers function calls, and produces a nutrition report that includes weight trends, daily food intake, and actionable advice for muscle gain without excess fat. This walkthrough showcases practical techniques for enriching AI agents with real‑world data while maintaining testable, modular code.