AccsoDotnetRuntimeMcp 1.0.0

dotnet add package AccsoDotnetRuntimeMcp --version 1.0.0
                    
NuGet\Install-Package AccsoDotnetRuntimeMcp -Version 1.0.0
                    
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="AccsoDotnetRuntimeMcp" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AccsoDotnetRuntimeMcp" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AccsoDotnetRuntimeMcp" />
                    
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 AccsoDotnetRuntimeMcp --version 1.0.0
                    
#r "nuget: AccsoDotnetRuntimeMcp, 1.0.0"
                    
#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 AccsoDotnetRuntimeMcp@1.0.0
                    
#: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=AccsoDotnetRuntimeMcp&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=AccsoDotnetRuntimeMcp&version=1.0.0
                    
Install as a Cake Tool

AccsoDotnetRuntimeMcp

A .NET library that adds an MCP (Model Context Protocol) server to ASP.NET Core web applications, exposing live runtime information — such as the effective application configuration, service registrations, runtime metrics (CPU, memory, GC, and thread data), application logs, and Entity Framework Core query history — to MCP-compatible clients like AI assistants and developer tools.

Requirements: This library uses the HTTP/SSE transport from ModelContextProtocol.AspNetCore, which depends on the ASP.NET Core middleware pipeline. Your project must use Microsoft.NET.Sdk.Web (i.e. be a WebApplication-based host). Plain console applications or Generic Host processes without ASP.NET Core are not supported.

What it does

Once registered, the library provides the following MCP tools to any connected client:

Tool Description
get_configuration Returns the current effective application configuration as a flat JSON key/value map. Sensitive keys (containing password, secret, key, token, or connectionstring) and null-valued entries are automatically excluded.
get_runtime_metrics Returns current CPU/memory usage and GC stats for the application.
get_services Returns the current effective service collection as a JSON key/value map from service types to their implementations.
get_logs Returns the recent application logs as a list of log entries. Each log entry contains a timestamp, log level, message, and category.
get_ef_core_queries Returns the recent Entity Framework Core queries executed by the application as a JSON array of query entries.

Installation

dotnet add package AccsoDotnetRuntimeMcp

Usage

Call AddRuntimeMcp() on your service collection and map the MCP endpoint after Build(). Both calls require an ASP.NET Core (WebApplication) host.

Additional setup is required if you want to use the Entity Framework Core query history tool — see Enabling the EF Core query history tool below.

// Program.cs
using AccsoDotnetRuntimeMcp;

var builder = WebApplication.CreateBuilder(args);

// 1. Register the MCP server and tools
builder.Services.AddRuntimeMcp();

// 1b. Optional: Add the interceptor to all your application's DbContexts to support the get_ef_core_queries tool 
builder.Services.AddDbContext<ApplicationDbContext>((serviceProvider, options) =>
{
    // ... other setup here

    // Add the interceptor to allow capturing queries
    options.AddRuntimeMcpInterceptor(serviceProvider);
});

var app = builder.Build();

// 2. Map the MCP HTTP endpoint
app.MapMcp("/mcp");

app.Run();

The MCP server is now available at http://localhost:<port>/mcp using HTTP/SSE transport.

Enabling the EF Core query history tool

The get_ef_core_queries tool is only populated once you register the RuntimeMcp interceptor on your DbContext. Call AddRuntimeMcpInterceptor(serviceProvider) when configuring each DbContext you want to capture queries from:

builder.Services.AddDbContext<ApplicationDbContext>((serviceProvider, options) =>
{
    // ... your existing configuration (provider, connection string, etc.)

    // Capture executed queries for the get_ef_core_queries tool
    options.AddRuntimeMcpInterceptor(serviceProvider);
});

The overload that receives the IServiceProvider (via the AddDbContext callback) is required so the interceptor can be resolved from DI. Repeat the AddRuntimeMcpInterceptor call for every DbContext you want to observe. Without this step the tool returns an empty list.

Security warning: The interceptor captures each executed command including its parameter values, and get_ef_core_queries returns them verbatim to connected MCP clients. These values can contain credentials, personal data, or other sensitive information. Enable this tool only when the MCP endpoint is exposed to trusted clients (see Security), and avoid enabling it in production or against databases holding sensitive data unless access to the /mcp endpoint is tightly restricted.

Connecting an MCP Client

GitHub Copilot in VS Code

1. Register the server

Create a .vscode/mcp.json file in your workspace (commit it to source control so the whole team shares it):

{
  "servers": {
    "my-app-runtime": {
      "type": "http",
      "url": "http://localhost:<port>/mcp"
    }
  }
}

Tip: You can also register the server globally by adding the same entry under "mcp" → "servers" in your VS Code user settings.json.

2. Start your application

Make sure your application is running and listening on the port you configured above before proceeding.

3. Enable Agent mode in Copilot Chat
  1. Open the Copilot Chat panel in VS Code (Ctrl+Alt+I / ⌃⌥I).
  2. Click the mode selector at the bottom-left of the chat input and choose Agent.
  3. Click the tools icon (looks like a plug/wrench) next to the input box. Your registered MCP servers are listed there — make sure my-app-runtime is enabled (checkbox checked).
4. Use the tool

With Agent mode active and the server enabled, just ask naturally:

"What is the current application configuration?" "Which environment is the app running in?" "What logging level is configured?"

Copilot will automatically invoke the get_configuration tool against your running application and present the results inline in the conversation.

Other MCP-compatible clients

Point the client at http://localhost:<port>/mcp (HTTP/SSE transport). Refer to your client's documentation for the exact configuration format.

Security

  • Sensitive values are never exposed. Configuration keys whose names contain password, secret, key, token, or connectionstring (case-insensitive) are filtered out before any data is returned to a client.
  • Restrict network access to the /mcp endpoint in production environments — treat it like any other internal diagnostic endpoint.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos 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.0.0 95 9/11/2026