Skip to content

Commit 832472f

Browse files
author
Jicheng Lu
committed
add mcp plugin and rename setting
1 parent e894130 commit 832472f

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static class BotSharpMcpExtensions
1818
/// <returns></returns>
1919
public static IServiceCollection AddBotSharpMCP(this IServiceCollection services, IConfiguration config)
2020
{
21-
var settings = config.GetSection("MCPSettings").Get<McpSettings>();
21+
var settings = config.GetSection("MCP").Get<McpSettings>();
2222
services.AddScoped<McpSettings>(provider => { return settings; });
2323
if (settings != null && !settings.McpServerConfigs.IsNullOrEmpty())
2424
{

src/Infrastructure/BotSharp.Core.MCP/Managers/McpClientManager.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@ namespace BotSharp.Core.MCP.Managers;
55

66
public class McpClientManager : IDisposable
77
{
8+
private readonly McpSettings _mcpSettings;
89

9-
private readonly McpSettings mcpSettings;
10-
11-
public McpClientManager(McpSettings settings)
10+
public McpClientManager(McpSettings mcpSettings)
1211
{
13-
mcpSettings = settings;
12+
_mcpSettings = mcpSettings;
1413
}
1514

1615
public async Task<IMcpClient> GetMcpClientAsync(string serverId)
1716
{
1817
return await McpClientFactory.CreateAsync(
19-
mcpSettings.McpServerConfigs.Where(x=> x.Name == serverId).First(),
20-
mcpSettings.McpClientOptions);
18+
_mcpSettings.McpServerConfigs.Where(x=> x.Name == serverId).First(),
19+
_mcpSettings.McpClientOptions);
2120
}
2221

2322
public void Dispose()
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using BotSharp.Abstraction.Plugins.Models;
2+
using BotSharp.Abstraction.Plugins;
3+
using BotSharp.Abstraction.Settings;
4+
using BotSharp.Core.MCP.Settings;
5+
using Microsoft.Extensions.Configuration;
6+
7+
namespace BotSharp.Core.MCP;
8+
9+
public class McpPlugin : IBotSharpPlugin
10+
{
11+
public string Id => "0cfb486a-229e-4470-a4c6-d2d4a5fdc727";
12+
public string Name => "Model context protocol";
13+
public string Description => "Model context protocol";
14+
15+
public SettingsMeta Settings =>
16+
new SettingsMeta("MCP");
17+
18+
public object GetNewSettingsInstance() =>
19+
new McpSettings();
20+
21+
public void RegisterDI(IServiceCollection services, IConfiguration config)
22+
{
23+
}
24+
25+
public bool AttachMenu(List<PluginMenuDef> menu)
26+
{
27+
return true;
28+
}
29+
}

src/WebStarter/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
}
173173
},
174174

175-
"MCPSettings": {
175+
"MCP": {
176176
"McpClientOptions": {
177177
"ClientInfo": {
178178
"Name": "SimpleToolsBotsharp",

0 commit comments

Comments
 (0)