Commit 3355bc75 authored by shrabbit's avatar shrabbit
Browse files

feat(RequestTools): InfiniteWait 返回等待耗时秒数,并简化 Transport 序列化及清理项目冗余配置

parent 51b54165
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -45,9 +45,4 @@
      <ProjectReference Include="..\McpBase.Shared\McpBase.Shared.csproj" />
    </ItemGroup>

    <!-- McpBase.Request 输出文件路径与项目路径 -->
    <PropertyGroup>
      <McpBaseRequestProjectPath>$(MSBuildThisFileDirectory)..\McpBase.Request\McpBase.Request.csproj</McpBaseRequestProjectPath>
      <McpBaseRequestOutputPath>$(MSBuildThisFileDirectory)..\McpBase.Request\bin\$(Configuration)\$(TargetFramework)\</McpBaseRequestOutputPath>
    </PropertyGroup>
</Project>
+7 −3
Original line number Diff line number Diff line
using System.ComponentModel;
using System.ComponentModel;
using System.Diagnostics;
using McpBase.Shared;
using ModelContextProtocol.Server;
@@ -7,9 +7,10 @@ namespace McpBase.McpServer.Tools;

public class RequestTools
{
    [McpServerTool, Description("进行无限等待。由用户决定是否结束。")]
    public async Task InfiniteWait([Description("message")]string? msg)
    [McpServerTool, Description("进行无限等待。由用户决定是否结束。返回从请求等待到同意继续之间的耗时(秒)。")]
    public async Task<string> InfiniteWait([Description("message")]string? msg)
    {
        var sw = Stopwatch.StartNew();
        var self = Process.GetCurrentProcess().Id;
        var psi = new ProcessStartInfo(Path.Join(AppDomain.CurrentDomain.BaseDirectory, "McpBase.Request.exe"))
        {
@@ -25,5 +26,8 @@ public class RequestTools
        };
        
        await Process.Start(psi)?.WaitForExitAsync()!;
        sw.Stop();

        return sw.Elapsed.TotalSeconds.ToString("f3");
    }
}
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <OutputType>Exe</OutputType>
+0 −10
Original line number Diff line number Diff line
@@ -7,16 +7,6 @@ class Program
{
    static void Main(string[] args)
    {
        try
        {
            Console.WriteLine(args[0]);
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
        }
        Console.ReadLine();
        
        if (args.Length < 1)
            return;
        
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ public class Transport<TSelf> : Transport

    public static string GetTransportString(Transport<TSelf> instance)
    {
        var json = JsonSerializer.Serialize<Transport<TSelf>>(instance);
        var json = JsonSerializer.Serialize(instance);
        return json;
    }