Aspire MCP Server Integration
This skill enables AI agents to interact with .NET Aspire distributed applications through the Model Context Protocol (MCP) server. Use this skill to monitor resources, debug issues, analyze distributed traces, and manage your Aspire AppHost applications.
Purpose
The Aspire MCP server provides programmatic access to:
- •All running resources (services, containers, executables, databases)
- •Console and structured logs for debugging
- •Distributed traces for performance analysis
- •Resource health status and endpoints
- •Available Aspire hosting integrations
- •AppHost management and resource commands
When to Use This Skill
Use this skill when you need to:
- •Check the health status of all Aspire resources
- •Debug startup errors or runtime failures
- •Analyze distributed tracing data across services
- •Monitor console logs from specific resources
- •Execute commands on running resources
- •Discover available Aspire integrations
- •Work with multiple AppHosts in a workspace
Available MCP Tools
Resource Management
list_resources
Lists all resources including their state, health status, source, endpoints, and commands.
Use cases:
- •Check if all services are running
- •Verify resource health before running tests
- •Get endpoint URLs for API testing
- •Check which commands are available for each resource
Example queries:
- •"Are all my Aspire resources healthy?"
- •"What endpoints are available for the API service?"
- •"Show me the status of all containers"
execute_resource_command
Executes a command on a specific resource.
Parameters:
- •
resource_name: Name of the resource (e.g., "menlo-api", "postgres") - •
command_name: Command to execute (e.g., "Restart", "Stop", "Start")
Use cases:
- •Restart unhealthy services
- •Stop containers for maintenance
- •Execute custom resource commands
Example queries:
- •"Restart the menlo-api service"
- •"Stop the postgres container"
Logging and Debugging
list_console_logs
Retrieves console output logs for a specific resource.
Parameters:
- •
resource_name: Name of the resource to get logs from
Use cases:
- •Read startup errors and stack traces
- •Debug application crashes
- •Monitor console output from services
- •Check database initialization logs
Example queries:
- •"Show me the console logs for menlo-api"
- •"What errors are in the postgres logs?"
- •"Check the last 50 lines of console output for the frontend"
list_structured_logs
Gathers structured logs with optional filtering by resource name.
Parameters:
- •
resource_name(optional): Filter logs by specific resource
Use cases:
- •Search for specific error messages
- •Filter logs by severity level
- •Analyze application behavior
- •Track request flow through services
Example queries:
- •"Show me all error-level structured logs"
- •"Find logs containing 'authentication failed'"
- •"What structured logs does menlo-api have?"
list_traces
Fetches distributed traces; can filter using an optional resource name.
Parameters:
- •
resource_name(optional): Filter traces by resource
Use cases:
- •Analyze request performance across services
- •Identify slow database queries
- •Debug cross-service communication issues
- •Track request flow through the system
Example queries:
- •"Show me the slowest traces in the last 5 minutes"
- •"Analyze HTTP request performance for menlo-api"
- •"What traces involve the postgres database?"
list_trace_structured_logs
Extracts structured logs associated with a particular trace.
Parameters:
- •
trace_id: The trace ID to get logs for
Use cases:
- •Correlate logs with specific requests
- •Debug failed requests end-to-end
- •Understand what happened during a slow request
Example queries:
- •"Show me all logs for trace ID abc123"
- •"What logs are associated with this slow request?"
Integration Discovery
list_integrations
Lists all available Aspire hosting integrations with their package IDs and versions.
Use cases:
- •Discover what integrations are available
- •Check package versions for integrations
- •Find the right integration for a new dependency
Example queries:
- •"What Aspire integrations are available for Redis?"
- •"List all database integrations"
- •"What version of the PostgreSQL integration is available?"
get_integration_docs
Retrieves documentation for specific Aspire hosting integration packages.
Parameters:
- •
package_id: The NuGet package ID of the integration
Use cases:
- •Learn how to configure an integration
- •Check what options are available
- •Get code examples for integration setup
Example queries:
- •"Show me the documentation for Aspire.Hosting.PostgreSQL"
- •"How do I configure the Redis integration?"
- •"What are the options for the Ollama integration?"
AppHost Management
list_apphosts
Shows all available AppHosts in the workspace.
Use cases:
- •Work with monorepo containing multiple Aspire apps
- •Switch between different application configurations
- •Manage multiple environments (dev, staging, etc.)
Example queries:
- •"What AppHosts are available?"
- •"List all Aspire applications in this workspace"
select_apphost
Designates a specific AppHost as the active working context.
Parameters:
- •
apphost_name: Name of the AppHost to select
Use cases:
- •Switch between multiple Aspire applications
- •Focus on a specific application context
- •Isolate operations to one AppHost
Example queries:
- •"Switch to the Menlo.AppHost"
- •"Make the staging AppHost active"
Setup Instructions
Prerequisites
- •.NET Aspire 13 or later installed
- •Aspire CLI installed (
dotnet tool install -g aspire) - •An Aspire AppHost project in your solution
Configuration Steps
Option 1: Automatic Configuration (Recommended)
Run the Aspire CLI command in your project directory:
cd /path/to/your/aspire/project aspire mcp init
This automatically detects Claude Code and creates .mcp.json configuration.
Option 2: Manual Configuration
Create .mcp.json in your project root:
{
"mcpServers": {
"aspire": {
"command": "aspire",
"args": ["mcp", "start"],
"transport": "stdio"
}
}
}
Verification
After configuration, restart Claude Code and verify:
- •Ask: "Are all my Aspire resources running?"
- •Ask: "Show me the console logs for [your-service-name]"
- •Ask: "List available Aspire integrations"
If the MCP server is configured correctly, you should get responses with actual resource data.
Best Practices
1. Resource Monitoring Workflow
When starting a development session:
- •Check resource health: "Are all my Aspire resources healthy?"
- •Review any unhealthy services: "Show console logs for [unhealthy-service]"
- •Restart if needed: "Restart [service-name]"
- •Verify: "Check the status of [service-name]"
2. Debugging Workflow
When encountering errors:
- •Check recent logs: "Show me console logs for [failing-service]"
- •Look for structured errors: "Show error-level structured logs for [service]"
- •Analyze traces: "Show me recent traces involving [service]"
- •Correlate: "Show structured logs for trace [trace-id]"
- •Fix and restart: "Restart [service]"
3. Performance Analysis Workflow
When optimizing performance:
- •Get slow traces: "Show me the slowest traces in the last 10 minutes"
- •Analyze trace details: "Show structured logs for trace [trace-id]"
- •Check resource involvement: "What resources are involved in this trace?"
- •Identify bottlenecks: "Which service has the highest latency?"
4. Integration Discovery Workflow
When adding new dependencies:
- •Search for integration: "What Aspire integrations are available for [technology]?"
- •Get documentation: "Show me the docs for [integration-package-id]"
- •Check version: "What version of [integration] is available?"
- •Follow docs to add integration to AppHost
Common Use Cases
Use Case 1: Debugging Startup Failures
Scenario: Your API service won't start.
Workflow:
- •"List all resources and their status"
- •"Show console logs for menlo-api" (find startup error)
- •"Show structured logs for menlo-api" (get detailed error info)
- •Fix the code
- •"Restart menlo-api"
- •"Verify menlo-api is healthy"
Use Case 2: Analyzing Slow Requests
Scenario: API responses are slow.
Workflow:
- •"Show me the slowest traces for menlo-api"
- •"Show structured logs for trace [slow-trace-id]"
- •"What database queries are in this trace?"
- •"Show postgres console logs" (check for slow queries)
- •Optimize query
- •"Compare trace performance before and after"
Use Case 3: Adding a New Integration
Scenario: You want to add Redis caching.
Workflow:
- •"What Aspire integrations are available for Redis?"
- •"Show documentation for Aspire.Hosting.Redis"
- •Follow docs to add to AppHost
- •"List resources" (verify Redis appears)
- •"Show Redis console logs" (verify startup)
Use Case 4: Multi-Service Debugging
Scenario: Request fails across multiple services.
Workflow:
- •"Show traces where status code is 500"
- •"Show structured logs for trace [failed-trace-id]"
- •"What resources are involved in this trace?"
- •"Show console logs for each involved service"
- •Identify root cause
- •"Restart affected services"
Resource Exclusion
To exclude sensitive resources from MCP access, use .ExcludeFromMcp() in your AppHost:
var secretsDb = builder.AddPostgres("secrets-db")
.ExcludeFromMcp(); // Not visible to AI agents
This is useful for:
- •Production databases
- •Secrets managers
- •Sensitive configuration services
- •Resources with destructive commands
Integration with Other Skills
This skill works well with:
- •mcp-builder: Build custom MCP servers to extend Aspire
- •webapp-testing: Use Aspire MCP to verify services before running tests
- •doc-coauthoring: Document your AppHost configuration and resource dependencies
Troubleshooting
MCP Server Not Responding
- •Check Aspire CLI is installed:
aspire --version - •Verify AppHost is running:
dotnet run --project src/api/Menlo.AppHost - •Check
.mcp.jsonis in project root - •Restart Claude Code
No Resources Listed
- •Verify AppHost is running
- •Check you're in the correct AppHost context: "List available AppHosts"
- •Switch if needed: "Select [apphost-name]"
- •Try: "List resources" again
Cannot Execute Commands
- •Check resource supports the command: "List resources" (shows available commands)
- •Verify resource name is correct (case-sensitive)
- •Check resource state (some commands only work in specific states)
Logs Not Available
- •Resources must be running to have logs
- •Some resources may not emit console logs (check structured logs instead)
- •Logs may be filtered by timestamp (request recent logs specifically)
Limitations
- •MCP server requires Aspire 13 or later
- •Resources must be running to access logs and traces
- •Trace retention is limited (typically last 15-30 minutes of activity)
- •Some resource commands may require elevated permissions
- •MCP server runs locally (no remote AppHost access)
References
- •Aspire MCP Server Documentation
- •Configure the MCP Server
- •Scaling AI Agents with Aspire
- •Model Context Protocol Specification
Examples
Example 1: Complete Debugging Session
User: "My API isn't responding"
Agent (using aspire-mcp skill):
- •
Calls list_resources Result: menlo-api state is "Failed"
- •
Calls list_console_logs for menlo-api Result: "System.InvalidOperationException: Database connection failed"
- •
Calls list_resources again Result: postgres state is "Running" but health is "Unhealthy"
- •
Calls list_console_logs for postgres Result: "ERROR: max connections reached"
Agent response: "Your API failed because the PostgreSQL database reached max connections. Restart postgres to clear connections, then restart menlo-api."
User: "Restart both services"
Agent: 5. Calls execute_resource_command(resource_name: "postgres", command_name: "Restart") 6. Calls execute_resource_command(resource_name: "menlo-api", command_name: "Restart") 7. Calls list_resources to verify Result: Both services now "Running" and "Healthy"
Agent response: "Both services restarted successfully and are now healthy."
Example 2: Performance Investigation
User: "Why are API requests slow?"
Agent (using aspire-mcp skill):
- •
Calls list_traces(resource_name: "menlo-api") Result: Shows traces with latencies from 50ms to 2500ms
- •
Calls list_trace_structured_logs for slowest trace Result: Shows database query took 2.3 seconds
- •
Calls list_structured_logs(resource_name: "postgres") Result: Shows query: "SELECT * FROM budgets JOIN transactions..." (no indexes)
Agent response: "Your slow requests are caused by an unindexed database query. The query 'SELECT * FROM budgets JOIN transactions...' takes 2.3 seconds. Consider adding indexes on the join columns."
Notes
- •This skill is specific to .NET Aspire projects with MCP server configured
- •Always verify AppHost is running before using MCP tools
- •Resource names are case-sensitive and must match AppHost configuration
- •Trace data is ephemeral (typically retained for 15-30 minutes)
- •For production environments, use .ExcludeFromMcp() on sensitive resources