-
Notifications
You must be signed in to change notification settings - Fork 14
Description
I am trying to expose a Model Context Protocol (MCP) endpoint through Azure API Management (APIM) using JSON-RPC over HTTP.
Regardless of the logic implemented, every request takes ~3 minutes (≈180 seconds) to return a response, even when the response is fully generated inside APIM policies and should return immediately.
This happens consistently and reproducibly.
Environment
Azure API Management (Consumption / Developer tier)
JSON-RPC 2.0 (MCP protocol)
HTTP POST endpoints
Tested with Postman and Claude Code
Backend APIs are healthy and respond immediately when called directly
What I’m trying to do
Expose an MCP endpoint such as:
POST /mcp
POST /healthcheck/mcp
That handles JSON-RPC methods like:
initialize
tools/list
tools/call
Some of these (e.g. tools/list, healthcheck) are fully handled inside APIM policies and should not call any backend.
Expected behavior
Requests handled entirely in APIM policies should return immediately (<100 ms).
APIM should not wait for backend timeouts if:
A response body is set
Or is used
Actual behavior
Every request takes ~180 seconds before returning
This happens even when:
The response is generated entirely in policy
is explicitly used
No backend is configured or required
After ~3 minutes, APIM finally returns 200 OK with the correct body
This delay happens 100% of the time.
Evidence
The delay is always ~3 minutes (≈180s), strongly suggesting an APIM timeout
Happens even on a brand new test endpoint (/healthcheck/mcp)
Happens even when responding only with tools/list
Happens even when no backend call is needed
Backend APIs respond instantly when called directly
What we already tried
✔ MCP implementation
initialize works
tools/list returns valid MCP response
tools/call logic implemented
✔ APIM policy experiments
Parsing request body with preserveContent: true
Defensive JSON parsing (try/catch)
Setting set-backend-service explicitly
Removing backend entirely
Using to short-circuit the pipeline
Moving logic between inbound / outbound
Separate APIs for MCP and healthcheck
Minimal policies (no routing, no backend, only return-response)
✔ Validation
Same behavior in multiple endpoints
Same behavior with minimal policies
Same behavior regardless of request content
Same behavior even when response body is static
Example request
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}
Example policy (simplified)
➡️ Still takes ~180 seconds to respond
Why this looks like a platform issue
should immediately terminate the pipeline
There is no backend dependency in these flows
The behavior is deterministic (always ~180s)
It affects multiple endpoints and APIs
It reproduces even with minimal configuration
This makes it very difficult (or impossible) to reliably host MCP / JSON-RPC endpoints on APIM.
Question
Is this a known limitation of Azure API Management?
Is there a required setting to prevent APIM from waiting for backend timeouts when using return-response?
Is APIM officially unsupported for JSON-RPC / MCP-style endpoints?
Any guidance or confirmation would be appreciated.