-
Notifications
You must be signed in to change notification settings - Fork 403
Description
Describe the bug
Maybe this is a known issue, but I can't find any documentation which states this.
I'm unable to successfully host the Azure MCP Server in Azure App Service (using a container) and connect to it using streamable-http.
I'm currently using the popular LibreChat open source project to interact with this (and several other) MCP servers. All other MCP servers work; only Azure MCP Server is giving me this issue.
Each time I try to invoke the Azure MCP Server, I get this error message:
Connection failed: Streamable HTTP error: Error POSTing to endpoint: {"error":{"code":-32001,"message":"Session not found"},"id":"","jsonrpc":"2.0"}
This error does not occur if I run the container locally via Docker Desktop with all the same environment variables.
This error also does not occur if I make a standard HTTP POST request to the Azure App Service endpoint using Invoke-WebRequest in PowerShell - those requests are successful.
The only difference I see between hosting locally and hosting in Azure App Service is in the log stream output.
HOSTING LOCALLY (anonymized):
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
Executing endpoint 'MCP Streamable HTTP | HTTP: POST /'
info: ModelContextProtocol.Server.McpServer[570385771]
Server (Azure MCP Server 2.0.0-beta.19) method 'initialize' request handler called.
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
Executed endpoint 'MCP Streamable HTTP | HTTP: POST /'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished HTTP/1.1 POST http://localhost:8080/ - 200 - text/event-stream 3167.1417ms
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (Azure MCP Server 2.0.0-beta.19), Client (@librechat/api-client 1.2.3) method 'initialize' request handler completed in 12.5028ms.
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 POST http://localhost:8080/ - application/json 54
info: Microsoft.IdentityModel.LoggingExtensions.IdentityLoggerAdapter[0]
IDX10242: Security token: '[PII of type 'Microsoft.IdentityModel.JsonWebTokens.JsonWebToken' is hidden. For more details, see https://aka.ms/IdentityModel/PII.]' has a valid signature.
info: Microsoft.IdentityModel.LoggingExtensions.IdentityLoggerAdapter[0]
IDX10239: Lifetime of the token is valid.
info: Microsoft.IdentityModel.LoggingExtensions.IdentityLoggerAdapter[0]
IDX10234: Audience Validated.Audience: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
info: Microsoft.IdentityModel.LoggingExtensions.IdentityLoggerAdapter[0]
IDX10245: Creating claims identity from the validated token: '[PII of type 'Microsoft.IdentityModel.JsonWebTokens.JsonWebToken' is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'.
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
Executing endpoint 'MCP Streamable HTTP | HTTP: POST /'
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
Executed endpoint 'MCP Streamable HTTP | HTTP: POST /'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished HTTP/1.1 POST http://localhost:8080/ - 202 0 - 5.9406ms
HOSTING IN AZURE APP SERVICE (anonymized):
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
Executing endpoint 'MCP Streamable HTTP | HTTP: POST /'
info: Microsoft.AspNetCore.Http.Result.JsonResult[1]
Setting HTTP status code 404.
info: Microsoft.AspNetCore.Http.Result.JsonResult[3]
Writing value of type 'JsonRpcError' as Json.
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
Executed endpoint 'MCP Streamable HTTP | HTTP: POST /'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished HTTP/1.1 POST http://app-mcp-server.azurewebsites.net/ - 404 - application/json;+charset=utf-8 1.2365ms
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 POST http://app-mcp-server.azurewebsites.net/ - application/json 170
info: Microsoft.IdentityModel.LoggingExtensions.IdentityLoggerAdapter[0]
IDX10242: Security token: '[PII of type 'Microsoft.IdentityModel.JsonWebTokens.JsonWebToken' is hidden. For more details, see https://aka.ms/IdentityModel/PII.]' has a valid signature.
info: Microsoft.IdentityModel.LoggingExtensions.IdentityLoggerAdapter[0]
IDX10239: Lifetime of the token is valid.
info: Microsoft.IdentityModel.LoggingExtensions.IdentityLoggerAdapter[0]
IDX10234: Audience Validated.Audience: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
info: Microsoft.IdentityModel.LoggingExtensions.IdentityLoggerAdapter[0]
IDX10245: Creating claims identity from the validated token: '[PII of type 'Microsoft.IdentityModel.JsonWebTokens.JsonWebToken' is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'.
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
Executing endpoint 'MCP Streamable HTTP | HTTP: POST /'
info: ModelContextProtocol.Server.McpServer[570385771]
Server (Azure MCP Server 2.0.0-beta.19) method 'initialize' request handler called.
info: ModelContextProtocol.Server.McpServer[1867955179]
Server (Azure MCP Server 2.0.0-beta.19), Client (@librechat/api-client 1.2.3) method 'initialize' request handler completed in 0.1322ms.
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
Executed endpoint 'MCP Streamable HTTP | HTTP: POST /'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished HTTP/1.1 POST http://app-mcp-server.azurewebsites.net/ - 200 - text/event-stream 1.0742ms
You can see the 404 error in the latter output when the initial streamable HTTP POST event occurs. Not sure if this is the actual cause or not.
This isn't an auth issue (or doesn't seem to be). Here are the LibreChat logs for OAuth to the Azure App Service-hosted MCP server:
info: [MCP][User: xxxxxxxxxxxxxxxxxxxxxxxx][AzureMCPServer] Establishing new connection
info: [MCP][AzureMCPServer][xxxxxxxxxxxxxxxxxxxxxxxx] Loaded OAuth tokens
info: [MCP][User: xxxxxxxxxxxxxxxxxxxxxxxx][AzureMCPServer] Creating streamable-http transport: https://app-mcp-server.azurewebsites.net/
info: [MCP][User: xxxxxxxxxxxxxxxxxxxxxxxx][AzureMCPServer] Connection successfully established
info: [MCP OAuth] Successfully reconnected AzureMCPServer for user xxxxxxxxxxxxxxxxxxxxxxxx
Expected behavior
MCP server connects and can be queried.
Actual behavior
Connection throws this error:
Connection failed: Streamable HTTP error: Error POSTing to endpoint: {"error":{"code":-32001,"message":"Session not found"},"id":"","jsonrpc":"2.0"}
Reproduction Steps
I think documenting all the steps to set up both Azure MCP Server in Azure App Service and configuring Entra ID and configuring local LibreChat deployment is more than I can reasonably enter here. If the details under the problem description are not enough, please let me know, and I'll provide any missing details.
Environment
- Azure App Service
- Windows 11
- PowerShell 7.5.4
- Latest LibreChat repo
- Azure MCP Server container image version 2.0.0-beta.19-amd64
Metadata
Metadata
Assignees
Labels
Type
Projects
Status