Skip to content

Modelcontextprotocol #968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 52 commits into from
Mar 26, 2025
Merged

Modelcontextprotocol #968

merged 52 commits into from
Mar 26, 2025

Conversation

geffzhang
Copy link
Collaborator

1、Integrated model context protocol ,use offical dotnet sdk https://github.com/modelcontextprotocol/csharp-sdk
2、map mcp tools to botsharp IFunctionCallback
3、test pizzabot with mcp sse server

geffzhang and others added 30 commits August 22, 2024 22:40

namespace BotSharp.Core.Mcp.Functions;

public class McpToolFunction : IFunctionCallback
Copy link
Member

Choose a reason for hiding this comment

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

Do you think the name McpToolAdapter is better?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is primarily responsible for converting calls or responses from the MCP tools to fit the API expected by BotSharp, “Adapter” would immediately signal this role to other developers. It interacts with mcp server and converts data between incompatible mcp tools interfaces, then McpToolAdapter is a clearer, more descriptive choice

if(agent.McpTools.Any(item => item.Functions.Any(x=> x.Name == message.FunctionName)))
{
var data = JsonDocument.Parse(JsonSerializer.Serialize(message.Data));
state.SaveStateByArgs(data);
Copy link
Member

Choose a reason for hiding this comment

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

Why do we save function response to state? normally speaking, we only store model extracted function input args into state.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mainly dealing with the example of this order_number.

return "The order number is P123-01: {order_number = \"P123-01\" }";


foreach (var fn in functions)
{
if (!agent.SecondaryFunctions.Any(x => x.Name.Equals(fn.Name, StringComparison.OrdinalIgnoreCase)))
Copy link
Member

Choose a reason for hiding this comment

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

@iceljc Is it the recommended way to use agent.SecondaryFunctions for McpTool?

if (mcpClient != null)
{
var tools = await mcpClient.ListToolsAsync().ToListAsync();
var funcnames = item.Functions.Select(x => x.Name).ToList();
Copy link
Member

Choose a reason for hiding this comment

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

funcNames

@geffzhang geffzhang requested review from iceljc and Oceania2018 March 26, 2025 00:53
@Oceania2018 Oceania2018 merged commit f0bf0b4 into master Mar 26, 2025
5 checks passed
@geffzhang geffzhang deleted the modelcontextprotocol branch May 1, 2025 01:53
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.

3 participants