mirror of https://github.com/abpframework/abp.git
Browse Source
Extracted AbpMcpServerTool to its own file and improved tool name validation in McpHttpClientService. Enhanced error handling and logging, made cache validity configurable, and fixed typos in ActivityNameConsts for AbpCli command telemetry constants.pull/24677/head
5 changed files with 104 additions and 72 deletions
@ -0,0 +1,43 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text.Json; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using ModelContextProtocol.Protocol; |
|||
using ModelContextProtocol.Server; |
|||
|
|||
namespace Volo.Abp.Cli.Commands.Services; |
|||
|
|||
internal class AbpMcpServerTool : McpServerTool |
|||
{ |
|||
private readonly string _name; |
|||
private readonly string _description; |
|||
private readonly JsonElement _inputSchema; |
|||
private readonly Func<RequestContext<CallToolRequestParams>, CancellationToken, ValueTask<CallToolResult>> _handler; |
|||
|
|||
public AbpMcpServerTool( |
|||
string name, |
|||
string description, |
|||
JsonElement inputSchema, |
|||
Func<RequestContext<CallToolRequestParams>, CancellationToken, ValueTask<CallToolResult>> handler) |
|||
{ |
|||
_name = name; |
|||
_description = description; |
|||
_inputSchema = inputSchema; |
|||
_handler = handler; |
|||
} |
|||
|
|||
public override Tool ProtocolTool => new Tool |
|||
{ |
|||
Name = _name, |
|||
Description = _description, |
|||
InputSchema = _inputSchema |
|||
}; |
|||
|
|||
public override IReadOnlyList<object> Metadata => Array.Empty<object>(); |
|||
|
|||
public override ValueTask<CallToolResult> InvokeAsync(RequestContext<CallToolRequestParams> context, CancellationToken cancellationToken) |
|||
{ |
|||
return _handler(context, cancellationToken); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue