Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 28, 2025

Description

Adds two new MCP tools to the CLI and introduces a new public API for resource agent content in Aspire.Hosting:

MCP Tools

  • list_integrations - Lists available Aspire hosting integrations (NuGet packages) from configured package channels, returns structured JSON with Integration schema containing short name, full package ID, and version. Description explains how to add integrations using aspire add <integration-name>.
  • get_resource_content - Gets agent content from a resource in the AppHost. Uses the auxiliary backchannel to invoke GetResourceAgentContentAsync RPC on the AppHost.

New Public API (Aspire.Hosting)

Introduces a new WithAgentContent API that allows resources to expose content to AI agents:

var postgres = builder.AddPostgres("pg")
    .WithAgentContent(async context =>
    {
        context.AppendLine("This is a PostgreSQL database used for user data.");
        context.AppendLine("Connection string format: Host=...;Database=...;Username=...;Password=...");
    });
  • AgentContentAnnotation - Annotation that stores a callback for generating agent content
  • AgentContentContext - Context with Resource, ServiceProvider, CancellationToken properties and AppendText()/AppendLine() methods for building content
  • WithAgentContent<T>() - Extension method on IResourceBuilder<T> using ResourceAnnotationMutationBehavior.Replace
  • All new public APIs marked with [Experimental("ASPIREAGENTCONTENT001")]

Changes

  • ListIntegrationsTool.cs - Uses IPackagingService to fetch packages, extracts friendly names, uses semantic versioning for correct ordering, returns structured JSON
  • GetResourceContentTool.cs - Uses auxiliary backchannel to invoke agent content callbacks on resources
  • AgentContentAnnotation.cs - New annotation and context types in Aspire.Hosting.ApplicationModel
  • ResourceBuilderExtensions.cs - Added WithAgentContent extension method
  • AuxiliaryBackchannelRpcTarget.cs - Added GetResourceAgentContentAsync RPC method
  • McpStartCommand.cs - Registers new tools
  • McpCommand.cs - Injects IPackagingService dependency
  • JsonSourceGenerationContext.cs - Added Integration and ListIntegrationsResponse types for AOT-compatible JSON serialization

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?
Original prompt

Add 2 new MCP tools to the CLI that does not talk to the app host.

  • A list_integrations tool that can list the integrations for the apphost
    -A get_aspire_docs tool that returns the content from https://aspire.dev/llms.txt

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add list_integrations and get_aspire_docs tools to CLI Add list_integrations and get_aspire_docs MCP tools to CLI Nov 28, 2025
Copilot AI requested a review from davidfowl November 28, 2025 07:46
Copilot finished work on behalf of davidfowl November 28, 2025 07:46

public override string Name => "get_aspire_docs";

public override string Description => "Get Aspire documentation content from aspire.dev/llms.txt. This provides a comprehensive overview of .NET Aspire documentation optimized for LLMs. This tool does not require a running AppHost.";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Aspire not .NET Aspire.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 66f7b8b - Changed ".NET Aspire" to "Aspire" in the description.


public override JsonElement GetInputSchema()
{
return JsonDocument.Parse("{ \"type\": \"object\", \"properties\": {} }").RootElement;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Introduce a schema for integrations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 66f7b8b - Added Integration class with name, packageId, and version properties, and ListIntegrationsResponse as the response schema.

{
return new CallToolResult
{
Content = [new TextContentBlock { Text = "No Aspire hosting integrations found." }]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't return text, return structured content (JSON).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 66f7b8b - Now returns structured JSON with the format {"integrations": [{"name": "Redis", "packageId": "Aspire.Hosting.Redis", "version": "9.0.0"}, ...]}

@davidfowl
Copy link
Member

@copilot Implement the PR feedback

Copy link
Contributor Author

Copilot AI commented Nov 28, 2025

@copilot Implement the PR feedback

Implemented in 66f7b8b - All feedback has been addressed.

Copilot finished work on behalf of davidfowl November 28, 2025 08:46
Copilot AI requested a review from davidfowl November 28, 2025 08:46
@davidfowl
Copy link
Member

@copilot Why does the schema from the ListIntegrationsTool and GetAspireDocsTool have no properties? For the ListIntegrationsTool we should respond with both names (long and short) and the description should describe how to add integrations to the apphost using the aspire cli.

Copy link
Contributor Author

Copilot AI commented Nov 28, 2025

@copilot Why does the schema from the ListIntegrationsTool and GetAspireDocsTool have no properties? For the ListIntegrationsTool we should respond with both names (long and short) and the description...

Fixed in 2c864f1 - The input schemas now include additionalProperties: false and more descriptive text explaining that no input is required and what the tool returns. The ListIntegrationsTool already returns both the short name (name like "Redis") and the full package ID (packageId like "Aspire.Hosting.Redis"). Updated the description to include aspire add <integration-name> usage instructions.

Copilot finished work on behalf of davidfowl November 28, 2025 08:56
@github-actions
Copy link
Contributor

github-actions bot commented Nov 28, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13231

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13231"

@mitchdenny
Copy link
Member

@copilot remove the GetAspireDocsTool from the CLI MCP server. instead I want you to introduce a new annotation called AgentContentAnnotation into the app model (put it in the Aspire.Hosting package.

Introduce an API that looks like this to the app model:

var myresource = builder.AddPostgres("pg")
  .WithAgentContent(async (context) => { });

The idea is that each resource can have a callback which is invoked to get text which can be returned to the agent. Introduce a new MCP tool called get_resource_content which uses the aux backchannel to invoke the callback on the AgentContentAnnotation within the app host.

The context instance will be a new type called AgentContentContext which exposes a model for appending text which is ultimately rendered to the client.

Copy link
Contributor Author

Copilot AI commented Dec 1, 2025

@copilot remove the GetAspireDocsTool from the CLI MCP server. instead I want you to introduce a new annotation called AgentContentAnnotation into the app model (put it in the Aspire.Hosting package...

Implemented in eeaf179:

  • Removed GetAspireDocsTool from the CLI MCP server
  • Added AgentContentAnnotation and AgentContentContext types in Aspire.Hosting.ApplicationModel
  • Added WithAgentContent<T>() extension method on IResourceBuilder<T>
  • Added get_resource_content MCP tool that uses the aux backchannel to invoke the callback
  • Added IServiceProvider to AgentContentContext
  • Marked all new public APIs with [Experimental("ASPIREAGENTCONTENT001")]

Copilot AI changed the title Add list_integrations and get_aspire_docs MCP tools to CLI Add list_integrations and get_resource_content MCP tools to CLI Dec 1, 2025
Copilot AI requested a review from mitchdenny December 1, 2025 04:52
Copilot finished work on behalf of mitchdenny December 1, 2025 04:52
@mitchdenny mitchdenny force-pushed the copilot/add-cli-tools-list-integrations-get-aspire-docs branch from 9ad1588 to 27515a1 Compare December 1, 2025 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants