Centralize MCP and RAG tool management in AIManagementChatClient #21636

Back

Summary

  • Centralize tool management: Move MCP tool loading and RAG tool preparation from AIChatCompletionIntegrationService and AIManagementChatClient<T> into AIManagementChatClient.PrepareOptionsAsync(), creating a single responsibility point for tool management during chat completions.
  • Add HasEmbedderConfiguration flag to ChatClientCreationConfiguration so RAG tools are only added when an embedder provider is actually configured for the workspace, preventing unnecessary tool injection.
  • Simplify AIManagementChatClient<T> to a thin resolver wrapper that delegates directly to the resolved IChatClient, removing duplicated MCP tool loading and FunctionInvokingChatClient wrapping logic.
  • Fix MCP argument parsing in both McpServerAppService and McpServerConfigurationStore to support space-separated argument strings (e.g. -y @modelcontextprotocol/server-filesystem /tmp) in addition to JSON arrays.
  • Increase default MCP timeout from 30s to 120s and properly pass it as InitializationTimeout to both HttpMcpClientFactory and StdioMcpClientFactory.
  • Fix duplicate [Route] attribute on ChatCompletionsController (removed extraneous [Route("v1")]).
  • Add unit tests for AIManagementChatClient covering RAG+MCP tool merging, MCP-only tools, FunctionInvokingChatClient validation, and caller-provided tool preservation.

Test plan

  • Add AIManagementChatClient_Tests with 4 test cases:
    • RAG + MCP tools are both added when embedder is configured
    • Only MCP tools are added when embedder is not configured
    • Exception is thrown when RAG is enabled but inner client is not FunctionInvokingChatClient
    • Caller-provided tools are preserved when merging with RAG and MCP tools
Version
10.2.0-rc.1
Release Date
24 February, 2026
Labels
abp-module-ai-management
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.