File tree Expand file tree Collapse file tree 9 files changed +107
-3
lines changed
ViewModels/Agents/Request Expand file tree Collapse file tree 9 files changed +107
-3
lines changed Original file line number Diff line number Diff line change 1+ namespace BotSharp . Abstraction . MCP . Models ;
2+
3+ public class McpServerConfigModel
4+ {
5+ /// <summary>
6+ /// Unique identifier for this server configuration.
7+ /// </summary>
8+ public string Id { get ; set ; } = null ! ;
9+
10+ /// <summary>
11+ /// Display name for the server.
12+ /// </summary>
13+ public string Name { get ; set ; } = null ! ;
14+
15+ /// <summary>
16+ /// The type of transport to use.
17+ /// </summary>
18+ [ JsonPropertyName ( "transport_type" ) ]
19+ public string TransportType { get ; set ; } = null ! ;
20+
21+ /// <summary>
22+ /// For stdio transport: path to the executable
23+ /// For HTTP transport: base URL of the server
24+ /// </summary>
25+ public string ? Location { get ; set ; }
26+
27+ /// <summary>
28+ /// Arguments (if any) to pass to the executable.
29+ /// </summary>
30+ public string [ ] ? Arguments { get ; set ; }
31+
32+ /// <summary>
33+ /// Additional transport-specific configuration.
34+ /// </summary>
35+ [ JsonPropertyName ( "transport_options" ) ]
36+ [ JsonIgnore ( Condition = JsonIgnoreCondition . WhenWritingNull ) ]
37+ public Dictionary < string , string > ? TransportOptions { get ; set ; }
38+ }
Original file line number Diff line number Diff line change 1+ namespace BotSharp . Abstraction . MCP . Services ;
2+
3+ public interface IMcpService
4+ {
5+ IEnumerable < McpServerConfigModel > GetServerConfigs ( ) => [ ] ;
6+ }
Original file line number Diff line number Diff line change 1818global using BotSharp . Abstraction . Files . Models ;
1919global using BotSharp . Abstraction . Files . Enums ;
2020global using BotSharp . Abstraction . Knowledges . Models ;
21- global using BotSharp . Abstraction . Crontab . Models ;
21+ global using BotSharp . Abstraction . Crontab . Models ;
22+ global using BotSharp . Abstraction . MCP . Models ;
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ public static IServiceCollection AddBotSharpMCP(this IServiceCollection services
2020 {
2121 var settings = config . GetSection ( "MCP" ) . Get < McpSettings > ( ) ;
2222 services . AddScoped ( provider => { return settings ; } ) ;
23+
2324 if ( settings != null && settings . Enabled && ! settings . McpServerConfigs . IsNullOrEmpty ( ) )
2425 {
2526 var clientManager = new McpClientManager ( settings ) ;
Original file line number Diff line number Diff line change 1+ using Microsoft . Extensions . Configuration ;
12using BotSharp . Abstraction . Plugins . Models ;
23using BotSharp . Abstraction . Plugins ;
34using BotSharp . Abstraction . Settings ;
45using BotSharp . Core . MCP . Settings ;
5- using Microsoft . Extensions . Configuration ;
6+ using BotSharp . Core . MCP . Services ;
67
78namespace BotSharp . Core . MCP ;
89
@@ -20,6 +21,7 @@ public object GetNewSettingsInstance() =>
2021
2122 public void RegisterDI ( IServiceCollection services , IConfiguration config )
2223 {
24+ services . AddScoped < IMcpService , McpService > ( ) ;
2325 }
2426
2527 public bool AttachMenu ( List < PluginMenuDef > menu )
Original file line number Diff line number Diff line change 1+ using BotSharp . Core . MCP . Settings ;
2+ using Microsoft . Extensions . Logging ;
3+
4+ namespace BotSharp . Core . MCP . Services ;
5+
6+ public class McpService : IMcpService
7+ {
8+ private readonly IServiceProvider _services ;
9+ private readonly ILogger < McpService > _logger ;
10+
11+ public McpService (
12+ IServiceProvider services ,
13+ ILogger < McpService > logger )
14+ {
15+ _services = services ;
16+ _logger = logger ;
17+ }
18+
19+ public IEnumerable < McpServerConfigModel > GetServerConfigs ( )
20+ {
21+ var settings = _services . GetRequiredService < McpSettings > ( ) ;
22+ var configs = settings ? . McpServerConfigs ?? [ ] ;
23+ return configs . Select ( x => new McpServerConfigModel
24+ {
25+ Id = x . Id ,
26+ Name = x . Name ,
27+ TransportType = x . TransportType ,
28+ TransportOptions = x . TransportOptions ,
29+ Arguments = x . Arguments ,
30+ Location = x . Location
31+ } ) ;
32+ }
33+ }
Original file line number Diff line number Diff line change 1313global using BotSharp . Abstraction . Functions ;
1414global using BotSharp . Abstraction . Functions . Models ;
1515global using BotSharp . Abstraction . Utilities ;
16+ global using BotSharp . Abstraction . MCP . Models ;
17+ global using BotSharp . Abstraction . MCP . Services ;
1618
Original file line number Diff line number Diff line change 1+ using BotSharp . Abstraction . MCP . Models ;
2+ using BotSharp . Abstraction . MCP . Services ;
3+
4+ namespace BotSharp . OpenAPI . Controllers ;
5+
6+ public class McpController : ControllerBase
7+ {
8+ private readonly IServiceProvider _services ;
9+
10+ public McpController ( IServiceProvider services )
11+ {
12+ _services = services ;
13+ }
14+
15+ [ HttpGet ( "/mcp/server-configs" ) ]
16+ public IEnumerable < McpServerConfigModel > GetMcpServerConfigs ( )
17+ {
18+ var mcp = _services . GetRequiredService < IMcpService > ( ) ;
19+ return mcp . GetServerConfigs ( ) ;
20+ }
21+ }
Original file line number Diff line number Diff line change 11using BotSharp . Abstraction . Agents . Models ;
22using BotSharp . Abstraction . Functions . Models ;
3- using BotSharp . Abstraction . Routing . Models ;
43using System . Text . Json . Serialization ;
54
65namespace BotSharp . OpenAPI . ViewModels . Agents ;
@@ -42,6 +41,7 @@ public class AgentUpdateModel
4241 /// <summary>
4342 /// McpTools
4443 /// </summary>
44+ [ JsonPropertyName ( "mcp_tools" ) ]
4545 public List < McpTool > ? McpTools { get ; set ; }
4646
4747 /// <summary>
You can’t perform that action at this time.
0 commit comments