Guides adding a new MCP server integration to AnimalAL-v1: create a nested kernel plugin wrapping the MCP server, add a system message in KernelConstants, register the plugin in StandardKernel, and add integration tests. Use when the user says "add MCP server", "integrate MCP server", "wire MCP tools", or asks how to add or connect a new MCP server to the project.
Guides the agent through adding a new MCP (Model Context Protocol) server integration to AnimalAL-v1. The workflow creates a nested kernel plugin that wraps the MCP server, wires a system message, registers the plugin in StandardKernel, and adds integration tests. Follows the patterns in DOCS/MCPIntegrations and reference implementations (NestedFetchPlugin, NestedFilesystemPlugin).
Before generating or editing files, gather:
MCP server identity
python -m mcp_server_fetchmcps/<server>/tools/*.json, read them to know tool names and parameters.Plugin name and agent name
Nested[Name]Plugin and agent name in StandardKernel will be "[Name]Agent" (e.g. FetchAgent, FilesystemAgent).System message
KernelConstants.cs (e.g. FetchSubKernelSystemMessage, FilesystemSubKernelSystemMessage).Tests
python, ["-m", "mcp_server_fetch"]).mcps/<server>/tools/*.json or src/Plugins/DOCS/MCPIntegrations/<name>-plugin-integration.md for tool names and parameters.McpCommandValidator and project conventions (e.g. allowed commands like python, python3, dotnet) so the plugin uses a valid command.src/Plugins/NestedKernel/SK/Nested[Name]Plugin.cs following NestedFetchPlugin or NestedFilesystemPlugin.Lazy<Task<Kernel>>), MCP client lifecycle, disposal, retry for transient failures, thread-safe initialization.Ask[Name]Agent) that takes user message and optional ChatHistory; pass ChatHistory via kernel arguments if the project uses context injection.IDisposable and IAsyncDisposable and disposes the MCP client.Reference files:
src/Plugins/NestedKernel/SK/NestedFetchPlugin.cssrc/Plugins/NestedKernel/SK/NestedFilesystemPlugin.cssrc/Plugins/NestedKernel/SK/NestedMCPKernelPlugin.cs (base MCP pattern)src/Utilities/KernelConstants.cs, add a new public const string (e.g. [Name]SubKernelSystemMessage).FetchSubKernelSystemMessage and FilesystemSubKernelSystemMessage.src/AnimalKernel/Core/StandardKernel.cs, inside AddNestedKernelPlugins:
new NestedFetchPlugin(_loggerFactory, _endpoint, _modelId)), passing any required ctor args.builder.Plugins.AddFromObject(pluginInstance, "[Name]Agent")._pluginInstances["[Name]Agent"] = pluginInstance._disposablePlugins for cleanup (follow existing nested plugins in that method).src/IntegrationTesterApp/TestCaseDefinitions.cs, add test cases that:
FetchAgent.AskFetchAgent).fetch, filesystem) for filtered runs.Use the add-plugin-test skill for structure and fields. After adding tests, run the smart-test-runner skill (or .\run-tests.ps1 -t <tag>) and fix code before relaxing assertions.
| Item | Path |
|---|---|
| Fetch MCP integration doc | src/Plugins/DOCS/MCPIntegrations/fetch-plugin-integration.md |
| Filesystem MCP integration doc | src/Plugins/DOCS/MCPIntegrations/filesystem-plugin-integration.md |
| Nested MCP base plugin | src/Plugins/NestedKernel/SK/NestedMCPKernelPlugin.cs |
| Nested fetch plugin | src/Plugins/NestedKernel/SK/NestedFetchPlugin.cs |
| Nested filesystem plugin | src/Plugins/NestedKernel/SK/NestedFilesystemPlugin.cs |
| System messages | src/Utilities/KernelConstants.cs |
| Plugin registration | src/AnimalKernel/Core/StandardKernel.cs (AddNestedKernelPlugins) |
| Test definitions | src/IntegrationTesterApp/TestCaseDefinitions.cs |
Nested[Name]Plugin.cs created following NestedFetchPlugin/NestedFilesystemPlugin and NestedMCPKernelPlugin pattern; implements IDisposable/IAsyncDisposable.KernelConstants.cs and used by the nested plugin’s internal kernel.AddNestedKernelPlugins: AddFromObject, _pluginInstances, and _disposablePlugins if applicable.TestCaseDefinitions.cs with expected tool, keywords, and tags..\run-tests.ps1 -t <tag>); failures addressed by fixing code, not by weakening assertions.