1. Conduid
  2. Science
  3. MyRegistry.Mcp.AspNetCore.MultiHost
MCP server · Science

MyRegistry.Mcp.AspNetCore.MultiHost

Host multiple MCP (Model Context Protocol) servers with distinct tool sets and configurations in a single ASP.NET Core application.

Unclaimed science
34Low

Scored 6 months ago · breakdown

About MyRegistry.Mcp.AspNetCore.MultiHost

MyRegistry.Mcp.AspNetCore.MultiHost is an MCP server in the Science category: host multiple MCP (Model Context Protocol) servers with distinct tool sets and configurations in a single ASP.NET Core application.

Install

From source
git clone https://github.com/relusion/Mcp.AspNetCore.MultiHost

This server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.

Ask AI

✦

Ask AI about MyRegistry.Mcp.AspNetCore.MultiHost

Powered by Claude · Grounded in docs

I know everything about MyRegistry.Mcp.AspNetCore.MultiHost. Ask me about installation, configuration, usage, or troubleshooting.

Security checks

  • ✓README presentThe repository ships documentation.

5 checks have not been run yet.

README

Mcp.AspNetCore.MultiHost

Host multiple MCP (Model Context Protocol) servers with distinct tool sets and configurations in a single ASP.NET Core application.

Features

  • Multiple MCP Hosts: Run multiple isolated MCP servers in a single application
  • Per-Host DI Containers: Each host has its own isolated dependency injection container
  • Service Bridging: Share services from the main application with MCP hosts
  • Flexible Configuration: Configure each host independently with different tools, prompts, and resources
  • Discovery Endpoint: Optional endpoint to list all available MCP hosts
  • Security Helpers: Origin validation for cross-origin protection

Installation

dotnet add package Mcp.AspNetCore.MultiHost

Quick Start

var builder = WebApplication.CreateBuilder(args);

// Register MCP hosts
builder.Services.AddMcpMultiHost(options =>
{
    options.AddHost("admin", host =>
    {
        host.WithRoutePrefix("/mcp/admin")
            .ConfigureMcpServer(mcp => mcp
                .WithHttpTransport()
                .WithTools<AdminTools>());
    });

    options.AddHost("user", host =>
    {
        host.WithRoutePrefix("/mcp/user")
            .ConfigureMcpServer(mcp => mcp
                .WithHttpTransport()
                .WithTools<UserTools>());
    });
});

var app = builder.Build();

// Map all MCP hosts
app.MapMcpMultiHost();

app.Run();

Configuration

Host Configuration

Each host is configured using the fluent builder API:

options.AddHost("myhost", host =>
{
    // Required: Set the route prefix
    host.WithRoutePrefix("/mcp/myhost");

    // Required: Configure MCP server
    host.ConfigureMcpServer(mcp => mcp
        .WithHttpTransport()
        .WithTools<MyTools>()
        .WithPrompts<MyPrompts>());

    // Optional: Add host-specific services
    host.ConfigureHostServices(services =>
    {
        services.AddSingleton<MyHostService>();
    });

    // Optional: Configure endpoint conventions
    host.ConfigureEndpoints(endpoints =>
    {
        endpoints.RequireAuthorization("AdminPolicy");
    });

    // Optional: Custom service bridging
    host.BridgeServices(bridge =>
    {
        bridge.ForwardAspNetCoreDefaults();
        bridge.ForwardSingleton<IMySharedService>();
    });
});

Discovery Endpoint

Enable a discovery endpoint to list all available MCP hosts:

app.MapMcpMultiHost(options =>
{
    options.MapDiscoveryEndpoint = true;
    options.DiscoveryEndpointPath = "/mcp/_hosts"; // default
});

Response format:

{
  "hosts": [
    { "name": "admin", "routePrefix": "/mcp/admin" },
    { "name": "user", "routePrefix": "/mcp/user" }
  ]
}

Service Bridging

By default, the following ASP.NET Core services are automatically bridged to each host:

  • ILoggerFactory (with ILogger<T> support)
  • IConfiguration
  • IHostEnvironment
  • IHostApplicationLifetime
  • IHttpContextAccessor (if registered)

Custom Bridging

Override the default bridging behavior:

host.BridgeServices(bridge =>
{
    // Include ASP.NET Core defaults
    bridge.ForwardAspNetCoreDefaults();

    // Forward additional singletons
    bridge.ForwardSingleton<IMyService>();

    // Forward with factory
    bridge.Forward<IMyService>(sp => sp.GetRequiredService<IMyService>());
});

Security

Origin Validation

Protect MCP endpoints from unauthorized cross-origin requests:

host.ConfigureEndpoints(endpoints =>
{
    endpoints.RequireSameOriginOrAllowed("https://trusted.example.com");
});

This filter:

  • Allows requests without Origin header (non-browser clients)
  • Allows same-origin requests
  • Allows explicitly listed origins
  • Blocks all other cross-origin requests with 403 Forbidden

Authorization

Apply ASP.NET Core authorization to MCP endpoints:

host.ConfigureEndpoints(endpoints =>
{
    endpoints.RequireAuthorization("MyPolicy");
});

Accessing the Registry

Inject IMcpHostRegistry to access registered hosts at runtime:

app.MapGet("/admin/hosts", (IMcpHostRegistry registry) =>
{
    return registry.Hosts.Select(h => new { h.Name, h.RoutePrefix });
});

Requirements

  • .NET 8.0 or later
  • ModelContextProtocol.AspNetCore 0.8.0-preview.1 or later

Architecture

Each MCP host runs in isolation with its own:

  • DI container
  • Service registrations
  • Tool definitions
  • Prompt templates

Services can be shared from the main application through bridging, but each host maintains its own instances of host-specific services.

                    Main Application
                           |
            +--------------+--------------+
            |              |              |
        [Host A]       [Host B]       [Host C]
         /mcp/a         /mcp/b         /mcp/c
            |              |              |
        Tools A        Tools B        Tools C

License

MIT

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

README copy captured when this server was indexed; it may lag the repository. The original is authoritative.

Questions

About MyRegistry.Mcp.AspNetCore.MultiHost

How do I install MyRegistry.Mcp.AspNetCore.MultiHost?

No package has been published for this server, so install it from source: clone the repository and follow its README.

Is MyRegistry.Mcp.AspNetCore.MultiHost safe to use with an AI agent?

Its trust score is 34 out of 100 (low). It passes 1 of the 1 static security checks run so far. It has no ConduID identity yet, so agent calls to it are not receipted.

Is MyRegistry.Mcp.AspNetCore.MultiHost still maintained?

Conduid hasn't recorded a commit date for this repository yet. Check the repository directly for recent activity.