75 lines
2.1 KiB
C#
75 lines
2.1 KiB
C#
using xIdentityHelper;
|
|
using System.Threading;
|
|
using xCommons.Providers;
|
|
using Newtonsoft.Json.Linq;
|
|
using xAiService.Interfaces;
|
|
using System.Threading.Tasks;
|
|
using xAiService.Controllers;
|
|
using xCommons.Configurations;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using xIdentityService.Interfaces;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
namespace xAiMcpServer.Controllers
|
|
{
|
|
[Authorize]
|
|
public class McpController : XAiMcpControllerBase
|
|
{
|
|
public McpController(
|
|
IXAiMcpHandler mcpHandler,
|
|
ILogger<McpController> logger,
|
|
XAppConfiguration appConfiguration,
|
|
IXIdentityProvider identityProvider,
|
|
XValidationProvider validationProvider
|
|
) : base(mcpHandler, appConfiguration, identityProvider, logger, validationProvider)
|
|
{ }
|
|
|
|
//
|
|
#region Override ...
|
|
/// <summary>
|
|
/// Handle MCP ...
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Authorize(Policy = XPolicies.EnabledUser)]
|
|
public override async Task<IActionResult> HandleMcp(
|
|
[FromBody] JObject request,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var userInfo = await GetUserInfo();
|
|
var connectionId = GetConnectionId();
|
|
|
|
//
|
|
var result = await base
|
|
.HandleMcp(
|
|
request: request,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Handle SSE EndPoint ...
|
|
/// </summary>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("sse")]
|
|
[AllowAnonymous]
|
|
public override async Task SseEndpoint(
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
await base
|
|
.SseEndpoint(cancellationToken);
|
|
}
|
|
#endregion
|
|
}
|
|
} |