semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

.NET: New Feature: Feature to support direct MCP integration in the .NET SDK

Open rajalakshmisenthilnathan opened this issue 6 months ago • 5 comments


Feature request to support direct MCP integration in the .NET SDK

Current Integration Methods: In .NET, MCP tools are converted into AI functions for use with semantic kernel agents, while the Python SDK offers a direct connector.

Python SDK Link: semantic-kernel/python/semantic_kernel/connectors/mcp.py at main · microsoft/semantic-kernel Official announcement: Semantic Kernel adds Model Context Protocol (MCP) support for Python | Semantic Kernel Python Sample: semantic-kernel/python/samples/concepts/mcp/agent_with_http_mcp_plugin.py at main · microsoft/seman…

Feature Request: Add native Model Context Protocol (MCP) integration to the .NET SDK to provide seamless client and server support for MCP tools, eliminating the need for converting MCP tools to AI Functions.

Update: Feature Request: Add native Model Context Protocol (MCP) integration to the .NET SDK to provide seamless client and server support for MCP tools, eliminating the need for converting MCP tools to Kernel Functions.

eliminating the need for converting MCP tools to AI Functions.

Can you elaborate on this? Every MCP tool that comes back from the MCP C# SDK via APIs like ListToolsAsync already is an AIFunction.

stephentoub avatar Oct 17 '25 13:10 stephentoub

Hello @stephentoub , I actually meant converting MCP tools to Kernel Functions. Below is a sample code in C#, where we are converting the MCP Tools (AI functions) into Kernel functions to create a plugin.

IList<McpClientTool> tools = await mcpClient.ListToolsAsync();
 
var functions = tools.Select(tool => tool.AsKernelFunction());

return KernelPluginFactory.CreateFromFunctions(mcpOptions.Name, tools); 

In Python, we see that there is support to achieve the same without converting to KernelFunction

async def main():
    # 1. Create the agent
    async with MCPStreamableHttpPlugin(
        name="LearnSite",
        description="Learn Docs Plugin",
        url="https://learn.microsoft.com/api/mcp",
    ) as learn_plugin:
        agent = ChatCompletionAgent(
            service=AzureChatCompletion(credential=AzureCliCredential()),
            name="DocsAgent",
            instructions="Answer questions about the Microsoft's Semantic Kernel SDK.",
            plugins=[learn_plugin],
        )

Is there a roadmap in C# to eliminate the conversion and directly support MCP as connectors? Thanks!

Are you asking if there's a plan to ship an API in Semantic Kernel that let's you replace this:

return KernelPluginFactory.CreateFromFunctions(mcpOptions.Name, 
    (await mcpClient.ListToolsAsync()).Select(tool => tool.AsKernelFunction()));

with a simpler line? I don't know. Why is that important?

stephentoub avatar Oct 23 '25 12:10 stephentoub

Currently, we’re using two libraries - the MCP Client SDK and the Semantic Kernel C# SDK -to achieve this functionality. I wanted to check if there’s a roadmap to include this feature directly in the SK C# SDK, similar to how it works in the python implementation. This would help reduce our dependency on using both libraries. However, this is not a blocking issue at the moment.

I wanted to check if there’s a roadmap to include this feature directly in the SK C# SDK, similar to how it works in the python implementation. This would help reduce our dependency on using both libraries.

Even if SK were to add direct MCP helpers, it would do so via a dependency on the ModelContextProtocol library (just as the Python implementation depends on the Python mcp library). You would not be removing the dependency from your transitive graph.

stephentoub avatar Oct 23 '25 14:10 stephentoub