diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Tools/HostedMcpServerTool.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Tools/HostedMcpServerTool.cs
index aa33a581710..f50d66be48f 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Tools/HostedMcpServerTool.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Tools/HostedMcpServerTool.cs
@@ -99,4 +99,9 @@ private static string ValidateUrl(Uri serverUrl)
///
///
public HostedMcpServerToolApprovalMode? ApprovalMode { get; set; }
+
+ ///
+ /// Gets or sets additional headers to include in requests to the remote MCP server.
+ ///
+ public IDictionary? Headers { get; set; }
}
diff --git a/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs b/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
index b37c475508a..01c859860a4 100644
--- a/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
@@ -551,12 +551,12 @@ void IDisposable.Dispose()
mcpTool.ServerName,
url,
mcpTool.AuthorizationToken,
- mcpTool.ServerDescription) :
+ mcpTool.ServerDescription, mcpTool.Headers) :
ResponseTool.CreateMcpTool(
mcpTool.ServerName,
new McpToolConnectorId(mcpTool.ServerAddress),
mcpTool.AuthorizationToken,
- mcpTool.ServerDescription);
+ mcpTool.ServerDescription, mcpTool.Headers);
if (mcpTool.AllowedTools is not null)
{
diff --git a/test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Tools/HostedMcpServerToolTests.cs b/test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Tools/HostedMcpServerToolTests.cs
index ec1dc407973..12b2147972c 100644
--- a/test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Tools/HostedMcpServerToolTests.cs
+++ b/test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Tools/HostedMcpServerToolTests.cs
@@ -65,6 +65,17 @@ public void Constructor_Roundtrips()
var customApprovalMode = new HostedMcpServerToolRequireSpecificApprovalMode(["tool1"], ["tool2"]);
tool.ApprovalMode = customApprovalMode;
Assert.Same(customApprovalMode, tool.ApprovalMode);
+
+ Assert.Null(tool.Headers);
+ IDictionary headers = new Dictionary
+ {
+ ["X-Custom-Header"] = "value1",
+ };
+ tool.Headers = headers;
+ Assert.Same(headers, tool.Headers);
+
+ tool.Headers = null;
+ Assert.Null(tool.Headers);
}
[Fact]