Skip to content

Add MCP gateway auto-discovery integrations for chat clients and agents#2

Closed
KSemenenko wants to merge 2 commits intomainfrom
codex/mcp-agent-framework-chat-integration
Closed

Add MCP gateway auto-discovery integrations for chat clients and agents#2
KSemenenko wants to merge 2 commits intomainfrom
codex/mcp-agent-framework-chat-integration

Conversation

@KSemenenko
Copy link
Member

Summary

  • add a reusable McpGatewayAutoDiscoveryChatClient and UseManagedCodeMcpGatewayAutoDiscovery(...) wrapper for staged tool exposure in chat loops
  • extend McpGatewayToolSet with discovered proxy-tool creation and add the shorter AddMcpGatewayTools(...) chat-options API
  • add scenario-driven integration coverage for direct IChatClient and Microsoft Agent Framework flows against a 50-tool catalog in both lexical fallback mode and vector mode
  • rewrite the README as consumer-facing onboarding and update architecture/ADR docs for the shipped auto-discovery flow

Testing

  • dotnet restore ManagedCode.MCPGateway.slnx
  • dotnet build ManagedCode.MCPGateway.slnx -c Release --no-restore
  • dotnet build ManagedCode.MCPGateway.slnx -c Release --no-restore -p:RunAnalyzers=true
  • dotnet test --solution ManagedCode.MCPGateway.slnx -c Release --no-build
  • cloc src tests
  • roslynator analyze src/ManagedCode.MCPGateway/ManagedCode.MCPGateway.csproj tests/ManagedCode.MCPGateway.Tests/ManagedCode.MCPGateway.Tests.csproj --severity-level warning

Copilot AI review requested due to automatic review settings March 8, 2026 08:52
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 071b700148

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds staged MCP gateway auto-discovery for chat clients and agents. It introduces McpGatewayAutoDiscoveryChatClient (and its UseManagedCodeMcpGatewayAutoDiscovery extension), the CreateDiscoveredTools/AddTools additions to McpGatewayToolSet, and integration tests covering both direct IChatClient and Microsoft Agent Framework scenarios against a 50-tool catalog in lexical and vector modes. It also rewrites the README as consumer-facing onboarding and adds a new ADR.

Changes:

  • New McpGatewayAutoDiscoveryChatClient and UseManagedCodeMcpGatewayAutoDiscovery wrapper for staged per-turn tool exposure in chat loops
  • Extended McpGatewayToolSet with CreateDiscoveredTools/AddTools and new ChatOptions.AddMcpGatewayTools extension; AddManagedCodeMcpGatewayTools marked obsolete
  • Integration tests (McpGatewayChatClientIntegrationTests, McpGatewayAgentFrameworkIntegrationTests) and enriched test helpers (TestChatClient with scenario support, GatewayIntegrationTestSupport); README/ADR/docs updated

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/ManagedCode.MCPGateway/McpGatewayAutoDiscoveryChatClient.cs New: per-request staged tool-discovery chat client wrapper
src/ManagedCode.MCPGateway/McpGatewayToolSet.cs Extended: AddTools, CreateDiscoveredTools, proxy-tool creation
src/ManagedCode.MCPGateway/Registration/McpGatewayChatOptionsExtensions.cs New: AddMcpGatewayTools + obsolete shims
src/ManagedCode.MCPGateway/Registration/McpGatewayChatClientExtensions.cs New: UseManagedCodeMcpGatewayAutoDiscovery extension
src/ManagedCode.MCPGateway/Configuration/McpGatewayAutoDiscoveryOptions.cs New: options for max tools, tool names
src/ManagedCode.MCPGateway/Internal/Serialization/McpGatewayJsonSerializer.cs Added JsonStringEnumConverter to serializer options
tests/ManagedCode.MCPGateway.Tests/ChatClient/McpGatewayChatClientIntegrationTests.cs New: integration tests for direct IChatClient auto-discovery
tests/ManagedCode.MCPGateway.Tests/Agents/McpGatewayAgentFrameworkIntegrationTests.cs New: integration tests for Agent Framework auto-discovery
tests/ManagedCode.MCPGateway.Tests/TestSupport/TestChatClient.cs Extended: scenario-driven invocation capture
tests/ManagedCode.MCPGateway.Tests/TestSupport/GatewayIntegrationTestSupport.cs New: 50-tool catalog + scenario builders + flow assertions
tests/ManagedCode.MCPGateway.Tests/TestSupport/TestEmbeddingGenerator.cs New CreateVector hook for semantic vector tests
tests/ManagedCode.MCPGateway.Tests/ManagedCode.MCPGateway.Tests.csproj Added Microsoft.Agents.AI package reference
Directory.Packages.props Added Microsoft.Agents.AI 1.0.0-rc3; bumped ModelContextProtocol to 1.1.0 and TUnit to 1.19.0
docs/ADR/ADR-0003-reusable-chat-client-and-agent-tool-modules.md New ADR documenting the AITool-module approach
docs/Architecture/Overview.md Updated architecture diagrams and module map
README.md Rewritten as consumer-facing onboarding
AGENTS.md New coding rules added

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@KSemenenko
Copy link
Member Author

Addressed all open review comments in 3dd9938.

Covered fixes:

  • ignore primitive/malformed gateway_tools_search payloads during auto-discovery replay
  • make McpGatewayToolSet.AddTools(...) return a composed copy instead of mutating the input list
  • normalize discovered tool names so they never start with a digit
  • rename the public chat-client extension to UseMcpGatewayAutoDiscovery(...)
  • remove obsolete chat-options legacy aliases and redundant test assertions

Verification:

  • dotnet restore ManagedCode.MCPGateway.slnx
  • dotnet build ManagedCode.MCPGateway.slnx -c Release --no-restore
  • dotnet build ManagedCode.MCPGateway.slnx -c Release --no-restore -p:RunAnalyzers=true
  • dotnet test --solution ManagedCode.MCPGateway.slnx -c Release --no-build
  • roslynator analyze src/ManagedCode.MCPGateway/ManagedCode.MCPGateway.csproj -p Configuration=Release --severity-level warning
  • roslynator analyze tests/ManagedCode.MCPGateway.Tests/ManagedCode.MCPGateway.Tests.csproj -p Configuration=Release --severity-level warning
  • cloc --include-lang=C# src tests

@KSemenenko
Copy link
Member Author

#3 contains all implemention

@KSemenenko KSemenenko closed this Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants