Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
changes:
- section: "Breaking Changes"
description: "Removed unused parameters from App Lens tools."
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
// Licensed under the MIT License.

using Azure.Mcp.Tools.AppLens.Models;
using Azure.Mcp.Tools.AppLens.Options;
using Azure.Mcp.Tools.AppLens.Options.Resource;
using Azure.Mcp.Tools.AppLens.Services;
using Microsoft.Extensions.Logging;
using Microsoft.Mcp.Core.Commands;
using Microsoft.Mcp.Core.Extensions;
using Microsoft.Mcp.Core.Models.Command;

namespace Azure.Mcp.Tools.AppLens.Commands.Resource;
Expand All @@ -29,43 +27,15 @@ namespace Azure.Mcp.Tools.AppLens.Commands.Resource;
Secret = false,
LocalRequired = false)]
public sealed class ResourceDiagnoseCommand(ILogger<ResourceDiagnoseCommand> logger, IAppLensService appLensService)
: GlobalCommand<ResourceDiagnoseOptions>
: BaseCommand<ResourceDiagnoseOptions, ResourceDiagnoseCommandResult>
{
Comment on lines 29 to 31
private readonly ILogger<ResourceDiagnoseCommand> _logger = logger;
private readonly IAppLensService _appLensService = appLensService;

protected override void RegisterOptions(Command command)
{
base.RegisterOptions(command);
command.Options.Add(AppLensOptionDefinitions.Subscription);
command.Options.Add(AppLensOptionDefinitions.ResourceGroup);
command.Options.Add(AppLensOptionDefinitions.ResourceType);
command.Options.Add(AppLensOptionDefinitions.Resource);
command.Options.Add(AppLensOptionDefinitions.Question);
}

protected override ResourceDiagnoseOptions BindOptions(ParseResult parseResult)
{
var options = base.BindOptions(parseResult);
options.Subscription = parseResult.GetValueOrDefault<string>(AppLensOptionDefinitions.Subscription.Name);
options.ResourceGroup = parseResult.GetValueOrDefault<string>(AppLensOptionDefinitions.ResourceGroup.Name);
options.Question = parseResult.GetValueOrDefault<string>(AppLensOptionDefinitions.Question.Name) ?? string.Empty;
options.Resource = parseResult.GetValueOrDefault<string>(AppLensOptionDefinitions.Resource.Name) ?? string.Empty;
options.ResourceType = parseResult.GetValueOrDefault<string>(AppLensOptionDefinitions.ResourceType.Name);
return options;
}

public override async Task<CommandResponse> ExecuteAsync(CommandContext context, ParseResult parseResult, CancellationToken cancellationToken)
public override async Task<CommandResponse> ExecuteAsync(CommandContext context, ResourceDiagnoseOptions options, CancellationToken cancellationToken)
{
try
{
if (!Validate(parseResult.CommandResult, context.Response).IsValid)
{
return context.Response;
}

ResourceDiagnoseOptions options = BindOptions(parseResult);

_logger.LogInformation("Diagnosing resource. Question: {Question}, Resource: {Resource}, Options: {Options}",
options.Question, options.Resource, options);

Expand Down
5 changes: 0 additions & 5 deletions tools/Azure.Mcp.Tools.AppLens/src/GlobalUsings.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Text.Json;
using System.Text.Json.Serialization;

namespace Azure.Mcp.Tools.AppLens.Models;
Expand Down
2 changes: 2 additions & 0 deletions tools/Azure.Mcp.Tools.AppLens/src/Models/AppLensModels.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Text.Json;

namespace Azure.Mcp.Tools.AppLens.Models;

/// <summary>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Azure.Mcp.Core.Options;
using Microsoft.Mcp.Core.Options;

namespace Azure.Mcp.Tools.AppLens.Options.Resource;

/// <summary>
/// Options for the AppLens resource diagnose command.
/// </summary>
public class ResourceDiagnoseOptions : GlobalOptions
public sealed class ResourceDiagnoseOptions
{
[Option(OptionDescriptions.Tenant)]
public string? Tenant { get; set; }

[Option("Azure resource group name. Provide this when disambiguating between multiple resources of the same name.")]
public string? ResourceGroup { get; set; }

/// <summary>
/// The user's question for diagnosis.
/// </summary>
public string Question { get; set; } = string.Empty;
[Option("User question")]
public required string Question { get; set; }

/// <summary>
/// The name of the resource to diagnose.
/// </summary>
public string Resource { get; set; } = string.Empty;
[Option("The name of the resource to investigate or diagnose")]
public required string Resource { get; set; }

/// <summary>
/// The Resource Type of the resource to diagnose. This is optional and used to disambiguate between multiple resources with the same name.
/// </summary>
[Option("Resource type. Provide this when disambiguating between multiple resources of the same name.")]
public string? ResourceType { get; set; }

/// <summary>
/// The subscription of the resource to diagnose. This is optional and used to disambiguate between multiple resources with the same name.
/// </summary>
[Option("Azure subscription ID or name. Provide this when disambiguating between multiple resources of the same name.")]
public string? Subscription { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.IdentityModel.Tokens.Jwt;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.Json;
using System.Threading.Channels;
using Azure.Core;
using Azure.Mcp.Core.Services.Azure;
Expand Down