feat: Add x-ms-agentid header for MCP platform calls#196
Merged
pontemonti merged 1 commit intomainfrom Feb 5, 2026
Merged
Conversation
Port from Node.js SDK PR #183 - adds x-ms-agentid header to all outbound HTTP requests to the MCP platform for agent identification. Header priority: 1. Agent Blueprint ID from TurnContext (agenticAppBlueprintId) 2. Agent Blueprint ID from token (xms_par_app_azp claim) 3. Entra Application ID from token (appid or azp claim) 4. Application name from entry assembly Changes: - Add GetAgentIdFromToken() and GetApplicationName() to Runtime Utility - Add AgentIdHeader constant to Tooling Constants - Update HttpContextHeadersHandler to add x-ms-agentid header - Pass authToken to HttpContextHeadersHandler for header resolution - Add InternalsVisibleTo for test access - Add comprehensive unit tests for new methods - Add PRD documentation
rahuldevikar761
approved these changes
Feb 5, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds the x-ms-agentid header to all outbound HTTP requests to the MCP platform for agent identification, porting functionality from the Node.js SDK (PR #183). The header enables the MCP platform to identify calling agents for logging, diagnostics, and usage analytics.
Changes:
- Added utility methods in Runtime package to extract agent identifiers from JWT tokens and application assembly
- Updated HttpContextHeadersHandler to inject the x-ms-agentid header with priority-based fallback logic
- Added comprehensive unit tests for token parsing with 11 test cases covering all priority paths
- Created PRD documentation describing the technical design and implementation strategy
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Tooling/Core/docs/prd-x-ms-agentid-header.md | PRD documentation detailing the technical design, priority logic, and implementation approach for the x-ms-agentid header feature |
| src/Tooling/Core/Utils/Constants.cs | Added AgentIdHeader constant for the x-ms-agentid header name |
| src/Tooling/Core/Services/McpToolServerConfigurationService.cs | Updated to pass authToken to HttpContextHeadersHandler constructor |
| src/Tooling/Core/Microsoft.Agents.A365.Tooling.csproj | Added InternalsVisibleTo attribute for test project access |
| src/Tooling/Core/Handlers/HttpContextHeadersHandler.cs | Implemented header injection logic with priority fallback: TurnContext blueprint ID > token claims > application name |
| src/Tests/Runtime.Tests/UtilityTests.cs | Added 11 unit tests for GetAgentIdFromToken() covering all claim priority paths and edge cases, plus test for GetApplicationName() |
| src/Runtime/Core/Utility.cs | Added GetAgentIdFromToken() method to extract agent ID from JWT with claim priority, and GetApplicationName() to get entry assembly name |
mrunalhirve128
approved these changes
Feb 5, 2026
pontemonti
pushed a commit
that referenced
this pull request
Feb 5, 2026
Add comprehensive guide for porting features from Node.js SDK to .NET SDK, including workflow steps, language translation patterns, and checklist template. Based on the experience porting x-ms-agentid header (PR #196).
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.
Overview
Port of Node.js SDK PR #183 - adds x-ms-agentid header to all outbound HTTP requests to the MCP platform for agent identification.
Related PR: microsoft/Agent365-nodejs#183
Problem Statement
The MCP platform needs to identify which agent is making tooling requests for:
Solution
Add the x-ms-agentid header to outbound requests with the following priority:
agenticAppBlueprintId)xms_par_app_azpclaim)appidorazpclaim)Changes
Runtime Package
GetAgentIdFromToken()- extracts agent ID from JWT with priority fallbackGetApplicationName()- returns entry assembly nameTooling Package
AgentIdHeaderconstant (x-ms-agentid)HttpContextHeadersHandlerto add the header when authToken is availableHttpContextHeadersHandlerconstructorInternalsVisibleTofor test accessTests
GetAgentIdFromToken()covering all priority pathsGetApplicationName()Documentation
Testing
Breaking Changes
None - this is a backward-compatible addition.