-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathMcpContext.cs
More file actions
46 lines (39 loc) · 1.09 KB
/
McpContext.cs
File metadata and controls
46 lines (39 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using MaIN.Domain.Configuration;
using MaIN.Domain.Entities;
using MaIN.Services.Constants;
using MaIN.Services.Services.Abstract;
using MaIN.Services.Services.Models;
namespace MaIN.Core.Hub.Contexts;
public sealed class McpContext
{
private readonly IMcpService _mcpService;
private Mcp? _mcpConfig;
internal McpContext(IMcpService mcpService)
{
_mcpService = mcpService;
_mcpConfig = Mcp.NotSet;
}
public McpContext WithConfig(Mcp mcpConfig)
{
_mcpConfig = mcpConfig;
return this;
}
public McpContext WithBackend(BackendType backendType)
{
_mcpConfig!.Backend = backendType;
return this;
}
public async Task<McpResult> PromptAsync(string prompt)
{
if (_mcpConfig == null)
{
throw new InvalidOperationException("MCP config not found");
}
return await _mcpService.Prompt(_mcpConfig!, [new Message()
{
Content = prompt,
Role = ServiceConstants.Roles.User,
Type = MessageType.CloudLLM
}]);
}
}