
open hack bug repro
Repro of Semantic Kernel Open Hack Bug
Repository Info
About This Server
Repro of Semantic Kernel Open Hack Bug
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
Semantic Kernel Function Name Mismatch Reproduction
This repository contains a sample application that demonstrates a function name mismatch issue when using Semantic Kernel with Model Context Protocol (MCP) tools.
Issue Description
When integrating external tools (such as Model Context Protocol tools) with Semantic Kernel, there's a mismatch between how functions are registered in the kernel and how they're expected to be called by the AI model. Functions are registered with a plugin name prefix (e.g., PizzaTools_get_pizzas), but the model appears to attempt to call them by their original names (e.g., get_pizzas).
Expected Behavior
The agent should be able to call functions that have been registered in the kernel, regardless of whether they have a plugin name prefix or not.
Actual Behavior
The agent appears unable to correctly match and invoke the functions when they have a plugin name prefix. Direct invocation works when using the full prefixed name, but the agent appears to attempt to call functions by their original names.
Reproduction Steps
- Register MCP tools as kernel functions
- Add these functions to a plugin with a name prefix
- Direct function invocation works when explicitly using the prefixed name
- When using the agent, function calls fail as the model appears to attempt to call the non-prefixed version
Code Example
See Program.cs for a complete working example. Key sections include:
// Converting MCP tools to Kernel functions
var kernelFunctions = new List<KernelFunction>();
foreach (var tool in tools)
{
try {
var function = tool.AsKernelFunction();
kernelFunctions.Add(function);
Console.WriteLine($"Successfully registered tool: {tool.Name} as function: {function.Name}");
}
catch (Exception ex) {
Console.WriteLine($"Error registering tool {tool.Name}: {ex.Message}");
}
}
// Adding functions to the kernel with a plugin name prefix
Kernel kernel = builder.Build();
kernel.Plugins.AddFromFunctions("PizzaTools", kernelFunctions);
// Direct invocation works with the full prefixed name
var getPizzasTool = kernel.Plugins"PizzaTools";
var pizzaResult = await kernel.InvokeAsync(getPizzasTool);
// But agent invocation fails as it tries to call the non-prefixed name
ChatCompletionAgent agent = new()
{
Instructions = "...",
Name = "PizzaAgent",
Kernel = kernel
};
Impact
This issue makes it challenging to integrate external tools with Semantic Kernel, as it requires additional workarounds to ensure the model knows the correct function names to call. It affects the usability and reliability of tool integration in agent-based applications.
Environment
- .NET 9.0
- Semantic Kernel 1.53.0
- Microsoft.SemanticKernel.Agents.Core 1.53.0
- ModelContextProtocol 0.2.0-preview.1
- Azure OpenAI Service (gpt-4o)
Setup Instructions
- Clone the repository
- Set your Azure OpenAI API key in
appsettings.jsonor using user secrets:dotnet user-secrets set "OpenAI:ApiKey" "your-api-key" - Run the application:
dotnet run
Project Structure
Program.cs- Main application code that demonstrates the issuePizzaOrderClient.csproj- Project file with required dependenciesappsettings.json- Configuration file for OpenAI and Pizza MCP endpointsopenapi.yaml- OpenAPI specification for the Pizza API
License
MIT
Quick Start
Clone the repository
git clone https://github.com/prpercival/open-hack-bug-reproInstall dependencies
cd open-hack-bug-repro
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.