InitialForce.SnoopAgent.BrokerHost 1.1.1

Prefix Reserved
dotnet add package InitialForce.SnoopAgent.BrokerHost --version 1.1.1
                    
NuGet\Install-Package InitialForce.SnoopAgent.BrokerHost -Version 1.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="InitialForce.SnoopAgent.BrokerHost" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="InitialForce.SnoopAgent.BrokerHost" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="InitialForce.SnoopAgent.BrokerHost" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add InitialForce.SnoopAgent.BrokerHost --version 1.1.1
                    
#r "nuget: InitialForce.SnoopAgent.BrokerHost, 1.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package InitialForce.SnoopAgent.BrokerHost@1.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=InitialForce.SnoopAgent.BrokerHost&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=InitialForce.SnoopAgent.BrokerHost&version=1.1.1
                    
Install as a Cake Tool

SnoopWPF.Agent.BrokerHost

Brokered-mode host library for SnoopWPF Agent. Provides the MCP broker infrastructure consumed by external host processes to communicate with injected WPF agents over a named pipe.

Requires .NET 8.0+.

When to Use

Use SnoopWPF.Agent.BrokerHost when you need to separate the MCP stdio anchor (the broker process) from the WPF target process. This is ideal for:

  • Testing frameworks that spawn fresh WPF app instances per test scenario
  • Third-party app inspection (injection mode via snoop-mcp.exe)
  • Host applications that must survive WPF target crashes/restarts

For simple co-located embedding (agent inside your own WPF app), use SnoopWPF.Agent instead.

Quick Start

using SnoopWPF.Agent.BrokerHost;
using ModelContextProtocol.Protocol;
using ModelContextProtocol.Server;
using System.Security.Cryptography;

// 1. Generate pipe name + token.
string pipeName = "my-app-" + Guid.NewGuid().ToString("N")[..8];
string tokenHex = Convert.ToHexString(RandomNumberGenerator.GetBytes(32));

// 2. FIRST statement: silence stdout. Broker owns MCP stdio.
Console.SetOut(TextWriter.Null);

// 3. Spawn the target process with the named pipe.
//    BrokerTargetSpawner writes BrokerHandshakePayload to the child's stdin automatically.
var process = BrokerTargetSpawner.Spawn(
    exe: @"C:\path\to\MyApp.exe",
    args: Array.Empty<string>(),
    pipeName: pipeName,
    tokenHex: tokenHex);

// 4. Run the MCP broker server on stdio.
using var cts = new CancellationTokenSource();
var opts = new BrokerOptions
{
    PipeName = pipeName,
    SessionToken = tokenHex,
    OnTargetDisconnected = () => cts.Cancel(),
};

var serverOptions = new McpServerOptions
{
    ServerInfo = new Implementation { Name = "my-broker", Version = "1.0.0" },
};
await using var transport = new StdioServerTransport(serverOptions);
await BrokerHost.Start(transport, opts, cts.Token);

Architecture

MCP client (Claude Code / Claude Desktop)
        | stdio
        v
 [Broker process]  <--named pipe-->  [Target WPF process]
 SnoopWPF.Agent.BrokerHost              SnoopAgent.StartBrokered()

Documentation

Product Compatible and additional computed target framework versions.
.NET net8.0-windows10.0.19041 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.1 54 6/9/2026