Skip to content

Commit a2fdc76

Browse files
authored
Merge pull request #1044 from SciSharp/mcpdummytools
Refactor InvokeFunction code
2 parents 1c7f57c + 1defef6 commit a2fdc76

21 files changed

Lines changed: 247 additions & 251 deletions

BotSharp.sln

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Core.Realtime", "s
131131
EndProject
132132
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.PizzaBot.MCPServer", "tests\BotSharp.PizzaBot.MCPServer\BotSharp.PizzaBot.MCPServer.csproj", "{8D2AD45F-836A-516F-DE6A-71443CEBB18A}"
133133
EndProject
134-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Core.MCP", "src\Infrastructure\BotSharp.Core.MCP\BotSharp.Core.MCP.csproj", "{534D1DD5-9D62-115C-F230-47080D76CE52}"
135-
EndProject
136134
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Test.ComputerUse", "tests\BotSharp.Test.ComputerUse\BotSharp.Test.ComputerUse.csproj", "{C19D9AC1-97DD-8E65-E8DB-D295A095AA2D}"
137135
EndProject
138136
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Plugin.OsDriver", "src\Plugins\BotSharp.Plugin.OsDriver\BotSharp.Plugin.OsDriver.csproj", "{B268E2F0-060F-8466-7D81-ABA4D735CA59}"
@@ -553,14 +551,6 @@ Global
553551
{8D2AD45F-836A-516F-DE6A-71443CEBB18A}.Release|Any CPU.Build.0 = Release|Any CPU
554552
{8D2AD45F-836A-516F-DE6A-71443CEBB18A}.Release|x64.ActiveCfg = Release|Any CPU
555553
{8D2AD45F-836A-516F-DE6A-71443CEBB18A}.Release|x64.Build.0 = Release|Any CPU
556-
{534D1DD5-9D62-115C-F230-47080D76CE52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
557-
{534D1DD5-9D62-115C-F230-47080D76CE52}.Debug|Any CPU.Build.0 = Debug|Any CPU
558-
{534D1DD5-9D62-115C-F230-47080D76CE52}.Debug|x64.ActiveCfg = Debug|Any CPU
559-
{534D1DD5-9D62-115C-F230-47080D76CE52}.Debug|x64.Build.0 = Debug|Any CPU
560-
{534D1DD5-9D62-115C-F230-47080D76CE52}.Release|Any CPU.ActiveCfg = Release|Any CPU
561-
{534D1DD5-9D62-115C-F230-47080D76CE52}.Release|Any CPU.Build.0 = Release|Any CPU
562-
{534D1DD5-9D62-115C-F230-47080D76CE52}.Release|x64.ActiveCfg = Release|Any CPU
563-
{534D1DD5-9D62-115C-F230-47080D76CE52}.Release|x64.Build.0 = Release|Any CPU
564554
{C19D9AC1-97DD-8E65-E8DB-D295A095AA2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
565555
{C19D9AC1-97DD-8E65-E8DB-D295A095AA2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
566556
{C19D9AC1-97DD-8E65-E8DB-D295A095AA2D}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -672,7 +662,6 @@ Global
672662
{AF329442-B48E-4B48-A18A-1C869D1BA6F5} = {D5293208-2BEF-42FC-A64C-5954F61720BA}
673663
{781F1465-365C-0F22-1775-25025DAFA4C7} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}
674664
{8D2AD45F-836A-516F-DE6A-71443CEBB18A} = {32FAFFFE-A4CB-4FEE-BF7C-84518BBC6DCC}
675-
{534D1DD5-9D62-115C-F230-47080D76CE52} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}
676665
{C19D9AC1-97DD-8E65-E8DB-D295A095AA2D} = {32FAFFFE-A4CB-4FEE-BF7C-84518BBC6DCC}
677666
{B268E2F0-060F-8466-7D81-ABA4D735CA59} = {51AFE054-AE99-497D-A593-69BAEFB5106F}
678667
{970BE341-9AC8-99A5-6572-E703C1E02FCB} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}

Directory.Packages.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@
114114
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
115115
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
116116
<PackageVersion Include="Shouldly" Version="4.3.0" />
117-
<PackageVersion Include="ModelContextProtocol" Version="0.1.0-preview.8" />
118-
<PackageVersion Include="ModelContextProtocol.AspNetCore" Version="0.1.0-preview.8" />
117+
<PackageVersion Include="ModelContextProtocol" Version="0.1.0-preview.11" />
118+
<PackageVersion Include="ModelContextProtocol.AspNetCore" Version="0.1.0-preview.11" />
119119
</ItemGroup>
120120
<ItemGroup>
121121
<PackageVersion Include="BotSharp.Core" Version="$(BotSharpVersion)" />

IFunctionExecutor.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace BotSharp.Core.Routing
8+
{
9+
public interface IFunctionExecutor
10+
{
11+
public Task<bool> Execute(RoleDialogModel message);
12+
13+
public Task<string> GetIndication(RoleDialogModel message);
14+
}
15+
}

src/Infrastructure/BotSharp.Core.MCP/BotSharp.Core.MCP.csproj

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/Infrastructure/BotSharp.Core.MCP/BotSharpMCPExtensions.cs

Lines changed: 0 additions & 67 deletions
This file was deleted.

src/Infrastructure/BotSharp.Core.MCP/Using.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@
221221
<PackageReference Include="Microsoft.Extensions.Http" />
222222
<PackageReference Include="Nanoid" />
223223
<PackageReference Include="Rougamo.Fody" />
224+
<PackageReference Include="ModelContextProtocol" />
224225
<PackageReference Include="System.ClientModel" />
225226
</ItemGroup>
226227

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using BotSharp.Core.MCP.Hooks;
2+
using BotSharp.Core.MCP.Managers;
3+
using BotSharp.Core.MCP.Services;
4+
using BotSharp.Core.MCP.Settings;
5+
using Microsoft.Extensions.Configuration;
6+
7+
namespace BotSharp.Core.MCP;
8+
9+
public static class BotSharpMcpExtensions
10+
{
11+
/// <summary>
12+
/// Add mcp
13+
/// </summary>
14+
/// <param name="services"></param>
15+
/// <param name="config"></param>
16+
/// <returns></returns>
17+
public static IServiceCollection AddBotSharpMCP(this IServiceCollection services, IConfiguration config)
18+
{
19+
var settings = config.GetSection("MCP").Get<McpSettings>();
20+
services.AddScoped(provider => settings);
21+
22+
if (settings != null && settings.Enabled && !settings.McpServerConfigs.IsNullOrEmpty())
23+
{
24+
services.AddScoped<IMcpService, McpService>();
25+
26+
var clientManager = new McpClientManager(settings);
27+
services.AddScoped(provider => clientManager);
28+
29+
// Register hooks
30+
services.AddScoped<IAgentHook, McpToolAgentHook>();
31+
}
32+
return services;
33+
}
34+
35+
}

src/Infrastructure/BotSharp.Core.MCP/Helpers/AiFunctionHelper.cs renamed to src/Infrastructure/BotSharp.Core/MCP/Helpers/AiFunctionHelper.cs

File renamed without changes.

src/Infrastructure/BotSharp.Core.MCP/Hooks/MCPToolAgentHook.cs renamed to src/Infrastructure/BotSharp.Core/MCP/Hooks/MCPToolAgentHook.cs

File renamed without changes.

0 commit comments

Comments
 (0)