Skip to content

Gin Transport panics and crashes entire process when the users requests unsupported method #116

@teodormarianmck

Description

@teodormarianmck

Steps to reproduce:

  • Start as gin server
  • run:
curl --location 'http://localhost:8000/mcp' \
--header 'Content-Type: application/json' \
--data '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/list_invalid",
    "params": {
        "submitter": "test",
        "content": {
        }
    }
}
  • unrecoverable panic (on different go routine) "invalid memory address or nil pointer dereference" because JsonRpcResponse is undefined
if err := p.transport.Send(ctx, transport.NewBaseMessageError(response)); err != nil {
	p.handleError(fmt.Errorf("failed to send error response: %w", err))
}
...
// Send implements Transport.Send
func (t *GinTransport) Send(ctx context.Context, message *transport.BaseJsonRpcMessage) error {
	key := message.JsonRpcResponse.Id
	responseChannel := t.responseMap[int64(key)]
	if responseChannel == nil {
		return fmt.Errorf("no response channel found for key: %d", key)
	}
	responseChannel <- message
	return nil
}
  • this in turn crashes the entire process using the MCP lib

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions