Conversation
- Inject ICommunicationService via constructor in SmsSendCommand and EmailSendCommand - Remove context.GetService<ICommunicationService>() from ExecuteAsync - Update SmsSendCommandTests to use shared fields and constructor injection - Update EmailSendCommandTests to pass service via constructor - Add changelog entry Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
…in SmsSendCommandTests Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor Azure.Mcp.Tools.Communication for dependency injection
refactor(communication): constructor DI for SmsSendCommand and EmailSendCommand
Mar 3, 2026
conniey
reviewed
Mar 10, 2026
Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
conniey
approved these changes
Mar 10, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the Communication tool’s send commands to use constructor-based dependency injection for ICommunicationService, improving testability and reducing reliance on CommandContext service resolution.
Changes:
- Updated
SmsSendCommandandEmailSendCommandto receiveICommunicationServicevia constructor injection and removedcontext.GetService<T>()usage. - Updated unit tests to construct commands with injected mocks rather than relying on DI resolution during execution.
- Added an Azure.Mcp.Server changelog entry for the refactor (PR #1913).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.Communication/src/Commands/Sms/SmsSendCommand.cs | Injects ICommunicationService via constructor and uses it directly in ExecuteAsync. |
| tools/Azure.Mcp.Tools.Communication/src/Commands/Email/EmailSendCommand.cs | Injects ICommunicationService via constructor and uses it directly in ExecuteAsync. |
| tools/Azure.Mcp.Tools.Communication/tests/Azure.Mcp.Tools.Communication.UnitTests/Sms/SmsSendCommandTests.cs | Updates tests to pass mocked service via constructor and reuse shared fields. |
| tools/Azure.Mcp.Tools.Communication/tests/Azure.Mcp.Tools.Communication.UnitTests/Email/EmailSendCommandTests.cs | Updates tests to pass mocked service via constructor injection. |
| servers/Azure.Mcp.Server/changelog-entries/1772567575847.yaml | Adds changelog entry describing the DI refactor. |
| global.json | Changes pinned .NET SDK version (flagged in review comment). |
Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
conniey
approved these changes
Mar 10, 2026
KarishmaGhiya
approved these changes
Mar 13, 2026
colbytimm
pushed a commit
to colbytimm/microsoft-mcp
that referenced
this pull request
Apr 20, 2026
…endCommand (microsoft#1913) * Initial plan * refactor: DI refactor for Azure.Mcp.Tools.Communication commands - Inject ICommunicationService via constructor in SmsSendCommand and EmailSendCommand - Remove context.GetService<ICommunicationService>() from ExecuteAsync - Update SmsSendCommandTests to use shared fields and constructor injection - Update EmailSendCommandTests to pass service via constructor - Add changelog entry Co-authored-by: conniey <10136526+conniey@users.noreply.github.com> * chore: remove accidentally committed global.json.bak Co-authored-by: conniey <10136526+conniey@users.noreply.github.com> * refactor: address code review - remove unused _serviceProvider field in SmsSendCommandTests Co-authored-by: conniey <10136526+conniey@users.noreply.github.com> * chore: remove accidentally committed global.json.bak Co-authored-by: conniey <10136526+conniey@users.noreply.github.com> * chore: add PR number to changelog entry Co-authored-by: conniey <10136526+conniey@users.noreply.github.com> * revert: restore global.json SDK version to 10.0.103 Co-authored-by: conniey <10136526+conniey@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ICommunicationServicevia constructor inSmsSendCommandandEmailSendCommandcontext.GetService<ICommunicationService>()fromExecuteAsyncSmsSendCommandTeststo use shared fields and constructor injectionEmailSendCommandTeststo pass service via constructorOriginal prompt
💡 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.