Bug Report: Invalid typecast in TMS.MCP.HTTPServer.General.pas causes EInvalidPointer crash

Hi,

I’d like to report a bug in TMS MCP (AI Studio)

File: TMS.MCP.HTTPServer.General.pas

In TTMSMCPGeneralHTTPServer.DoCommandGet, there is an invalid typecast that causes memory corruption and EInvalidPointer crashes when clients connect to the MCP HTTP server.

Bug location (line 177-178):

if not Assigned(AContext.Data) then
AContext.Data := TTMSMCPGeneralHTTPServerConnection(AContext); // BUG: typecast instead of Create
Expected (compare with DoCommandOther at line 196-197):

if not Assigned(AContext.Data) then
AContext.Data := TTMSMCPGeneralHTTPServerConnection.Create(AContext); // Correct

This causes EInvalidPointer in TIdContext.Destroy when Indy frees the connection context.

Reproduction:

Start MCP server using TTMSMCPStreamableHTTPTransport with Indy (General HTTP server)
Connect an MCP client, in my case it’s Claude Desktop.
Application crashes with EInvalidPointer

Thank you!

Hi,

Thank you for reporting. This had already been fixed internally just not yet synced to TMS AI Studio. We’ll make sure this is synced in the next release.

1 Like