McpClient.CreateAsync times out behind APIM in .NET SDK while MCP Inspector/Azure AI Foundry succeed
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by reproducing the provided net10.0 example with HttpClientTransport in StreamableHttp mode, focusing on McpClient.CreateAsync initialization before ListToolsAsync. Compare the SDK's initialization behavior with the same APIM endpoint and authentication in MCP Inspector and Azure AI Foundry; done when CreateAsync completes and tool listing succeeds without a timeout.
Written by the indexing model from the issue text.
Description
Summary
I am seeing a consistent timeout when initialising McpClient from the MCP .NET SDK.
The same MCP server works successfully in:
- MCP Inspector
- Azure AI Foundry
The MCP server is exposed behind Azure API Management (APIM).
Environment
- .NET:
net10.0 ModelContextProtocolpackage:1.1.0- MCP transport mode:
HttpTransportMode.StreamableHttp
Observed behaviour
McpClient.CreateAsync(...) times out and throws:
System.TimeoutException: The operation has timed out.
Expected behavior
McpClient.CreateAsync(...) should initialize successfully with the same endpoint/auth that works in MCP Inspector and Azure AI Foundry.
Repro steps
- Set MCP endpoint and APIM subscription key.
- Call McpClient.CreateAsync(...) directly with HttpClientTransport (StreamableHttp).
- Immediately call ListToolsAsync().
- Timeout occurs during McpClient.CreateAsync(...) (initialization), before tool listing.
using ModelContextProtocol.Client;
using HttpClientTransport = ModelContextProtocol.Client.HttpClientTransport;
var key = Environment.GetEnvironmentVariable("APIM_SUBSCRIPTION_KEY")
?? throw new InvalidOperationException("Set APIM_SUBSCRIPTION_KEY");
await using McpClient mcpClient = await McpClient.CreateAsync(
new HttpClientTransport(new HttpClientTransportOptions
{
TransportMode = ModelContextProtocol.Client.HttpTransportMode.StreamableHttp,
Endpoint = new Uri("https://<redacted>.azure-api.net/apim-mcp/mcp"),
AdditionalHeaders = new Dictionary<string, string>
{
["Ocp-Apim-Subscription-Key"] = key
}
}));
var tools = await mcpClient.ListToolsAsync();
Console.WriteLine($"Tools: {tools.Count}");
- Dominant language
- C#
- Stars
- 4.5k
- Forks
- 814
- Avg merge
- 9d 19h
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from modelcontextprotocol/csharp-sdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
modelcontextprotocol/csharp-sdk#1867 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
modelcontextprotocol/csharp-sdk#1840 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
modelcontextprotocol/csharp-sdk#1836 ·
-
enhancement needs confirmation
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
modelcontextprotocol/csharp-sdk#678 · 1 comment ·
-
enhancement needs confirmation P3 ready for work
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
modelcontextprotocol/csharp-sdk#515 · 6 comments · 3 reactions ·
All issues in modelcontextprotocol/csharp-sdk
Similar issues
-
priority-0
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
StackExchange/StackExchange.Redis#3249 ·
-
[Feat] 조합 영역 구분선 개선 Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100