Azure / Azure/MCP

McpClient.CreateAsync times out behind APIM in .NET SDK while MCP Inspector/Azure AI Foundry succeed

Open
#149 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
28
Forks
75
Avg merge
9d 2h
Merged PRs (30d)
3

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`
- `ModelContextProtocol` package: `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
1. Set MCP endpoint and APIM subscription key.
2. Call McpClient.CreateAsync(...) directly with HttpClientTransport (StreamableHttp).
3. Immediately call ListToolsAsync().
4. 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://.azure-api.net/apim-mcp/mcp"),
AdditionalHeaders = new Dictionary
{
["Ocp-Apim-Subscription-Key"] = key
}
}));

var tools = await mcpClient.ListToolsAsync();
Console.WriteLine($"Tools: {tools.Count}");
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.