Skip to content
Docs Try Aspire

Aspire MCP server

The Aspire MCP server gives AI coding agents direct runtime access to your running Aspire application. Through the Model Context Protocol (MCP), agents can query resource status, read logs, inspect distributed traces, and execute commands — without you copy-pasting terminal output.

The MCP server is configured automatically when you run aspire agent init and select Install Aspire MCP server.

To set up your project for AI coding agents, see Use AI coding agents.

The aspire agent init command creates MCP server configuration files for your detected AI environment:

Creates or updates .vscode/mcp.json:

.vscode/mcp.json
{
"servers": {
"aspire": {
"type": "stdio",
"command": "aspire",
"args": [
"agent",
"mcp"
]
}
}
}

The Aspire MCP server provides the following tools to AI agents:

ToolDescription
list_resourcesLists all resources, including state, health status, source, endpoints, and commands
list_console_logsLists console logs for a resource
list_structured_logsLists structured logs, optionally filtered by resource name
list_tracesLists distributed traces, optionally filtered by resource name
list_trace_structured_logsLists structured logs for a specific trace
execute_resource_commandExecutes a resource command (start, stop, restart)
list_apphostsLists detected AppHost connections and their scope
select_apphostSelects which AppHost to use when multiple are running
list_integrationsLists available Aspire hosting integration packages
get_integration_docsGets documentation for a specific integration package
list_docsLists all available documentation pages from aspire.dev
search_docsSearches aspire.dev documentation using keyword-based search
get_docRetrieves the full content of a documentation page by slug
doctorDiagnoses Aspire environment issues and verifies setup
refresh_toolsRequests the server to re-emit its tool list for clients to re-fetch

By default, all resources, console logs, and telemetry are accessible through the MCP server. You can exclude specific resources and their associated telemetry by annotating them with ExcludeFromMcp():

AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var apiservice = builder.AddProject<Projects.AspireApp_ApiService>("apiservice")
.ExcludeFromMcp();
builder.AddProject<Projects.AspireApp_Web>("webfrontend")
.WithExternalHttpEndpoints()
.WithReference(apiservice);
builder.Build().Run();

The Aspire MCP server is a development-time tool designed for local use.

The MCP server uses the STDIO transport protocol when started via aspire agent mcp:

  • The MCP server runs as a local child process spawned by your AI assistant.
  • Communication happens over standard input/output (STDIO) pipes.
  • There are no open network ports — the server doesn’t listen on any network interface.
  • Only the parent process (your AI assistant) can communicate with the MCP server.

The MCP server provides access to:

  • Resource metadata — names, types, states, health status, endpoints, and commands
  • Console logs — standard output and error streams
  • Structured logs — log entries via OpenTelemetry
  • Distributed traces — request flow across resources
  • Integration catalog — available hosting integration packages
  • Product documentation — Official LLMS.txt-based aspire.dev content

The MCP server does not expose:

  • Source code or file system contents
  • Environment variable values or secrets
  • Network traffic or raw request/response payloads
  • Access to the host machine beyond the Aspire AppHost process

With STDIO transport (the default), no additional authentication is required — communication is restricted to the local process pipe.

For the HTTP-based MCP endpoint exposed by the Aspire dashboard (used in manual MCP configuration for older Aspire versions), an API key (x-mcp-api-key header) is required.

For teams evaluating the Aspire MCP server:

  • Development-time only — not included in published or deployed applications
  • No external network access — no network listeners when using STDIO transport
  • Data stays local — telemetry remains on the developer’s machine. Data shared with AI assistants is governed by the assistant’s own data policies
  • Granular access control — use ExcludeFromMcp() to restrict sensitive resources
  • No persistent storage — all data is in memory for the session duration
  • Open specification — implements the Model Context Protocol specification

The MCP server is part of the Aspire CLI tooling and runs separately from your AppHost — it doesn’t require explicit exclusion from deployments.

If your AppHost includes dev-only resources, use ExecutionContext.IsRunMode to exclude them from production:

AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var api = builder.AddProject<Projects.Api>("api");
if (builder.ExecutionContext.IsRunMode)
{
// Only available during local development
builder.AddContainer("dev-tool", "some-dev-image");
}
builder.Build().Run();

AI models have limits on how much data they can process. The Aspire MCP server may limit data returned from tools:

  • Large data fields (e.g., long stack traces) may be truncated
  • Large collections of telemetry may be shortened by omitting older items

If you run into issues, check the open MCP issues on GitHub.

The MCP server automatically detects running AppHosts within the working directory scope:

  • It continuously monitors for AppHost changes — no restart needed
  • Use list_apphosts to see detected AppHosts
  • Use select_apphost to switch between multiple running AppHosts
  1. Verify the Aspire CLI is installed:

    Aspire CLI
    aspire --version
  2. Confirm your AppHost is running:

    Aspire CLI
    aspire start
  3. Test the MCP server directly:

    Aspire CLI
    aspire agent mcp

    If it starts without errors, the issue is in your AI assistant’s configuration.

  4. Regenerate configuration:

    Aspire CLI
    aspire agent init
  • Ensure .mcp.json exists in your project root — run aspire agent init to regenerate
  • On Windows, commands like npx require a cmd.exe /c prefix
  • Restart Claude Code to re-establish stale MCP connections