Commit 51b54165 authored by shrabbit's avatar shrabbit
Browse files

feat(RequestTools): 新增 InfiniteWait 无限等待工具,通过独立子进程实现并注册到 MCP 服务

parent c513ac51
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
<Solution>
  <Project Path="src/McpBase.McpServer/McpBase.McpServer.csproj" />
  <Project Path="src/McpBase.Request/McpBase.Request.csproj" />
  <Project Path="src/McpBase.Shared/McpBase.Shared.csproj" />
</Solution>
+10 −0
Original line number Diff line number Diff line
@@ -40,4 +40,14 @@
        <PackageReference Include="shRabbit.Base" Version="1.12.1" />
    </ItemGroup>

    <ItemGroup>
      <ProjectReference Include="..\McpBase.Request\McpBase.Request.csproj" />
      <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>
+2 −0
Original line number Diff line number Diff line
using System.Reflection;
using McpBase.McpServer.Tools;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@@ -19,6 +20,7 @@ builder.Services
    .WithStdioServerTransport()
    .WithTools<RandomNumberTools>()
    .WithTools<NetworkTools>()
    .WithTools<RequestTools>()
    .WithTools<ProcessState>();

await builder.Build().RunAsync();
 No newline at end of file
+29 −0
Original line number Diff line number Diff line
using System.ComponentModel;
using System.Diagnostics;
using McpBase.Shared;
using ModelContextProtocol.Server;

namespace McpBase.McpServer.Tools;

public class RequestTools
{
    [McpServerTool, Description("进行无限等待。由用户决定是否结束。")]
    public async Task InfiniteWait([Description("message")]string? msg)
    {
        var self = Process.GetCurrentProcess().Id;
        var psi = new ProcessStartInfo(Path.Join(AppDomain.CurrentDomain.BaseDirectory, "McpBase.Request.exe"))
        {
            ArgumentList =
            {
                SendInfWaitTransport.GetTransportString(new SendInfWaitTransport
                {
                    Pid = self,
                    Message = msg ?? string.Empty
                })
            },
            UseShellExecute = true
        };
        
        await Process.Start(psi)?.WaitForExitAsync()!;
    }
}
 No newline at end of file
+18 −0
Original line number Diff line number Diff line
<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net10.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
        <InvariantGlobalization>true</InvariantGlobalization>
        <RuntimeIdentifiers>win-x64;win-arm64;osx-arm64;linux-x64;linux-arm64;linux-musl-x64</RuntimeIdentifiers>
        <SelfContained>true</SelfContained>
        <PublishSelfContained>true</PublishSelfContained>
    </PropertyGroup>

    <ItemGroup>
      <ProjectReference Include="..\McpBase.Shared\McpBase.Shared.csproj" />
    </ItemGroup>

</Project>
Loading