AccsoDotnetRuntimeMcp 1.0.0
dotnet add package AccsoDotnetRuntimeMcp --version 1.0.0
NuGet\Install-Package AccsoDotnetRuntimeMcp -Version 1.0.0
<PackageReference Include="AccsoDotnetRuntimeMcp" Version="1.0.0" />
<PackageVersion Include="AccsoDotnetRuntimeMcp" Version="1.0.0" />
<PackageReference Include="AccsoDotnetRuntimeMcp" />
paket add AccsoDotnetRuntimeMcp --version 1.0.0
#r "nuget: AccsoDotnetRuntimeMcp, 1.0.0"
#:package AccsoDotnetRuntimeMcp@1.0.0
#addin nuget:?package=AccsoDotnetRuntimeMcp&version=1.0.0
#tool nuget:?package=AccsoDotnetRuntimeMcp&version=1.0.0
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 useMicrosoft.NET.Sdk.Web(i.e. be aWebApplication-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_queriesreturns 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/mcpendpoint 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 usersettings.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
- Open the Copilot Chat panel in VS Code (
Ctrl+Alt+I/⌃⌥I). - Click the mode selector at the bottom-left of the chat input and choose Agent.
- 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-runtimeis 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, orconnectionstring(case-insensitive) are filtered out before any data is returned to a client. - Restrict network access to the
/mcpendpoint in production environments — treat it like any other internal diagnostic endpoint.
License
| Product | Versions 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. |
-
net10.0
- Microsoft.EntityFrameworkCore (>= 10.0.11)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.11)
- ModelContextProtocol.AspNetCore (>= 1.4.1)
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 |