Skip to content

Conversation

anannya03
Copy link
Contributor

@anannya03 anannya03 commented Sep 8, 2025

What does this PR do?

This PR introduces a new tool azmcp-eventgrid-subscription-list that allows users to list all Event Grid subscripts within a given subscription/topic. It's also possible to filter based on resource group and location.

“List all Event Grid subscriptions in my subscription”

GitHub issue number?

#299

Pre-merge Checklist

  • Required for All PRs
    • Read contribution guidelines
    • PR title clearly describes the change
    • Commit history is clean with descriptive messages (cleanup guide)
    • Added comprehensive tests for new/modified functionality
    • Updated CHANGELOG.md for product changes (features, bug fixes, UI/UX, updated dependencies)
    • Spelling check passes: .\eng\common\spelling\Invoke-Cspell.ps1
  • For MCP tool changes:
    • One tool per PR: This PR adds or modifies only one MCP tool for faster review cycles
    • Updated README.md documentation
    • Updated command list in /docs/azmcp-commands.md
    • Updated test prompts in /docs/e2eTestPrompts.md
    • [] For new or modified tool descriptions, ran ToolDescriptionEvaluator and obtained a score of 0.4 or more and a top 3 ranking for all related test prompts
  • 👉 For Community (non-Azure team member) PRs:
    • Security review: Reviewed code for security vulnerabilities, malicious code, or suspicious activities before running tests (crypto mining, spam, data exfiltration, etc.)
    • Manual tests run: added comment /azp run azure - mcp to run Live Test Pipeline

@anannya03 anannya03 force-pushed the list-event-subscription branch from 222acc9 to f7160c8 Compare September 9, 2025 14:19
@anannya03 anannya03 marked this pull request as ready for review September 10, 2025 03:27
@Copilot Copilot AI review requested due to automatic review settings September 10, 2025 03:27
@anannya03 anannya03 requested a review from a team as a code owner September 10, 2025 03:27
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new EventGrid subscription listing tool to the Azure MCP Server, enabling users to discover and filter Event Grid subscriptions across their Azure resources.

  • Adds azmcp_eventgrid_subscription_list command with comprehensive filtering capabilities
  • Implements subscription retrieval from both custom topics and system topics
  • Provides detailed subscription information including endpoints, filters, and retry policies

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
SubscriptionListCommandTests.cs New unit test file with comprehensive test coverage for subscription listing scenarios
SubscriptionListCommand.cs New command implementation for listing Event Grid subscriptions with filtering options
EventGridService.cs Extended service with subscription retrieval logic for custom and system topics
IEventGridService.cs Added interface method for subscription operations
EventGridSubscriptionInfo.cs New model representing Event Grid subscription data
SubscriptionListOptions.cs New options class for subscription list command parameters
EventGridOptionDefinitions.cs Added topic name and location option definitions
Various documentation files Updated with new command information and examples

@anannya03 anannya03 force-pushed the list-event-subscription branch from 627226d to f44b964 Compare September 10, 2025 14:08
command.Validators.Clear();

// Custom validation: Either --topic or --subscription (or env var) is required
command.Validators.Add(commandResult =>
Copy link
Contributor

Choose a reason for hiding this comment

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

We have similar parsing in other places in this code. Let's figure out a way to refactor this so we don't have AZURE_SUBSCRIPTION_ID parsing in multiple places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found that SubscriptionCommand.cs(Core) and SubscriptionListCommand.cs(EventGrid) was using this method parsing. I created a helper method in SubscriptionCommand.cs, and called that in both the places.

I also saw that we were calling
var originalValue = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID"); and
Environment.SetEnvironmentVariable("AZURE_SUBSCRIPTION_ID", "env-subs");
in a few of our test file.

So, I created a getter/setter method in EnvironmentVariableHelpers.cs to set/get the Azure Subscription ID, and called this get/set method in the rest of our code.

@github-project-automation github-project-automation bot moved this from Untriaged to In Progress in Azure MCP Server Sep 15, 2025
@anannya03 anannya03 force-pushed the list-event-subscription branch from bff5307 to 76083a0 Compare September 16, 2025 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

5 participants