NamespaceToolLoader: the tool loader that supports namespace mode without creating child azmcp processes#704
Merged
anuchandy merged 8 commits intomicrosoft:mainfrom Oct 7, 2025
Conversation
Member
Author
|
/azp run mcp - pullrequest - live |
|
Azure Pipelines successfully started running 1 pipeline(s). |
…creating child azmcp processes
c5dad6f to
ef1a683
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new NamespaceToolLoader that enables direct in-process command execution for Azure namespace tools, eliminating the need for child azmcp processes in namespace mode. This approach significantly reduces memory usage (80-140 MB per namespace), improves performance, and maintains the same hierarchical tool structure and learn mode behavior.
- Memory optimization: Eliminates child process overhead through direct in-process command execution
- Performance improvement: Replaces cross-process stdio communication with direct method calls
- Architecture enhancement: Maintains existing client experience while improving scalability
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 11 comments.
| File | Description |
|---|---|
NamespaceToolLoader.cs |
New tool loader implementing direct in-process Azure command execution with hierarchical namespace support and learn mode |
NamespaceToolLoaderTests.cs |
Comprehensive unit tests covering tool loading, command execution, caching, thread safety, and error handling scenarios |
ServiceCollectionExtensions.cs |
Updated dependency injection configuration to use NamespaceToolLoader in namespace mode and simplified discovery strategy registration |
alzimmermsft
reviewed
Oct 6, 2025
…common logic extraction later)
2f16aad to
96de765
Compare
Member
Author
|
/azp run mcp - pullrequest - live |
|
Azure Pipelines successfully started running 1 pipeline(s). |
joshfree
approved these changes
Oct 7, 2025
alzimmermsft
approved these changes
Oct 7, 2025
Member
Author
|
/azp run mcp - pullrequest - live |
|
Azure Pipelines successfully started running 1 pipeline(s). |
alzimmermsft
approved these changes
Oct 7, 2025
Member
|
@anuchandy please add the missing changelog entry retroactively |
colbytimm
pushed a commit
to colbytimm/microsoft-mcp
that referenced
this pull request
Dec 8, 2025
…hout creating child azmcp processes (microsoft#704) * NamespaceToolLoader: the tool loader that supports namespace without creating child azmcp processes * Remove ConvertToJsonElements and rely on the guarantees provided by mcp-libs. * Using JsonSerializer.SerializeToElement for tests * Simplify CreateNamespaceTool * Align NamespaceToolLoader logic closer to ServerToolLoader (enabling common logic extraction later) * align command exclusion behavior with ServerToolLoader * simplify methods (remove unnecessary async attributes) * adjust tests to adapt exclusion behavior
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.
What does this PR do?
Today, when we start
azmcpin default mode (which is equivalent to--mode namespace, the default mode for VS Code as well), the server creates a newazmcpprocess for every command group (child namespace name) and uses a stdio channel to invoke commands.Below is the output of all azmcp processes after I used the "Azure MCP Server" (via VS Code extension) in Copilot and tried a few tool calls. Each
azmcpprocess uses approximately 80-140 MB of memory.server/azmcp server start --mode namespaceserver/azmcp server start --mode all --namespace subscriptionserver/azmcp server start --mode all --namespace marketplaceserver/azmcp server start --mode all --namespace storageserver/azmcp server start --mode all --namespace cosmosserver/azmcp server start --mode all --namespace aksserver/azmcp server start --mode all --namespace acrserver/azmcp server start --mode all --namespace postgresserver/azmcp server start --mode all --namespace groupserver/azmcp server start --mode all --namespace keyvaultserver/azmcp server start --mode all --namespace kustoserver/azmcp server start --mode all --namespace appserviceThis PR introduces direct in-process command execution via the new
NamespaceToolLoader, eliminating all childazmcpprocess spawning in namespace mode. This new tool loader executes Azure namespace commands directly in-process viaCommandFactory.GroupCommands()Benefits
Follow-up work item, another pr: Apply a similar concept to the less frequently used
--mode single, which collapses everything under a singleazuretool.GitHub issue number?
[Link to the GitHub issue this PR addresses]Pre-merge Checklist
servers/Azure.Mcp.Server/CHANGELOG.mdand/orservers/Fabric.Mcp.Server/CHANGELOG.mdfor product changes (features, bug fixes, UI/UX, updated dependencies)servers/Azure.Mcp.Server/README.mdand/orservers/Fabric.Mcp.Server/README.mddocumentation/docs/azmcp-commands.mdand/or/docs/fabric-commands.mdToolDescriptionEvaluatorand obtained a score of0.4or more and a top 3 ranking for all related test prompts/docs/e2eTestPrompts.mdcrypto mining, spam, data exfiltration, etc.)/azp run mcp - pullrequest - liveto run Live Test Pipeline